Home | History | Annotate | Download | only in resources
      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 [[if multi_platform:]]
     38 # Build with platform-specific subdirectories, to reduce the download size of
     39 # the app.
     40 MULTI_PLATFORM = 1
     41 [[]]
     42 
     43 include $(NACL_SDK_ROOT)/tools/common.mk
     44 
     45 [[if desc.get('SOCKET_PERMISSIONS'):]]
     46 CHROME_ARGS += --allow-nacl-socket-api=localhost
     47 [[]]
     48 
     49 TARGET = {{targets[0]['NAME']}}
     50 [[ExpandDict('DEPS', targets[0].get('DEPS', []))]]
     51 [[ExpandDict('LIBS', targets[0].get('LIBS', []))]]
     52 
     53 [[for target in targets:]]
     54 [[  source_list = (s for s in sorted(target['SOURCES']) if not s.endswith('.h'))]]
     55 [[  source_list = ' \\\n  '.join(source_list)]]
     56 [[  sources = target['NAME'] + '_SOURCES']]
     57 [[  cflags = target['NAME'] + '_CFLAGS']]
     58 [[  flags = target.get('CFLAGS', [])]]
     59 [[  flags.extend(target.get('CXXFLAGS', []))]]
     60 [[  if len(targets) == 1:]]
     61 [[    sources = 'SOURCES']]
     62 [[    cflags = 'CFLAGS']]
     63 [[  ]]
     64 [[  ExpandDict(cflags, flags)]]
     65 [[  for define in target.get('DEFINES', []):]]
     66 {{cflags}} += -D{{define}}
     67 [[  ]]
     68 [[  if 'CFLAGS_GCC' in target:]]
     69 ifneq ($(TOOLCHAIN),pnacl)
     70 {{cflags}} += {{' '.join(target['CFLAGS_GCC'])}}
     71 endif
     72 [[  ]]
     73 {{sources}} = {{source_list}}
     74 
     75 # Build rules generated by macros from common.mk:
     76 
     77 [[if targets[0].get('DEPS'):]]
     78 $(foreach dep,$(DEPS),$(eval $(call DEPEND_RULE,$(dep))))
     79 [[if len(targets) > 1:]]
     80 [[  for target in targets:]]
     81 [[    name = target['NAME'] ]]
     82 $(foreach src,$({{name}}_SOURCES),$(eval $(call COMPILE_RULE,$(src),$({{name}}_CFLAGS))))
     83 [[else:]]
     84 $(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS))))
     85 [[]]
     86 
     87 [[for target in targets:]]
     88 [[  sources = target['NAME'] + '_SOURCES']]
     89 [[  name = target['NAME'] ]]
     90 [[  if len(targets) == 1:]]
     91 [[    sources = 'SOURCES']]
     92 [[    name = '$(TARGET)']]
     93 [[  if target['TYPE'] == 'so':]]
     94 $(eval $(call SO_RULE,{{name}},$({{sources}})))
     95 [[  elif target['TYPE'] == 'so-standalone':]]
     96 $(eval $(call SO_RULE,{{name}},$({{sources}}),,,1))
     97 [[  else:]]
     98 # The PNaCl workflow uses both an unstripped and finalized/stripped binary.
     99 # On NaCl, only produce a stripped binary for Release configs (not Debug).
    100 ifneq (,$(or $(findstring pnacl,$(TOOLCHAIN)),$(findstring Release,$(CONFIG))))
    101 $(eval $(call LINK_RULE,{{name}}_unstripped,$({{sources}}),$(LIBS),$(DEPS)))
    102 $(eval $(call STRIP_RULE,{{name}},{{name}}_unstripped))
    103 else
    104 $(eval $(call LINK_RULE,{{name}},$({{sources}}),$(LIBS),$(DEPS)))
    105 endif
    106 [[]]
    107 
    108 $(eval $(call NMF_RULE,$(TARGET),)){{post}}
    109