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 [[def ExpandDict(key, value_in, pre_list=[], post_list=[]):]]
5 [[ value = value_in or [] ]]
6 [[ pre = pre_list or [] ]]
7 [[ post = post_list or [] ]]
8 [[ if type(value) is not dict:]]
10 [[ out.extend(value)]]
13 {{key}} = {{' '.join(out)}}
17 [[ for subkey in value:]]
19 [[ out.extend(value[subkey])]]
21 {{key}}_{{subkey}} = {{' '.join(out)}}
23 {{key}} = $({{key}}_$(TOOLCHAIN))
26 [[target = targets[0] ]]
27 # GNU Makefile based on shared rules provided by the Native Client SDK.
28 # See README.Makefiles for more details.
30 VALID_TOOLCHAINS := {{' '.join(tools)}}
31 NACL_SDK_ROOT ?= $(abspath $(CURDIR)/../..)
32 [[if 'INCLUDES' in target:]]
33 EXTRA_INC_PATHS={{' '.join(target['INCLUDES'])}}
36 TARGET = {{target['NAME']}}
38 include $(NACL_SDK_ROOT)/tools/common.mk
40 [[ExpandDict('DEPS', targets[0].get('DEPS', []))]]
41 [[ExpandDict('LIBS', targets[0].get('LIBS', []), pre_list=['$(DEPS)'])]]
42 [[flags = target.get('CFLAGS', [])]]
43 [[flags.extend(target.get('CXXFLAGS', []))]]
44 [[ExpandDict('CFLAGS', flags)]]
45 [[if 'CFLAGS_GCC' in target:]]
46 ifneq ($(TOOLCHAIN),pnacl)
47 CFLAGS += {{' '.join(target['CFLAGS_GCC'])}}
51 [[for define in target.get('DEFINES', []):]]
52 CFLAGS += -D{{define}}
56 [[for source in sorted(target['SOURCES']):]]
62 # Build rules generated by macros from common.mk:
64 [[if targets[0].get('DEPS'):]]
65 $(foreach dep,$(DEPS),$(eval $(call DEPEND_RULE,$(dep))))
67 $(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS))))
68 $(eval $(call LIB_RULE,$(TARGET),$(SOURCES)))
70 [[if target['TYPE'] != 'static-lib':]]
71 ifneq (,$(findstring $(TOOLCHAIN),glibc bionic))
72 $(eval $(call SO_RULE,$(TARGET),$(SOURCES),$(LIBS),$(DEPS)))