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:]] 9[[ out = pre]] 10[[ out.extend(value)]] 11[[ out.extend(post)]] 12[[ if out:]] 13{{key}} = {{' '.join(out)}} 14[[ ]] 15[[ return]] 16[[ ]] 17[[ for subkey in value:]] 18[[ out = pre]] 19[[ out.extend(value[subkey])]] 20[[ out.extend(post)]] 21{{key}}_{{subkey}} = {{' '.join(out)}} 22[[ ]] 23{{key}} = $({{key}}_$(TOOLCHAIN)) 24[[]] 25 26[[target = targets[0] ]] 27# GNU Makefile based on shared rules provided by the Native Client SDK. 28# See README.Makefiles for more details. 29 30VALID_TOOLCHAINS := {{' '.join(tools)}} 31NACL_SDK_ROOT ?= $(abspath $(CURDIR)/../..) 32[[if 'INCLUDES' in target:]] 33EXTRA_INC_PATHS={{' '.join(target['INCLUDES'])}} 34[[]] 35 36include $(NACL_SDK_ROOT)/tools/common.mk 37 38TARGET = {{target['NAME']}} 39[[ExpandDict('DEPS', targets[0].get('DEPS', []))]] 40[[ExpandDict('LIBS', targets[0].get('LIBS', []), pre_list=['$(DEPS)'])]] 41[[flags = target.get('CFLAGS', [])]] 42[[flags.extend(target.get('CXXFLAGS', []))]] 43[[ExpandDict('CFLAGS', flags)]] 44[[if 'CFLAGS_GCC' in target:]] 45ifneq ($(TOOLCHAIN),pnacl) 46CFLAGS += {{' '.join(target['CFLAGS_GCC'])}} 47endif 48[[]] 49 50SOURCES = \ 51[[for source in sorted(target['SOURCES']):]] 52 {{source}} \ 53[[]] 54 55all: install 56 57# Build rules generated by macros from common.mk: 58 59[[if targets[0].get('DEPS'):]] 60$(foreach dep,$(DEPS),$(eval $(call DEPEND_RULE,$(dep)))) 61[[]] 62$(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS)))) 63$(eval $(call LIB_RULE,$(TARGET),$(SOURCES))) 64 65[[if target['TYPE'] != 'static-lib':]] 66ifeq ($(TOOLCHAIN),glibc) 67$(eval $(call SO_RULE,$(TARGET),$(SOURCES),$(LIBS),$(DEPS))) 68endif 69[[]] 70{{post}} 71