sbsv2/raptor/lib/flm/template_ext.flm
changeset 0 044383f39525
child 3 e1eecf4d390d
child 590 360bd6b35136
equal deleted inserted replaced
-1:000000000000 0:044383f39525
       
     1 # Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 # All rights reserved.
       
     3 # This component and the accompanying materials are made available
       
     4 # under the terms of the License "Eclipse Public License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Nokia Corporation - initial contribution.
       
    10 #
       
    11 # Contributors:
       
    12 #
       
    13 # Description:
       
    14 # Template Extension Makefile  (TEM) FLM
       
    15 # Knows how to run TEMs
       
    16 # 
       
    17 #
       
    18 
       
    19 ################################# FLM Parameter description ##
       
    20 # Parameters:
       
    21 #   TEMPLATE_EXTENSION_MAKEFILE
       
    22 #   PRODUCT_INCLUDE
       
    23 #   EPOCROOT:=
       
    24 #   PLATFORM:=$(VARIANTPLATFORM)
       
    25 # The current configuration either UREL or UDEB:
       
    26 #   CFG:=$(VARIANTTYPE)
       
    27 # Relative path to EPOCROOT. (to where?):
       
    28 #   TO_ROOT:=
       
    29 # The path to the top-level bld.inf.
       
    30 # Note: if a bld.inf file #includes another bld.inf, this variable will
       
    31 # always contain the directory of that top-level file. If you require
       
    32 # the directory of the bld.inf which actually references the makefile,
       
    33 # use $(EXTENSION_ROOT) instead.
       
    34 #   TO_BLDINF:=
       
    35 # The project's working build directory under \epoc32\build\..
       
    36 #   EPOCBLD:=
       
    37 # The path to the directory containing the bld.inf in which the extension makefile was called:
       
    38 #   EXTENSION_ROOT:=
       
    39 # The path of the host-platform specific (i.e. the shell) makefile containing the above definitions:
       
    40 #   HOST_SHELL:=
       
    41 # The current platform in lower case to be used as part of path
       
    42 # names.
       
    43 #   PLATFORM_PATH:=
       
    44 # The current configuration in lower case to be used as part of
       
    45 # path names.
       
    46 #   CFG_PATH:=
       
    47 # A list of options passed from a bld.inf to this
       
    48 # Template Extension Makefile
       
    49 #  O._MEMBERS:=
       
    50 # Options should have the name specifed in the bld.inf 
       
    51 # but with a prefix of "O." e.g. O.PATH or O.FILENAME
       
    52 # (in which case O._MEMBERS:=PATH FILENAME)
       
    53 
       
    54 # create the working directory for the TEM
       
    55 $(shell $(GNUMKDIR) -p $(EPOCBLD))
       
    56 
       
    57 ################################ Standard Variables ##
       
    58 # We may set the following 
       
    59 # for the sake of template
       
    60 # extension makefiles which
       
    61 # need to know them:
       
    62 
       
    63 ## Path element separator.
       
    64 /:=/
       
    65 ## PATH environment variable separator.
       
    66 ;:=:
       
    67 
       
    68 ####
       
    69 # Various file and directory manipulation tools.
       
    70 # We are using the standard GNU coretools.
       
    71 # On Windows these are supplied by CYGWIN
       
    72 RMDIR:=$(GNURMDIR)
       
    73 RM:=$(GNURM)
       
    74 ERASE:=$(GNURM)
       
    75 MKDIR:=$(GNUMKDIR)
       
    76 CP:=$(GNUCP)
       
    77 ARMV7BUILD:=
       
    78 
       
    79 ######################## Target Specific Parameters ##
       
    80 # We need to declare the parameters for the TEM 
       
    81 # to be target specific to the unique targets
       
    82 # that we have created.
       
    83 
       
    84 UNIQ:=$(TEMPLATE_EXTENSION_MAKEFILE)$(PLATFORM)$(TO_ROOT)$(TO_BLDINF)$(EPOCBLD)$(EXTENSION_ROOT)$(TEMCOUNT)
       
    85 UNIQ:=$(word 1,$(shell echo $(UNIQ) | $(GNUMD5SUM)))
       
    86 
       
    87 # Work out the other FINAL target if we're building both udeb and urel
       
    88 ifneq ($($(UNIQ)),)
       
    89 
       
    90 ifeq ($(CFG),urel)
       
    91 OTHER_CFG:=udeb
       
    92 endif
       
    93 ifeq ($(CFG),udeb)
       
    94 OTHER_CFG:=urel
       
    95 endif
       
    96 ifeq ($(CFG),rel)
       
    97 OTHER_CFG:=deb
       
    98 endif
       
    99 ifeq ($(CFG),deb)
       
   100 OTHER_CFG:=rel
       
   101 endif
       
   102 
       
   103 OTHER_MAKMAKE:=$(UNIQ)_$(OTHER_CFG)_MAKMAKE
       
   104 OTHER_BLD:=$(UNIQ)_$(OTHER_CFG)_BLD
       
   105 OTHER_FREEZE:=$(UNIQ)_$(OTHER_CFG)_FREEZE
       
   106 OTHER_LIB:=$(UNIQ)_$(OTHER_CFG)_LIB
       
   107 OTHER_CLEANLIB:=$(UNIQ)_$(OTHER_CFG)_CLEANLIB
       
   108 OTHER_RESOURCE:=$(UNIQ)_$(OTHER_CFG)_RESOURCE
       
   109 OTHER_CLEAN:=$(UNIQ)_$(OTHER_CFG)_CLEAN
       
   110 OTHER_FINAL:=$(UNIQ)_$(OTHER_CFG)_FINAL
       
   111 endif # ifneq ($($(UNIQ)),)
       
   112 
       
   113 # Set $($(UNIQ)) so it can be detected if we're run again
       
   114 $(UNIQ):=1
       
   115 
       
   116 tem_$(notdir $(TEMPLATE_EXTENSION_MAKEFILE))_$(PLATFORM)_$(CFG):=$(tem_$(notdir $(TEMPLATE_EXTENSION_MAKEFILE))_$(PLATFORM)_$(CFG)) $(UNIQ)_$(CFG)
       
   117 
       
   118 TEPARAMETERS:= \
       
   119 	EPOCROOT PLATFORM CFG TO_ROOT TO_BLDINF \
       
   120 	EPOCBLD EXTENSION_ROOT HOST_SHELL       \
       
   121 	RMDIR RM ERASE MKDIR CP                 \
       
   122 	PLATFORM_PATH CFG_PATH                  \
       
   123 	TEMPLATE_EXTENSION_MAKEFILE             \
       
   124 	TARGET SOURCE DEPENDENCIES TOOL PRODUCT_INCLUDE \
       
   125 	RVCTBIN RVCTINC RVCTLIB
       
   126 
       
   127 
       
   128 # The standard Template Extension Makefile Targets
       
   129 # These will be implemented in terms of double colon
       
   130 # rules - such that make FREEZE will cause all FREEZE 
       
   131 # targets to be evaluated.
       
   132 # For each call of this FLM we also need
       
   133 # to create unique versions of each of these targets
       
   134 # so that there is something to attach
       
   135 # the current FLM parameters to using target-specific 
       
   136 # variable declarations.
       
   137 
       
   138 TETARGETS:= \
       
   139 	MAKMAKE     \
       
   140 	BLD         \
       
   141 	FREEZE      \
       
   142 	LIB         \
       
   143 	CLEANLIB    \
       
   144 	RESOURCE    \
       
   145 	CLEAN       \
       
   146 	RELEASABLES \
       
   147 	FINAL
       
   148 
       
   149 # If we split the makefiles then only use a subset of
       
   150 # the targets for each group makefile.
       
   151 #
       
   152 ifeq ($(MAKEFILE_GROUP),BITMAP)
       
   153 TETARGETS:=MAKMAKE
       
   154 endif
       
   155 #
       
   156 ifeq ($(MAKEFILE_GROUP),RESOURCE)
       
   157 TETARGETS:=RESOURCE
       
   158 endif
       
   159 #
       
   160 ifeq ($(MAKEFILE_GROUP),ALL)
       
   161 TETARGETS:=BLD FREEZE LIB CLEANLIB CLEAN RELEASABLES FINAL
       
   162 endif
       
   163 
       
   164 # Hook into global targets
       
   165 #
       
   166 MAKMAKE_HOOK:=BITMAP
       
   167 BLD_HOOK:=TARGET
       
   168 FREEZE_HOOK:=FREEZE
       
   169 LIB_HOOK:=LIBRARY
       
   170 CLEAN_HOOK:=CLEAN
       
   171 CLEANLIB_HOOK:=CLEAN
       
   172 RESOURCE_HOOK:=RESOURCE
       
   173 FINAL_HOOK:=FINAL
       
   174 RELEASABLES_HOOK:=RELEASABLES
       
   175 
       
   176 # make sure TEMS happen at the right stages
       
   177 # OTHER_$(STAGE) only set if running udeb+urel
       
   178 MAKMAKE_DEPS:=EXPORT $(OTHER_MAKMAKE)
       
   179 RESOURCE_DEPS:=BITMAP $(OTHER_RESOURCE)
       
   180 LIB_DEPS:=RESOURCE $(OTHER_LIB)
       
   181 BLD_DEPS:=LIBRARY $(OTHER_BLD)
       
   182 FINAL_DEPS:=TARGET $(OTHER_FINAL)
       
   183 FREEZE_DEPS:=$(OTHER_FREEZE)
       
   184 CLEANLIB_DEPS:=$(OTHER_CLEANLIB)
       
   185 CLEAN_DEPS:=$(OTHER_CLEAN)
       
   186 
       
   187 export /
       
   188 export ;
       
   189 export SHELL
       
   190 
       
   191 #################################### Global Targets ##
       
   192 ## All the global targets for the TEM
       
   193 # TEMs are called as sub-makes.
       
   194 
       
   195 define getMember
       
   196 $(subst $$,$$$$,$(O.$(1)))
       
   197 endef
       
   198 
       
   199 define callTEM
       
   200 .PHONY:: $(UNIQ)_$(CFG)_$(1) 
       
   201 $($(1)_HOOK):: $(UNIQ)_$(CFG)_$(1)
       
   202 
       
   203 $(EPOCROOT)/epoc32/build/TEM_$(1):: $(UNIQ)_$(CFG)_$(1)
       
   204 
       
   205 $(UNIQ)_$(CFG)_$(1) : $($(1)_DEPS)
       
   206 	$(call startrule,tem,FORCESUCCESS,$(notdir $(TEMPLATE_EXTENSION_MAKEFILE))_$(1)) \
       
   207 	$(foreach V,$(TEPARAMETERS),$(V)='$($(V))') TEMTARGET='$(1)' $(foreach V,$(O._MEMBERS),$(V)='$(call getMember,$(V))')  $(TEMMAKE) -C $(EPOCBLD) -f $(TEMPLATE_EXTENSION_MAKEFILE) $(if $(SAVESPACE),$(subst BLD,SAVESPACE,$(1)),$(1)) \
       
   208 	$(call endrule,tem)
       
   209 ifneq ($(call isoneof,$(1),RELEASABLES FINAL),)
       
   210 	$(call startrawoutput) \
       
   211 	echo "$(call whatLogOpen)" ; \
       
   212 	$(foreach V,$(TEPARAMETERS),$(V)='$($(V))') TEMTARGET='$(1)' \
       
   213 	$(foreach V,$(O._MEMBERS),$(V)='$(call getMember,$(V))')  \
       
   214 	$(TEMMAKE) -s --no-print-directory -C $(EPOCBLD) -f $(TEMPLATE_EXTENSION_MAKEFILE) RELEASABLES | \
       
   215 	(read -r LINE; while [ $$$$? -eq 0 ]; do \
       
   216 	if [[ ! $$$$LINE =~ "Nothing to be done for"  ]] ; then echo "$(call whatLogItem,TEM,$$$$LINE)"; fi; \
       
   217 	read -r LINE; done; ); \
       
   218 	echo "$(call whatLogClose)" \
       
   219 	$(call endrawoutput) 
       
   220 
       
   221 WHATTEM:: $(UNIQ)_$(CFG)_RELEASABLES
       
   222 
       
   223 endif
       
   224 
       
   225 
       
   226 tem_debug::
       
   227 	@echo "TEM_DEBUG: O._MEMBERS=$(O._MEMBERS)"
       
   228 endef
       
   229 
       
   230 $(foreach TETRG,$(TETARGETS),$(eval $(call callTEM,$(TETRG))))