Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Makefile.housekeeping 30KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064
  1. # -*- makefile -*- : Force emacs to use Makefile mode
  2. #
  3. # This file contains various boring housekeeping functions that would
  4. # otherwise seriously clutter up the main Makefile.
  5. ###############################################################################
  6. #
  7. # Find a usable "echo -e" substitute.
  8. #
  9. TAB := $(shell $(PRINTF) '\t')
  10. ECHO_E_ECHO := $(ECHO)
  11. ECHO_E_ECHO_E := $(ECHO) -e
  12. ECHO_E_BIN_ECHO := /bin/echo
  13. ECHO_E_BIN_ECHO_E := /bin/echo -e
  14. ECHO_E_ECHO_TAB := $(shell $(ECHO_E_ECHO) '\t' | cat)
  15. ECHO_E_ECHO_E_TAB := $(shell $(ECHO_E_ECHO_E) '\t' | cat)
  16. ECHO_E_BIN_ECHO_TAB := $(shell $(ECHO_E_BIN_ECHO) '\t')
  17. ECHO_E_BIN_ECHO_E_TAB := $(shell $(ECHO_E_BIN_ECHO_E) '\t')
  18. ifeq ($(ECHO_E_ECHO_TAB),$(TAB))
  19. ECHO_E := $(ECHO_E_ECHO)
  20. endif
  21. ifeq ($(ECHO_E_ECHO_E_TAB),$(TAB))
  22. ECHO_E := $(ECHO_E_ECHO_E)
  23. endif
  24. ifeq ($(ECHO_E_BIN_ECHO_TAB),$(TAB))
  25. ECHO_E := $(ECHO_E_BIN_ECHO)
  26. endif
  27. ifeq ($(ECHO_E_BIN_ECHO_E_TAB),$(TAB))
  28. ECHO_E := $(ECHO_E_BIN_ECHO_E)
  29. endif
  30. .echocheck :
  31. ifdef ECHO_E
  32. @$(TOUCH) $@
  33. else
  34. @$(PRINTF) '%24s : x%sx\n' 'tab' '$(TAB)'
  35. @$(PRINTF) '%24s : x%sx\n' '"$(ECHO_E_ECHO) \t"' \
  36. '$(ECHO_E_ECHO_TAB)'
  37. @$(PRINTF) '%24s : x%sx\n' '"$(ECHO_E_ECHO_E) \t"' \
  38. '$(ECHO_E_ECHO_E_TAB)'
  39. @$(PRINTF) '%24s : x%sx\n' '"$(ECHO_E_BIN_ECHO) \t"' \
  40. '$(ECHO_E_BIN_ECHO_TAB)'
  41. @$(PRINTF) '%24s : x%sx\n' '"$(ECHO_E_BIN_ECHO_E) \t"' \
  42. '$(ECHO_E_BIN_ECHO_E_TAB)'
  43. @$(ECHO) "No usable \"echo -e\" substitute found"
  44. @exit 1
  45. endif
  46. MAKEDEPS += .echocheck
  47. VERYCLEANUP += .echocheck
  48. echo :
  49. @$(ECHO) "Using \"$(ECHO_E)\" for \"echo -e\""
  50. ###############################################################################
  51. #
  52. # Generate a usable "seq" substitute
  53. #
  54. define seq
  55. $(shell awk 'BEGIN { for ( i = $(1) ; i <= $(2) ; i++ ) print i }')
  56. endef
  57. ###############################################################################
  58. #
  59. # Determine host OS
  60. #
  61. HOST_OS := $(shell uname -s)
  62. hostos :
  63. @$(ECHO) $(HOST_OS)
  64. ###############################################################################
  65. #
  66. # Determine compiler
  67. CCDEFS := $(shell $(CC) -E -x c -c /dev/null -dM | cut -d" " -f2)
  68. ccdefs:
  69. @$(ECHO) $(CCDEFS)
  70. ifeq ($(filter __ICC,$(CCDEFS)),__ICC)
  71. CCTYPE := icc
  72. else
  73. CCTYPE := gcc
  74. endif
  75. cctype:
  76. @$(ECHO) $(CCTYPE)
  77. ###############################################################################
  78. #
  79. # Check for tools that can cause failed builds
  80. #
  81. .toolcheck :
  82. @if $(CC) -v 2>&1 | grep -is 'gcc version 2\.96' > /dev/null; then \
  83. $(ECHO) 'gcc 2.96 is unsuitable for compiling Etherboot'; \
  84. $(ECHO) 'Use gcc 2.95 or gcc 3.x instead'; \
  85. exit 1; \
  86. fi
  87. @if [ `perl -e 'use bytes; print chr(255)' | wc -c` = 2 ]; then \
  88. $(ECHO) 'Your Perl version has a Unicode handling bug'; \
  89. $(ECHO) 'Execute this command before compiling Etherboot:'; \
  90. $(ECHO) 'export LANG=$${LANG%.UTF-8}'; \
  91. exit 1; \
  92. fi
  93. @$(TOUCH) $@
  94. MAKEDEPS += .toolcheck
  95. VERYCLEANUP += .toolcheck
  96. ###############################################################################
  97. #
  98. # Check for various tool workarounds
  99. #
  100. # Make syntax does not allow use of comma or space in certain places.
  101. # This ugly workaround is suggested in the manual.
  102. #
  103. COMMA := ,
  104. EMPTY :=
  105. SPACE := $(EMPTY) $(EMPTY)
  106. # Check for an old version of gas (binutils 2.9.1)
  107. #
  108. OLDGAS := $(shell $(AS) --version | grep -q '2\.9\.1' && $(ECHO) -DGAS291)
  109. CFLAGS += $(OLDGAS)
  110. oldgas :
  111. @$(ECHO) $(oldgas)
  112. # Some widespread patched versions of gcc include -fstack-protector by
  113. # default, even when -ffreestanding is specified. We therefore need
  114. # to disable -fstack-protector if the compiler supports it.
  115. #
  116. ifeq ($(CCTYPE),gcc)
  117. SP_TEST = $(CC) -fno-stack-protector -x c -c /dev/null \
  118. -o /dev/null >/dev/null 2>&1
  119. SP_FLAGS := $(shell $(SP_TEST) && $(ECHO) '-fno-stack-protector')
  120. CFLAGS += $(SP_FLAGS)
  121. endif
  122. # gcc 4.4 generates .eh_frame sections by default, which distort the
  123. # output of "size". Inhibit this.
  124. #
  125. ifeq ($(CCTYPE),gcc)
  126. CFI_TEST = $(CC) -fno-dwarf2-cfi-asm -x c -c /dev/null \
  127. -o /dev/null >/dev/null 2>&1
  128. CFI_FLAGS := $(shell $(CFI_TEST) && $(ECHO) '-fno-dwarf2-cfi-asm')
  129. CFLAGS += $(CFI_FLAGS)
  130. endif
  131. # Some versions of gas choke on division operators, treating them as
  132. # comment markers. Specifying --divide will work around this problem,
  133. # but isn't available on older gas versions.
  134. #
  135. DIVIDE_TEST = $(AS) --divide /dev/null -o /dev/null 2>/dev/null
  136. DIVIDE_FLAGS := $(shell $(DIVIDE_TEST) && $(ECHO) '--divide')
  137. ASFLAGS += $(DIVIDE_FLAGS)
  138. ###############################################################################
  139. #
  140. # Build verbosity
  141. #
  142. ifeq ($(V),1)
  143. Q :=
  144. QM := @\#
  145. else
  146. Q := @
  147. QM := @
  148. endif
  149. ###############################################################################
  150. #
  151. # Set BIN according to whatever was specified on the command line as
  152. # the build target.
  153. #
  154. # Determine how many different BIN directories are mentioned in the
  155. # make goals.
  156. #
  157. BIN_GOALS := $(filter bin/% bin-%,$(MAKECMDGOALS))
  158. BIN_GOAL_BINS := $(foreach BG,$(BIN_GOALS),$(firstword $(subst /, ,$(BG))))
  159. NUM_BINS := $(words $(sort $(BIN_GOAL_BINS)))
  160. ifeq ($(NUM_BINS),0)
  161. # No BIN directory was specified. Set BIN to "bin" as a sensible
  162. # default.
  163. BIN := bin
  164. else # NUM_BINS == 0
  165. ifeq ($(NUM_BINS),1)
  166. # If exactly one BIN directory was specified, set BIN to match this
  167. # directory.
  168. #
  169. BIN := $(firstword $(BIN_GOAL_BINS))
  170. else # NUM_BINS == 1
  171. # More than one BIN directory was specified. We cannot handle the
  172. # latter case within a single make invocation, so set up recursive
  173. # targets for each BIN directory.
  174. #
  175. # Leave $(BIN) undefined. This has implications for any target that
  176. # depends on $(BIN); such targets should be made conditional upon the
  177. # existence of $(BIN).
  178. #
  179. $(BIN_GOALS) : % : BIN_RECURSE
  180. $(Q)$(MAKE) --no-print-directory BIN=$(firstword $(subst /, ,$@)) $@
  181. .PHONY : BIN_RECURSE
  182. endif # NUM_BINS == 1
  183. endif # NUM_BINS == 0
  184. ifdef BIN
  185. # Create $(BIN) directory if it doesn't exist yet
  186. #
  187. ifeq ($(wildcard $(BIN)),)
  188. $(shell $(MKDIR) -p $(BIN))
  189. endif
  190. # Target to allow e.g. "make bin-efi arch"
  191. #
  192. $(BIN) :
  193. @# Do nothing, silently
  194. .PHONY : $(BIN)
  195. # Remove everything in $(BIN) for a "make clean"
  196. #
  197. CLEANUP += $(BIN)/*.* # Avoid picking up directories
  198. endif # defined(BIN)
  199. # Determine whether or not we need to include the dependency files
  200. #
  201. NO_DEP_TARGETS := $(BIN) clean veryclean
  202. ifeq ($(MAKECMDGOALS),)
  203. NEED_DEPS := 1
  204. endif
  205. ifneq ($(strip $(filter-out $(NO_DEP_TARGETS),$(MAKECMDGOALS))),)
  206. NEED_DEPS := 1
  207. endif
  208. ###############################################################################
  209. #
  210. # Select build architecture and platform based on $(BIN)
  211. #
  212. # BIN has the form bin[-[arch-]platform]
  213. ARCHS := $(patsubst arch/%,%,$(wildcard arch/*))
  214. PLATFORMS := $(patsubst config/defaults/%.h,%,\
  215. $(wildcard config/defaults/*.h))
  216. archs :
  217. @$(ECHO) $(ARCHS)
  218. platforms :
  219. @$(ECHO) $(PLATFORMS)
  220. ifdef BIN
  221. # Determine architecture portion of $(BIN), if present
  222. BIN_ARCH := $(strip $(foreach A,$(ARCHS),\
  223. $(patsubst bin-$(A)-%,$(A),\
  224. $(filter bin-$(A)-%,$(BIN)))))
  225. # Determine platform portion of $(BIN), if present
  226. ifeq ($(BIN_ARCH),)
  227. BIN_PLATFORM := $(patsubst bin-%,%,$(filter bin-%,$(BIN)))
  228. else
  229. BIN_PLATFORM := $(patsubst bin-$(BIN_ARCH)-%,%,$(BIN))
  230. endif
  231. # Determine build architecture
  232. DEFAULT_ARCH := i386
  233. ARCH := $(firstword $(BIN_ARCH) $(DEFAULT_ARCH))
  234. CFLAGS += -DARCH=$(ARCH)
  235. arch :
  236. @$(ECHO) $(ARCH)
  237. .PHONY : arch
  238. # Determine build platform
  239. DEFAULT_PLATFORM := pcbios
  240. PLATFORM := $(firstword $(BIN_PLATFORM) $(DEFAULT_PLATFORM))
  241. CFLAGS += -DPLATFORM=$(PLATFORM)
  242. platform :
  243. @$(ECHO) $(PLATFORM)
  244. endif # defined(BIN)
  245. # Include architecture-specific Makefile
  246. ifdef ARCH
  247. MAKEDEPS += arch/$(ARCH)/Makefile
  248. include arch/$(ARCH)/Makefile
  249. endif
  250. # Include architecture-specific include path
  251. ifdef ARCH
  252. INCDIRS += arch/$(ARCH)/include
  253. INCDIRS += arch/$(ARCH)/include/$(PLATFORM)
  254. endif
  255. ###############################################################################
  256. #
  257. # Source file handling
  258. # SRCDIRS lists all directories containing source files.
  259. srcdirs :
  260. @$(ECHO) $(SRCDIRS)
  261. # SRCS lists all .c or .S files found in any SRCDIR
  262. #
  263. SRCS += $(wildcard $(patsubst %,%/*.c,$(SRCDIRS)))
  264. SRCS += $(wildcard $(patsubst %,%/*.S,$(SRCDIRS)))
  265. srcs :
  266. @$(ECHO) $(SRCS)
  267. # AUTO_SRCS lists all files in SRCS that are not mentioned in
  268. # NON_AUTO_SRCS. Files should be added to NON_AUTO_SRCS if they
  269. # cannot be built using the standard build template.
  270. #
  271. AUTO_SRCS = $(filter-out $(NON_AUTO_SRCS),$(SRCS))
  272. autosrcs :
  273. @$(ECHO) $(AUTO_SRCS)
  274. # Just about everything else in this section depends upon having
  275. # $(BIN) set
  276. ifdef BIN
  277. # INCDIRS lists the include path
  278. incdirs :
  279. @$(ECHO) $(INCDIRS)
  280. # Common flags
  281. #
  282. CFLAGS += $(foreach INC,$(INCDIRS),-I$(INC))
  283. CFLAGS += -Os
  284. CFLAGS += -g
  285. ifeq ($(CCTYPE),gcc)
  286. CFLAGS += -ffreestanding
  287. CFLAGS += -Wall -W -Wformat-nonliteral
  288. endif
  289. ifeq ($(CCTYPE),icc)
  290. CFLAGS += -fno-builtin
  291. CFLAGS += -no-ip
  292. CFLAGS += -no-gcc
  293. CFLAGS += -diag-disable 111 # Unreachable code
  294. CFLAGS += -diag-disable 128 # Unreachable loop
  295. CFLAGS += -diag-disable 170 # Array boundary checks
  296. CFLAGS += -diag-disable 177 # Unused functions
  297. CFLAGS += -diag-disable 181 # printf() format checks
  298. CFLAGS += -diag-disable 188 # enum strictness
  299. CFLAGS += -diag-disable 193 # Undefined preprocessor identifiers
  300. CFLAGS += -diag-disable 280 # switch ( constant )
  301. CFLAGS += -diag-disable 310 # K&R parameter lists
  302. CFLAGS += -diag-disable 424 # Extra semicolon
  303. CFLAGS += -diag-disable 589 # Declarations mid-code
  304. CFLAGS += -diag-disable 593 # Unused variables
  305. CFLAGS += -diag-disable 810 # Casting ints to smaller ints
  306. CFLAGS += -diag-disable 981 # Sequence point violations
  307. CFLAGS += -diag-disable 1292 # Ignored attributes
  308. CFLAGS += -diag-disable 1338 # void pointer arithmetic
  309. CFLAGS += -diag-disable 1361 # Variable-length arrays
  310. CFLAGS += -diag-disable 1418 # Missing prototypes
  311. CFLAGS += -diag-disable 1419 # Missing prototypes
  312. CFLAGS += -diag-disable 1599 # Hidden variables
  313. CFLAGS += -Wall -Wmissing-declarations
  314. endif
  315. CFLAGS += $(EXTRA_CFLAGS)
  316. ASFLAGS += $(EXTRA_ASFLAGS)
  317. LDFLAGS += $(EXTRA_LDFLAGS)
  318. # Inhibit -Werror if NO_WERROR is specified on make command line
  319. #
  320. ifneq ($(NO_WERROR),1)
  321. CFLAGS += -Werror
  322. ASFLAGS += --fatal-warnings
  323. endif
  324. # Function trace recorder state in the last build. This is needed
  325. # in order to correctly rebuild whenever the function recorder is
  326. # enabled/disabled.
  327. #
  328. FNREC_STATE := $(BIN)/.fnrec.state
  329. ifeq ($(wildcard $(FNREC_STATE)),)
  330. FNREC_OLD := <invalid>
  331. else
  332. FNREC_OLD := $(shell cat $(FNREC_STATE))
  333. endif
  334. ifeq ($(FNREC_OLD),$(FNREC))
  335. $(FNREC_STATE) :
  336. else
  337. $(FNREC_STATE) : clean
  338. $(shell $(ECHO) "$(FNREC)" > $(FNREC_STATE))
  339. endif
  340. VERYCLEANUP += $(FNREC_STATE)
  341. MAKEDEPS += $(FNREC_STATE)
  342. ifeq ($(FNREC),1)
  343. # Enabling -finstrument-functions affects gcc's analysis and leads to spurious
  344. # warnings about use of uninitialised variables.
  345. #
  346. CFLAGS += -Wno-uninitialized
  347. CFLAGS += -finstrument-functions
  348. CFLAGS += -finstrument-functions-exclude-file-list=core/fnrec.c
  349. endif
  350. # compiler.h is needed for our linking and debugging system
  351. #
  352. CFLAGS += -include compiler.h
  353. # CFLAGS for specific object types
  354. #
  355. CFLAGS_c +=
  356. CFLAGS_S += -DASSEMBLY
  357. # Base object name of the current target
  358. #
  359. OBJECT = $(firstword $(subst ., ,$(@F)))
  360. # CFLAGS for specific object files. You can define
  361. # e.g. CFLAGS_rtl8139, and have those flags automatically used when
  362. # compiling bin/rtl8139.o.
  363. #
  364. OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
  365. $(BIN)/%.flags :
  366. @$(ECHO) $(OBJ_CFLAGS)
  367. # ICC requires postprocessing objects to fix up table alignments
  368. #
  369. ifeq ($(CCTYPE),icc)
  370. POST_O = && $(ICCFIX) $@
  371. POST_O_DEPS := $(ICCFIX)
  372. else
  373. POST_O :=
  374. POST_O_DEPS :=
  375. endif
  376. # Rules for specific object types.
  377. #
  378. COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
  379. RULE_c = $(Q)$(COMPILE_c) -c $< -o $@ $(POST_O)
  380. RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -Ddebug_$(subst -,_,$(OBJECT))=$* -c $< -o $@ $(POST_O)
  381. RULE_c_to_c = $(Q)$(COMPILE_c) -E -c $< > $@
  382. RULE_c_to_s = $(Q)$(COMPILE_c) -S -g0 -c $< -o $@
  383. PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
  384. ASSEMBLE_S = $(AS) $(ASFLAGS)
  385. RULE_S = $(Q)$(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
  386. RULE_S_to_s = $(Q)$(PREPROCESS_S) $< > $@
  387. DEBUG_TARGETS += dbg%.o c s
  388. # We automatically generate rules for any file mentioned in AUTO_SRCS
  389. # using the following set of templates. It would be cleaner to use
  390. # $(eval ...), but this function exists only in GNU make >= 3.80.
  391. # deps_template : generate dependency list for a given source file
  392. #
  393. # $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
  394. # $(2) is the source type (e.g. "c")
  395. # $(3) is the source base name (e.g. "rtl8139")
  396. #
  397. define deps_template
  398. @$(ECHO) " [DEPS] $(1)"
  399. @$(MKDIR) -p $(BIN)/deps/$(dir $(1))
  400. @$(CPP) $(CFLAGS) $(CFLAGS_$(2)) $(CFLAGS_$(3)) -DOBJECT=$(3) \
  401. -Wno-error -M $(1) -MG -MP | \
  402. sed 's/\.o\s*:/_DEPS =/' > $(BIN)/deps/$(1).d
  403. endef
  404. # rules_template : generate rules for a given source file
  405. #
  406. # $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
  407. # $(2) is the source type (e.g. "c")
  408. # $(3) is the source base name (e.g. "rtl8139")
  409. #
  410. define rules_template
  411. @$(ECHO) " [RULES] $(1)"
  412. @$(MKDIR) -p $(BIN)/rules/$(dir $(1))
  413. @$(ECHO_E) '\n$$(BIN)/$(3).o :' \
  414. '$(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(3)_DEPS)' \
  415. '\n\t$$(QM)$(ECHO) " [BUILD] $$@"' \
  416. '\n\t$$(RULE_$(2))\n' \
  417. '\nBOBJS += $$(BIN)/$(3).o\n' \
  418. $(foreach TGT,$(DEBUG_TARGETS), \
  419. $(if $(RULE_$(2)_to_$(TGT)), \
  420. '\n$$(BIN)/$(3).$(TGT) :' \
  421. '$(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(3)_DEPS)' \
  422. '\n\t$$(QM)$(ECHO) " [BUILD] $$@"' \
  423. '\n\t$$(RULE_$(2)_to_$(TGT))\n' \
  424. '\n$(TGT)_OBJS += $$(BIN)/$(3).$(TGT)\n' ) ) \
  425. '\n$(BIN)/deps/$(1).d : $$($(3)_DEPS)\n' \
  426. '\nTAGS : $$($(3)_DEPS)\n' > $(BIN)/rules/$(1).r
  427. @$(PERL) $(PARSEROM) $(1) >> $(BIN)/rules/$(1).r
  428. endef
  429. # Rule to generate the dependency list file
  430. #
  431. $(BIN)/deps/%.d : % $(MAKEDEPS)
  432. $(call deps_template,$<,$(subst .,,$(suffix $<)),$(basename $(notdir $<)))
  433. # Calculate and include the list of dependency list files
  434. #
  435. AUTO_DEPS = $(patsubst %,$(BIN)/deps/%.d,$(AUTO_SRCS))
  436. ifdef NEED_DEPS
  437. ifneq ($(AUTO_DEPS),)
  438. -include $(AUTO_DEPS)
  439. endif
  440. endif
  441. autodeps :
  442. @$(ECHO) $(AUTO_DEPS)
  443. VERYCLEANUP += $(BIN)/deps
  444. # Rule to generate the rules file
  445. #
  446. $(BIN)/rules/%.r : % $(MAKEDEPS) $(PARSEROM)
  447. $(call rules_template,$<,$(subst .,,$(suffix $<)),$(basename $(notdir $<)))
  448. # Calculate and include the list of rules files
  449. #
  450. AUTO_RULES = $(patsubst %,$(BIN)/rules/%.r,$(AUTO_SRCS))
  451. ifdef NEED_DEPS
  452. ifneq ($(AUTO_RULES),)
  453. -include $(AUTO_RULES)
  454. endif
  455. endif
  456. autorules :
  457. @$(ECHO) $(AUTO_RULES)
  458. VERYCLEANUP += $(BIN)/rules
  459. # The following variables are created by the rules files
  460. #
  461. bobjs :
  462. @$(ECHO) $(BOBJS)
  463. drivers :
  464. @$(ECHO) $(DRIVERS)
  465. .PHONY : drivers
  466. roms :
  467. @$(ECHO) $(ROMS)
  468. # List of embedded images included in the last build of embedded.o.
  469. # This is needed in order to correctly rebuild embedded.o whenever the
  470. # list of objects changes.
  471. #
  472. EMBEDDED_LIST := $(BIN)/.embedded.list
  473. ifeq ($(wildcard $(EMBEDDED_LIST)),)
  474. EMBEDDED_IMAGE_OLD := <invalid>
  475. else
  476. EMBEDDED_IMAGE_OLD := $(shell cat $(EMBEDDED_LIST))
  477. endif
  478. ifneq ($(EMBEDDED_IMAGE_OLD),$(EMBEDDED_IMAGE))
  479. $(shell $(ECHO) "$(EMBEDDED_IMAGE)" > $(EMBEDDED_LIST))
  480. endif
  481. $(EMBEDDED_LIST) :
  482. VERYCLEANUP += $(EMBEDDED_LIST)
  483. EMBEDDED_FILES := $(subst $(COMMA), ,$(EMBEDDED_IMAGE))
  484. EMBED_ALL := $(foreach i,$(call seq,1,$(words $(EMBEDDED_FILES))),\
  485. EMBED ( $(i), \"$(word $(i), $(EMBEDDED_FILES))\",\
  486. \"$(notdir $(word $(i),$(EMBEDDED_FILES)))\" ))
  487. $(BIN)/embedded.o : $(EMBEDDED_FILES) $(EMBEDDED_LIST)
  488. # This file uses .incbin inline assembly to include a binary file.
  489. # Unfortunately ccache does not detect this dependency and caches builds even
  490. # when the binary file has changed.
  491. #
  492. $(BIN)/embedded.o : override CC := env CCACHE_DISABLE=1 $(CC)
  493. CFLAGS_embedded = -DEMBED_ALL="$(EMBED_ALL)"
  494. # Generate error usage information
  495. #
  496. $(BIN)/%.einfo : $(BIN)/%.o
  497. $(QM)$(ECHO) " [EINFO] $@"
  498. $(Q)$(OBJCOPY) -O binary -j .einfo --set-section-flags .einfo=alloc \
  499. $< $@
  500. EINFOS := $(patsubst $(BIN)/%.o,$(BIN)/%.einfo,$(BOBJS))
  501. $(BIN)/errors : $(EINFOS) $(EINFO)
  502. $(QM)$(ECHO) " [EINFO] $@"
  503. $(Q)$(EINFO) $(EINFOS) | sort > $@
  504. # Generate the NIC file from the parsed source files. The NIC file is
  505. # only for rom-o-matic.
  506. #
  507. $(BIN)/NIC : $(AUTO_DEPS)
  508. @$(ECHO) '# This is an automatically generated file, do not edit' > $@
  509. @$(ECHO) '# It does not affect anything in the build, ' \
  510. 'it is only for rom-o-matic' >> $@
  511. @$(ECHO) >> $@
  512. @perl -ne 'chomp; print "$$1\n" if /\# NIC\t(.*)$$/' $^ >> $@
  513. CLEANUP += $(BIN)/NIC # Doesn't match the $(BIN)/*.* pattern
  514. # Analyse a target name (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and
  515. # derive the variables:
  516. #
  517. # TGT_ELEMENTS : the elements of the target (e.g. "dfe538 prism2_pci")
  518. # TGT_PREFIX : the prefix type (e.g. "zrom")
  519. # TGT_DRIVERS : the driver for each element (e.g. "rtl8139 prism2_pci")
  520. # TGT_ROM_NAME : the ROM name (e.g. "dfe538")
  521. # TGT_MEDIA : the media type (e.g. "rom")
  522. #
  523. DRIVERS_ipxe = $(DRIVERS)
  524. CARD_DRIVER = $(firstword $(DRIVER_$(1)) $(1))
  525. TGT_ELEMENTS = $(subst --, ,$(firstword $(subst ., ,$(notdir $@))))
  526. TGT_PREFIX = $(word 2,$(subst ., ,$(notdir $@)))
  527. TGT_ROM_NAME = $(firstword $(TGT_ELEMENTS))
  528. TGT_DRIVERS = $(strip $(if $(DRIVERS_$(TGT_ROM_NAME)), \
  529. $(DRIVERS_$(TGT_ROM_NAME)), \
  530. $(foreach TGT_ELEMENT,$(TGT_ELEMENTS), \
  531. $(call CARD_DRIVER,$(TGT_ELEMENT))) ))
  532. TGT_MEDIA = $(subst z,,$(TGT_PREFIX))
  533. # Look up ROM IDs for the current target
  534. # (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and derive the variables:
  535. #
  536. # TGT_PCI_VENDOR : the PCI vendor ID (e.g. "0x1186")
  537. # TGT_PCI_DEVICE : the PCI device ID (e.g. "0x1300")
  538. #
  539. TGT_PCI_VENDOR = $(PCI_VENDOR_$(TGT_ROM_NAME))
  540. TGT_PCI_DEVICE = $(PCI_DEVICE_$(TGT_ROM_NAME))
  541. # Calculate link-time options for the current target
  542. # (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and derive the variables:
  543. #
  544. # TGT_LD_DRIVERS : symbols to require in order to drag in the relevant drivers
  545. # (e.g. "obj_rtl8139 obj_prism2_pci")
  546. # TGT_LD_IDS : symbols to define in order to fill in ID structures in the
  547. # ROM header (e.g."pci_vendor_id=0x1186 pci_device_id=0x1300")
  548. #
  549. TGT_LD_DRIVERS = $(subst -,_,$(patsubst %,obj_%,$(TGT_DRIVERS)))
  550. TGT_LD_PREFIX = obj_$(TGT_PREFIX)prefix
  551. TGT_LD_IDS = pci_vendor_id=$(firstword $(TGT_PCI_VENDOR) 0) \
  552. pci_device_id=$(firstword $(TGT_PCI_DEVICE) 0)
  553. # Calculate linker flags based on link-time options for the current
  554. # target type (e.g. "bin/dfe538--prism2_pci.zrom.tmp") and derive the
  555. # variables:
  556. #
  557. # TGT_LD_FLAGS : target-specific flags to pass to linker (e.g.
  558. # "-u obj_zpciprefix -u obj_rtl8139 -u obj_prism2_pci
  559. # --defsym pci_vendor=0x1186 --defsym pci_device=0x1300")
  560. #
  561. TGT_LD_FLAGS = $(foreach SYM,$(TGT_LD_PREFIX) $(TGT_LD_DRIVERS) obj_config,\
  562. -u $(SYM) --defsym check_$(SYM)=$(SYM) ) \
  563. $(patsubst %,--defsym %,$(TGT_LD_IDS)) \
  564. $(TGT_LD_FLAGS_PRE)
  565. # Calculate list of debugging versions of objects to be included in
  566. # the target.
  567. #
  568. DEBUG_LIST = $(subst $(COMMA), ,$(DEBUG))
  569. DEBUG_OBJ_LEVEL = $(firstword $(word 2,$(subst :, ,$(1))) 1)
  570. DEBUG_OBJ_BASE = $(word 1,$(subst :, ,$(1))).dbg$(call DEBUG_OBJ_LEVEL,$(1))
  571. DEBUG_OBJ = $(BIN)/$(call DEBUG_OBJ_BASE,$(1)).o
  572. DEBUG_ORIG_OBJ = $(BIN)/$(word 1,$(subst :, ,$(1))).o
  573. DEBUG_OBJS = $(foreach D,$(DEBUG_LIST),$(call DEBUG_OBJ,$(D)))
  574. DEBUG_ORIG_OBJS = $(foreach D,$(DEBUG_LIST),$(call DEBUG_ORIG_OBJ,$(D)))
  575. BLIB_OBJS = $(DEBUG_OBJS) $(filter-out $(DEBUG_ORIG_OBJS),$(BOBJS))
  576. # Print out all derived information for a given target.
  577. #
  578. $(BIN)/%.info :
  579. @$(ECHO) 'Elements : $(TGT_ELEMENTS)'
  580. @$(ECHO) 'Prefix : $(TGT_PREFIX)'
  581. @$(ECHO) 'Drivers : $(TGT_DRIVERS)'
  582. @$(ECHO) 'ROM name : $(TGT_ROM_NAME)'
  583. @$(ECHO) 'Media : $(TGT_MEDIA)'
  584. @$(ECHO)
  585. @$(ECHO) 'PCI vendor : $(TGT_PCI_VENDOR)'
  586. @$(ECHO) 'PCI device : $(TGT_PCI_DEVICE)'
  587. @$(ECHO)
  588. @$(ECHO) 'LD driver symbols : $(TGT_LD_DRIVERS)'
  589. @$(ECHO) 'LD prefix symbols : $(TGT_LD_PREFIX)'
  590. @$(ECHO) 'LD ID symbols : $(TGT_LD_IDS)'
  591. @$(ECHO)
  592. @$(ECHO) 'LD target flags : $(TGT_LD_FLAGS)'
  593. @$(ECHO)
  594. @$(ECHO) 'Debugging objects : $(DEBUG_OBJS)'
  595. @$(ECHO) 'Replaced objects : $(DEBUG_ORIG_OBJS)'
  596. # List of objects included in the last build of blib. This is needed
  597. # in order to correctly rebuild blib whenever the list of objects
  598. # changes.
  599. #
  600. BLIB_LIST := $(BIN)/.blib.list
  601. ifeq ($(wildcard $(BLIB_LIST)),)
  602. BLIB_OBJS_OLD := <invalid>
  603. else
  604. BLIB_OBJS_OLD := $(shell cat $(BLIB_LIST))
  605. endif
  606. ifneq ($(BLIB_OBJS_OLD),$(BLIB_OBJS))
  607. $(shell $(ECHO) "$(BLIB_OBJS)" > $(BLIB_LIST))
  608. endif
  609. $(BLIB_LIST) :
  610. VERYCLEANUP += $(BLIB_LIST)
  611. # Library of all objects
  612. #
  613. BLIB = $(BIN)/blib.a
  614. $(BLIB) : $(BLIB_OBJS) $(BLIB_LIST) $(MAKEDEPS)
  615. $(Q)$(RM) $(BLIB)
  616. $(QM)$(ECHO) " [AR] $@"
  617. $(Q)$(AR) r $@ $(BLIB_OBJS)
  618. $(Q)$(RANLIB) $@
  619. blib : $(BLIB)
  620. # Command to generate build ID. Must be unique for each $(BIN)/%.tmp,
  621. # even within the same build run.
  622. #
  623. BUILD_ID_CMD := perl -e 'printf "0x%08x", int ( rand ( 0xffffffff ) );'
  624. # Build an intermediate object file from the objects required for the
  625. # specified target.
  626. #
  627. $(BIN)/%.tmp : $(BLIB) $(MAKEDEPS) $(LDSCRIPT)
  628. $(QM)$(ECHO) " [LD] $@"
  629. $(Q)$(LD) $(LDFLAGS) -T $(LDSCRIPT) $(TGT_LD_FLAGS) $(BLIB) -o $@ \
  630. --defsym _build_id=`$(BUILD_ID_CMD)` -Map $(BIN)/$*.tmp.map
  631. $(Q)$(OBJDUMP) -ht $@ | $(PERL) $(SORTOBJDUMP) >> $(BIN)/$*.tmp.map
  632. # Keep intermediate object file (useful for debugging)
  633. .PRECIOUS : $(BIN)/%.tmp
  634. # Show a linker map for the specified target
  635. #
  636. $(BIN)/%.map : $(BIN)/%.tmp
  637. @less $(BIN)/$*.tmp.map
  638. # Get objects list for the specified target
  639. #
  640. define objs_list
  641. $(sort $(foreach OBJ_SYMBOL,\
  642. $(filter obj_%,$(shell $(NM) $(1) | cut -d" " -f3)),\
  643. $(patsubst obj_%,%,$(OBJ_SYMBOL))))
  644. endef
  645. $(BIN)/%.objs : $(BIN)/%.tmp
  646. $(Q)$(ECHO) $(call objs_list,$<)
  647. $(BIN)/%.sizes : $(BIN)/%.tmp
  648. $(Q)$(SIZE) -t $(foreach OBJ,$(call objs_list,$<),$(wildcard $(BIN)/$(subst _,?,$(OBJ)).o)) | \
  649. sort -g
  650. # Get dependency list for the specified target
  651. #
  652. define deps_list
  653. $(sort $(foreach OBJ,$(call objs_list,$(1)),$($(OBJ)_DEPS)))
  654. endef
  655. $(BIN)/%.deps : $(BIN)/%.tmp
  656. $(Q)$(ECHO) $(call deps_list,$<)
  657. # Get unneeded source files for the specified target
  658. #
  659. define nodeps_list
  660. $(sort $(filter-out $(call deps_list,$(1)),\
  661. $(foreach BOBJ,$(BOBJS),\
  662. $($(basename $(notdir $(BOBJ)))_DEPS))))
  663. endef
  664. $(BIN)/%.nodeps : $(BIN)/%.tmp
  665. $(Q)$(ECHO) $(call nodeps_list,$<)
  666. # Get licensing verdict for the specified target
  667. #
  668. define unlicensed_deps_list
  669. $(shell grep -L FILE_LICENCE $(call deps_list,$(1)))
  670. endef
  671. define licence_list
  672. $(patsubst __licence_%,%,\
  673. $(filter __licence_%,$(shell $(NM) $(1) | cut -d" " -f3)))
  674. endef
  675. $(BIN)/%.licence : $(BIN)/%.tmp
  676. $(QM)$(ECHO) " [LICENCE] $@"
  677. $(Q)$(if $(strip $(call unlicensed_deps_list,$<)),\
  678. echo -n "Unable to determine licence because the following " ;\
  679. echo "files are missing a licence declaration:" ;\
  680. echo $(call unlicensed_deps_list,$<);\
  681. exit 1,\
  682. $(PERL) $(LICENCE) $(call licence_list,$<))
  683. # Extract compression information from intermediate object file
  684. #
  685. $(BIN)/%.zinfo : $(BIN)/%.tmp
  686. $(QM)$(ECHO) " [ZINFO] $@"
  687. $(Q)$(OBJCOPY) -O binary -j .zinfo $< $@
  688. # Build raw binary file from intermediate object file
  689. #
  690. $(BIN)/%.bin : $(BIN)/%.tmp
  691. $(QM)$(ECHO) " [BIN] $@"
  692. $(Q)$(OBJCOPY) -O binary -R .zinfo $< $@
  693. # Compress raw binary file
  694. #
  695. $(BIN)/%.zbin : $(BIN)/%.bin $(BIN)/%.zinfo $(ZBIN)
  696. $(QM)$(ECHO) " [ZBIN] $@"
  697. $(Q)$(ZBIN) $(BIN)/$*.bin $(BIN)/$*.zinfo > $@
  698. # Rules for each media format. These are generated and placed in an
  699. # external Makefile fragment. We could do this via $(eval ...), but
  700. # that would require make >= 3.80.
  701. #
  702. # Note that there's an alternative way to generate most .rom images:
  703. # they can be copied from their 'master' ROM image using cp and
  704. # reprocessed with makerom to add the PCI IDs and ident string. The
  705. # relevant rule would look something like:
  706. #
  707. # $(BIN)/dfe538%rom : $(BIN)/rtl8139%rom
  708. # cat $< $@
  709. # $(FINALISE_rom)
  710. #
  711. # You can derive the ROM/driver relationships using the variables
  712. # DRIVER_<rom> and/or ROMS_<driver>.
  713. #
  714. # We don't currently do this, because (a) it would require generating
  715. # yet more Makefile fragments (since you need a rule for each ROM in
  716. # ROMS), and (b) the linker is so fast that it probably wouldn't make
  717. # much difference to the overall build time.
  718. media :
  719. @$(ECHO) $(MEDIA)
  720. AUTO_MEDIA = $(filter-out $(NON_AUTO_MEDIA),$(MEDIA))
  721. automedia :
  722. @$(ECHO) $(AUTO_MEDIA)
  723. # media_template : create Makefile rules for specified media
  724. #
  725. # $(1) is the media name (e.g. "rom")
  726. #
  727. define media_template
  728. @$(ECHO) " [MEDIARULES] $(1)"
  729. @$(MKDIR) -p $(BIN)/rules/$(dir $(1))
  730. @$(ECHO_E) '$$(BIN)/%.$(1) : $$(BIN)/%.$(1).zbin' \
  731. '\n\t$$(QM)$(ECHO) " [FINISH] $$@"' \
  732. '\n\t$$(Q)$$(CP) $$< $$@' \
  733. '\n\t$$(Q)$$(PAD_$(1))' \
  734. '\n\t$$(Q)$$(FINALISE_$(1))' \
  735. > $(BIN)/rules/$(1).media.r
  736. endef
  737. # Rule to generate the Makefile rules to be included
  738. #
  739. $(BIN)/rules/%.media.r : $(MAKEDEPS)
  740. $(call media_template,$*)
  741. # Calculate and include the list of Makefile rules files
  742. #
  743. MEDIA_RULES = $(patsubst %,$(BIN)/rules/%.media.r,$(AUTO_MEDIA))
  744. mediarules :
  745. @$(ECHO) $(MEDIA_RULES)
  746. ifdef NEED_DEPS
  747. ifneq ($(MEDIA_RULES),)
  748. -include $(MEDIA_RULES)
  749. endif
  750. endif
  751. # Wrap up binary blobs (for embedded images)
  752. #
  753. $(BIN)/%.o : payload/%.img
  754. $(QM)echo " [WRAP] $@"
  755. $(Q)$(LD) -b binary -r -o $@ $< --undefined obj_payload \
  756. --defsym obj_$*=0
  757. BOBJS += $(patsubst payload/%.img,$(BIN)/%.o,$(wildcard payload/*.img))
  758. # The "allXXXs" targets for each suffix
  759. #
  760. allall: allroms allzroms allpxes allisos alldsks
  761. allroms allzroms : all%s : $(foreach ROM,$(ROMS),$(BIN)/$(ROM).%)
  762. allpxes allisos alldsks : all%s : $(foreach DRIVER,$(DRIVERS),$(BIN)/$(DRIVER).%)
  763. # Alias for ipxe.%
  764. #
  765. $(BIN)/etherboot.% : $(BIN)/ipxe.%
  766. ln -sf $(notdir $<) $@
  767. endif # defined(BIN)
  768. ###############################################################################
  769. #
  770. # The compression utilities
  771. #
  772. $(NRV2B) : util/nrv2b.c $(MAKEDEPS)
  773. $(QM)$(ECHO) " [HOSTCC] $@"
  774. $(Q)$(HOST_CC) -O2 -DENCODE -DDECODE -DMAIN -DVERBOSE -DNDEBUG \
  775. -DBITSIZE=32 -DENDIAN=0 -o $@ $<
  776. CLEANUP += $(NRV2B)
  777. $(ZBIN) : util/zbin.c util/nrv2b.c $(MAKEDEPS)
  778. $(QM)$(ECHO) " [HOSTCC] $@"
  779. $(Q)$(HOST_CC) -O2 -o $@ $<
  780. CLEANUP += $(ZBIN)
  781. ###############################################################################
  782. #
  783. # The EFI image converter
  784. #
  785. ELF2EFI_CFLAGS := -I$(BINUTILS_DIR)/include -I$(BFD_DIR)/include \
  786. -I$(ZLIB_DIR)/include -idirafter include \
  787. -L$(BINUTILS_DIR)/lib -L$(BFD_DIR)/lib -L$(ZLIB_DIR)/lib \
  788. -lbfd -liberty -lz -Wl,--no-warn-search-mismatch
  789. $(ELF2EFI32) : util/elf2efi.c $(MAKEDEPS)
  790. $(QM)$(ECHO) " [HOSTCC] $@"
  791. $(Q)$(HOST_CC) $< $(ELF2EFI_CFLAGS) -DEFI_TARGET_IA32 -O2 -o $@
  792. CLEANUP += $(ELF2EFI32)
  793. $(ELF2EFI64) : util/elf2efi.c $(MAKEDEPS)
  794. $(QM)$(ECHO) " [HOSTCC] $@"
  795. $(Q)$(HOST_CC) $< $(ELF2EFI_CFLAGS) -DEFI_TARGET_X64 -O2 -o $@
  796. CLEANUP += $(ELF2EFI64)
  797. $(EFIROM) : util/efirom.c $(MAKEDEPS)
  798. $(QM)$(ECHO) " [HOSTCC] $@"
  799. $(Q)$(HOST_CC) -idirafter include -O2 -o $@ $<
  800. CLEANUP += $(EFIROM)
  801. ###############################################################################
  802. #
  803. # The ICC fixup utility
  804. #
  805. $(ICCFIX) : util/iccfix.c $(MAKEDEPS)
  806. $(QM)$(ECHO) " [HOSTCC] $@"
  807. $(Q)$(HOST_CC) -idirafter include -O2 -o $@ $<
  808. CLEANUP += $(ICCFIX)
  809. ###############################################################################
  810. #
  811. # The error usage information utility
  812. #
  813. $(EINFO) : util/einfo.c $(MAKEDEPS)
  814. $(QM)$(ECHO) " [HOSTCC] $@"
  815. $(Q)$(HOST_CC) -idirafter include -O2 -o $@ $<
  816. CLEANUP += $(EINFO)
  817. ###############################################################################
  818. #
  819. # Local configs
  820. #
  821. config/local/%.h :
  822. $(Q)touch $@
  823. ###############################################################################
  824. #
  825. # Auto-incrementing build serial number. Append "bs" to your list of
  826. # build targets to get a serial number printed at the end of the
  827. # build. Enable -DBUILD_SERIAL in order to see it when the code runs.
  828. #
  829. BUILDSERIAL_H = config/.buildserial.h
  830. BUILDSERIAL_NOW = config/.buildserial.now
  831. BUILDSERIAL_NEXT = config/.buildserial.next
  832. $(BUILDSERIAL_NOW) $(BUILDSERIAL_NEXT) :
  833. $(ECHO) 1 > $@
  834. $(BUILDSERIAL_H) : $(BUILDSERIAL_NOW) $(BUILDSERIAL_NEXT)
  835. $(ECHO) '#define BUILD_SERIAL_NUM $(shell cat $<)' > $@
  836. ifeq ($(filter bs,$(MAKECMDGOALS)),bs)
  837. $(shell diff -q $(BUILDSERIAL_NOW) $(BUILDSERIAL_NEXT) > /dev/null || \
  838. cp -f $(BUILDSERIAL_NEXT) $(BUILDSERIAL_NOW))
  839. endif
  840. bs : $(BUILDSERIAL_NOW)
  841. @$(ECHO) $$(( $(shell cat $<) + 1 )) > $(BUILDSERIAL_NEXT)
  842. @$(ECHO) "Build serial number is $(shell cat $<)"
  843. ###############################################################################
  844. #
  845. # Build the TAGS file(s) for emacs
  846. #
  847. TAGS :
  848. ctags -e -R -f $@ --exclude=bin
  849. CLEANUP += TAGS
  850. ###############################################################################
  851. #
  852. # Force rebuild for any given target
  853. #
  854. %.rebuild :
  855. rm -f $*
  856. $(Q)$(MAKE) $*
  857. ###############################################################################
  858. #
  859. # Symbol table checks
  860. #
  861. ifdef BIN
  862. SYMTAB = $(BIN)/symtab
  863. $(SYMTAB) : $(BLIB)
  864. $(OBJDUMP) -w -t $< > $@
  865. CLEANUP += $(BIN)/symtab
  866. symcheck : $(SYMTAB)
  867. $(PERL) $(SYMCHECK) $<
  868. endif # defined(BIN)
  869. ###############################################################################
  870. #
  871. # Build bochs symbol table
  872. #
  873. ifdef BIN
  874. $(BIN)/%.bxs : $(BIN)/%.tmp
  875. $(NM) $< | cut -d" " -f1,3 > $@
  876. endif # defined(BIN)
  877. ###############################################################################
  878. #
  879. # Documentation
  880. #
  881. ifdef BIN
  882. $(BIN)/doxygen.cfg : doxygen.cfg $(MAKEDEPS)
  883. $(Q)$(PERL) -pe 's{\@SRCDIRS\@}{$(SRCDIRS)}; ' \
  884. -e 's{\@INCDIRS\@}{$(filter-out .,$(INCDIRS))}; ' \
  885. -e 's{\@BIN\@}{$(BIN)}; ' \
  886. -e 's{\@ARCH\@}{$(ARCH)}; ' \
  887. $< > $@
  888. $(BIN)/doc : $(BIN)/doxygen.cfg
  889. $(Q)$(DOXYGEN) $<
  890. .PHONY : $(BIN)/doc
  891. doc : $(BIN)/doc
  892. doc-clean :
  893. $(Q)$(RM) -r $(BIN)/doc
  894. VERYCLEANUP += $(BIN)/doc
  895. docview :
  896. @[ -f $(BIN)/doc/html/index.html ] || $(MAKE) $(BIN)/doc
  897. @if [ -n "$$BROWSER" ] ; then \
  898. ( $$BROWSER $(BIN)/doc/html/index.html & ) ; \
  899. else \
  900. $(ECHO) "Documentation index in $(BIN)/doc/html/index.html" ; \
  901. fi
  902. endif # defined(BIN)
  903. ###############################################################################
  904. #
  905. # Clean-up
  906. #
  907. clean :
  908. $(RM) $(CLEANUP)
  909. veryclean : clean
  910. $(RM) -r $(VERYCLEANUP)