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 30VALID_TOOLCHAINS := {{' '.join(tools)}} 31{{pre}} 32NACL_SDK_ROOT ?= $(abspath $(CURDIR)/{{rel_sdk}}) 33include $(NACL_SDK_ROOT)/tools/common.mk 34 35[[if desc.get('SOCKET_PERMISSIONS'):]] 36CHROME_ARGS += --allow-nacl-socket-api=localhost 37[[]] 38 39TARGET = {{targets[0]['NAME']}} 40[[ExpandDict('DEPS', targets[0].get('DEPS', []))]] 41[[ExpandDict('LIBS', targets[0].get('LIBS', []), pre_list=['$(DEPS)'])]] 42 43[[for target in targets:]] 44[[ source_list = (s for s in sorted(target['SOURCES']) if not s.endswith('.h'))]] 45[[ source_list = ' \\\n '.join(source_list)]] 46[[ sources = target['NAME'] + '_SOURCES']] 47[[ cflags = target['NAME'] + '_CFLAGS']] 48[[ flags = target.get('CFLAGS', [])]] 49[[ flags.extend(target.get('CXXFLAGS', []))]] 50[[ if len(targets) == 1:]] 51[[ sources = 'SOURCES']] 52[[ cflags = 'CFLAGS']] 53[[ ]] 54[[ ExpandDict(cflags, flags)]] 55[[ if 'CFLAGS_GCC' in target:]] 56ifneq ($(TOOLCHAIN),pnacl) 57{{cflags}} += {{' '.join(target['CFLAGS_GCC'])}} 58endif 59[[ ]] 60{{sources}} = {{source_list}} 61 62# Build rules generated by macros from common.mk: 63 64[[if targets[0].get('DEPS'):]] 65$(foreach dep,$(DEPS),$(eval $(call DEPEND_RULE,$(dep)))) 66[[if len(targets) > 1:]] 67[[ for target in targets:]] 68[[ name = target['NAME'] ]] 69$(foreach src,$({{name}}_SOURCES),$(eval $(call COMPILE_RULE,$(src),$({{name}}_CFLAGS)))) 70[[else:]] 71$(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS)))) 72[[]] 73 74[[for target in targets:]] 75[[ sources = target['NAME'] + '_SOURCES']] 76[[ name = target['NAME'] ]] 77[[ if len(targets) == 1:]] 78[[ sources = 'SOURCES']] 79[[ name = '$(TARGET)']] 80[[ if target['TYPE'] == 'so':]] 81$(eval $(call SO_RULE,{{name}},$({{sources}}))) 82[[ elif target['TYPE'] == 'so-standalone':]] 83$(eval $(call SO_RULE,{{name}},$({{sources}}),,,1)) 84[[ else:]] 85ifeq ($(CONFIG),Release) 86$(eval $(call LINK_RULE,{{name}}_unstripped,$({{sources}}),$(LIBS),$(DEPS))) 87$(eval $(call STRIP_RULE,{{name}},{{name}}_unstripped)) 88else 89$(eval $(call LINK_RULE,{{name}},$({{sources}}),$(LIBS),$(DEPS))) 90endif 91[[]] 92 93$(eval $(call NMF_RULE,$(TARGET),)){{post}} 94