Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

Makefile.housekeeping 42KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559
  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. ifeq ($(CCTYPE),gcc)
  82. GCC_2_96_BANNER := $(shell $(CC) -v 2>&1 | grep -is 'gcc version 2\.96')
  83. ifneq ($(GCC_2_96_BANNER),)
  84. $(warning gcc 2.96 is unsuitable for compiling iPXE)
  85. $(warning Use gcc 2.95 or a newer version instead)
  86. $(error Unsuitable build environment found)
  87. endif
  88. endif
  89. PERL_UNICODE_CHECK := $(shell $(PERL) -e 'use bytes; print chr(255)' | wc -c)
  90. ifeq ($(PERL_UNICODE_CHECK),2)
  91. $(warning Your Perl version has a Unicode handling bug)
  92. $(warning Execute this command before building iPXE:)
  93. $(warning export LANG=$${LANG%.UTF-8})
  94. $(error Unsuitable build environment found)
  95. endif
  96. LD_GOLD_BANNER := $(shell $(LD) -v 2>&1 | grep 'GNU gold')
  97. ifneq ($(LD_GOLD_BANNER),)
  98. $(warning GNU gold is unsuitable for building iPXE)
  99. $(warning Use GNU ld instead)
  100. $(error Unsuitable build environment found)
  101. endif
  102. ###############################################################################
  103. #
  104. # Check if $(eval ...) is available to use
  105. #
  106. HAVE_EVAL :=
  107. ifndef NO_EVAL
  108. $(eval HAVE_EVAL := yes)
  109. endif
  110. eval :
  111. @$(ECHO) $(HAVE_EVAL)
  112. ###############################################################################
  113. #
  114. # Check for various tool workarounds
  115. #
  116. WORKAROUND_CFLAGS :=
  117. WORKAROUND_ASFLAGS :=
  118. WORKAROUND_LDFLAGS :=
  119. # Make syntax does not allow use of comma or space in certain places.
  120. # This ugly workaround is suggested in the manual.
  121. #
  122. COMMA := ,
  123. EMPTY :=
  124. SPACE := $(EMPTY) $(EMPTY)
  125. HASH := \#
  126. define NEWLINE
  127. endef
  128. # Some widespread patched versions of gcc include -fstack-protector by
  129. # default, even when -ffreestanding is specified. We therefore need
  130. # to disable -fstack-protector if the compiler supports it.
  131. #
  132. ifeq ($(CCTYPE),gcc)
  133. SP_TEST = $(CC) -fno-stack-protector -x c -c /dev/null \
  134. -o /dev/null >/dev/null 2>&1
  135. SP_FLAGS := $(shell $(SP_TEST) && $(ECHO) '-fno-stack-protector')
  136. WORKAROUND_CFLAGS += $(SP_FLAGS)
  137. endif
  138. # gcc 4.4 generates .eh_frame sections by default, which distort the
  139. # output of "size". Inhibit this.
  140. #
  141. ifeq ($(CCTYPE),gcc)
  142. CFI_TEST = $(CC) -fno-dwarf2-cfi-asm -fno-exceptions -fno-unwind-tables \
  143. -fno-asynchronous-unwind-tables -x c -c /dev/null \
  144. -o /dev/null >/dev/null 2>&1
  145. CFI_FLAGS := $(shell $(CFI_TEST) && \
  146. $(ECHO) '-fno-dwarf2-cfi-asm -fno-exceptions ' \
  147. '-fno-unwind-tables -fno-asynchronous-unwind-tables')
  148. WORKAROUND_CFLAGS += $(CFI_FLAGS)
  149. endif
  150. # gcc 4.6 generates spurious warnings if -Waddress is in force.
  151. # Inhibit this.
  152. #
  153. ifeq ($(CCTYPE),gcc)
  154. WNA_TEST = $(CC) -Wno-address -x c -c /dev/null -o /dev/null >/dev/null 2>&1
  155. WNA_FLAGS := $(shell $(WNA_TEST) && $(ECHO) '-Wno-address')
  156. WORKAROUND_CFLAGS += $(WNA_FLAGS)
  157. endif
  158. # Some versions of gas choke on division operators, treating them as
  159. # comment markers. Specifying --divide will work around this problem,
  160. # but isn't available on older gas versions.
  161. #
  162. DIVIDE_TEST = $(AS) --divide /dev/null -o /dev/null 2>/dev/null
  163. DIVIDE_FLAGS := $(shell $(DIVIDE_TEST) && $(ECHO) '--divide')
  164. WORKAROUND_ASFLAGS += $(DIVIDE_FLAGS)
  165. ###############################################################################
  166. #
  167. # Build verbosity
  168. #
  169. ifeq ($(V),1)
  170. Q :=
  171. QM := @\#
  172. else
  173. Q := @
  174. QM := @
  175. endif
  176. ###############################################################################
  177. #
  178. # Checker
  179. #
  180. ifeq ($(C),1)
  181. export REAL_CC := $(CC)
  182. CC := cgcc
  183. CFLAGS += -Wno-decl
  184. endif
  185. ###############################################################################
  186. #
  187. # Set BIN according to whatever was specified on the command line as
  188. # the build target.
  189. #
  190. # Determine how many different BIN directories are mentioned in the
  191. # make goals.
  192. #
  193. BIN_GOALS := $(filter bin bin/% bin-%,$(MAKECMDGOALS))
  194. BIN_GOALS_BINS := $(sort $(foreach BG,$(BIN_GOALS),\
  195. $(firstword $(subst /, ,$(BG)))))
  196. NUM_BINS := $(words $(BIN_GOALS_BINS))
  197. ifeq ($(NUM_BINS),0)
  198. # No BIN directory was specified. Set BIN to "bin" as a sensible
  199. # default.
  200. BIN := bin
  201. else # NUM_BINS == 0
  202. ifeq ($(NUM_BINS),1)
  203. # If exactly one BIN directory was specified, set BIN to match this
  204. # directory.
  205. #
  206. BIN := $(firstword $(BIN_GOALS_BINS))
  207. else # NUM_BINS == 1
  208. # More than one BIN directory was specified. We cannot handle the
  209. # latter case within a single make invocation, so set up recursive
  210. # targets for each BIN directory. Use exactly one target for each BIN
  211. # directory since running multiple make invocations within the same
  212. # BIN directory is likely to cause problems.
  213. #
  214. # Leave $(BIN) undefined. This has implications for any target that
  215. # depends on $(BIN); such targets should be made conditional upon the
  216. # existence of $(BIN).
  217. #
  218. BIN_GOALS_FIRST := $(foreach BGB,$(BIN_GOALS_BINS),\
  219. $(firstword $(filter $(BGB)/%,$(BIN_GOALS))))
  220. BIN_GOALS_OTHER := $(filter-out $(BIN_GOALS_FIRST),$(BIN_GOALS))
  221. $(BIN_GOALS_FIRST) : % : BIN_RECURSE
  222. $(Q)$(MAKE) --no-print-directory BIN=$(firstword $(subst /, ,$@)) \
  223. $(filter $(firstword $(subst /, ,$@))/%, $(BIN_GOALS))
  224. $(BIN_GOALS_OTHER) : % : BIN_RECURSE
  225. $(Q)$(TRUE)
  226. .PHONY : BIN_RECURSE
  227. endif # NUM_BINS == 1
  228. endif # NUM_BINS == 0
  229. ifdef BIN
  230. # Create $(BIN) directory if it doesn't exist yet
  231. #
  232. ifeq ($(wildcard $(BIN)),)
  233. $(shell $(MKDIR) -p $(BIN))
  234. endif
  235. # Target to allow e.g. "make bin-efi arch"
  236. #
  237. $(BIN) :
  238. @# Do nothing, silently
  239. .PHONY : $(BIN)
  240. # Remove everything in $(BIN) for a "make clean"
  241. #
  242. CLEANUP += $(BIN)/*.* # Avoid picking up directories
  243. endif # defined(BIN)
  244. # Determine whether or not we need to include the dependency files
  245. #
  246. NO_DEP_TARGETS := $(BIN) clean veryclean
  247. ifeq ($(MAKECMDGOALS),)
  248. NEED_DEPS := 1
  249. endif
  250. ifneq ($(strip $(filter-out $(NO_DEP_TARGETS),$(MAKECMDGOALS))),)
  251. NEED_DEPS := 1
  252. endif
  253. ###############################################################################
  254. #
  255. # Select build architecture and platform based on $(BIN)
  256. #
  257. # BIN has the form bin[-[<arch>-]<platform>[-sb]]
  258. ARCHS := $(patsubst arch/%,%,$(wildcard arch/*))
  259. PLATFORMS := $(patsubst config/defaults/%.h,%,\
  260. $(wildcard config/defaults/*.h))
  261. archs :
  262. @$(ECHO) $(ARCHS)
  263. platforms :
  264. @$(ECHO) $(PLATFORMS)
  265. ifdef BIN
  266. # Split $(BIN) into architecture, platform, and security flag (where present)
  267. BIN_ELEMENTS := $(subst -,$(SPACE),$(BIN))
  268. BIN_APS := $(wordlist 2,4,$(BIN_ELEMENTS))
  269. ifeq ($(lastword $(BIN_APS)),sb)
  270. BIN_AP := $(wordlist 2,$(words $(BIN_APS)),discard $(BIN_APS))
  271. BIN_SECUREBOOT := 1
  272. else
  273. BIN_AP := $(BIN_APS)
  274. BIN_SECUREBOOT := 0
  275. endif
  276. BIN_PLATFORM := $(lastword $(BIN_AP))
  277. BIN_ARCH := $(wordlist 2,$(words $(BIN_AP)),discard $(BIN_AP))
  278. # Determine build architecture
  279. DEFAULT_ARCH := i386
  280. ARCH := $(firstword $(BIN_ARCH) $(DEFAULT_ARCH))
  281. CFLAGS += -DARCH=$(ARCH)
  282. arch :
  283. @$(ECHO) $(ARCH)
  284. .PHONY : arch
  285. # Determine build platform
  286. DEFAULT_PLATFORM := pcbios
  287. PLATFORM := $(firstword $(BIN_PLATFORM) $(DEFAULT_PLATFORM))
  288. CFLAGS += -DPLATFORM=$(PLATFORM)
  289. platform :
  290. @$(ECHO) $(PLATFORM)
  291. # Determine security flag
  292. DEFAULT_SECUREBOOT := 0
  293. SECUREBOOT := $(firstword $(BIN_SECUREBOOT) $(DEFAULT_SECUREBOOT))
  294. CFLAGS += -DSECUREBOOT=$(SECUREBOOT)
  295. secureboot :
  296. @$(ECHO) $(SECUREBOOT)
  297. endif # defined(BIN)
  298. # Include architecture-specific Makefile
  299. ifdef ARCH
  300. MAKEDEPS += arch/$(ARCH)/Makefile
  301. include arch/$(ARCH)/Makefile
  302. endif
  303. # Include architecture-specific include path
  304. ifdef ARCH
  305. INCDIRS += arch/$(ARCH)/include
  306. INCDIRS += arch/$(ARCH)/include/$(PLATFORM)
  307. endif
  308. ###############################################################################
  309. #
  310. # Source file handling
  311. # Exclude known-insecure files from Secure Boot builds
  312. ifeq ($(SECUREBOOT),0)
  313. SRCDIRS += $(SRCDIRS_INSEC)
  314. endif
  315. # SRCDIRS lists all directories containing source files.
  316. srcdirs :
  317. @$(ECHO) $(SRCDIRS)
  318. # SRCS lists all .c or .S files found in any SRCDIR
  319. #
  320. SRCS += $(wildcard $(patsubst %,%/*.c,$(SRCDIRS)))
  321. SRCS += $(wildcard $(patsubst %,%/*.S,$(SRCDIRS)))
  322. srcs :
  323. @$(ECHO) $(SRCS)
  324. # AUTO_SRCS lists all files in SRCS that are not mentioned in
  325. # NON_AUTO_SRCS. Files should be added to NON_AUTO_SRCS if they
  326. # cannot be built using the standard build template.
  327. #
  328. AUTO_SRCS = $(filter-out $(NON_AUTO_SRCS),$(SRCS))
  329. autosrcs :
  330. @$(ECHO) $(AUTO_SRCS)
  331. # Just about everything else in this section depends upon having
  332. # $(BIN) set
  333. ifdef BIN
  334. # INCDIRS lists the include path
  335. incdirs :
  336. @$(ECHO) $(INCDIRS)
  337. # Common flags
  338. #
  339. CFLAGS += $(foreach INC,$(INCDIRS),-I$(INC))
  340. CFLAGS += -Os
  341. CFLAGS += -g
  342. ifeq ($(CCTYPE),gcc)
  343. CFLAGS += -ffreestanding
  344. CFLAGS += -Wall -W -Wformat-nonliteral
  345. HOST_CFLAGS += -Wall -W -Wformat-nonliteral
  346. endif
  347. ifeq ($(CCTYPE),icc)
  348. CFLAGS += -fno-builtin
  349. CFLAGS += -no-ip
  350. CFLAGS += -no-gcc
  351. CFLAGS += -diag-disable 111 # Unreachable code
  352. CFLAGS += -diag-disable 128 # Unreachable loop
  353. CFLAGS += -diag-disable 170 # Array boundary checks
  354. CFLAGS += -diag-disable 177 # Unused functions
  355. CFLAGS += -diag-disable 181 # printf() format checks
  356. CFLAGS += -diag-disable 188 # enum strictness
  357. CFLAGS += -diag-disable 193 # Undefined preprocessor identifiers
  358. CFLAGS += -diag-disable 280 # switch ( constant )
  359. CFLAGS += -diag-disable 310 # K&R parameter lists
  360. CFLAGS += -diag-disable 424 # Extra semicolon
  361. CFLAGS += -diag-disable 589 # Declarations mid-code
  362. CFLAGS += -diag-disable 593 # Unused variables
  363. CFLAGS += -diag-disable 810 # Casting ints to smaller ints
  364. CFLAGS += -diag-disable 981 # Sequence point violations
  365. CFLAGS += -diag-disable 1292 # Ignored attributes
  366. CFLAGS += -diag-disable 1338 # void pointer arithmetic
  367. CFLAGS += -diag-disable 1361 # Variable-length arrays
  368. CFLAGS += -diag-disable 1418 # Missing prototypes
  369. CFLAGS += -diag-disable 1419 # Missing prototypes
  370. CFLAGS += -diag-disable 1599 # Hidden variables
  371. CFLAGS += -Wall -Wmissing-declarations
  372. endif
  373. CFLAGS += $(WORKAROUND_CFLAGS) $(EXTRA_CFLAGS)
  374. ASFLAGS += $(WORKAROUND_ASFLAGS) $(EXTRA_ASFLAGS)
  375. LDFLAGS += $(WORKAROUND_LDFLAGS) $(EXTRA_LDFLAGS)
  376. HOST_CFLAGS += -O2 -g
  377. # Inhibit -Werror if NO_WERROR is specified on make command line
  378. #
  379. ifneq ($(NO_WERROR),1)
  380. CFLAGS += -Werror
  381. ASFLAGS += --fatal-warnings
  382. HOST_CFLAGS += -Werror
  383. endif
  384. # Function trace recorder state in the last build. This is needed
  385. # in order to correctly rebuild whenever the function recorder is
  386. # enabled/disabled.
  387. #
  388. FNREC_STATE := $(BIN)/.fnrec.state
  389. ifeq ($(wildcard $(FNREC_STATE)),)
  390. FNREC_OLD := <invalid>
  391. else
  392. FNREC_OLD := $(shell cat $(FNREC_STATE))
  393. endif
  394. ifeq ($(FNREC_OLD),$(FNREC))
  395. $(FNREC_STATE) :
  396. else
  397. $(FNREC_STATE) : clean
  398. $(shell $(ECHO) "$(FNREC)" > $(FNREC_STATE))
  399. endif
  400. VERYCLEANUP += $(FNREC_STATE)
  401. MAKEDEPS += $(FNREC_STATE)
  402. ifeq ($(FNREC),1)
  403. # Enabling -finstrument-functions affects gcc's analysis and leads to spurious
  404. # warnings about use of uninitialised variables.
  405. #
  406. CFLAGS += -Wno-uninitialized
  407. CFLAGS += -finstrument-functions
  408. CFLAGS += -finstrument-functions-exclude-file-list=core/fnrec.c
  409. endif
  410. # Enable per-item sections and section garbage collection. Note that
  411. # some older versions of gcc support -fdata-sections but treat it as
  412. # implying -fno-common, which would break our build. Some other older
  413. # versions issue a spurious and uninhibitable warning if
  414. # -ffunction-sections is used with -g, which would also break our
  415. # build since we use -Werror.
  416. #
  417. ifeq ($(CCTYPE),gcc)
  418. DS_TEST = $(ECHO) 'char x;' | \
  419. $(CC) -fdata-sections -S -x c - -o - 2>/dev/null | \
  420. grep -E '\.comm' > /dev/null
  421. DS_FLAGS := $(shell $(DS_TEST) && $(ECHO) '-fdata-sections')
  422. FS_TEST = $(CC) -ffunction-sections -g -c -x c /dev/null \
  423. -o /dev/null 2>/dev/null
  424. FS_FLAGS := $(shell $(FS_TEST) && $(ECHO) '-ffunction-sections')
  425. CFLAGS += $(FS_FLAGS) $(DS_FLAGS)
  426. endif
  427. LDFLAGS += --gc-sections
  428. # Force creation of static binaries (required for OpenBSD, does no
  429. # harm on other platforms).
  430. #
  431. LDFLAGS += -static
  432. # compiler.h is needed for our linking and debugging system
  433. #
  434. CFLAGS += -include include/compiler.h
  435. # The section type character (e.g. "@" in "@progbits") varies by
  436. # architecture.
  437. #
  438. CFLAGS += -DASM_TCHAR='$(ASM_TCHAR)' -DASM_TCHAR_OPS='$(ASM_TCHAR_OPS)'
  439. # CFLAGS for specific object types
  440. #
  441. CFLAGS_c +=
  442. CFLAGS_S += -DASSEMBLY
  443. # Base object name of the current target
  444. #
  445. OBJECT = $(firstword $(subst ., ,$(@F)))
  446. # CFLAGS for specific object files. You can define
  447. # e.g. CFLAGS_rtl8139, and have those flags automatically used when
  448. # compiling bin/rtl8139.o.
  449. #
  450. OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
  451. $(BIN)/%.flags :
  452. @$(ECHO) $(OBJ_CFLAGS)
  453. # ICC requires postprocessing objects to fix up table alignments
  454. #
  455. ifeq ($(CCTYPE),icc)
  456. POST_O = && $(ICCFIX) $@
  457. POST_O_DEPS := $(ICCFIX)
  458. else
  459. POST_O :=
  460. POST_O_DEPS :=
  461. endif
  462. # Debug level calculations
  463. #
  464. DBGLVL_MAX = -DDBGLVL_MAX=$(firstword $(subst ., ,$(1)))
  465. DBGLVL_DFLT = -DDBGLVL_DFLT=$(lastword $(subst ., ,$(1)))
  466. DBGLVL = $(call DBGLVL_MAX,$(1)) $(call DBGLVL_DFLT,$(1))
  467. # Rules for specific object types.
  468. #
  469. COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
  470. RULE_c = $(Q)$(COMPILE_c) -c $< -o $@ $(POST_O)
  471. RULE_c_to_ids.o = $(Q)$(ECHO_E) '$(OBJ_IDS_ASM_NL)' | $(ASSEMBLE_S) -o $@
  472. RULE_c_to_dbg%.o= $(Q)$(COMPILE_c) $(call DBGLVL,$*) -c $< -o $@ $(POST_O)
  473. RULE_c_to_c = $(Q)$(COMPILE_c) -E -c $< > $@
  474. RULE_c_to_s = $(Q)$(COMPILE_c) -S -g0 -c $< -o $@
  475. PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
  476. ASSEMBLE_S = $(AS) $(ASFLAGS)
  477. RULE_S = $(Q)$(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
  478. RULE_S_to_dbg%.o= $(Q)$(PREPROCESS_S) $(call DBGLVL,$*) $< | $(ASSEMBLE_S) -o $@
  479. RULE_S_to_s = $(Q)$(PREPROCESS_S) $< > $@
  480. GENERIC_TARGETS += ids.o dbg%.o c s
  481. # List of embedded images included in the last build of embedded.o.
  482. # This is needed in order to correctly rebuild embedded.o whenever the
  483. # list of objects changes.
  484. #
  485. EMBED := $(EMBEDDED_IMAGE) # Maintain backwards compatibility
  486. EMBEDDED_LIST := $(BIN)/.embedded.list
  487. ifeq ($(wildcard $(EMBEDDED_LIST)),)
  488. EMBED_OLD := <invalid>
  489. else
  490. EMBED_OLD := $(shell cat $(EMBEDDED_LIST))
  491. endif
  492. ifneq ($(EMBED_OLD),$(EMBED))
  493. $(shell $(ECHO) "$(EMBED)" > $(EMBEDDED_LIST))
  494. endif
  495. $(EMBEDDED_LIST) : $(MAKEDEPS)
  496. VERYCLEANUP += $(EMBEDDED_LIST)
  497. EMBEDDED_FILES := $(subst $(COMMA), ,$(EMBED))
  498. EMBED_ALL := $(foreach i,$(call seq,1,$(words $(EMBEDDED_FILES))),\
  499. EMBED ( $(i), \"$(word $(i), $(EMBEDDED_FILES))\",\
  500. \"$(notdir $(word $(i),$(EMBEDDED_FILES)))\" ))
  501. embedded_DEPS += $(EMBEDDED_FILES) $(EMBEDDED_LIST)
  502. CFLAGS_embedded = -DEMBED_ALL="$(EMBED_ALL)"
  503. # List of trusted root certificates
  504. #
  505. TRUSTED_LIST := $(BIN)/.trusted.list
  506. ifeq ($(wildcard $(TRUSTED_LIST)),)
  507. TRUST_OLD := <invalid>
  508. else
  509. TRUST_OLD := $(shell cat $(TRUSTED_LIST))
  510. endif
  511. ifneq ($(TRUST_OLD),$(TRUST))
  512. $(shell $(ECHO) "$(TRUST)" > $(TRUSTED_LIST))
  513. endif
  514. $(TRUSTED_LIST) : $(MAKEDEPS)
  515. VERYCLEANUP += $(TRUSTED_LIST)
  516. # Trusted root certificate fingerprints
  517. #
  518. TRUSTED_CERTS := $(subst $(COMMA), ,$(TRUST))
  519. TRUSTED_FPS := $(foreach CERT,$(TRUSTED_CERTS),\
  520. 0x$(subst :,$(COMMA) 0x,$(lastword $(subst =, ,\
  521. $(shell $(OPENSSL) x509 -in $(CERT) -noout -sha256 \
  522. -fingerprint))))$(COMMA))
  523. rootcert_DEPS += $(TRUSTED_FILES) $(TRUSTED_LIST)
  524. CFLAGS_rootcert = $(if $(TRUSTED_FPS),-DTRUSTED="$(TRUSTED_FPS)")
  525. # List of embedded certificates
  526. #
  527. CERT_LIST := $(BIN)/.certificate.list
  528. ifeq ($(wildcard $(CERT_LIST)),)
  529. CERT_OLD := <invalid>
  530. else
  531. CERT_OLD := $(shell cat $(CERT_LIST))
  532. endif
  533. ifneq ($(CERT_OLD),$(CERT))
  534. $(shell $(ECHO) "$(CERT)" > $(CERT_LIST))
  535. endif
  536. $(CERT_LIST) : $(MAKEDEPS)
  537. VERYCLEANUP += $(CERT_LIST)
  538. # Embedded certificates concatenated and then split into one file per
  539. # certificate (even if original files contained certificate chains)
  540. #
  541. CERT_FILES := $(subst $(COMMA), ,$(CERT))
  542. CERT_CONCAT := $(BIN)/.certificates.pem
  543. ifneq ($(CERT),)
  544. CERT_COUNT := $(shell grep "BEGIN CERTIFICATE" $(CERT_FILES) | wc -l)
  545. $(CERT_CONCAT) : $(CERT_FILES) $(CERT_LIST)
  546. $(Q)cat $(CERT_FILES) > $@
  547. # We must use an (otherwise unnecessary) pattern rule here to encode
  548. # the fact that one "csplit" command generates multiple targets
  549. CERT_PEMS := $(foreach i,$(call seq,1,$(CERT_COUNT)),\
  550. $(BIN)/.certificate.pem.$(i))
  551. $(subst .pem.,.%.,$(CERT_PEMS)) : $(BIN)/.certificates.%
  552. $(Q)$(CSPLIT) -q -n 1 -f $(BIN)/.certificate.pem. $< \
  553. '/BEGIN CERTIFICATE/' '{*}'
  554. CERT_DERS := $(subst .certificate.pem.,.certificate.der.,$(CERT_PEMS))
  555. $(BIN)/.certificate.der.% : $(BIN)/.certificate.pem.%
  556. $(Q)$(OPENSSL) x509 -in $< -outform DER -out $@
  557. CERT_ALL := $(foreach i,$(call seq,1,$(CERT_COUNT)),\
  558. CERT ( $(i), \"$(word $(i),$(CERT_DERS))\" ))
  559. endif
  560. certstore_DEPS += $(CERT_LIST) $(CERT_FILES) $(CERT_PEMS) $(CERT_DERS)
  561. CFLAGS_certstore += -DCERT_ALL="$(CERT_ALL)"
  562. CLEANUP += $(BIN)/.certificate.* $(BIN)/.certificates.*
  563. # (Single-element) list of private keys
  564. #
  565. ifdef KEY
  566. PRIVKEY := $(KEY) # Maintain backwards compatibility
  567. endif
  568. PRIVKEY_LIST := $(BIN)/.private_key.list
  569. ifeq ($(wildcard $(PRIVKEY_LIST)),)
  570. PRIVKEY_OLD := <invalid>
  571. else
  572. PRIVKEY_OLD := $(shell cat $(PRIVKEY_LIST))
  573. endif
  574. ifneq ($(PRIVKEY_OLD),$(PRIVKEY))
  575. $(shell $(ECHO) "$(PRIVKEY)" > $(PRIVKEY_LIST))
  576. endif
  577. $(PRIVKEY_LIST) : $(MAKEDEPS)
  578. VERYCLEANUP += $(PRIVKEY_LIST)
  579. # Embedded private key
  580. #
  581. PRIVKEY_INC := $(BIN)/.private_key.der
  582. ifdef PRIVKEY
  583. $(PRIVKEY_INC) : $(PRIVKEY) $(PRIVKEY_LIST)
  584. $(Q)$(OPENSSL) rsa -in $< -outform DER -out $@
  585. privkey_DEPS += $(PRIVKEY_INC)
  586. endif
  587. CLEANUP += $(BIN)/.private_key.*
  588. privkey_DEPS += $(PRIVKEY_LIST)
  589. CFLAGS_privkey += $(if $(PRIVKEY),-DPRIVATE_KEY="\"$(PRIVKEY_INC)\"")
  590. # (Single-element) list of named configurations
  591. #
  592. CONFIG_LIST := $(BIN)/.config.list
  593. ifeq ($(wildcard $(CONFIG_LIST)),)
  594. CONFIG_OLD := <invalid>
  595. else
  596. CONFIG_OLD := $(shell cat $(CONFIG_LIST))
  597. endif
  598. ifneq ($(CONFIG_OLD),$(CONFIG))
  599. $(shell $(ECHO) "$(CONFIG)" > $(CONFIG_LIST))
  600. endif
  601. $(CONFIG_LIST) : $(MAKEDEPS)
  602. VERYCLEANUP += $(CONFIG_LIST)
  603. # Named configurations
  604. #
  605. ifneq ($(CONFIG),)
  606. ifneq ($(wildcard config/$(CONFIG)),)
  607. CFLAGS += -DCONFIG=$(CONFIG)
  608. endif
  609. CFLAGS += -DLOCAL_CONFIG=$(CONFIG)
  610. endif
  611. config/named.h : $(CONFIG_LIST)
  612. $(Q)$(TOUCH) $@
  613. .PRECIOUS : config/named.h
  614. # (Single-element) list of assertion configuration
  615. #
  616. ASSERT_LIST := $(BIN)/.assert.list
  617. ifeq ($(wildcard $(ASSERT_LIST)),)
  618. ASSERT_OLD := <invalid>
  619. else
  620. ASSERT_OLD := $(shell cat $(ASSERT_LIST))
  621. endif
  622. ifneq ($(ASSERT_OLD),$(ASSERT))
  623. $(shell $(ECHO) "$(ASSERT)" > $(ASSERT_LIST))
  624. endif
  625. $(ASSERT_LIST) : $(MAKEDEPS)
  626. VERYCLEANUP += $(ASSERT_LIST)
  627. # Assertion configuration
  628. #
  629. ifneq ($(ASSERT),)
  630. CFLAGS += -DASSERTING=$(ASSERT)
  631. endif
  632. include/assert.h : $(ASSERT_LIST)
  633. $(Q)$(TOUCH) $@
  634. .PRECIOUS : include/assert.h
  635. # (Single-element) list of profiling configuration
  636. #
  637. PROFILE_LIST := $(BIN)/.profile.list
  638. ifeq ($(wildcard $(PROFILE_LIST)),)
  639. PROFILE_OLD := <invalid>
  640. else
  641. PROFILE_OLD := $(shell cat $(PROFILE_LIST))
  642. endif
  643. ifneq ($(PROFILE_OLD),$(PROFILE))
  644. $(shell $(ECHO) "$(PROFILE)" > $(PROFILE_LIST))
  645. endif
  646. $(PROFILE_LIST) : $(MAKEDEPS)
  647. VERYCLEANUP += $(PROFILE_LIST)
  648. # Profiling configuration
  649. #
  650. ifneq ($(PROFILE),)
  651. CFLAGS += -DPROFILING=$(PROFILE)
  652. endif
  653. include/ipxe/profile.h : $(PROFILE_LIST)
  654. $(Q)$(TOUCH) $@
  655. .PRECIOUS : include/ipxe/profile.h
  656. # These files use .incbin inline assembly to include a binary file.
  657. # Unfortunately ccache does not detect this dependency and caches
  658. # builds even when the binary file has changed.
  659. #
  660. $(BIN)/embedded.% : override CC := env CCACHE_DISABLE=1 $(CC)
  661. $(BIN)/certstore.% : override CC := env CCACHE_DISABLE=1 $(CC)
  662. $(BIN)/privkey.% : override CC := env CCACHE_DISABLE=1 $(CC)
  663. # Debug message autocolourisation range
  664. #
  665. DBGCOL_LIST := $(BIN)/.dbgcol.list
  666. ifeq ($(wildcard $(DBGCOL_LIST)),)
  667. DBGCOL_OLD := <invalid>
  668. else
  669. DBGCOL_OLD := $(shell cat $(DBGCOL_LIST))
  670. endif
  671. ifneq ($(DBGCOL_OLD),$(DBGCOL))
  672. $(shell $(ECHO) "$(DBGCOL)" > $(DBGCOL_LIST))
  673. endif
  674. $(DBGCOL_LIST) : $(MAKEDEPS)
  675. VERYCLEANUP += $(DBGCOL_LIST)
  676. DBGCOL_COLOURS := $(subst -, ,$(DBGCOL))
  677. DBGCOL_MIN := $(firstword $(DBGCOL_COLOURS))
  678. DBGCOL_MAX := $(lastword $(DBGCOL_COLOURS))
  679. debug_DEPS += $(DBGCOL_LIST)
  680. CFLAGS_debug += $(if $(DBGCOL_MIN),-DDBGCOL_MIN=$(DBGCOL_MIN))
  681. CFLAGS_debug += $(if $(DBGCOL_MAX),-DDBGCOL_MAX=$(DBGCOL_MAX))
  682. # We automatically generate rules for any file mentioned in AUTO_SRCS
  683. # using the following set of templates. We use $(eval ...) if
  684. # available, otherwise we generate separate Makefile fragments and
  685. # include them.
  686. # deps_template : generate dependency list for a given source file
  687. #
  688. # $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
  689. #
  690. define deps_template_file
  691. $(call deps_template_parts,$(1),$(subst .,,$(suffix $(1))),$(basename $(notdir $(1))))
  692. endef
  693. #
  694. # $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
  695. # $(2) is the source type (e.g. "c")
  696. # $(3) is the source base name (e.g. "rtl8139")
  697. #
  698. define deps_template_parts
  699. @$(ECHO) " [DEPS] $(1)"
  700. @$(MKDIR) -p $(BIN)/deps/$(dir $(1))
  701. $(Q)$(CPP) $(CFLAGS) $(CFLAGS_$(2)) $(CFLAGS_$(3)) -DOBJECT=$(3) \
  702. -Wno-error -M $(1) -MG -MP | \
  703. sed 's/\.o\s*:/_DEPS +=/' > $(BIN)/deps/$(1).d
  704. endef
  705. # rules_template : generate rules for a given source file
  706. #
  707. # $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
  708. #
  709. define rules_template
  710. $(call rules_template_parts,$(1),$(subst .,,$(suffix $(1))),$(basename $(notdir $(1))))
  711. endef
  712. #
  713. # $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
  714. # $(2) is the source type (e.g. "c")
  715. # $(3) is the source base name (e.g. "rtl8139")
  716. #
  717. define rules_template_parts
  718. $$(BIN)/$(3).o : $(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(3)_DEPS)
  719. $$(QM)$(ECHO) " [BUILD] $$@"
  720. $$(RULE_$(2))
  721. BOBJS += $$(BIN)/$(3).o
  722. $(foreach TGT,$(GENERIC_TARGETS),$(if $(RULE_$(2)_to_$(TGT)),$(NEWLINE)$(call rules_template_target,$(1),$(2),$(3),$(TGT))))
  723. $$(BIN)/deps/$(1).d : $$($(3)_DEPS)
  724. TAGS : $$($(3)_DEPS)
  725. endef
  726. #
  727. # $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
  728. # $(2) is the source type (e.g. "c")
  729. # $(3) is the source base name (e.g. "rtl8139")
  730. # $(4) is the destination type (e.g. "dbg%.o")
  731. #
  732. define rules_template_target
  733. $$(BIN)/$(3).$(4) : $(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(3)_DEPS)
  734. $$(QM)$(ECHO) " [BUILD] $$@"
  735. $$(RULE_$(2)_to_$(4))
  736. $(TGT)_OBJS += $$(BIN)/$(3).$(4)
  737. endef
  738. #
  739. # $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
  740. #
  741. define rules_template_file
  742. @$(ECHO) " [RULES] $(1)"
  743. @$(MKDIR) -p $(BIN)/rules/$(dir $(1))
  744. @$(ECHO_E) '$(subst $(NEWLINE),\n,$(call rules_template,$(1)))' \
  745. > $(BIN)/rules/$(1).r
  746. endef
  747. # Generate the dependency files
  748. #
  749. $(BIN)/deps/%.d : % $(MAKEDEPS)
  750. $(call deps_template_file,$<)
  751. # Calculate list of dependency files
  752. #
  753. AUTO_DEPS = $(patsubst %,$(BIN)/deps/%.d,$(AUTO_SRCS))
  754. autodeps :
  755. @$(ECHO) $(AUTO_DEPS)
  756. VERYCLEANUP += $(BIN)/deps
  757. # Include dependency files
  758. #
  759. ifdef NEED_DEPS
  760. ifneq ($(AUTO_DEPS),)
  761. -include $(AUTO_DEPS)
  762. endif
  763. endif
  764. # Generate the rules files
  765. #
  766. $(BIN)/rules/%.r : % $(MAKEDEPS)
  767. $(call rules_template_file,$<)
  768. # Calculate list of rules files
  769. #
  770. AUTO_RULES = $(patsubst %,$(BIN)/rules/%.r,$(AUTO_SRCS))
  771. autorules :
  772. @$(ECHO) $(AUTO_RULES)
  773. VERYCLEANUP += $(BIN)/rules
  774. # Evaluate rules (or include rules files)
  775. #
  776. ifdef NEED_DEPS
  777. ifneq ($(AUTO_RULES),)
  778. ifneq ($(HAVE_EVAL),)
  779. $(foreach SRC,$(AUTO_SRCS),$(eval $(call rules_template,$(SRC))))
  780. else
  781. -include $(AUTO_RULES)
  782. endif
  783. endif
  784. endif
  785. # Files to be parsed using parserom.pl
  786. #
  787. ROM_SRCS = $(foreach SRC,$(AUTO_SRCS),\
  788. $(if $(findstring drivers/,$(SRC)),$(SRC)))
  789. romsrcs :
  790. @$(ECHO) $(ROM_SRCS)
  791. # List of files to be parsed using parserom.pl
  792. #
  793. ROM_SRCS_LIST := $(BIN)/.rom.list
  794. ifeq ($(wildcard $(ROM_SRCS_LIST)),)
  795. ROM_SRCS_OLD := <invalid>
  796. else
  797. ROM_SRCS_OLD := $(shell cat $(ROM_SRCS_LIST))
  798. endif
  799. ifneq ($(ROM_SRCS_OLD),$(ROM_SRCS))
  800. $(shell $(ECHO) "$(ROM_SRCS)" > $(ROM_SRCS_LIST))
  801. endif
  802. $(ROM_SRCS_LIST) : $(MAKEDEPS)
  803. VERYCLEANUP += $(ROM_SRCS_LIST)
  804. # ROM definition file
  805. #
  806. ROMDEFS = $(BIN)/.rom.defs
  807. $(ROMDEFS) : $(ROM_SRCS) $(ROM_SRCS_LIST) $(PARSEROM) $(MAKEDEPS)
  808. $(QM)$(ECHO) " [PARSEROM]"
  809. $(Q)$(PERL) $(PARSEROM) $(ROM_SRCS) > $@
  810. VERYCLEANUP += $(ROMDEFS)
  811. # Evaluate ROM definition file
  812. ifdef NEED_DEPS
  813. ifneq ($(ROM_SRCS),)
  814. -include $(ROMDEFS)
  815. endif
  816. endif
  817. # Device ID tables (using IDs from ROM definition file)
  818. #
  819. define obj_pci_id_asm
  820. .section ".pci_devlist.$(1)", "a", $(ASM_TCHAR)progbits
  821. .globl pci_devlist_$(1)
  822. pci_devlist_$(1):
  823. .short ( 0x$(1) & 0xffff )
  824. endef
  825. define obj_isa_id_asm
  826. endef
  827. OBJ_IDS_ASM = $(foreach ROM,$(ROMS_$(OBJECT)),$(call obj_$(ROM_TYPE_$(ROM))_id_asm,$(ROM)))
  828. OBJ_IDS_ASM_NL = $(subst $(NEWLINE),\n,$(OBJ_IDS_ASM))
  829. $(BIN)/%.ids :
  830. @$(ECHO_E) '$(OBJ_IDS_ASM_NL)'
  831. BOBJS += $(patsubst %,$(BIN)/%.ids.o,$(DRIVERS))
  832. # The following variables are created by the autogenerated rules
  833. #
  834. bobjs :
  835. @$(ECHO) $(BOBJS)
  836. drivers_% :
  837. @$(ECHO) $(DRIVERS_$*)
  838. drivers :
  839. @$(ECHO) $(DRIVERS)
  840. .PHONY : drivers
  841. roms :
  842. @$(ECHO) $(ROMS)
  843. # Generate error usage information
  844. #
  845. $(BIN)/%.einfo : $(BIN)/%.o
  846. $(QM)$(ECHO) " [EINFO] $@"
  847. $(Q)$(OBJCOPY) -O binary -j .einfo --set-section-flags .einfo=alloc \
  848. $< $@
  849. EINFOS := $(patsubst $(BIN)/%.o,$(BIN)/%.einfo,$(BOBJS))
  850. $(BIN)/errors : $(EINFOS) $(EINFO)
  851. $(QM)$(ECHO) " [EINFO] $@"
  852. $(Q)$(EINFO) $(EINFOS) | sort > $@
  853. CLEANUP += $(BIN)/errors # Doesn't match the $(BIN)/*.* pattern
  854. # Generate the NIC file from the parsed source files. The NIC file is
  855. # only for rom-o-matic.
  856. #
  857. $(BIN)/NIC : $(AUTO_DEPS)
  858. @$(ECHO) '# This is an automatically generated file, do not edit' > $@
  859. @$(ECHO) '# It does not affect anything in the build, ' \
  860. 'it is only for rom-o-matic' >> $@
  861. @$(ECHO) >> $@
  862. @perl -ne 'chomp; print "$$1\n" if /\# NIC\t(.*)$$/' $^ >> $@
  863. CLEANUP += $(BIN)/NIC # Doesn't match the $(BIN)/*.* pattern
  864. # Select drivers to be included in the all-drivers build
  865. #
  866. DRIVERS_ipxe = $(DRIVERS_net) $(DRIVERS_infiniband) \
  867. $(DRIVERS_xen) $(DRIVERS_hyperv)
  868. # Analyse a target name (e.g. "bin/dfe538--prism2_pci.rom.tmp") and
  869. # derive the variables:
  870. #
  871. # TGT_ELEMENTS : the elements of the target (e.g. "dfe538 prism2_pci")
  872. # TGT_PREFIX : the prefix type (e.g. "pcirom")
  873. # TGT_DRIVERS : the driver for each element (e.g. "rtl8139 prism2_pci")
  874. # TGT_ROM_NAME : the ROM name (e.g. "dfe538")
  875. #
  876. TGT_ELEMENTS = $(subst --, ,$(firstword $(subst ., ,$(notdir $@))))
  877. TGT_ROM_NAME = $(firstword $(TGT_ELEMENTS))
  878. TGT_DRIVERS = $(strip $(foreach TGT_ELEMENT,$(TGT_ELEMENTS), \
  879. $(if $(DRIVERS_$(TGT_ELEMENT)), \
  880. $(DRIVERS_$(TGT_ELEMENT)), \
  881. $(firstword $(DRIVER_$(TGT_ELEMENT)) \
  882. $(TGT_ELEMENT)))))
  883. TGT_PREFIX_NAME = $(word 2,$(subst ., ,$(notdir $@)))
  884. TGT_PREFIX = $(strip $(if $(filter rom,$(TGT_PREFIX_NAME)), \
  885. $(ROM_TYPE_$(TGT_ROM_NAME))rom, \
  886. $(TGT_PREFIX_NAME)))
  887. # Look up ROM IDs for the current target
  888. # (e.g. "bin/dfe538--prism2_pci.rom.tmp") and derive the variables:
  889. #
  890. # TGT_PCI_VENDOR : the PCI vendor ID (e.g. "0x1186")
  891. # TGT_PCI_DEVICE : the PCI device ID (e.g. "0x1300")
  892. #
  893. TGT_PCI_VENDOR = $(PCI_VENDOR_$(TGT_ROM_NAME))
  894. TGT_PCI_DEVICE = $(PCI_DEVICE_$(TGT_ROM_NAME))
  895. # Calculate link-time options for the current target
  896. # (e.g. "bin/dfe538--prism2_pci.rom.tmp") and derive the variables:
  897. #
  898. # TGT_LD_DRIVERS : symbols to require in order to drag in the relevant drivers
  899. # (e.g. "obj_rtl8139 obj_prism2_pci")
  900. # TGT_LD_IDS : symbols to define in order to fill in ID structures in the
  901. # ROM header (e.g."pci_vendor_id=0x1186 pci_device_id=0x1300")
  902. #
  903. TGT_LD_DRIVERS = $(subst -,_,$(patsubst %,obj_%,$(TGT_DRIVERS)))
  904. TGT_LD_IDS = pci_vendor_id=$(firstword $(TGT_PCI_VENDOR) 0) \
  905. pci_device_id=$(firstword $(TGT_PCI_DEVICE) 0)
  906. TGT_LD_DEVLIST = $(foreach ELEM,$(TGT_ELEMENTS),$(if $(PCI_VENDOR_$(ELEM)),\
  907. pci_devlist_$(patsubst 0x%,%,$(PCI_VENDOR_$(ELEM)))$(patsubst 0x%,%,$(PCI_DEVICE_$(ELEM)))))
  908. TGT_LD_ENTRY = _$(TGT_PREFIX)_start
  909. # Calculate linker flags based on link-time options for the current
  910. # target type (e.g. "bin/dfe538--prism2_pci.rom.tmp") and derive the
  911. # variables:
  912. #
  913. # TGT_LD_FLAGS : target-specific flags to pass to linker (e.g.
  914. # "-u obj_zpciprefix -u obj_rtl8139 -u obj_prism2_pci
  915. # --defsym pci_vendor=0x1186 --defsym pci_device=0x1300")
  916. #
  917. TGT_LD_FLAGS = $(foreach SYM,$(TGT_LD_ENTRY) $(TGT_LD_DRIVERS) \
  918. $(TGT_LD_DEVLIST) obj_config obj_config_$(PLATFORM),\
  919. -u $(SYM) --defsym check_$(SYM)=$(SYM) ) \
  920. $(patsubst %,--defsym %,$(TGT_LD_IDS)) \
  921. -e $(TGT_LD_ENTRY)
  922. # Calculate list of debugging versions of objects to be included in
  923. # the target.
  924. #
  925. DEBUG_LIST = $(subst $(COMMA), ,$(DEBUG))
  926. DEBUG_MAX = $(firstword $(word 2,$(subst :, ,$(1))) 1)
  927. DEBUG_DFLT = $(if $(word 3,$(subst :, ,$(1))),.$(word 3,$(subst :, ,$(1))))
  928. DEBUG_LEVEL = $(call DEBUG_MAX,$(1))$(call DEBUG_DFLT,$(1))
  929. DEBUG_BASE = $(firstword $(subst :, ,$(1))).dbg$(call DEBUG_LEVEL,$(1))
  930. DEBUG_OBJ = $(BIN)/$(call DEBUG_BASE,$(1)).o
  931. DEBUG_ORIG_OBJ = $(BIN)/$(firstword $(subst :, ,$(1))).o
  932. DEBUG_OBJS = $(foreach D,$(DEBUG_LIST),$(call DEBUG_OBJ,$(D)))
  933. DEBUG_ORIG_OBJS = $(foreach D,$(DEBUG_LIST),$(call DEBUG_ORIG_OBJ,$(D)))
  934. BLIB_OBJS = $(DEBUG_OBJS) $(filter-out $(DEBUG_ORIG_OBJS),$(BOBJS))
  935. # Print out all derived information for a given target.
  936. #
  937. $(BIN)/%.info :
  938. @$(ECHO) 'Elements : $(TGT_ELEMENTS)'
  939. @$(ECHO) 'Prefix : $(TGT_PREFIX)'
  940. @$(ECHO) 'Drivers : $(TGT_DRIVERS)'
  941. @$(ECHO) 'ROM name : $(TGT_ROM_NAME)'
  942. @$(ECHO)
  943. @$(ECHO) 'PCI vendor : $(TGT_PCI_VENDOR)'
  944. @$(ECHO) 'PCI device : $(TGT_PCI_DEVICE)'
  945. @$(ECHO)
  946. @$(ECHO) 'LD driver symbols : $(TGT_LD_DRIVERS)'
  947. @$(ECHO) 'LD ID symbols : $(TGT_LD_IDS)'
  948. @$(ECHO) 'LD devlist symbols : $(TGT_LD_DEVLIST)'
  949. @$(ECHO) 'LD entry point : $(TGT_LD_ENTRY)'
  950. @$(ECHO)
  951. @$(ECHO) 'LD target flags : $(TGT_LD_FLAGS)'
  952. @$(ECHO)
  953. @$(ECHO) 'Debugging objects : $(DEBUG_OBJS)'
  954. @$(ECHO) 'Replaced objects : $(DEBUG_ORIG_OBJS)'
  955. # List of objects included in the last build of blib. This is needed
  956. # in order to correctly rebuild blib whenever the list of objects
  957. # changes.
  958. #
  959. BLIB_LIST := $(BIN)/.blib.list
  960. ifeq ($(wildcard $(BLIB_LIST)),)
  961. BLIB_OBJS_OLD := <invalid>
  962. else
  963. BLIB_OBJS_OLD := $(shell cat $(BLIB_LIST))
  964. endif
  965. ifneq ($(BLIB_OBJS_OLD),$(BLIB_OBJS))
  966. $(shell $(ECHO) "$(BLIB_OBJS)" > $(BLIB_LIST))
  967. endif
  968. $(BLIB_LIST) : $(MAKEDEPS)
  969. VERYCLEANUP += $(BLIB_LIST)
  970. # Library of all objects
  971. #
  972. BLIB = $(BIN)/blib.a
  973. $(BLIB) : $(BLIB_OBJS) $(BLIB_LIST) $(MAKEDEPS)
  974. $(Q)$(RM) $(BLIB)
  975. $(QM)$(ECHO) " [AR] $@"
  976. $(Q)$(AR) r $@ $(sort $(BLIB_OBJS))
  977. $(Q)$(RANLIB) $@
  978. blib : $(BLIB)
  979. # Command to generate build ID. Must be unique for each $(BIN)/%.tmp,
  980. # even within the same build run.
  981. #
  982. BUILD_ID_CMD := perl -e 'printf "0x%08x", int ( rand ( 0xffffffff ) );'
  983. # Build timestamp
  984. #
  985. BUILD_TIMESTAMP := $(shell date +%s)
  986. # Build version
  987. #
  988. GIT_INDEX := $(if $(GITVERSION),$(if $(wildcard ../.git/index),../.git/index))
  989. $(BIN)/version.%.o : core/version.c $(MAKEDEPS) $(GIT_INDEX)
  990. $(QM)$(ECHO) " [VERSION] $@"
  991. $(Q)$(COMPILE_c) -DBUILD_NAME="\"$*\"" \
  992. -DVERSION_MAJOR=$(VERSION_MAJOR) \
  993. -DVERSION_MINOR=$(VERSION_MINOR) \
  994. -DVERSION_PATCH=$(VERSION_PATCH) \
  995. -DVERSION="\"$(VERSION)\"" \
  996. -c $< -o $@
  997. # Build an intermediate object file from the objects required for the
  998. # specified target.
  999. #
  1000. $(BIN)/%.tmp : $(BIN)/version.%.o $(BLIB) $(MAKEDEPS) $(LDSCRIPT)
  1001. $(QM)$(ECHO) " [LD] $@"
  1002. $(Q)$(LD) $(LDFLAGS) -T $(LDSCRIPT) $(TGT_LD_FLAGS) $< $(BLIB) -o $@ \
  1003. --defsym _build_id=`$(BUILD_ID_CMD)` \
  1004. --defsym _build_timestamp=$(BUILD_TIMESTAMP) \
  1005. -Map $(BIN)/$*.tmp.map
  1006. $(Q)$(OBJDUMP) -ht $@ | $(PERL) $(SORTOBJDUMP) >> $(BIN)/$*.tmp.map
  1007. # Keep intermediate object file (useful for debugging)
  1008. .PRECIOUS : $(BIN)/%.tmp
  1009. # Show a linker map for the specified target
  1010. #
  1011. $(BIN)/%.map : $(BIN)/%.tmp
  1012. @less $(BIN)/$*.tmp.map
  1013. # Get objects list for the specified target
  1014. #
  1015. define objs_list
  1016. $(sort $(foreach OBJ_SYMBOL,\
  1017. $(filter obj_%,$(shell $(NM) $(1) | cut -d" " -f3)),\
  1018. $(patsubst obj_%,%,$(OBJ_SYMBOL))))
  1019. endef
  1020. $(BIN)/%.objs : $(BIN)/%.tmp
  1021. $(Q)$(ECHO) $(call objs_list,$<)
  1022. $(BIN)/%.sizes : $(BIN)/%.tmp
  1023. $(Q)$(SIZE) -t $(foreach OBJ,$(call objs_list,$<),$(wildcard $(BIN)/$(subst _,?,$(OBJ)).o)) | \
  1024. sort -g
  1025. # Get dependency list for the specified target
  1026. #
  1027. define deps_list
  1028. $(sort $(foreach OBJ,$(call objs_list,$(1)),$($(OBJ)_DEPS)))
  1029. endef
  1030. $(BIN)/%.deps : $(BIN)/%.tmp
  1031. $(Q)$(ECHO) $(call deps_list,$<)
  1032. # Get unneeded source files for the specified target
  1033. #
  1034. define nodeps_list
  1035. $(sort $(filter-out $(call deps_list,$(1)),\
  1036. $(foreach BOBJ,$(BOBJS),\
  1037. $($(basename $(notdir $(BOBJ)))_DEPS))))
  1038. endef
  1039. $(BIN)/%.nodeps : $(BIN)/%.tmp
  1040. $(Q)$(ECHO) $(call nodeps_list,$<)
  1041. # Get licensing verdict for the specified target
  1042. #
  1043. define licensable_deps_list
  1044. $(filter-out config/local/%.h,\
  1045. $(filter-out $(BIN)/.%.list,\
  1046. $(call deps_list,$(1))))
  1047. endef
  1048. define unlicensed_deps_list
  1049. $(shell grep -L FILE_LICENCE $(call licensable_deps_list,$(1)))
  1050. endef
  1051. define licence_list
  1052. $(sort $(foreach LICENCE,\
  1053. $(filter __licence__%,$(shell $(NM) $(1) | cut -d" " -f3)),\
  1054. $(word 2,$(subst __, ,$(LICENCE)))))
  1055. endef
  1056. $(BIN)/%.licence_list : $(BIN)/%.tmp
  1057. $(Q)$(ECHO) $(call licence_list,$<)
  1058. $(BIN)/%.licence : $(BIN)/%.tmp
  1059. $(QM)$(ECHO) " [LICENCE] $@"
  1060. $(Q)$(if $(strip $(call unlicensed_deps_list,$<)),\
  1061. echo -n "Unable to determine licence because the following " ;\
  1062. echo "files are missing a licence declaration:" ;\
  1063. echo $(call unlicensed_deps_list,$<);\
  1064. exit 1,\
  1065. $(PERL) $(LICENCE) $(call licence_list,$<))
  1066. # Extract compression information from intermediate object file
  1067. #
  1068. $(BIN)/%.zinfo : $(BIN)/%.tmp
  1069. $(QM)$(ECHO) " [ZINFO] $@"
  1070. $(Q)$(OBJCOPY) -O binary -j .zinfo $< $@
  1071. # Build raw binary file from intermediate object file
  1072. #
  1073. $(BIN)/%.bin : $(BIN)/%.tmp
  1074. $(QM)$(ECHO) " [BIN] $@"
  1075. $(Q)$(OBJCOPY) -O binary -R .zinfo $< $@
  1076. # Compress raw binary file
  1077. #
  1078. $(BIN)/%.zbin : $(BIN)/%.bin $(BIN)/%.zinfo $(ZBIN)
  1079. $(QM)$(ECHO) " [ZBIN] $@"
  1080. $(Q)$(ZBIN) $(BIN)/$*.bin $(BIN)/$*.zinfo > $@
  1081. # Rules for each media format. These are generated and placed in an
  1082. # external Makefile fragment. We could do this via $(eval ...), but
  1083. # that would require make >= 3.80.
  1084. #
  1085. # Note that there's an alternative way to generate most .rom images:
  1086. # they can be copied from their 'master' ROM image using cp and
  1087. # reprocessed with makerom to add the PCI IDs and ident string. The
  1088. # relevant rule would look something like:
  1089. #
  1090. # $(BIN)/dfe538%rom : $(BIN)/rtl8139%rom
  1091. # cat $< $@
  1092. # $(FINALISE_rom)
  1093. #
  1094. # You can derive the ROM/driver relationships using the variables
  1095. # DRIVER_<rom> and/or ROMS_<driver>.
  1096. #
  1097. # We don't currently do this, because (a) it would require generating
  1098. # yet more Makefile fragments (since you need a rule for each ROM in
  1099. # ROMS), and (b) the linker is so fast that it probably wouldn't make
  1100. # much difference to the overall build time.
  1101. # Add NON_AUTO_MEDIA to the media list, so that they show up in the
  1102. # output of "make"
  1103. #
  1104. MEDIA += $(NON_AUTO_MEDIA)
  1105. media :
  1106. @$(ECHO) $(MEDIA)
  1107. AUTO_MEDIA = $(filter-out $(NON_AUTO_MEDIA),$(MEDIA))
  1108. automedia :
  1109. @$(ECHO) $(AUTO_MEDIA)
  1110. # media_template : create media rules
  1111. #
  1112. # $(1) is the media name (e.g. "rom")
  1113. #
  1114. define media_template
  1115. $(if $(filter $(1),$(AUTO_MEDIA)),$(call auto_media_template,$(1)))
  1116. LIST_$(1) := $$(if $$(LIST_NAME_$(1)),$$($$(LIST_NAME_$(1))),$$(DRIVERS))
  1117. ALL_$(1) = $$(foreach ITEM,$$(LIST_$(1)),$$(BIN)/$$(ITEM).$(1))
  1118. $$(BIN)/all$(1)s : $$(ALL_$(1))
  1119. $$(BIN)/allall : $$(BIN)/all$(1)s
  1120. all$(1)s : $$(BIN)/all$(1)s
  1121. allall : $$(BIN)/allall
  1122. endef
  1123. #
  1124. # $(1) is the media name (e.g. "rom")
  1125. #
  1126. define auto_media_template
  1127. $$(BIN)/%.$(1) : $$(BIN)/%.$(1).zbin
  1128. $$(QM)echo " [FINISH] $$@"
  1129. $$(Q)$$(CP) $$< $$@
  1130. $$(Q)$$(if $$(PAD_$(1)),$$(PAD_$(1)) $$@)
  1131. $$(Q)$$(if $$(FINALISE_$(1)),$$(FINALISE_$(1)) $$@)
  1132. endef
  1133. #
  1134. # $(1) is the media name (e.g. "rom")
  1135. #
  1136. define media_template_file
  1137. @$(ECHO) " [MEDIARULES] $(1)"
  1138. @$(MKDIR) -p $(BIN)/rules/$(dir $(1))
  1139. @$(ECHO_E) '$(subst $(NEWLINE),\n,$(call media_template,$(1)))' \
  1140. > $(BIN)/rules/$(1).media.r
  1141. endef
  1142. # Generate media rules files
  1143. #
  1144. $(BIN)/rules/%.media.r : $(MAKEDEPS)
  1145. $(call media_template_file,$*)
  1146. # Calculate list of media rules files
  1147. #
  1148. MEDIA_RULES = $(patsubst %,$(BIN)/rules/%.media.r,$(MEDIA))
  1149. mediarules :
  1150. @$(ECHO) $(MEDIA_RULES)
  1151. # Evaluate media rules (or include media rules files)
  1152. #
  1153. ifdef NEED_DEPS
  1154. ifneq ($(MEDIA_RULES),)
  1155. ifneq ($(HAVE_EVAL),)
  1156. $(foreach MEDIUM,$(MEDIA),$(eval $(call media_template,$(MEDIUM))))
  1157. else
  1158. -include $(MEDIA_RULES)
  1159. endif
  1160. endif
  1161. endif
  1162. # Alias for ipxe.%
  1163. #
  1164. $(BIN)/etherboot.% : $(BIN)/ipxe.%
  1165. ln -sf $(notdir $<) $@
  1166. endif # defined(BIN)
  1167. ###############################################################################
  1168. #
  1169. # The compression utilities
  1170. #
  1171. ZBIN_LDFLAGS := -llzma
  1172. $(ZBIN) : util/zbin.c $(MAKEDEPS)
  1173. $(QM)$(ECHO) " [HOSTCC] $@"
  1174. $(Q)$(HOST_CC) $(HOST_CFLAGS) $< $(ZBIN_LDFLAGS) -o $@
  1175. CLEANUP += $(ZBIN)
  1176. ###############################################################################
  1177. #
  1178. # The EFI image converter
  1179. #
  1180. $(ELF2EFI32) : util/elf2efi.c $(MAKEDEPS)
  1181. $(QM)$(ECHO) " [HOSTCC] $@"
  1182. $(Q)$(HOST_CC) $(HOST_CFLAGS) -idirafter include -DEFI_TARGET32 $< -o $@
  1183. CLEANUP += $(ELF2EFI32)
  1184. $(ELF2EFI64) : util/elf2efi.c $(MAKEDEPS)
  1185. $(QM)$(ECHO) " [HOSTCC] $@"
  1186. $(Q)$(HOST_CC) $(HOST_CFLAGS) -idirafter include -DEFI_TARGET64 $< -o $@
  1187. CLEANUP += $(ELF2EFI64)
  1188. $(EFIROM) : util/efirom.c $(MAKEDEPS)
  1189. $(QM)$(ECHO) " [HOSTCC] $@"
  1190. $(Q)$(HOST_CC) $(HOST_CFLAGS) -idirafter include -o $@ $<
  1191. CLEANUP += $(EFIROM)
  1192. $(EFIFATBIN) : util/efifatbin.c $(MAKEDEPS)
  1193. $(QM)$(ECHO) " [HOSTCC] $@"
  1194. $(Q)$(HOST_CC) $(HOST_CFLAGS) -idirafter include -o $@ $<
  1195. CLEANUP += $(EFIFATBIN)
  1196. ###############################################################################
  1197. #
  1198. # The ICC fixup utility
  1199. #
  1200. $(ICCFIX) : util/iccfix.c $(MAKEDEPS)
  1201. $(QM)$(ECHO) " [HOSTCC] $@"
  1202. $(Q)$(HOST_CC) $(HOST_CFLAGS) -idirafter include -o $@ $<
  1203. CLEANUP += $(ICCFIX)
  1204. ###############################################################################
  1205. #
  1206. # The error usage information utility
  1207. #
  1208. $(EINFO) : util/einfo.c $(MAKEDEPS)
  1209. $(QM)$(ECHO) " [HOSTCC] $@"
  1210. $(Q)$(HOST_CC) $(HOST_CFLAGS) -idirafter include -o $@ $<
  1211. CLEANUP += $(EINFO)
  1212. ###############################################################################
  1213. #
  1214. # Local configs
  1215. #
  1216. CONFIG_HEADERS := $(patsubst config/%,%,$(wildcard config/*.h))
  1217. CONFIG_LOCAL_HEADERS := $(foreach HEADER,$(CONFIG_HEADERS),\
  1218. config/local/$(HEADER))
  1219. $(CONFIG_LOCAL_HEADERS) :
  1220. $(Q)$(TOUCH) $@
  1221. .PRECIOUS : $(CONFIG_LOCAL_HEADERS)
  1222. ifneq ($(CONFIG),)
  1223. CONFIG_LOCAL_NAMED_HEADERS := $(foreach HEADER,$(CONFIG_HEADERS),\
  1224. config/local/$(CONFIG)/$(HEADER))
  1225. $(CONFIG_LOCAL_NAMED_HEADERS) :
  1226. $(Q)$(MKDIR) -p $(dir $@)
  1227. $(Q)$(TOUCH) $@
  1228. .PRECIOUS : $(CONFIG_LOCAL_NAMED_HEADERS)
  1229. endif
  1230. ###############################################################################
  1231. #
  1232. # Build the TAGS file(s) for emacs
  1233. #
  1234. TAGS :
  1235. ctags -e -R -f $@ --exclude=bin
  1236. CLEANUP += TAGS
  1237. ###############################################################################
  1238. #
  1239. # Force rebuild for any given target
  1240. #
  1241. %.rebuild :
  1242. rm -f $*
  1243. $(Q)$(MAKE) $*
  1244. ###############################################################################
  1245. #
  1246. # Symbol table checks
  1247. #
  1248. ifdef BIN
  1249. SYMTAB = $(BIN)/symtab
  1250. $(SYMTAB) : $(BLIB)
  1251. $(OBJDUMP) -w -t $< > $@
  1252. CLEANUP += $(BIN)/symtab
  1253. symcheck : $(SYMTAB)
  1254. $(PERL) $(SYMCHECK) $<
  1255. endif # defined(BIN)
  1256. ###############################################################################
  1257. #
  1258. # Build bochs symbol table
  1259. #
  1260. ifdef BIN
  1261. $(BIN)/%.bxs : $(BIN)/%.tmp
  1262. $(NM) $< | cut -d" " -f1,3 > $@
  1263. endif # defined(BIN)
  1264. ###############################################################################
  1265. #
  1266. # Documentation
  1267. #
  1268. ifdef BIN
  1269. $(BIN)/doxygen.cfg : doxygen.cfg $(MAKEDEPS)
  1270. $(Q)$(PERL) -pe 's{\@SRCDIRS\@}{$(SRCDIRS)}; ' \
  1271. -e 's{\@INCDIRS\@}{$(filter-out .,$(INCDIRS))}; ' \
  1272. -e 's{\@BIN\@}{$(BIN)}; ' \
  1273. -e 's{\@ARCH\@}{$(ARCH)}; ' \
  1274. $< > $@
  1275. $(BIN)/doc : $(BIN)/doxygen.cfg
  1276. $(Q)$(DOXYGEN) $<
  1277. .PHONY : $(BIN)/doc
  1278. doc : $(BIN)/doc
  1279. doc-clean :
  1280. $(Q)$(RM) -r $(BIN)/doc
  1281. VERYCLEANUP += $(BIN)/doc
  1282. docview :
  1283. @[ -f $(BIN)/doc/html/index.html ] || $(MAKE) $(BIN)/doc
  1284. @if [ -n "$$BROWSER" ] ; then \
  1285. ( $$BROWSER $(BIN)/doc/html/index.html & ) ; \
  1286. else \
  1287. $(ECHO) "Documentation index in $(BIN)/doc/html/index.html" ; \
  1288. fi
  1289. endif # defined(BIN)
  1290. ###############################################################################
  1291. #
  1292. # Keyboard maps
  1293. #
  1294. hci/keymap/keymap_%.c :
  1295. $(Q)$(PERL) $(GENKEYMAP) $* > $@
  1296. ###############################################################################
  1297. #
  1298. # Force deletion of incomplete targets
  1299. #
  1300. .DELETE_ON_ERROR :
  1301. ###############################################################################
  1302. #
  1303. # Clean-up
  1304. #
  1305. ifeq ($(NUM_BINS),0)
  1306. ALLBINS := bin{,-*}
  1307. CLEANUP := $(patsubst $(BIN)/%,$(ALLBINS)/%,$(CLEANUP))
  1308. VERYCLEANUP := $(patsubst $(BIN)/%,$(ALLBINS)/%,$(VERYCLEANUP))
  1309. endif
  1310. clean :
  1311. $(RM) $(CLEANUP)
  1312. veryclean : clean
  1313. $(RM) -r $(VERYCLEANUP)