Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / native_client_sdk / src / resources / Makefile.example.template
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 [[if 'INCLUDES' in targets[0]:]]
34 EXTRA_INC_PATHS={{' '.join(targets[0]['INCLUDES'])}}
35 [[]]
36
37 include $(NACL_SDK_ROOT)/tools/common.mk
38
39 [[if desc.get('SOCKET_PERMISSIONS'):]]
40 CHROME_ARGS += --allow-nacl-socket-api=localhost
41 [[]]
42
43 TARGET = {{targets[0]['NAME']}}
44 [[if sel_ldr and targets[0].get('SEL_LDR_LIBS'):]]
45 ifdef SEL_LDR
46 [[  ExpandDict('DEPS', targets[0].get('SEL_LDR_DEPS', []))]]
47 [[  ExpandDict('LIBS', targets[0].get('SEL_LDR_LIBS', []))]]
48 else
49 [[  ExpandDict('DEPS', targets[0].get('DEPS', []))]]
50 [[  ExpandDict('LIBS', targets[0].get('LIBS', []))]]
51 endif
52 [[else:]]
53 [[  ExpandDict('DEPS', targets[0].get('DEPS', []))]]
54 [[  ExpandDict('LIBS', targets[0].get('LIBS', []))]]
55 [[]]
56
57 [[for target in targets:]]
58 [[  source_list = (s for s in sorted(target['SOURCES']) if not s.endswith('.h'))]]
59 [[  source_list = ' \\\n  '.join(source_list)]]
60 [[  sources = target['NAME'] + '_SOURCES']]
61 [[  cflags = target['NAME'] + '_CFLAGS']]
62 [[  flags = target.get('CFLAGS', [])]]
63 [[  flags.extend(target.get('CXXFLAGS', []))]]
64 [[  if len(targets) == 1:]]
65 [[    sources = 'SOURCES']]
66 [[    cflags = 'CFLAGS']]
67 [[  ]]
68 [[  ExpandDict(cflags, flags)]]
69 [[  if 'CFLAGS_GCC' in target:]]
70 ifneq ($(TOOLCHAIN),pnacl)
71 {{cflags}} += {{' '.join(target['CFLAGS_GCC'])}}
72 endif
73 [[  ]]
74 {{sources}} = {{source_list}}
75
76 # Build rules generated by macros from common.mk:
77
78 [[if targets[0].get('DEPS'):]]
79 $(foreach dep,$(DEPS),$(eval $(call DEPEND_RULE,$(dep))))
80 [[if len(targets) > 1:]]
81 [[  for target in targets:]]
82 [[    name = target['NAME'] ]]
83 $(foreach src,$({{name}}_SOURCES),$(eval $(call COMPILE_RULE,$(src),$({{name}}_CFLAGS))))
84 [[else:]]
85 $(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS))))
86 [[]]
87
88 [[for target in targets:]]
89 [[  sources = target['NAME'] + '_SOURCES']]
90 [[  name = target['NAME'] ]]
91 [[  if len(targets) == 1:]]
92 [[    sources = 'SOURCES']]
93 [[    name = '$(TARGET)']]
94 [[  if target['TYPE'] == 'so':]]
95 $(eval $(call SO_RULE,{{name}},$({{sources}})))
96 [[  elif target['TYPE'] == 'so-standalone':]]
97 $(eval $(call SO_RULE,{{name}},$({{sources}}),,,1))
98 [[  else:]]
99 ifeq ($(CONFIG),Release)
100 $(eval $(call LINK_RULE,{{name}}_unstripped,$({{sources}}),$(LIBS),$(DEPS)))
101 $(eval $(call STRIP_RULE,{{name}},{{name}}_unstripped))
102 else
103 $(eval $(call LINK_RULE,{{name}},$({{sources}}),$(LIBS),$(DEPS)))
104 endif
105 [[]]
106
107 $(eval $(call NMF_RULE,$(TARGET),)){{post}}