You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile.housekeeping 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. # -*- makefile -*- : Force emacs to use Makefile mode
  2. # This file contains various boring housekeeping functions that would
  3. # otherwise seriously clutter up the main Makefile.
  4. # Objects to be removed by "make clean"
  5. #
  6. CLEANUP := $(BIN)/*.* # *.* to avoid catching the "CVS" directory
  7. # Show what we're using for "echo -e"
  8. #
  9. echo :
  10. @$(ECHO) Using "$(ECHO)" to echo
  11. # Version number calculations
  12. #
  13. VERSION_MAJOR = 0
  14. VERSION_MINOR = 5
  15. VERSION_PATCH = 1
  16. EXTRAVERSION =
  17. MM_VERSION = $(VERSION_MAJOR).$(VERSION_MINOR)
  18. VERSION = $(MM_VERSION).$(VERSION_PATCH)$(EXTRAVERSION)
  19. CFLAGS += -DVERSION_MAJOR=$(VERSION_MAJOR) \
  20. -DVERSION_MINOR=$(VERSION_MINOR) \
  21. -DVERSION=\"$(VERSION)\"
  22. IDENT = '$(@F) $(VERSION) (GPL) etherboot.org'
  23. version :
  24. @$(ECHO) $(VERSION)
  25. # Check for tools that can cause failed builds
  26. #
  27. .toolcheck : Makefile Config
  28. @if $(CC) -v 2>&1 | grep -is 'gcc version 2\.96' > /dev/null; then \
  29. $(ECHO) 'gcc 2.96 is unsuitable for compiling Etherboot'; \
  30. $(ECHO) 'Use gcc 2.95 or gcc 3.x instead'; \
  31. exit 1; \
  32. fi
  33. @if [ `perl -e 'use bytes; print chr(255)' | wc -c` = 2 ]; then \
  34. $(ECHO) 'Your Perl version has a Unicode handling bug'; \
  35. $(ECHO) 'Execute this command before compiling Etherboot:'; \
  36. $(ECHO) 'export LANG=$${LANG%.UTF-8}'; \
  37. exit 1; \
  38. fi
  39. @$(TOUCH) $@
  40. VERYCLEANUP += .toolcheck
  41. # Build verbosity
  42. #
  43. ifeq ($(V),1)
  44. Q =
  45. QM = @\#
  46. else
  47. Q = @
  48. QM = @
  49. endif
  50. # Check for an old version of gas (binutils 2.9.1)
  51. #
  52. OLDGAS := $(shell $(AS) --version | grep -q '2\.9\.1' && $(ECHO) -DGAS291)
  53. CFLAGS += $(OLDGAS)
  54. oldgas :
  55. @$(ECHO) $(oldgas)
  56. # compiler.h is needed for our linking and debugging system
  57. #
  58. CFLAGS += -include compiler.h
  59. # config/%.h files are generated from config.h using mkconfig.pl
  60. config/%.h : config.h
  61. $(MKCONFIG) $<
  62. CLEANUP += config/*.h
  63. # SRCDIRS lists all directories containing source files.
  64. srcdirs :
  65. @$(ECHO) $(SRCDIRS)
  66. # SRCS lists all .c or .S files found in any SRCDIR
  67. #
  68. SRCS += $(wildcard $(patsubst %,%/*.c,$(SRCDIRS)))
  69. SRCS += $(wildcard $(patsubst %,%/*.S,$(SRCDIRS)))
  70. srcs :
  71. @$(ECHO) $(SRCS)
  72. # AUTO_SRCS lists all files in SRCS that are not mentioned in
  73. # NON_AUTO_SRCS. Files should be added to NON_AUTO_SRCS if they
  74. # cannot be built using the standard build template.
  75. #
  76. AUTO_SRCS = $(filter-out $(NON_AUTO_SRCS),$(SRCS))
  77. autosrcs :
  78. @$(ECHO) $(AUTO_SRCS)
  79. # We automatically generate rules for any file mentioned in AUTO_SRCS
  80. # using the following set of templates. It would be cleaner to use
  81. # $(eval ...), but this function exists only in GNU make >= 3.80.
  82. # src_template : generate Makefile rules for a given source file
  83. #
  84. # $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
  85. # $(2) is the full path to the .d file (e.g. "bin/deps/drivers/net/rtl8139.d")
  86. # $(3) is the source type (e.g. "c")
  87. # $(4) is the source base name (e.g. "rtl8139")
  88. #
  89. define src_template
  90. @$(ECHO) "Generating Makefile rules for $(1)"
  91. @$(MKDIR) -p $(dir $(2))
  92. @$(RM) $(2)
  93. @$(TOUCH) $(2)
  94. $(foreach OBJ,$(if $(OBJS_$(4)),$(OBJS_$(4)),$(4)), \
  95. $(call obj_template,$(1),$(2),$(3),$(OBJ)))
  96. @$(PARSEROM) $(1) >> $(2)
  97. endef
  98. # obj_template : generate Makefile rules for a given resultant object
  99. # of a particular source file. (We can have multiple objects per
  100. # source file via the OBJS_xxx list.)
  101. #
  102. # $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
  103. # $(2) is the full path to the .d file (e.g. "bin/deps/drivers/net/rtl8139.d")
  104. # $(3) is the source type (e.g. "c")
  105. # $(4) is the object name (e.g. "rtl8139")
  106. #
  107. define obj_template
  108. @$(CPP) $(CFLAGS) $(CFLAGS_$(3)) $(CFLAGS_$(4)) -DOBJECT=$(4) \
  109. -Wno-error -M $(1) -MT "$(4)_DEPS" -MG -MP | \
  110. sed 's/_DEPS\s*:/_DEPS =/' >> $(2)
  111. @$(ECHO) '\n$$(BIN)/$(4).o : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \
  112. '\n\t$$(QM)$(ECHO) " [BUILD] $$@"\n' \
  113. '\n\t$$(RULE_$(3))\n' \
  114. '\nBOBJS += $$(BIN)/$(4).o\n' \
  115. $(foreach TGT,$(DEBUG_TARGETS), \
  116. $(if $(RULE_$(3)_to_$(TGT)), \
  117. '\n$$(BIN)/$(4).$(TGT) : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \
  118. '\n\t$$(QM)$(ECHO) " [BUILD] $$@"\n' \
  119. '\n\t$$(RULE_$(3)_to_$(TGT))\n' \
  120. '\n$(TGT)_OBJS += $$(BIN)/$(4).$(TGT)\n' ) ) \
  121. '\n$(2) : $$($(4)_DEPS)\n' \
  122. '\nTAGS : $$($(4)_DEPS)\n' \
  123. >> $(2)
  124. endef
  125. # Rule to generate the Makefile rules files to be included
  126. #
  127. $(BIN)/deps/%.d : % $(MAKEDEPS) $(PARSEROM)
  128. $(if $(filter $(AUTO_SRCS),$<),$(call src_template,$<,$@,$(subst .,,$(suffix $<)),$(basename $(notdir $<))),@$(ECHO) 'ERROR: $< is not an AUTO_SRC' ; exit 1)
  129. # Calculate and include the list of Makefile rules files
  130. #
  131. AUTO_DEPS = $(patsubst %,$(BIN)/deps/%.d,$(AUTO_SRCS))
  132. include $(AUTO_DEPS)
  133. autodeps :
  134. @$(ECHO) $(AUTO_DEPS)
  135. VERYCLEANUP += $(BIN)/deps
  136. # The following variables are created by the Makefile rules files
  137. #
  138. bobjs :
  139. @$(ECHO) $(BOBJS)
  140. drivers :
  141. @$(ECHO) $(DRIVERS)
  142. .PHONY : drivers
  143. roms :
  144. @$(ECHO) $(ROMS)
  145. # Generate the NIC file from the parsed source files. The NIC file is
  146. # only for rom-o-matic.
  147. #
  148. $(BIN)/NIC : $(AUTO_DEPS)
  149. @$(ECHO) '# This is an automatically generated file, do not edit' > $@
  150. @$(ECHO) '# It does not affect anything in the build, ' \
  151. 'it is only for rom-o-matic' >> $@
  152. @$(ECHO) >> $@
  153. @perl -ne 'chomp; print "$$1\n" if /\# NIC\t(.*)$$/' $^ >> $@
  154. CLEANUP += $(BIN)/NIC
  155. # Analyse a target name (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and
  156. # derive the variables:
  157. #
  158. # TGT_ELEMENTS : the elements of the target (e.g. "dfe538 prism2_pci")
  159. # TGT_PREFIX : the prefix type (e.g. "zrom")
  160. # TGT_DRIVERS : the driver for each element (e.g. "rtl8139 prism2_pci")
  161. # TGT_ROM_NAME : the ROM name (e.g. "dfe538")
  162. # TGT_MEDIA : the media type (e.g. "rom")
  163. #
  164. DRIVERS_gpxe = $(DRIVERS)
  165. CARD_DRIVER = $(firstword $(DRIVER_$(1)) $(1))
  166. TGT_ELEMENTS = $(subst --, ,$(firstword $(subst ., ,$(notdir $@))))
  167. TGT_PREFIX = $(word 2,$(subst ., ,$(notdir $@)))
  168. TGT_ROM_NAME = $(firstword $(TGT_ELEMENTS))
  169. TGT_DRIVERS = $(strip $(if $(DRIVERS_$(TGT_ROM_NAME)), \
  170. $(DRIVERS_$(TGT_ROM_NAME)), \
  171. $(foreach TGT_ELEMENT,$(TGT_ELEMENTS), \
  172. $(call CARD_DRIVER,$(TGT_ELEMENT))) ))
  173. TGT_MEDIA = $(subst z,,$(TGT_PREFIX))
  174. # Look up ROM IDs for the current target
  175. # (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and derive the variables:
  176. #
  177. # TGT_PCI_VENDOR : the PCI vendor ID (e.g. "0x1186")
  178. # TGT_PCI_DEVICE : the PCI device ID (e.g. "0x1300")
  179. #
  180. TGT_PCI_VENDOR = $(PCI_VENDOR_$(TGT_ROM_NAME))
  181. TGT_PCI_DEVICE = $(PCI_DEVICE_$(TGT_ROM_NAME))
  182. # Calculate link-time options for the current target
  183. # (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and derive the variables:
  184. #
  185. # TGT_LD_DRIVERS : symbols to require in order to drag in the relevant drivers
  186. # (e.g. "obj_rtl8139 obj_prism2_pci")
  187. # TGT_LD_IDS : symbols to define in order to fill in ID structures in the
  188. # ROM header (e.g."pci_vendor_id=0x1186 pci_device_id=0x1300")
  189. #
  190. TGT_LD_DRIVERS = $(subst -,_,$(patsubst %,obj_%,$(TGT_DRIVERS)))
  191. TGT_LD_PREFIX = obj_$(TGT_PREFIX)prefix
  192. TGT_LD_IDS = $(if $(TGT_PCI_VENDOR),pci_vendor_id=$(TGT_PCI_VENDOR)) \
  193. $(if $(TGT_PCI_DEVICE),pci_device_id=$(TGT_PCI_DEVICE))
  194. # Calculate linker flags based on link-time options for the current
  195. # target type (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and derive the
  196. # variables:
  197. #
  198. # TGT_LD_FLAGS : target-specific flags to pass to linker (e.g.
  199. # "-u obj_zpciprefix -u obj_rtl8139 -u obj_prism2_pci
  200. # --defsym pci_vendor=0x1186 --defsym pci_device=0x1300")
  201. #
  202. TGT_LD_FLAGS = $(foreach SYM,$(TGT_LD_PREFIX) $(TGT_LD_DRIVERS) obj_config,\
  203. -u $(SYM) --defsym check_$(SYM)=$(SYM) ) \
  204. $(patsubst %,--defsym %,$(TGT_LD_IDS))
  205. # Calculate makerom flags for the specific target
  206. # (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and derive the variables:
  207. #
  208. # TGT_MAKEROM_FLAGS : target-specific flags for makerom (e.g.
  209. # "-p 0x1186,0x1300")
  210. #
  211. TGT_MAKEROM_FLAGS = $(strip $(MAKEROM_FLAGS_$(TGT_ROM_NAME)) \
  212. $(if $(TGT_PCI_VENDOR),$(strip -p $(TGT_PCI_VENDOR),$(TGT_PCI_DEVICE))))
  213. # Calculate list of debugging versions of objects to be included in
  214. # the target.
  215. #
  216. COMMA := ,
  217. DEBUG_LIST = $(subst $(COMMA), ,$(DEBUG))
  218. DEBUG_OBJ_LEVEL = $(firstword $(word 2,$(subst :, ,$(1))) 1)
  219. DEBUG_OBJ_BASE = $(word 1,$(subst :, ,$(1))).dbg$(call DEBUG_OBJ_LEVEL,$(1))
  220. DEBUG_OBJ = $(BIN)/$(call DEBUG_OBJ_BASE,$(1)).o
  221. DEBUG_ORIG_OBJ = $(BIN)/$(word 1,$(subst :, ,$(1))).o
  222. DEBUG_OBJS = $(foreach D,$(DEBUG_LIST),$(call DEBUG_OBJ,$(D)))
  223. DEBUG_ORIG_OBJS = $(foreach D,$(DEBUG_LIST),$(call DEBUG_ORIG_OBJ,$(D)))
  224. BLIB_OBJS = $(DEBUG_OBJS) $(filter-out $(DEBUG_ORIG_OBJS),$(BOBJS))
  225. # Print out all derived information for a given target.
  226. #
  227. $(BIN)/%.info :
  228. @$(ECHO) 'Elements : $(TGT_ELEMENTS)'
  229. @$(ECHO) 'Prefix : $(TGT_PREFIX)'
  230. @$(ECHO) 'Drivers : $(TGT_DRIVERS)'
  231. @$(ECHO) 'ROM name : $(TGT_ROM_NAME)'
  232. @$(ECHO) 'Media : $(TGT_MEDIA)'
  233. @$(ECHO)
  234. @$(ECHO) 'PCI vendor : $(TGT_PCI_VENDOR)'
  235. @$(ECHO) 'PCI device : $(TGT_PCI_DEVICE)'
  236. @$(ECHO)
  237. @$(ECHO) 'LD driver symbols : $(TGT_LD_DRIVERS)'
  238. @$(ECHO) 'LD prefix symbols : $(TGT_LD_PREFIX)'
  239. @$(ECHO) 'LD ID symbols : $(TGT_LD_IDS)'
  240. @$(ECHO)
  241. @$(ECHO) 'LD target flags : $(TGT_LD_FLAGS)'
  242. @$(ECHO)
  243. @$(ECHO) 'makerom target flags : $(TGT_MAKEROM_FLAGS)'
  244. @$(ECHO)
  245. @$(ECHO) 'Debugging objects : $(DEBUG_OBJS)'
  246. @$(ECHO) 'Replaced objects : $(DEBUG_ORIG_OBJS)'
  247. # List of objects included in the last build of blib. This is needed
  248. # in order to correctly rebuild blib whenever the list of objects
  249. # changes.
  250. #
  251. BLIB_LIST = $(BIN)/.blib.list
  252. ifneq ($(shell cat $(BLIB_LIST)),$(BLIB_OBJS))
  253. $(shell $(ECHO) "$(BLIB_OBJS)" > $(BLIB_LIST))
  254. endif
  255. $(BLIB_LIST) :
  256. VERYCLEANUP += $(BLIB_LIST)
  257. # Library of all objects
  258. #
  259. BLIB = $(BIN)/blib.a
  260. $(BLIB) : $(BLIB_OBJS) $(BLIB_LIST) $(MAKEDEPS)
  261. $(Q)$(RM) $(BLIB)
  262. $(QM)$(ECHO) " [AR] $@"
  263. $(Q)$(AR) r $@ $(BLIB_OBJS)
  264. $(Q)$(RANLIB) $@
  265. blib : $(BLIB)
  266. # Build an intermediate object file from the objects required for the
  267. # specified target.
  268. #
  269. $(BIN)/%.tmp : $(BLIB) $(MAKEDEPS) $(LDSCRIPT)
  270. $(QM)$(ECHO) " [LD] $@"
  271. $(Q)$(LD) $(LDFLAGS) -T $(LDSCRIPT) $(TGT_LD_FLAGS) $(BLIB) -o $@ \
  272. -Map $(BIN)/$*.tmp.map
  273. $(Q)$(OBJDUMP) -ht $@ | $(SORTOBJDUMP) >> $(BIN)/$*.tmp.map
  274. # Show a linker map for the specified target
  275. #
  276. $(BIN)/%.map : $(BIN)/%.tmp
  277. @less $(BIN)/$*.tmp.map
  278. # Extract compression information from intermediate object file
  279. #
  280. $(BIN)/%.zinfo : $(BIN)/%.tmp
  281. $(QM)$(ECHO) " [ZINFO] $@"
  282. $(Q)$(OBJCOPY) -O binary -j .zinfo $< $@
  283. # Build raw binary file from intermediate object file
  284. #
  285. $(BIN)/%.bin : $(BIN)/%.tmp
  286. $(QM)$(ECHO) " [BIN] $@"
  287. $(Q)$(OBJCOPY) -O binary -R .zinfo $< $@
  288. # Compress raw binary file
  289. #
  290. $(BIN)/%.zbin : $(BIN)/%.bin $(BIN)/%.zinfo $(ZBIN)
  291. $(QM)$(ECHO) " [ZBIN] $@"
  292. $(Q)$(ZBIN) $(BIN)/$*.bin $(BIN)/$*.zinfo > $@
  293. # Build bochs symbol table
  294. $(BIN)/%.bxs : $(BIN)/%.tmp
  295. $(NM) $< | cut -d" " -f1,3 > $@
  296. # Rules for each media format. These are generated and placed in an
  297. # external Makefile fragment. We could do this via $(eval ...), but
  298. # that would require make >= 3.80.
  299. #
  300. # Note that there's an alternative way to generate most .rom images:
  301. # they can be copied from their 'master' ROM image using cp and
  302. # reprocessed with makerom to add the PCI IDs and ident string. The
  303. # relevant rule would look something like:
  304. #
  305. # $(BIN)/dfe538%rom : $(BIN)/rtl8139%rom
  306. # cat $< $@
  307. # $(FINALISE_rom)
  308. #
  309. # You can derive the ROM/driver relationships using the variables
  310. # DRIVER_<rom> and/or ROMS_<driver>.
  311. #
  312. # We don't currently do this, because (a) it would require generating
  313. # yet more Makefile fragments (since you need a rule for each ROM in
  314. # ROMS), and (b) the linker is so fast that it probably wouldn't make
  315. # much difference to the overall build time.
  316. media :
  317. @$(ECHO) $(MEDIA)
  318. AUTO_MEDIA = $(filter-out $(NON_AUTO_MEDIA),$(MEDIA))
  319. automedia :
  320. @$(ECHO) $(AUTO_MEDIA)
  321. # media_template : create Makefile rules for specified media
  322. #
  323. # $(1) is the media name (e.g. "rom")
  324. # $(2) is the full path to the .d file (e.g. "bin/deps/rom.media.d")
  325. #
  326. define media_template
  327. @$(ECHO) "Generating Makefile rules for $(1) media"
  328. @$(MKDIR) -p $(dir $(2))
  329. @$(RM) $(2)
  330. @$(TOUCH) $(2)
  331. @$(ECHO) '$$(BIN)/%.$(1) : $$(BIN)/%.$(1).zbin' \
  332. '\n\t$$(QM)$(ECHO) " [FINISH] $$@"' \
  333. '\n\t$$(Q)$$(CP) $$< $$@' \
  334. '\n\t$$(Q)$$(FINALISE_$(1))' \
  335. > $(2)
  336. endef
  337. # Rule to generate the Makefile rules to be included
  338. #
  339. $(BIN)/deps/%.media.d : $(MAKEDEPS)
  340. $(if $(filter $(AUTO_MEDIA),$*), \
  341. $(call media_template,$*,$@), \
  342. @$(ECHO) 'ERROR: $* is not an AUTO_MEDIA' ; exit 1)
  343. # Calculate and include the list of Makefile rules files
  344. #
  345. MEDIA_DEPS = $(patsubst %,$(BIN)/deps/%.media.d,$(AUTO_MEDIA))
  346. mediadeps :
  347. @$(ECHO) $(MEDIA_DEPS)
  348. include $(MEDIA_DEPS)
  349. # The "allXXXs" targets for each suffix
  350. #
  351. allall: allroms allzroms allpxes allisos alldsks
  352. allroms allzroms : all%s : $(foreach ROM,$(ROMS),$(BIN)/$(ROM).%)
  353. allpxes allisos alldsks : all%s : $(foreach DRIVER,$(DRIVERS),$(BIN)/$(DRIVER).%)
  354. # Alias for gpxe.%
  355. #
  356. $(BIN)/etherboot.% : $(BIN)/gpxe.%
  357. ln -sf $(notdir $<) $@
  358. # Wrap up binary blobs
  359. #
  360. $(BIN)/%.o : payload/%.img
  361. $(QM)echo " [WRAP] $@"
  362. $(Q)$(LD) -b binary -r -o $@ $< --undefined obj_payload \
  363. --defsym obj_$*=0
  364. BOBJS += $(patsubst payload/%.img,$(BIN)/%.o,$(wildcard payload/*.img))
  365. # The compression utilities
  366. #
  367. $(NRV2B) : util/nrv2b.c $(MAKEDEPS)
  368. $(QM)$(ECHO) " [HOSTCC] $@"
  369. $(Q)$(HOST_CC) -O2 -DENCODE -DDECODE -DMAIN -DVERBOSE -DNDEBUG \
  370. -DBITSIZE=32 -DENDIAN=0 -o $@ $<
  371. CLEANUP += $(NRV2B)
  372. $(ZBIN) : util/zbin.c util/nrv2b.c $(MAKEDEPS)
  373. $(QM)$(ECHO) " [HOSTCC] $@"
  374. $(Q)$(HOST_CC) -O2 -o $@ $<
  375. CLEANUP += $(ZBIN)
  376. # Auto-incrementing build serial number. Append "bs" to your list of
  377. # build targets to get a serial number printed at the end of the
  378. # build. Enable -DBUILD_SERIAL in order to see it when the code runs.
  379. #
  380. BUILDSERIAL_H = config/.buildserial.h
  381. BUILDSERIAL_NOW = config/.buildserial.now
  382. BUILDSERIAL_NEXT = config/.buildserial.next
  383. $(BUILDSERIAL_NOW) $(BUILDSERIAL_NEXT) :
  384. $(ECHO) 1 > $@
  385. $(BUILDSERIAL_H) : $(BUILDSERIAL_NOW) $(BUILDSERIAL_NEXT)
  386. $(ECHO) '#define BUILD_SERIAL_NUM $(shell cat $<)' > $@
  387. ifeq ($(filter bs,$(MAKECMDGOALS)),bs)
  388. $(shell diff -q $(BUILDSERIAL_NOW) $(BUILDSERIAL_NEXT) > /dev/null || \
  389. cp -f $(BUILDSERIAL_NEXT) $(BUILDSERIAL_NOW))
  390. endif
  391. bs : $(BUILDSERIAL_NOW)
  392. @$(ECHO) $$(( $(shell cat $<) + 1 )) > $(BUILDSERIAL_NEXT)
  393. @$(ECHO) "Build serial number is $(shell cat $<)"
  394. # List of available architectures
  395. #
  396. ARCHS = $(filter-out CVS,$(patsubst arch/%,%,$(wildcard arch/*)))
  397. archs :
  398. @$(ECHO) $(ARCHS)
  399. OTHER_ARCHS = $(filter-out $(ARCH),$(ARCHS))
  400. otherarchs :
  401. @$(ECHO) $(OTHER_ARCHS)
  402. # Build the TAGS file for emacs
  403. #
  404. TAGS : TAGS.$(ARCH)
  405. TAGS.$(ARCH) :
  406. ctags -e -R -f $@ --exclude=bin \
  407. $(foreach ARCH,$(OTHER_ARCHS),--exclude=arch/$(ARCH))
  408. CLEANUP += TAGS*
  409. # Symbol table checks
  410. #
  411. SYMTAB = $(BIN)/symtab
  412. $(SYMTAB) : $(BLIB)
  413. $(OBJDUMP) -w -t $< > $@
  414. CLEANUP += $(BIN)/symtab
  415. symcheck : $(SYMTAB)
  416. $(SYMCHECK) $<
  417. # Force rebuild for any given target
  418. #
  419. $(BIN)/%.rebuild :
  420. rm -f $(BIN)/$*
  421. $(MAKE) $(MAKEFLAGS) $(BIN)/$*
  422. # Documentation
  423. #
  424. $(BIN)/doxygen.cfg : doxygen.cfg $(MAKEDEPS)
  425. $(PERL) -pe 's{\@SRCDIRS\@}{$(SRCDIRS)}; ' \
  426. -e 's{\@BIN\@}{$(BIN)}; ' \
  427. -e 's{\@ARCH\@}{$(ARCH)}; ' \
  428. $< > $@
  429. $(BIN)/doc : $(BIN)/doxygen.cfg
  430. $(DOXYGEN) $<
  431. .PHONY : $(BIN)/doc
  432. VERYCLEANUP += $(BIN)/doc
  433. doc : $(BIN)/doc
  434. docview :
  435. @[ -f $(BIN)/doc/html/index.html ] || $(MAKE) $(BIN)/doc
  436. @if [ -n "$$BROWSER" ] ; then \
  437. ( $$BROWSER $(BIN)/doc/html/index.html & ) ; \
  438. else \
  439. $(ECHO) "Documentation index in $(BIN)/doc/html/index.html" ; \
  440. fi
  441. # Clean-up
  442. #
  443. clean :
  444. $(RM) $(CLEANUP)
  445. veryclean : clean
  446. $(RM) -r $(VERYCLEANUP)
  447. # Make clean tarballs for release
  448. gpxe-tarball : ../VERSION
  449. ($(ECHO) -n $(VERSION) ''; date -u +'%Y-%m-%d') > ../VERSION
  450. $(RM) -r /tmp/gpxe/gpxe-$(VERSION)
  451. mkdir -p /tmp/gpxe/gpxe-$(VERSION)
  452. cp -rP .. /tmp/gpxe/gpxe-$(VERSION)
  453. $(RM) -r /tmp/gpxe/CVS
  454. ( cd /tmp/gpxe/gpxe-$(VERSION)/src ; $(RM) -r bin/deps ; $(MAKE) clean ; $(MAKE) veryclean )
  455. ( cd /tmp/gpxe; tar cf /tmp/gpxe/gpxe-$(VERSION).tar --exclude CVS --exclude "#*" \
  456. --exclude "*~" gpxe-$(VERSION) )
  457. bzip2 -9 < /tmp/gpxe/gpxe-$(VERSION).tar > /tmp/gpxe/gpxe-$(VERSION).tar.bz2
  458. gzip -9 < /tmp/gpxe/gpxe-$(VERSION).tar > /tmp/gpxe/gpxe-$(VERSION).tar.gz
  459. $(RM) -r /tmp/gpxe/gpxe-$(VERSION)
  460. $(RM) /tmp/gpxe/gpxe-$(VERSION).tar
  461. ( cd /tmp/gpxe ; tar -zxf /tmp/gpxe/gpxe-$(VERSION).tar.gz )