metaflm.mk 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. #
  2. # Copyright (c) 2007-2011 Nokia Corporation and/or its subsidiary(-ies).
  3. # All rights reserved.
  4. # This component and the accompanying materials are made available
  5. # under the terms of the License "Eclipse Public License v1.0"
  6. # which accompanies this distribution, and is available
  7. # at the URL "http://www.eclipse.org/legal/epl-v10.html".
  8. #
  9. # Initial Contributors:
  10. # Nokia Corporation - initial contribution.
  11. #
  12. # Contributors:
  13. #
  14. # Description:
  15. #
  16. # Macros for creating Standard targets
  17. ifeq ($(_METAFLM_MK_),)
  18. _METAFLM_MK_:=1
  19. # GENERATE STANDARD CLEAN TARGET
  20. # example usage:
  21. # $(eval $(call GenerateStandardCleanTarget,$(FILE_LIST),$(DIRECTORY_LIST)))
  22. ## CLEAN macros #####################################
  23. # The clean macro does not generate a target but extension makefiles do have
  24. # CLEAN targets that need to be attached to something.
  25. .PHONY:: CLEAN
  26. define GenerateStandardCleanTarget
  27. $(info <clean bldinf='$(COMPONENT_META)' mmp='$(PROJECT_META)' config='$(SBS_CONFIGURATION)'>)
  28. $(foreach ITEM,$(1),$(info <file>$(ITEM)</file>))
  29. $(foreach ITEM,$(2),$(info <dir>$(ITEM)</dir>))
  30. $(info </clean>)
  31. endef
  32. ## End CLEAN macros #####################################
  33. ## WHAT macros #####################################
  34. ## Begin --what Macros #####
  35. define outputWhat
  36. ifeq ($(OSTYPE),cygwin)
  37. $(2)::
  38. @for FILE in $(subst %20,$(CHAR_SPACE),$(subst /,\\,$(call dblquote,$(1)))); do \
  39. echo $$$$FILE; \
  40. done;
  41. else
  42. $(2)::
  43. @for FILE in $(subst %20,$(CHAR_SPACE),$(1)); do \
  44. echo $$$$FILE; \
  45. done
  46. endif
  47. endef
  48. ## End --what Macros #####
  49. ## Begin .whatlog Macros #####
  50. define whatLogOpen
  51. <whatlog bldinf='$(COMPONENT_META)' mmp='$(PROJECT_META)' config='$(SBS_CONFIGURATION)'>
  52. endef
  53. define whatLogItem
  54. $(if $(findstring EXPORT,$(1)),<export ,$(if $(findstring RESOURCE,$(1)),<resource>,$(if $(findstring BITMAP,$(1)),<bitmap>,$(if $(findstring STRINGTABLE,$(1)),<stringtable>,$(if $(findstring ARCHIVE,$(1)),<member>,<build>)))))$(subst %20,$(CHAR_SPACE),$(2))$(if $(findstring EXPORT,$(1)),/>,$(if $(findstring RESOURCE,$(1)),</resource>,$(if $(findstring BITMAP,$(1)),</bitmap>,$(if $(findstring STRINGTABLE,$(1)),</stringtable>,$(if $(findstring ARCHIVE,$(1)),</member>,</build>)))))
  55. endef
  56. define whatLogClose
  57. </whatlog>
  58. endef
  59. define outputWhatLog
  60. $(info $(call whatLogOpen))
  61. $(foreach ITEM,$(1),$(info $(call whatLogItem,$(2),$(ITEM))))
  62. $(info $(call whatLogClose))
  63. endef
  64. ## End .whatlog Macros #####
  65. # General FLM entry points for what-related processing
  66. define WhatExports
  67. endef
  68. define whatmacro
  69. $(call outputWhatLog,$(1),$(2))
  70. endef
  71. define whatUnzip
  72. endef
  73. ## END WHAT UNZIP MACRO
  74. ## End WHAT macros #####################################
  75. # Macro for creating the test BATCH files.
  76. # Arguments: $(1) -> Target Name $(2) -> Output Batch file path
  77. # remember to catch the $(SHELL) output so that make doesn't
  78. # try to interpret it as make output.
  79. define MakeTestBatchFiles
  80. $(if $(TESTBATCHFILES),
  81. $(if $(BATCHFILE_CREATED_$(2)),
  82. $(if $(TARGET_CREATED_$(2)_$(TARGET)),
  83. ,
  84. MTBF_OUTPUT:=$$(shell echo -e "$(1)\r" >> $(2))
  85. )
  86. ,
  87. MTBF_OUTPUT:=$$(shell $(GNUMKDIR) -p $(dir $(2)))
  88. MTBF_OUTPUT:=$$(shell echo -e "$(1)\r" > $(2))
  89. )
  90. )
  91. endef
  92. ## path creation #########################
  93. # Make the destination directory if neccessary. For some
  94. # make engines we must do this outside the rule or they
  95. # get confused by the apparent way in which different rules
  96. # can create a particular directory and they infer some kind
  97. # of dependency.
  98. # Makepath. Copyright (C) 2008 Symbian Software Ltd.
  99. # buffering with repeat prevention, makes directories after every 30 calls. Any more might overload
  100. # the createprocess limit on arguments.
  101. #
  102. # makepathLIST is initialised in globals.mk
  103. define makepath_single
  104. $(if $(findstring $1,$(makepathLIST)),,$(eval makepathLIST:=$(makepathLIST) $1))
  105. $(if $(subst 30,,$(words $(makepathLIST))),,$(shell $(GNUMKDIR) -p $(makepathLIST))$(eval makepathLIST:=))
  106. endef
  107. # The following turns out to be extremely slow - something to do with using eval
  108. # or to do with creating huge numbers of TARGET_ variables? BTW, this is an attempt
  109. # to not make things that we have already made.
  110. # define makepath
  111. # $(info makepath_start)$(foreach DIR,$1,$(if $(TARGET_$(1)),,$(call makepath_single,$(DIR))$(eval TARGET_$(1):=1)))$(info makepath_end)
  112. # endef
  113. # In general, makepath creates directories during FLM evaluation.
  114. # However, if the WHAT target is being processed then it should do nothing.
  115. ifeq ($(filter WHAT,$(call uppercase,$(MAKECMDGOALS))),)
  116. define makepath
  117. $(strip $(foreach DIR,$(sort $1),$(call makepath_single,$(DIR))))
  118. endef
  119. else
  120. define makepath
  121. endef
  122. endif
  123. define makepathfor
  124. $(call makepath,$(dir $1))
  125. endef
  126. # Make any remaining paths in the path buffer
  127. define makepathfinalise
  128. $(strip $(if $(makepathLIST),$(shell $(GNUMKDIR) -p $(makepathLIST))$(eval makepathLIST:=),))
  129. endef
  130. ## Macros for writing FLMs without needing to know eval
  131. # declaring targets as RELEASABLE, for example,
  132. #
  133. # $(call raptor_release,$(TARGET1) $(TARGET2),RESOURCE)
  134. #
  135. # the optional type (RESOURCE) can be one of,
  136. # EXPORT RESOURCE BITMAP STRINGTABLE ARCHIVE
  137. #
  138. # no argument means just a default (binary) releasable.
  139. #
  140. define raptor_release
  141. $(eval $(call outputWhatLog,$1,$2))
  142. endef
  143. # declaring things that need to be cleaned.
  144. #
  145. # any files which are generated but are not RELEASABLE should be listed
  146. # using this macro, for example,
  147. #
  148. # $(call raptor_clean,$(OBJECT_FILES))
  149. #
  150. define raptor_clean
  151. $(eval $(call GenerateStandardCleanTarget,$1))
  152. endef
  153. endif
  154. # end of metaflm
  155. ## END TEST BATCH FILES MACRO