rules.project
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:11k
源码类别:

VxWorks

开发平台:

C/C++

  1. # rules.project - makefile target rules for BSP
  2. #
  3. # modification history
  4. # --------------------
  5. # 01t,13mar02,sn   SPR 74080 - added large project support for Diab
  6. # 01s,04feb02,rbl  add dummy "force" target to help with sub-projects
  7. # 01r,07dec01,tpw  Remove HEX_HIGH_FLAGS and HEX_LOW_FLAGS, and fix proj %.hex
  8. # 01q,08nov01,tpw  Add general %.bin rule.
  9. # 01p,06nov01,tpw  Add %.old rule to facilitate conversions to old OMFs
  10. # 01o,20oct01,dat  Relocating tool specific macro
  11. # 01n,17sep01,sn   moved LARGE_PROJECT defs here
  12. # 01m,24apr00,dat  SPR 30819, fix project link of ROM images
  13. # 01m,06jan00,dra  updated for new .hex file generation.
  14. # 01l,11mar99,sn   To prevent make from sticking "informative" messages
  15. #                  about what it's doing in prjObjs.lst, 
  16. #                  changed -s -> --no-print-directory.
  17. # 01k,10mar99,ren  Circumventing bug in gnu make, where if there is a t in the 
  18. #                  pathname, it puts a tab char instead.
  19. # 01j,04mar99,sn   added machinery to handle large projects
  20. # 01i,19feb99,ren  clean did not remove correct files
  21. # 01h,11nov98,sn   partially link using LD_PARTIAL
  22. #                  clean now removes .rpo files
  23. # 01g,09jul98,ms   changed libs.size to libs.siz
  24. # 01f,01jul98,jmp  replaced LIBS by the library name in libs.nm and libs.siz
  25. #                  rules.
  26. # 01e,29jun98,ms   module xref support; nm->nm -ng. new rules for autoscale.
  27. # 01e,02jun98,ms   updated prjConfig.c rules and dependancies.
  28. # 01d,02jun98,ms   updated description, removed implicit rules, rom*.o rules
  29. # 01c,02apr98,pcn  Removed Objcopy changes from Tempest view
  30. # 01b,15dec97,pcn  Added Objcopy in BSP build.
  31. # 01a,20oct97,ms   created from rules.bsp
  32. #
  33. # DESCRIPTION
  34. # This file contains rules used in building targets.
  35. # It uses variable definitions from defs.bsp and the BSP
  36. # Makefile, which can be overriden as needed.
  37. #
  38. # The following have no default values and must be defined in the project
  39. #    CPU                cpu type
  40. #    TOOL               compiler tool (e.g., gnu)
  41. #    PRJ_TYPE           image to build (e.g., vxWorks, bootrom, wdb)
  42. #    BSP_DIR            directory of the BSP on which this project is based
  43. #    ROM_SIZE           number of bytes of ROM space as in config.h
  44. #    ROM_TEXT_ADRS      ROM entry address
  45. #    ROM_LINK_ADRS      ROM link address
  46. #    RAM_LOW_ADRS       RAM address to which VxWorks is linked
  47. #    RAM_HIGH_ADRS      RAM address to which the boot code is linked
  48. #
  49. # The following variables specify what to build
  50. #
  51. #    DEFAULT_RULE       what to build
  52. #    RELEASE            images made as part of WRS release step
  53. #
  54. # OVERVIEW OF THE BUILD RULES
  55. #
  56. # The makefile stub is imported by BSP Makefiles to provide rules for
  57. # building VxWorks and application code. This section provides an overview
  58. # of how the system works.
  59. #
  60. # VxWorks is built in stages
  61. #   The object files are then partially linked against the archives,
  62. # typically just target/lib/lib$(CPU)$(TOOL)vx.a, to produce a
  63. # relocatable vxWorks object file.
  64. #   We then optially build some support modules (ctdt.o or symTbl.o)
  65. # to link with the relocatable vxWorks object file. These support
  66. # modules are called POSTLINK_MODULES because they are built after
  67. # the main link stage for vxWorks. This is done because these modules
  68. # are derived from the relocatable vxWorks object file.
  69. #   A fully linked executable is then formed according to one of four
  70. # possible rules:
  71. #       %_downLoadable  RAM resident (no relocation of the code)
  72. #       %_romResident   ROM resident (data segment copied to RAM)
  73. #       %_rom           ROM copy to RAM (entire image copied to RAM)
  74. #       %_romCompress   ROM uncompress to RAM (entire image uncompressed to RAM)
  75. # The first image is linked to RAM and must be loaded to RAM by some
  76. # external program such as a VxWorks bootROM.
  77. # The last three images start executing from ROM. See romStart.c for
  78. # details on how these images work.
  79. #   Finally, there are also post-processing rules available:
  80. #       %.sym           stripped image containing only the symbol table
  81. #       %.hex           srecord
  82. # %.old convert to old OMF (eg. ARM COFF, Pentium a.out)
  83. # %.bin convert to binary image
  84. #
  85. # LINKING
  86. #
  87. # The four images are linked quite differently.
  88. # The following is a summary of the default link addresses:
  89. # %_downLoadable text and data are contiguous, starting at RAM_LOW_ADRS
  90. # %_romResident text at ROM_LINK_ADRS, data at RAM_LOW_ADRS
  91. # %_rom         text at ROM_LINK_ADRS, data at HIGH_ADRS. This image contains
  92. #               a %_downLoadable subimage which is linked to
  93. #               RAM_LOW_ADRS. The %_rom_cpy just copies the subimage to
  94. #               RAM_LOW_ADRS and jumps to it (see romStart.c for details).
  95. # %_romCompress just like %_rom, but the subimage is compressed.
  96. #
  97. # SUMMARY OF CHANGES
  98. #
  99. # * Many macros have changed, but the project creation wizards
  100. #   automcatically convert from the old to the new.
  101. # * There are now only four main rules.
  102. # * The post-processing rules (%.hex, %.sym, etc.) apply to any image.
  103. # * ROM images are linked to ROM addresses so one no longer needs to
  104. #   write position independant ROM startup code.
  105. # * Build with debugging on by default (CC_DEBUG = -g).
  106. # * The macro DEFAULT_RULE can be changed to override the default build rule.
  107. # * Link flags are passed to romStart.c, eliminating the need for CPU ifdef's.
  108. # * By default, rebuild all BSP objects every time. Generate dependancies
  109. #   for user modules (not previously done).
  110. # * ctdt.o and symTbl.o are only built if the appropriate macro is defined
  111. #   in config.h.
  112. # * The vxWorks.sym file is built only if INCLUDE_NET_SYM_TBL is defined
  113. #   in config.h.
  114. # * Intermediate Makefile images are no longer deleted.
  115. # I960 IMI
  116. imi : $(IBR)
  117. $(LD) -o $@ $(LD_IMI_ADRS) $(IBR)
  118. # Large projects require special treatment because of the small command 
  119. # line length limit on Windows 95/98. 
  120. # Instead of passing the list of project objects $(PRJ_OBJS)  on 
  121. # the command line we pass the name of a file ($(PRJ_OBJS_FILE))
  122. # that contains this list using the "@file" syntax. This syntax is 
  123. # supported by the GNU tools ar<arch>,ld<arch> and nm<arch>. 
  124. # These definitions are here rather than in defs.project because they
  125. # rely on the value of $(LARGE_PROJECT) passed in from make.$(CPU)$(TOOL)
  126. ifneq ($(LARGE_PROJECT),)
  127. PRJ_OBJS_FILE=$(subst /,$(DIRCHAR),$(PRJ_DIR)/prjObjs.lst)
  128. else
  129. PRJ_OBJS_FILE=
  130. endif
  131. ifneq ($(PRJ_OBJS_FILE),)
  132. PRJ_OBJS_FOR_LD_PARTIAL=$(OPTION_PASS_TO_LD)$(OPTION_INDIRECT_FILE)$(PRJ_OBJS_FILE)
  133. PRJ_OBJS_FOR_LD=$(OPTION_INDIRECT_FILE)$(PRJ_OBJS_FILE)
  134. PRJ_OBJS_FOR_NM=$(OPTION_NM_INDIRECT_FILE)$(PRJ_OBJS_FILE)
  135. PRJ_OBJS_FOR_AR=$(OPTION_INDIRECT_FILE)$(PRJ_OBJS_FILE)
  136. else
  137. PRJ_OBJS_FOR_LD_PARTIAL=$(PRJ_OBJS)
  138. PRJ_OBJS_FOR_LD=$(PRJ_OBJS)
  139. PRJ_OBJS_FOR_NM=$(PRJ_OBJS)
  140. PRJ_OBJS_FOR_AR=$(PRJ_OBJS)
  141. endif
  142. ifneq ($(PRJ_OBJS_FILE),)
  143. # This rule creates the project object list file by delegating
  144. # the work to another target ($(PRJ_OBJS_FILE)_make) that in turn 
  145. # depends on one target per project object.
  146. $(PRJ_OBJS_FILE) : $(PRJ_DIR)/Makefile
  147. -$(RM) $@
  148. @echo Generating $(subst ,/, $@)...
  149. @$(MAKE) --no-print-directory -f $(PRJ_DIR)/Makefile $@_make > $(PRJ_OBJS_FILE)
  150. $(PRJ_OBJS_FILE)_make : $(foreach obj,$(PRJ_OBJS),$(obj)_._write_._)
  151. # We have one "write" target per project object. Each one
  152. # writes the name of the object to stdout.
  153. # The point of using "_._write_._" is simply to ensure
  154. # that the targets have odd enough names that they don't
  155. # clash with any existing targets.
  156. $(foreach obj,$(PRJ_OBJS),$(obj)_._write_._) :
  157. @echo $(subst _._write_._,,$@)
  158. endif
  159. ################################################################################
  160. #
  161. # meta build targets
  162. #
  163. ## make will default to "exe"
  164. exe : $(DEFAULT_RULE)
  165. release : $(RELEASE)
  166. __always_build__:
  167. clean   :
  168. - $(RM) *.o *.rpo ctdt.c symTbl.c $(PRJ_TYPE)* *.out *.pl
  169. - $(RM) $(PRJ_DIR)/prjComps.h $(PRJ_DIR)/prjParams.h $(PRJ_DIR)/prjConfig.c $(PRJ_DIR)/linkSyms.c
  170. - $(RM) $(PRJ_DIR)/libs.nm $(PRJ_DIR)/libs.size
  171. ###############################################################################
  172. #
  173. # Rule for generating the module xref and component library databases
  174. #
  175. mxrDoc: $(PRJ_DIR)/libs.nm $(PRJ_DIR)/libs.siz
  176. $(PRJ_DIR)/libs.nm:
  177. $(NM) $(NM_GLOB_FLAGS) $(MXR_LIBS) > $(PRJ_DIR)/libs.nm
  178. $(PRJ_DIR)/libs.siz:
  179. $(SIZE) $(MXR_LIBS) > $(PRJ_DIR)/libs.siz
  180. $(PRJ_DIR)/prjConfig.c $(PRJ_DIR)/prjComps.h $(PRJ_DIR)/prjParams.h $(PRJ_DIR)/linkSyms.c: 
  181. $(PRJ_DIR)/$(PRJ_FILE)
  182. - @ $(RM) $@
  183. $(CFG_GEN) $(PRJ_DIR)/$(PRJ_FILE)
  184. ###############################################################################
  185. #
  186. # Rule in support of autoscaling
  187. mxrInfo: $(PRJ_DIR)/mxrInfo.nm $(PRJ_DIR)/mxrInfo.size
  188. $(PRJ_DIR)/mxrInfo.nm: $(MXR_USR_OBJS)
  189. $(NM)  $(NM_GLOB_FLAGS) $(MXR_USR_OBJS) > $(subst /,$(DIRCHAR),$@)
  190. $(PRJ_DIR)/mxrInfo.size: $(MXR_USR_OBJS)
  191. $(SIZE) $(MXR_USR_OBJS) > $(subst /,$(DIRCHAR),$@)
  192. ###############################################################################
  193. #
  194. # Rule in support of dynamic loading
  195. dynLoad.o: __always_build__
  196. $(AR) -x $(LIBS) $(LIB_OBJS) 
  197. $(LD_PARTIAL) $(USR_OBJS) $(LIB_OBJS) -o $@
  198. ################################################################################
  199. #
  200. # 3 rules for objcopy flags: START_FLAGS & HEX_FLAGS, NO_VMA_FLAGS, VMA_FLAGS
  201.  
  202. # 1st rule: if NO_VMA_FLAGS==VMA_FLAGS(==0), create final output file.
  203. ifeq ($(strip $(NO_VMA_FLAGS)),$(strip $(VMA_FLAGS)))
  204.         BINHEX_OUTPUT_FILE = $@$(MAP_EXT)
  205. else
  206.         BINHEX_OUTPUT_FILE = out.tmp1
  207. endif
  208.  
  209. # 2nd rule: if NO_VMA_FLAGS!=0 && VMA_FLAGS==0, create final output file.
  210. # Note: NO_VMA_FLAGS!=0 will be tested each time.
  211. ifeq ($(strip $(VMA_FLAGS)),)
  212.         BINCONV_OUTPUT_FILE = $@$(MAP_EXT)
  213. else
  214.         BINCONV_OUTPUT_FILE = out.tmp2
  215. endif
  216.  
  217. # 3rd rule: if VMA_FLAGS!=0 && NO_VMA_FLAGS==0, use out.tmp1 else out.tmp2.
  218. # Note: VMA_FLAGS!=0 will be tested each time.
  219. ifeq ($(strip $(NO_VMA_FLAGS)),)
  220.         BINCONV_INPUT_FILE = out.tmp1
  221. else
  222.         BINCONV_INPUT_FILE = out.tmp2
  223. endif
  224. ################################################################################
  225. #
  226. # rules for building derived images
  227. #
  228. %.hex: %
  229. - @ $(RM) $@
  230. $(BINHEX) $(START_FLAGS) $(HEX_FLAGS) $(SECT_SPEC)$<$(TXT_OFFSET) 
  231. $(IMI_SPEC)$(IMI)$(IMI_OFFSET) $(BINHEX_OUTPUT_FILE)
  232. ifneq ($(strip $(NO_VMA_FLAGS)),)
  233. $(BINCONV) $(NO_VMA_FLAGS) out.tmp1 $(BINCONV_OUTPUT_FILE)
  234. endif
  235. ifneq ($(strip $(VMA_FLAGS)),)
  236. $(BINCONV) $(VMA_FLAGS) $(BINCONV_INPUT_FILE) $@$(MAP_EXT)
  237. endif
  238. - @ $(RM) out.tmp*
  239. %.old: %
  240. - @ $(RM) $@
  241. $(BINCONV) $(OBJCOPY_OLD_OMF) $< $@
  242. %.bin: %
  243. - @ $(RM) $@
  244. $(EXTRACT_BIN) $< $@
  245. ################################################################################
  246. #
  247. # subproject support
  248. #
  249. # wind_force_make has no dependency and no rule. Depending on wind_force_make is
  250. # a way to ensure that a rule is always executed. 
  251. wind_force_make: ;
  252. include $(TGT_DIR)/h/make/rules.$(PRJ_TYPE)