template_ext.flm 6.6 KB

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