OLD | NEW |
| (Empty) |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 | |
5 # GNU Makefile based on shared rules provided by the Native Client SDK. | |
6 # See README.Makefiles for more details. | |
7 [[]] | |
8 [[def ExpandDict(key, value_in, pre_list=[], post_list=[]):]] | |
9 [[ value = value_in or [] ]] | |
10 [[ pre = pre_list or [] ]] | |
11 [[ post = post_list or [] ]] | |
12 [[ if type(value) is not dict:]] | |
13 [[ out = pre]] | |
14 [[ out.extend(value)]] | |
15 [[ out.extend(post)]] | |
16 [[ if out:]] | |
17 {{key}} = {{' '.join(out)}} | |
18 [[ ]] | |
19 [[ return]] | |
20 [[ ]] | |
21 [[ for subkey in value:]] | |
22 [[ out = pre]] | |
23 [[ out.extend(value[subkey])]] | |
24 [[ out.extend(post)]] | |
25 {{key}}_{{subkey}} = {{' '.join(out)}} | |
26 [[ ]] | |
27 {{key}} = $({{key}}_$(TOOLCHAIN)) | |
28 [[]] | |
29 | |
30 VALID_TOOLCHAINS := {{' '.join(tools)}} | |
31 {{pre}} | |
32 NACL_SDK_ROOT ?= $(abspath $(CURDIR)/{{rel_sdk}}) | |
33 include $(NACL_SDK_ROOT)/tools/common.mk | |
34 | |
35 TARGET = {{targets[0]['NAME']}} | |
36 [[ExpandDict('DEPS', targets[0].get('DEPS', []))]] | |
37 [[ExpandDict('LIBS', targets[0].get('LIBS', []), pre_list=['$(DEPS)'])]] | |
38 | |
39 [[for target in targets:]] | |
40 [[ source_list = (s for s in sorted(target['SOURCES']) if not s.endswith('.h'))
]] | |
41 [[ source_list = ' \\\n '.join(source_list)]] | |
42 [[ sources = target['NAME'] + '_SOURCES']] | |
43 [[ cflags = target['NAME'] + '_CFLAGS']] | |
44 [[ flags = target.get('CFLAGS', [])]] | |
45 [[ flags.extend(target.get('CXXFLAGS', []))]] | |
46 [[ if len(targets) == 1:]] | |
47 [[ sources = 'SOURCES']] | |
48 [[ cflags = 'CFLAGS']] | |
49 [[ ]] | |
50 [[ ExpandDict(cflags, flags)]] | |
51 [[ if 'CFLAGS_GCC' in target:]] | |
52 ifneq ($(TOOLCHAIN),pnacl) | |
53 {{cflags}} += {{' '.join(target['CFLAGS_GCC'])}} | |
54 endif | |
55 [[ ]] | |
56 {{sources}} = {{source_list}} | |
57 | |
58 # Build rules generated by macros from common.mk: | |
59 | |
60 [[if targets[0].get('DEPS'):]] | |
61 $(foreach dep,$(DEPS),$(eval $(call DEPEND_RULE,$(dep)))) | |
62 [[if len(targets) > 1:]] | |
63 [[ for target in targets:]] | |
64 [[ name = target['NAME'] ]] | |
65 $(foreach src,$({{name}}_SOURCES),$(eval $(call COMPILE_RULE,$(src),$({{name}}_C
FLAGS)))) | |
66 [[else:]] | |
67 $(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS)))) | |
68 [[]] | |
69 | |
70 [[for target in targets:]] | |
71 [[ sources = target['NAME'] + '_SOURCES']] | |
72 [[ name = target['NAME'] ]] | |
73 [[ if len(targets) == 1:]] | |
74 [[ sources = 'SOURCES']] | |
75 [[ name = '$(TARGET)']] | |
76 [[ if target['TYPE'] == 'so':]] | |
77 $(eval $(call SO_RULE,{{name}},$({{sources}}))) | |
78 [[ elif target['TYPE'] == 'so-standalone':]] | |
79 $(eval $(call SO_RULE,{{name}},$({{sources}}),,,1)) | |
80 [[ else:]] | |
81 ifeq ($(CONFIG),Release) | |
82 $(eval $(call LINK_RULE,{{name}}_unstripped,$({{sources}}),$(LIBS),$(DEPS))) | |
83 $(eval $(call STRIP_RULE,{{name}},{{name}}_unstripped)) | |
84 else | |
85 $(eval $(call LINK_RULE,{{name}},$({{sources}}),$(LIBS),$(DEPS))) | |
86 endif | |
87 [[]] | |
88 | |
89 $(eval $(call NMF_RULE,$(TARGET),)){{post}} | |
OLD | NEW |