1 # -*- makefile -*- : Force emacs to use Makefile mode
3 # This file contains various boring housekeeping functions that would
4 # otherwise seriously clutter up the main Makefile.
6 ###############################################################################
8 # Find a usable "echo -e" substitute.
10 TAB := $(shell $(PRINTF) '\t')
11 ECHO_E_ECHO := $(ECHO)
12 ECHO_E_ECHO_E := $(ECHO) -e
13 ECHO_E_BIN_ECHO := /bin/echo
14 ECHO_E_BIN_ECHO_E := /bin/echo -e
15 ECHO_E_ECHO_TAB := $(shell $(ECHO_E_ECHO) '\t' | cat)
16 ECHO_E_ECHO_E_TAB := $(shell $(ECHO_E_ECHO_E) '\t' | cat)
17 ECHO_E_BIN_ECHO_TAB := $(shell $(ECHO_E_BIN_ECHO) '\t')
18 ECHO_E_BIN_ECHO_E_TAB := $(shell $(ECHO_E_BIN_ECHO_E) '\t')
20 ifeq ($(ECHO_E_ECHO_TAB),$(TAB))
21 ECHO_E := $(ECHO_E_ECHO)
23 ifeq ($(ECHO_E_ECHO_E_TAB),$(TAB))
24 ECHO_E := $(ECHO_E_ECHO_E)
26 ifeq ($(ECHO_E_BIN_ECHO_TAB),$(TAB))
27 ECHO_E := $(ECHO_E_BIN_ECHO)
29 ifeq ($(ECHO_E_BIN_ECHO_E_TAB),$(TAB))
30 ECHO_E := $(ECHO_E_BIN_ECHO_E)
37 @$(PRINTF) '%24s : x%sx\n' 'tab' '$(TAB)'
38 @$(PRINTF) '%24s : x%sx\n' '"$(ECHO_E_ECHO) \t"' \
40 @$(PRINTF) '%24s : x%sx\n' '"$(ECHO_E_ECHO_E) \t"' \
41 '$(ECHO_E_ECHO_E_TAB)'
42 @$(PRINTF) '%24s : x%sx\n' '"$(ECHO_E_BIN_ECHO) \t"' \
43 '$(ECHO_E_BIN_ECHO_TAB)'
44 @$(PRINTF) '%24s : x%sx\n' '"$(ECHO_E_BIN_ECHO_E) \t"' \
45 '$(ECHO_E_BIN_ECHO_E_TAB)'
46 @$(ECHO) "No usable \"echo -e\" substitute found"
49 MAKEDEPS += .echocheck
50 VERYCLEANUP += .echocheck
53 @$(ECHO) "Using \"$(ECHO_E)\" for \"echo -e\""
55 ###############################################################################
57 # Generate a usable "seq" substitute
60 $(shell awk 'BEGIN { for ( i = $(1) ; i <= $(2) ; i++ ) print i }')
63 ###############################################################################
67 HOST_OS := $(shell uname -s)
71 ###############################################################################
75 CCDEFS := $(shell $(CC) -E -x c -c /dev/null -dM | cut -d" " -f2)
79 ifeq ($(filter __ICC,$(CCDEFS)),__ICC)
87 ###############################################################################
89 # Check for tools that can cause failed builds
93 GCC_2_96_BANNER := $(shell $(CC) -v 2>&1 | grep -is 'gcc version 2\.96')
94 ifneq ($(GCC_2_96_BANNER),)
95 $(warning gcc 2.96 is unsuitable for compiling iPXE)
96 $(warning Use gcc 2.95 or a newer version instead)
97 $(error Unsuitable build environment found)
101 PERL_UNICODE_CHECK := $(shell $(PERL) -e 'use bytes; print chr(255)' | wc -c)
102 ifeq ($(PERL_UNICODE_CHECK),2)
103 $(warning Your Perl version has a Unicode handling bug)
104 $(warning Execute this command before building iPXE:)
105 $(warning export LANG=$${LANG%.UTF-8})
106 $(error Unsuitable build environment found)
109 LD_GOLD_BANNER := $(shell $(LD) -v 2>&1 | grep 'GNU gold')
110 ifneq ($(LD_GOLD_BANNER),)
111 $(warning GNU gold is unsuitable for building iPXE)
112 $(warning Use GNU ld instead)
113 $(error Unsuitable build environment found)
116 ###############################################################################
118 # Check if $(eval ...) is available to use
123 $(eval HAVE_EVAL := yes)
126 @$(ECHO) $(HAVE_EVAL)
128 ###############################################################################
130 # Check for various tool workarounds
134 WORKAROUND_ASFLAGS :=
135 WORKAROUND_LDFLAGS :=
137 # Make syntax does not allow use of comma or space in certain places.
138 # This ugly workaround is suggested in the manual.
142 SPACE := $(EMPTY) $(EMPTY)
149 # Some widespread patched versions of gcc include -fstack-protector by
150 # default, even when -ffreestanding is specified. We therefore need
151 # to disable -fstack-protector if the compiler supports it.
154 SP_TEST = $(CC) -fno-stack-protector -x c -c /dev/null \
155 -o /dev/null >/dev/null 2>&1
156 SP_FLAGS := $(shell $(SP_TEST) && $(ECHO) '-fno-stack-protector')
157 WORKAROUND_CFLAGS += $(SP_FLAGS)
160 # gcc 4.4 generates .eh_frame sections by default, which distort the
161 # output of "size". Inhibit this.
164 CFI_TEST = $(CC) -fno-dwarf2-cfi-asm -fno-exceptions -fno-unwind-tables \
165 -fno-asynchronous-unwind-tables -x c -c /dev/null \
166 -o /dev/null >/dev/null 2>&1
167 CFI_FLAGS := $(shell $(CFI_TEST) && \
168 $(ECHO) '-fno-dwarf2-cfi-asm -fno-exceptions ' \
169 '-fno-unwind-tables -fno-asynchronous-unwind-tables')
170 WORKAROUND_CFLAGS += $(CFI_FLAGS)
173 # gcc 4.6 generates spurious warnings if -Waddress is in force.
177 WNA_TEST = $(CC) -Wno-address -x c -c /dev/null -o /dev/null >/dev/null 2>&1
178 WNA_FLAGS := $(shell $(WNA_TEST) && $(ECHO) '-Wno-address')
179 WORKAROUND_CFLAGS += $(WNA_FLAGS)
182 # Some versions of gas choke on division operators, treating them as
183 # comment markers. Specifying --divide will work around this problem,
184 # but isn't available on older gas versions.
186 DIVIDE_TEST = $(AS) --divide /dev/null -o /dev/null 2>/dev/null
187 DIVIDE_FLAGS := $(shell $(DIVIDE_TEST) && $(ECHO) '--divide')
188 WORKAROUND_ASFLAGS += $(DIVIDE_FLAGS)
190 ###############################################################################
202 ###############################################################################
207 export REAL_CC := $(CC)
212 ###############################################################################
214 # Set BIN according to whatever was specified on the command line as
218 # Determine how many different BIN directories are mentioned in the
221 BIN_GOALS := $(filter bin bin/% bin-%,$(MAKECMDGOALS))
222 BIN_GOALS_BINS := $(sort $(foreach BG,$(BIN_GOALS),\
223 $(firstword $(subst /, ,$(BG)))))
224 NUM_BINS := $(words $(BIN_GOALS_BINS))
228 # No BIN directory was specified. Set BIN to "bin" as a sensible
237 # If exactly one BIN directory was specified, set BIN to match this
240 BIN := $(firstword $(BIN_GOALS_BINS))
244 # More than one BIN directory was specified. We cannot handle the
245 # latter case within a single make invocation, so set up recursive
246 # targets for each BIN directory. Use exactly one target for each BIN
247 # directory since running multiple make invocations within the same
248 # BIN directory is likely to cause problems.
250 # Leave $(BIN) undefined. This has implications for any target that
251 # depends on $(BIN); such targets should be made conditional upon the
252 # existence of $(BIN).
254 BIN_GOALS_FIRST := $(foreach BGB,$(BIN_GOALS_BINS),\
255 $(firstword $(filter $(BGB)/%,$(BIN_GOALS))))
256 BIN_GOALS_OTHER := $(filter-out $(BIN_GOALS_FIRST),$(BIN_GOALS))
258 $(BIN_GOALS_FIRST) : % : BIN_RECURSE
259 $(Q)$(MAKE) --no-print-directory BIN=$(firstword $(subst /, ,$@)) \
260 $(filter $(firstword $(subst /, ,$@))/%, $(BIN_GOALS))
261 $(BIN_GOALS_OTHER) : % : BIN_RECURSE
265 endif # NUM_BINS == 1
266 endif # NUM_BINS == 0
270 # Create $(BIN) directory if it doesn't exist yet
272 ifeq ($(wildcard $(BIN)),)
273 $(shell $(MKDIR) -p $(BIN))
276 # Target to allow e.g. "make bin-efi arch"
279 @# Do nothing, silently
282 # Remove everything in $(BIN) for a "make clean"
284 CLEANUP += $(BIN)/*.* # Avoid picking up directories
288 # Determine whether or not we need to include the dependency files
290 NO_DEP_TARGETS := $(BIN) clean veryclean
291 ifeq ($(MAKECMDGOALS),)
294 ifneq ($(strip $(filter-out $(NO_DEP_TARGETS),$(MAKECMDGOALS))),)
298 ###############################################################################
300 # Select build architecture and platform based on $(BIN)
302 # BIN has the form bin[-[arch-]platform]
304 ARCHS := $(patsubst arch/%,%,$(wildcard arch/*))
305 PLATFORMS := $(patsubst config/defaults/%.h,%,\
306 $(wildcard config/defaults/*.h))
311 @$(ECHO) $(PLATFORMS)
315 # Determine architecture portion of $(BIN), if present
316 BIN_ARCH := $(strip $(foreach A,$(ARCHS),\
317 $(patsubst bin-$(A)-%,$(A),\
318 $(filter bin-$(A)-%,$(BIN)))))
320 # Determine platform portion of $(BIN), if present
322 BIN_PLATFORM := $(patsubst bin-%,%,$(filter bin-%,$(BIN)))
324 BIN_PLATFORM := $(patsubst bin-$(BIN_ARCH)-%,%,$(BIN))
327 # Determine build architecture
329 ARCH := $(firstword $(BIN_ARCH) $(DEFAULT_ARCH))
330 CFLAGS += -DARCH=$(ARCH)
335 # Determine build platform
336 DEFAULT_PLATFORM := pcbios
337 PLATFORM := $(firstword $(BIN_PLATFORM) $(DEFAULT_PLATFORM))
338 CFLAGS += -DPLATFORM=$(PLATFORM)
344 # Include architecture-specific Makefile
346 MAKEDEPS += arch/$(ARCH)/Makefile
347 include arch/$(ARCH)/Makefile
350 # Include architecture-specific include path
352 INCDIRS += arch/$(ARCH)/include
353 INCDIRS += arch/$(ARCH)/include/$(PLATFORM)
356 ###############################################################################
358 # Source file handling
360 # SRCDIRS lists all directories containing source files.
364 # SRCS lists all .c or .S files found in any SRCDIR
366 SRCS += $(wildcard $(patsubst %,%/*.c,$(SRCDIRS)))
367 SRCS += $(wildcard $(patsubst %,%/*.S,$(SRCDIRS)))
371 # AUTO_SRCS lists all files in SRCS that are not mentioned in
372 # NON_AUTO_SRCS. Files should be added to NON_AUTO_SRCS if they
373 # cannot be built using the standard build template.
375 AUTO_SRCS = $(filter-out $(NON_AUTO_SRCS),$(SRCS))
377 @$(ECHO) $(AUTO_SRCS)
379 # Just about everything else in this section depends upon having
384 # INCDIRS lists the include path
390 CFLAGS += $(foreach INC,$(INCDIRS),-I$(INC))
394 CFLAGS += -ffreestanding
395 CFLAGS += -Wall -W -Wformat-nonliteral
396 HOST_CFLAGS += -Wall -W -Wformat-nonliteral
399 CFLAGS += -fno-builtin
402 CFLAGS += -diag-disable 111 # Unreachable code
403 CFLAGS += -diag-disable 128 # Unreachable loop
404 CFLAGS += -diag-disable 170 # Array boundary checks
405 CFLAGS += -diag-disable 177 # Unused functions
406 CFLAGS += -diag-disable 181 # printf() format checks
407 CFLAGS += -diag-disable 188 # enum strictness
408 CFLAGS += -diag-disable 193 # Undefined preprocessor identifiers
409 CFLAGS += -diag-disable 280 # switch ( constant )
410 CFLAGS += -diag-disable 310 # K&R parameter lists
411 CFLAGS += -diag-disable 424 # Extra semicolon
412 CFLAGS += -diag-disable 589 # Declarations mid-code
413 CFLAGS += -diag-disable 593 # Unused variables
414 CFLAGS += -diag-disable 810 # Casting ints to smaller ints
415 CFLAGS += -diag-disable 981 # Sequence point violations
416 CFLAGS += -diag-disable 1292 # Ignored attributes
417 CFLAGS += -diag-disable 1338 # void pointer arithmetic
418 CFLAGS += -diag-disable 1361 # Variable-length arrays
419 CFLAGS += -diag-disable 1418 # Missing prototypes
420 CFLAGS += -diag-disable 1419 # Missing prototypes
421 CFLAGS += -diag-disable 1599 # Hidden variables
422 CFLAGS += -Wall -Wmissing-declarations
424 CFLAGS += $(WORKAROUND_CFLAGS) $(EXTRA_CFLAGS)
425 ASFLAGS += $(WORKAROUND_ASFLAGS) $(EXTRA_ASFLAGS)
426 LDFLAGS += $(WORKAROUND_LDFLAGS) $(EXTRA_LDFLAGS)
427 HOST_CFLAGS += -O2 -g
429 # Inhibit -Werror if NO_WERROR is specified on make command line
431 ifneq ($(NO_WERROR),1)
433 ASFLAGS += --fatal-warnings
434 HOST_CFLAGS += -Werror
437 # Function trace recorder state in the last build. This is needed
438 # in order to correctly rebuild whenever the function recorder is
441 FNREC_STATE := $(BIN)/.fnrec.state
442 ifeq ($(wildcard $(FNREC_STATE)),)
443 FNREC_OLD := <invalid>
445 FNREC_OLD := $(shell cat $(FNREC_STATE))
447 ifeq ($(FNREC_OLD),$(FNREC))
450 $(FNREC_STATE) : clean
451 $(shell $(ECHO) "$(FNREC)" > $(FNREC_STATE))
454 VERYCLEANUP += $(FNREC_STATE)
455 MAKEDEPS += $(FNREC_STATE)
458 # Enabling -finstrument-functions affects gcc's analysis and leads to spurious
459 # warnings about use of uninitialised variables.
461 CFLAGS += -Wno-uninitialized
462 CFLAGS += -finstrument-functions
463 CFLAGS += -finstrument-functions-exclude-file-list=core/fnrec.c
466 # Enable per-item sections and section garbage collection. Note that
467 # some older versions of gcc support -fdata-sections but treat it as
468 # implying -fno-common, which would break our build. Some other older
469 # versions issue a spurious and uninhibitable warning if
470 # -ffunction-sections is used with -g, which would also break our
471 # build since we use -Werror.
474 DS_TEST = $(ECHO) 'char x;' | \
475 $(CC) -fdata-sections -S -x c - -o - 2>/dev/null | \
476 grep -E '\.comm' > /dev/null
477 DS_FLAGS := $(shell $(DS_TEST) && $(ECHO) '-fdata-sections')
478 FS_TEST = $(CC) -ffunction-sections -g -c -x c /dev/null \
479 -o /dev/null 2>/dev/null
480 FS_FLAGS := $(shell $(FS_TEST) && $(ECHO) '-ffunction-sections')
481 CFLAGS += $(FS_FLAGS) $(DS_FLAGS)
483 LDFLAGS += --gc-sections
485 # Force creation of static binaries (required for OpenBSD, does no
486 # harm on other platforms).
490 # compiler.h is needed for our linking and debugging system
492 CFLAGS += -include include/compiler.h
494 # CFLAGS for specific object types
497 CFLAGS_S += -DASSEMBLY
499 # Base object name of the current target
501 OBJECT = $(firstword $(subst ., ,$(@F)))
503 # CFLAGS for specific object files. You can define
504 # e.g. CFLAGS_rtl8139, and have those flags automatically used when
505 # compiling bin/rtl8139.o.
507 OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
509 @$(ECHO) $(OBJ_CFLAGS)
511 # ICC requires postprocessing objects to fix up table alignments
514 POST_O = && $(ICCFIX) $@
515 POST_O_DEPS := $(ICCFIX)
521 # Rules for specific object types.
523 COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
524 RULE_c = $(Q)$(COMPILE_c) -c $< -o $@ $(POST_O)
525 RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -DDBGLVL_MAX=$* -c $< -o $@ $(POST_O)
526 RULE_c_to_c = $(Q)$(COMPILE_c) -E -c $< > $@
527 RULE_c_to_s = $(Q)$(COMPILE_c) -S -g0 -c $< -o $@
529 PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
530 ASSEMBLE_S = $(AS) $(ASFLAGS)
531 RULE_S = $(Q)$(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
532 RULE_S_to_dbg%.o = $(Q)$(PREPROCESS_S) -DDBGLVL_MAX=$* $< | $(ASSEMBLE_S) -o $@
533 RULE_S_to_s = $(Q)$(PREPROCESS_S) $< > $@
535 DEBUG_TARGETS += dbg%.o c s
537 # List of embedded images included in the last build of embedded.o.
538 # This is needed in order to correctly rebuild embedded.o whenever the
539 # list of objects changes.
541 EMBED := $(EMBEDDED_IMAGE) # Maintain backwards compatibility
542 EMBEDDED_LIST := $(BIN)/.embedded.list
543 ifeq ($(wildcard $(EMBEDDED_LIST)),)
544 EMBED_OLD := <invalid>
546 EMBED_OLD := $(shell cat $(EMBEDDED_LIST))
548 ifneq ($(EMBED_OLD),$(EMBED))
549 $(shell $(ECHO) "$(EMBED)" > $(EMBEDDED_LIST))
552 $(EMBEDDED_LIST) : $(MAKEDEPS)
554 VERYCLEANUP += $(EMBEDDED_LIST)
556 EMBEDDED_FILES := $(subst $(COMMA), ,$(EMBED))
557 EMBED_ALL := $(foreach i,$(call seq,1,$(words $(EMBEDDED_FILES))),\
558 EMBED ( $(i), \"$(word $(i), $(EMBEDDED_FILES))\",\
559 \"$(notdir $(word $(i),$(EMBEDDED_FILES)))\" ))
561 embedded_DEPS += $(EMBEDDED_FILES) $(EMBEDDED_LIST)
563 CFLAGS_embedded = -DEMBED_ALL="$(EMBED_ALL)"
565 # List of trusted root certificates
567 TRUSTED_LIST := $(BIN)/.trusted.list
568 ifeq ($(wildcard $(TRUSTED_LIST)),)
569 TRUST_OLD := <invalid>
571 TRUST_OLD := $(shell cat $(TRUSTED_LIST))
573 ifneq ($(TRUST_OLD),$(TRUST))
574 $(shell $(ECHO) "$(TRUST)" > $(TRUSTED_LIST))
577 $(TRUSTED_LIST) : $(MAKEDEPS)
579 VERYCLEANUP += $(TRUSTED_LIST)
581 # Trusted root certificate fingerprints
583 TRUSTED_CERTS := $(subst $(COMMA), ,$(TRUST))
584 TRUSTED_FPS := $(foreach CERT,$(TRUSTED_CERTS),\
585 0x$(subst :,$(COMMA) 0x,$(lastword $(subst =, ,\
586 $(shell $(OPENSSL) x509 -in $(CERT) -noout -sha256 \
587 -fingerprint))))$(COMMA))
589 rootcert_DEPS += $(TRUSTED_FILES) $(TRUSTED_LIST)
591 CFLAGS_rootcert = $(if $(TRUSTED_FPS),-DTRUSTED="$(TRUSTED_FPS)")
593 # List of embedded certificates
595 CERT_LIST := $(BIN)/.certificate.list
596 ifeq ($(wildcard $(CERT_LIST)),)
597 CERT_OLD := <invalid>
599 CERT_OLD := $(shell cat $(CERT_LIST))
601 ifneq ($(CERT_OLD),$(CERT))
602 $(shell $(ECHO) "$(CERT)" > $(CERT_LIST))
605 $(CERT_LIST) : $(MAKEDEPS)
607 VERYCLEANUP += $(CERT_LIST)
609 # Embedded certificates concatenated and then split into one file per
610 # certificate (even if original files contained certificate chains)
612 CERT_FILES := $(subst $(COMMA), ,$(CERT))
613 CERT_CONCAT := $(BIN)/.certificates.pem
617 CERT_COUNT := $(shell grep "BEGIN CERTIFICATE" $(CERT_FILES) | wc -l)
619 $(CERT_CONCAT) : $(CERT_FILES) $(CERT_LIST)
620 $(Q)cat $(CERT_FILES) > $@
622 # We must use an (otherwise unnecessary) pattern rule here to encode
623 # the fact that one "csplit" command generates multiple targets
624 CERT_PEMS := $(foreach i,$(call seq,1,$(CERT_COUNT)),\
625 $(BIN)/.certificate.pem.$(i))
626 $(subst .pem.,.%.,$(CERT_PEMS)) : $(BIN)/.certificates.%
627 $(Q)$(CSPLIT) -q -n 1 -f $(BIN)/.certificate.pem. $< \
628 '/BEGIN CERTIFICATE/' '{*}'
630 CERT_DERS := $(subst .certificate.pem.,.certificate.der.,$(CERT_PEMS))
631 $(BIN)/.certificate.der.% : $(BIN)/.certificate.pem.%
632 $(Q)$(OPENSSL) x509 -in $< -outform DER -out $@
634 CERT_ALL := $(foreach i,$(call seq,1,$(CERT_COUNT)),\
635 CERT ( $(i), \"$(word $(i),$(CERT_DERS))\" ))
639 certstore_DEPS += $(CERT_LIST) $(CERT_FILES) $(CERT_PEMS) $(CERT_DERS)
641 CFLAGS_certstore += -DCERT_ALL="$(CERT_ALL)"
643 CLEANUP += $(BIN)/.certificate.* $(BIN)/.certificates.*
645 # (Single-element) list of private keys
648 PRIVKEY := $(KEY) # Maintain backwards compatibility
650 PRIVKEY_LIST := $(BIN)/.private_key.list
651 ifeq ($(wildcard $(PRIVKEY_LIST)),)
652 PRIVKEY_OLD := <invalid>
654 PRIVKEY_OLD := $(shell cat $(PRIVKEY_LIST))
656 ifneq ($(PRIVKEY_OLD),$(PRIVKEY))
657 $(shell $(ECHO) "$(PRIVKEY)" > $(PRIVKEY_LIST))
660 $(PRIVKEY_LIST) : $(MAKEDEPS)
662 VERYCLEANUP += $(PRIVKEY_LIST)
664 # Embedded private key
666 PRIVKEY_INC := $(BIN)/.private_key.der
669 $(PRIVKEY_INC) : $(PRIVKEY) $(PRIVKEY_LIST)
670 $(Q)$(OPENSSL) rsa -in $< -outform DER -out $@
672 privkey_DEPS += $(PRIVKEY_INC)
675 CLEANUP += $(BIN)/.private_key.*
677 privkey_DEPS += $(PRIVKEY_LIST)
679 CFLAGS_privkey += $(if $(PRIVKEY),-DPRIVATE_KEY="\"$(PRIVKEY_INC)\"")
681 # (Single-element) list of named configurations
683 CONFIG_LIST := $(BIN)/.config.list
684 ifeq ($(wildcard $(CONFIG_LIST)),)
685 CONFIG_OLD := <invalid>
687 CONFIG_OLD := $(shell cat $(CONFIG_LIST))
689 ifneq ($(CONFIG_OLD),$(CONFIG))
690 $(shell $(ECHO) "$(CONFIG)" > $(CONFIG_LIST))
693 $(CONFIG_LIST) : $(MAKEDEPS)
695 VERYCLEANUP += $(CONFIG_LIST)
697 # Named configurations
700 ifneq ($(wildcard config/$(CONFIG)),)
701 CFLAGS += -DCONFIG=$(CONFIG)
703 CFLAGS += -DLOCAL_CONFIG=$(CONFIG)
706 config/named.h : $(CONFIG_LIST)
709 .PRECIOUS : config/named.h
711 # These files use .incbin inline assembly to include a binary file.
712 # Unfortunately ccache does not detect this dependency and caches
713 # builds even when the binary file has changed.
715 $(BIN)/embedded.% : override CC := env CCACHE_DISABLE=1 $(CC)
716 $(BIN)/certstore.% : override CC := env CCACHE_DISABLE=1 $(CC)
717 $(BIN)/privkey.% : override CC := env CCACHE_DISABLE=1 $(CC)
719 # Debug message autocolourisation range
721 DBGCOL_LIST := $(BIN)/.dbgcol.list
722 ifeq ($(wildcard $(DBGCOL_LIST)),)
723 DBGCOL_OLD := <invalid>
725 DBGCOL_OLD := $(shell cat $(DBGCOL_LIST))
727 ifneq ($(DBGCOL_OLD),$(DBGCOL))
728 $(shell $(ECHO) "$(DBGCOL)" > $(DBGCOL_LIST))
731 $(DBGCOL_LIST) : $(MAKEDEPS)
733 VERYCLEANUP += $(DBGCOL_LIST)
735 DBGCOL_COLOURS := $(subst -, ,$(DBGCOL))
736 DBGCOL_MIN := $(word 1,$(DBGCOL_COLOURS))
737 DBGCOL_MAX := $(word 2,$(DBGCOL_COLOURS))
739 debug_DEPS += $(DBGCOL_LIST)
741 CFLAGS_debug += $(if $(DBGCOL_MIN),-DDBGCOL_MIN=$(DBGCOL_MIN))
742 CFLAGS_debug += $(if $(DBGCOL_MAX),-DDBGCOL_MAX=$(DBGCOL_MAX))
744 # We automatically generate rules for any file mentioned in AUTO_SRCS
745 # using the following set of templates. We use $(eval ...) if
746 # available, otherwise we generate separate Makefile fragments and
749 # deps_template : generate dependency list for a given source file
751 # $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
753 define deps_template_file
754 $(call deps_template_parts,$(1),$(subst .,,$(suffix $(1))),$(basename $(notdir $(1))))
757 # $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
758 # $(2) is the source type (e.g. "c")
759 # $(3) is the source base name (e.g. "rtl8139")
761 define deps_template_parts
762 @$(ECHO) " [DEPS] $(1)"
763 @$(MKDIR) -p $(BIN)/deps/$(dir $(1))
764 $(Q)$(CPP) $(CFLAGS) $(CFLAGS_$(2)) $(CFLAGS_$(3)) -DOBJECT=$(3) \
765 -Wno-error -M $(1) -MG -MP | \
766 sed 's/\.o\s*:/_DEPS +=/' > $(BIN)/deps/$(1).d
767 $(Q)$(if $(findstring drivers/,$(1)),\
768 $(PERL) $(PARSEROM) $(1) >> $(BIN)/deps/$(1).d)
771 # rules_template : generate rules for a given source file
773 # $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
775 define rules_template
776 $(call rules_template_parts,$(1),$(subst .,,$(suffix $(1))),$(basename $(notdir $(1))))
779 # $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
780 # $(2) is the source type (e.g. "c")
781 # $(3) is the source base name (e.g. "rtl8139")
783 define rules_template_parts
784 $$(BIN)/$(3).o : $(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(3)_DEPS)
785 $$(QM)$(ECHO) " [BUILD] $$@"
787 BOBJS += $$(BIN)/$(3).o
788 $(foreach TGT,$(DEBUG_TARGETS),$(if $(RULE_$(2)_to_$(TGT)),$(NEWLINE)$(call rules_template_target,$(1),$(2),$(3),$(TGT))))
789 $$(BIN)/deps/$(1).d : $$($(3)_DEPS)
793 # $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
794 # $(2) is the source type (e.g. "c")
795 # $(3) is the source base name (e.g. "rtl8139")
796 # $(4) is the destination type (e.g. "dbg%.o")
798 define rules_template_target
799 $$(BIN)/$(3).$(4) : $(1) $$(MAKEDEPS) $$(POST_O_DEPS) $$($(3)_DEPS)
800 $$(QM)$(ECHO) " [BUILD] $$@"
801 $$(RULE_$(2)_to_$(4))
802 $(TGT)_OBJS += $$(BIN)/$(3).$(4)
805 # $(1) is the full path to the source file (e.g. "drivers/net/rtl8139.c")
807 define rules_template_file
808 @$(ECHO) " [RULES] $(1)"
809 @$(MKDIR) -p $(BIN)/rules/$(dir $(1))
810 @$(ECHO_E) '$(subst $(NEWLINE),\n,$(call rules_template,$(1)))' \
811 > $(BIN)/rules/$(1).r
814 # Generate the dependency files
816 $(BIN)/deps/%.d : % $(MAKEDEPS) $(PARSEROM)
817 $(call deps_template_file,$<)
819 # Calculate list of dependency files
821 AUTO_DEPS = $(patsubst %,$(BIN)/deps/%.d,$(AUTO_SRCS))
823 @$(ECHO) $(AUTO_DEPS)
824 VERYCLEANUP += $(BIN)/deps
826 # Include dependency files
829 ifneq ($(AUTO_DEPS),)
830 -include $(AUTO_DEPS)
834 # Generate the rules files
836 $(BIN)/rules/%.r : % $(MAKEDEPS)
837 $(call rules_template_file,$<)
839 # Calculate list of rules files
841 AUTO_RULES = $(patsubst %,$(BIN)/rules/%.r,$(AUTO_SRCS))
843 @$(ECHO) $(AUTO_RULES)
844 VERYCLEANUP += $(BIN)/rules
846 # Evaluate rules (or include rules files)
849 ifneq ($(AUTO_RULES),)
850 ifneq ($(HAVE_EVAL),)
851 $(foreach SRC,$(AUTO_SRCS),$(eval $(call rules_template,$(SRC))))
853 -include $(AUTO_RULES)
858 # The following variables are created by the rules files
868 # Generate error usage information
870 $(BIN)/%.einfo : $(BIN)/%.o
871 $(QM)$(ECHO) " [EINFO] $@"
872 $(Q)$(OBJCOPY) -O binary -j .einfo --set-section-flags .einfo=alloc \
875 EINFOS := $(patsubst $(BIN)/%.o,$(BIN)/%.einfo,$(BOBJS))
876 $(BIN)/errors : $(EINFOS) $(EINFO)
877 $(QM)$(ECHO) " [EINFO] $@"
878 $(Q)$(EINFO) $(EINFOS) | sort > $@
879 CLEANUP += $(BIN)/errors # Doesn't match the $(BIN)/*.* pattern
881 # Generate the NIC file from the parsed source files. The NIC file is
882 # only for rom-o-matic.
884 $(BIN)/NIC : $(AUTO_DEPS)
885 @$(ECHO) '# This is an automatically generated file, do not edit' > $@
886 @$(ECHO) '# It does not affect anything in the build, ' \
887 'it is only for rom-o-matic' >> $@
889 @perl -ne 'chomp; print "$$1\n" if /\# NIC\t(.*)$$/' $^ >> $@
890 CLEANUP += $(BIN)/NIC # Doesn't match the $(BIN)/*.* pattern
892 # Analyse a target name (e.g. "bin/dfe538--prism2_pci.rom.tmp") and
893 # derive the variables:
895 # TGT_ELEMENTS : the elements of the target (e.g. "dfe538 prism2_pci")
896 # TGT_PREFIX : the prefix type (e.g. "pcirom")
897 # TGT_DRIVERS : the driver for each element (e.g. "rtl8139 prism2_pci")
898 # TGT_ROM_NAME : the ROM name (e.g. "dfe538")
900 DRIVERS_ipxe = $(DRIVERS)
901 CARD_DRIVER = $(firstword $(DRIVER_$(1)) $(1))
902 TGT_ELEMENTS = $(subst --, ,$(firstword $(subst ., ,$(notdir $@))))
903 TGT_ROM_NAME = $(firstword $(TGT_ELEMENTS))
904 TGT_DRIVERS = $(strip $(if $(DRIVERS_$(TGT_ROM_NAME)), \
905 $(DRIVERS_$(TGT_ROM_NAME)), \
906 $(foreach TGT_ELEMENT,$(TGT_ELEMENTS), \
907 $(call CARD_DRIVER,$(TGT_ELEMENT))) ))
908 TGT_PREFIX_NAME = $(word 2,$(subst ., ,$(notdir $@)))
909 TGT_PREFIX = $(strip $(if $(filter rom,$(TGT_PREFIX_NAME)), \
910 $(ROM_TYPE_$(TGT_ROM_NAME))rom, \
913 # Look up ROM IDs for the current target
914 # (e.g. "bin/dfe538--prism2_pci.rom.tmp") and derive the variables:
916 # TGT_PCI_VENDOR : the PCI vendor ID (e.g. "0x1186")
917 # TGT_PCI_DEVICE : the PCI device ID (e.g. "0x1300")
919 TGT_PCI_VENDOR = $(PCI_VENDOR_$(TGT_ROM_NAME))
920 TGT_PCI_DEVICE = $(PCI_DEVICE_$(TGT_ROM_NAME))
922 # Calculate link-time options for the current target
923 # (e.g. "bin/dfe538--prism2_pci.rom.tmp") and derive the variables:
925 # TGT_LD_DRIVERS : symbols to require in order to drag in the relevant drivers
926 # (e.g. "obj_rtl8139 obj_prism2_pci")
927 # TGT_LD_IDS : symbols to define in order to fill in ID structures in the
928 # ROM header (e.g."pci_vendor_id=0x1186 pci_device_id=0x1300")
930 TGT_LD_DRIVERS = $(subst -,_,$(patsubst %,obj_%,$(TGT_DRIVERS)))
931 TGT_LD_IDS = pci_vendor_id=$(firstword $(TGT_PCI_VENDOR) 0) \
932 pci_device_id=$(firstword $(TGT_PCI_DEVICE) 0)
933 TGT_LD_ENTRY = _$(TGT_PREFIX)_start
935 # Calculate linker flags based on link-time options for the current
936 # target type (e.g. "bin/dfe538--prism2_pci.rom.tmp") and derive the
939 # TGT_LD_FLAGS : target-specific flags to pass to linker (e.g.
940 # "-u obj_zpciprefix -u obj_rtl8139 -u obj_prism2_pci
941 # --defsym pci_vendor=0x1186 --defsym pci_device=0x1300")
943 TGT_LD_FLAGS = $(foreach SYM,$(TGT_LD_ENTRY) $(TGT_LD_DRIVERS) obj_config,\
944 -u $(SYM) --defsym check_$(SYM)=$(SYM) ) \
945 $(patsubst %,--defsym %,$(TGT_LD_IDS)) \
948 # Calculate list of debugging versions of objects to be included in
951 DEBUG_LIST = $(subst $(COMMA), ,$(DEBUG))
952 DEBUG_OBJ_LEVEL = $(firstword $(word 2,$(subst :, ,$(1))) 1)
953 DEBUG_OBJ_BASE = $(word 1,$(subst :, ,$(1))).dbg$(call DEBUG_OBJ_LEVEL,$(1))
954 DEBUG_OBJ = $(BIN)/$(call DEBUG_OBJ_BASE,$(1)).o
955 DEBUG_ORIG_OBJ = $(BIN)/$(word 1,$(subst :, ,$(1))).o
956 DEBUG_OBJS = $(foreach D,$(DEBUG_LIST),$(call DEBUG_OBJ,$(D)))
957 DEBUG_ORIG_OBJS = $(foreach D,$(DEBUG_LIST),$(call DEBUG_ORIG_OBJ,$(D)))
958 BLIB_OBJS = $(DEBUG_OBJS) $(filter-out $(DEBUG_ORIG_OBJS),$(BOBJS))
960 # Print out all derived information for a given target.
963 @$(ECHO) 'Elements : $(TGT_ELEMENTS)'
964 @$(ECHO) 'Prefix : $(TGT_PREFIX)'
965 @$(ECHO) 'Drivers : $(TGT_DRIVERS)'
966 @$(ECHO) 'ROM name : $(TGT_ROM_NAME)'
968 @$(ECHO) 'PCI vendor : $(TGT_PCI_VENDOR)'
969 @$(ECHO) 'PCI device : $(TGT_PCI_DEVICE)'
971 @$(ECHO) 'LD driver symbols : $(TGT_LD_DRIVERS)'
972 @$(ECHO) 'LD ID symbols : $(TGT_LD_IDS)'
973 @$(ECHO) 'LD entry point : $(TGT_LD_ENTRY)'
975 @$(ECHO) 'LD target flags : $(TGT_LD_FLAGS)'
977 @$(ECHO) 'Debugging objects : $(DEBUG_OBJS)'
978 @$(ECHO) 'Replaced objects : $(DEBUG_ORIG_OBJS)'
980 # List of objects included in the last build of blib. This is needed
981 # in order to correctly rebuild blib whenever the list of objects
984 BLIB_LIST := $(BIN)/.blib.list
985 ifeq ($(wildcard $(BLIB_LIST)),)
986 BLIB_OBJS_OLD := <invalid>
988 BLIB_OBJS_OLD := $(shell cat $(BLIB_LIST))
990 ifneq ($(BLIB_OBJS_OLD),$(BLIB_OBJS))
991 $(shell $(ECHO) "$(BLIB_OBJS)" > $(BLIB_LIST))
994 $(BLIB_LIST) : $(MAKEDEPS)
996 VERYCLEANUP += $(BLIB_LIST)
998 # Library of all objects
1000 BLIB = $(BIN)/blib.a
1001 $(BLIB) : $(BLIB_OBJS) $(BLIB_LIST) $(MAKEDEPS)
1003 $(QM)$(ECHO) " [AR] $@"
1004 $(Q)$(AR) r $@ $(sort $(BLIB_OBJS))
1008 # Command to generate build ID. Must be unique for each $(BIN)/%.tmp,
1009 # even within the same build run.
1011 BUILD_ID_CMD := perl -e 'printf "0x%08x", int ( rand ( 0xffffffff ) );'
1015 BUILD_TIMESTAMP := $(shell date +%s)
1019 GIT_INDEX := $(if $(GITVERSION),$(if $(wildcard ../.git/index),../.git/index))
1020 $(BIN)/version.%.o : core/version.c $(MAKEDEPS) $(GIT_INDEX)
1021 $(QM)$(ECHO) " [VERSION] $@"
1022 $(Q)$(COMPILE_c) -DBUILD_NAME="\"$*\"" \
1023 -DVERSION_MAJOR=$(VERSION_MAJOR) \
1024 -DVERSION_MINOR=$(VERSION_MINOR) \
1025 -DVERSION_PATCH=$(VERSION_PATCH) \
1026 -DVERSION="\"$(VERSION)\"" \
1029 # Build an intermediate object file from the objects required for the
1032 $(BIN)/%.tmp : $(BIN)/version.%.o $(BLIB) $(MAKEDEPS) $(LDSCRIPT)
1033 $(QM)$(ECHO) " [LD] $@"
1034 $(Q)$(LD) $(LDFLAGS) -T $(LDSCRIPT) $(TGT_LD_FLAGS) $< $(BLIB) -o $@ \
1035 --defsym _build_id=`$(BUILD_ID_CMD)` \
1036 --defsym _build_timestamp=$(BUILD_TIMESTAMP) \
1037 -Map $(BIN)/$*.tmp.map
1038 $(Q)$(OBJDUMP) -ht $@ | $(PERL) $(SORTOBJDUMP) >> $(BIN)/$*.tmp.map
1040 # Keep intermediate object file (useful for debugging)
1041 .PRECIOUS : $(BIN)/%.tmp
1043 # Show a linker map for the specified target
1045 $(BIN)/%.map : $(BIN)/%.tmp
1046 @less $(BIN)/$*.tmp.map
1048 # Get objects list for the specified target
1051 $(sort $(foreach OBJ_SYMBOL,\
1052 $(filter obj_%,$(shell $(NM) $(1) | cut -d" " -f3)),\
1053 $(patsubst obj_%,%,$(OBJ_SYMBOL))))
1055 $(BIN)/%.objs : $(BIN)/%.tmp
1056 $(Q)$(ECHO) $(call objs_list,$<)
1057 $(BIN)/%.sizes : $(BIN)/%.tmp
1058 $(Q)$(SIZE) -t $(foreach OBJ,$(call objs_list,$<),$(wildcard $(BIN)/$(subst _,?,$(OBJ)).o)) | \
1061 # Get dependency list for the specified target
1064 $(sort $(foreach OBJ,$(call objs_list,$(1)),$($(OBJ)_DEPS)))
1066 $(BIN)/%.deps : $(BIN)/%.tmp
1067 $(Q)$(ECHO) $(call deps_list,$<)
1069 # Get unneeded source files for the specified target
1072 $(sort $(filter-out $(call deps_list,$(1)),\
1073 $(foreach BOBJ,$(BOBJS),\
1074 $($(basename $(notdir $(BOBJ)))_DEPS))))
1076 $(BIN)/%.nodeps : $(BIN)/%.tmp
1077 $(Q)$(ECHO) $(call nodeps_list,$<)
1079 # Get licensing verdict for the specified target
1081 define licensable_deps_list
1082 $(filter-out config/local/%.h,\
1083 $(filter-out $(BIN)/.%.list,\
1084 $(call deps_list,$(1))))
1086 define unlicensed_deps_list
1087 $(shell grep -L FILE_LICENCE $(call licensable_deps_list,$(1)))
1090 $(sort $(foreach LICENCE,\
1091 $(filter __licence__%,$(shell $(NM) $(1) | cut -d" " -f3)),\
1092 $(word 2,$(subst __, ,$(LICENCE)))))
1094 $(BIN)/%.licence_list : $(BIN)/%.tmp
1095 $(Q)$(ECHO) $(call licence_list,$<)
1096 $(BIN)/%.licence : $(BIN)/%.tmp
1097 $(QM)$(ECHO) " [LICENCE] $@"
1098 $(Q)$(if $(strip $(call unlicensed_deps_list,$<)),\
1099 echo -n "Unable to determine licence because the following " ;\
1100 echo "files are missing a licence declaration:" ;\
1101 echo $(call unlicensed_deps_list,$<);\
1103 $(PERL) $(LICENCE) $(call licence_list,$<))
1105 # Extract compression information from intermediate object file
1107 $(BIN)/%.zinfo : $(BIN)/%.tmp
1108 $(QM)$(ECHO) " [ZINFO] $@"
1109 $(Q)$(OBJCOPY) -O binary -j .zinfo $< $@
1111 # Build raw binary file from intermediate object file
1113 $(BIN)/%.bin : $(BIN)/%.tmp
1114 $(QM)$(ECHO) " [BIN] $@"
1115 $(Q)$(OBJCOPY) -O binary -R .zinfo $< $@
1117 # Compress raw binary file
1119 $(BIN)/%.zbin : $(BIN)/%.bin $(BIN)/%.zinfo $(ZBIN)
1120 $(QM)$(ECHO) " [ZBIN] $@"
1121 $(Q)$(ZBIN) $(BIN)/$*.bin $(BIN)/$*.zinfo > $@
1123 # Rules for each media format. These are generated and placed in an
1124 # external Makefile fragment. We could do this via $(eval ...), but
1125 # that would require make >= 3.80.
1127 # Note that there's an alternative way to generate most .rom images:
1128 # they can be copied from their 'master' ROM image using cp and
1129 # reprocessed with makerom to add the PCI IDs and ident string. The
1130 # relevant rule would look something like:
1132 # $(BIN)/dfe538%rom : $(BIN)/rtl8139%rom
1136 # You can derive the ROM/driver relationships using the variables
1137 # DRIVER_<rom> and/or ROMS_<driver>.
1139 # We don't currently do this, because (a) it would require generating
1140 # yet more Makefile fragments (since you need a rule for each ROM in
1141 # ROMS), and (b) the linker is so fast that it probably wouldn't make
1142 # much difference to the overall build time.
1144 # Add NON_AUTO_MEDIA to the media list, so that they show up in the
1147 MEDIA += $(NON_AUTO_MEDIA)
1152 AUTO_MEDIA = $(filter-out $(NON_AUTO_MEDIA),$(MEDIA))
1154 @$(ECHO) $(AUTO_MEDIA)
1156 # media_template : create media rules
1158 # $(1) is the media name (e.g. "rom")
1160 define media_template
1161 $(if $(filter $(1),$(AUTO_MEDIA)),$(call auto_media_template,$(1)))
1162 LIST_$(1) := $$(if $$(LIST_NAME_$(1)),$$($$(LIST_NAME_$(1))),$$(DRIVERS))
1163 ALL_$(1) = $$(foreach ITEM,$$(LIST_$(1)),$$(BIN)/$$(ITEM).$(1))
1164 $$(BIN)/all$(1)s : $$(ALL_$(1))
1165 $$(BIN)/allall : $$(BIN)/all$(1)s
1166 all$(1)s : $$(BIN)/all$(1)s
1167 allall : $$(BIN)/allall
1170 # $(1) is the media name (e.g. "rom")
1172 define auto_media_template
1173 $$(BIN)/%.$(1) : $$(BIN)/%.$(1).zbin
1174 $$(QM)echo " [FINISH] $$@"
1176 $$(Q)$$(if $$(PAD_$(1)),$$(PAD_$(1)) $$@)
1177 $$(Q)$$(if $$(FINALISE_$(1)),$$(FINALISE_$(1)) $$@)
1180 # $(1) is the media name (e.g. "rom")
1182 define media_template_file
1183 @$(ECHO) " [MEDIARULES] $(1)"
1184 @$(MKDIR) -p $(BIN)/rules/$(dir $(1))
1185 @$(ECHO_E) '$(subst $(NEWLINE),\n,$(call media_template,$(1)))' \
1186 > $(BIN)/rules/$(1).media.r
1189 # Generate media rules files
1191 $(BIN)/rules/%.media.r : $(MAKEDEPS)
1192 $(call media_template_file,$*)
1194 # Calculate list of media rules files
1196 MEDIA_RULES = $(patsubst %,$(BIN)/rules/%.media.r,$(MEDIA))
1198 @$(ECHO) $(MEDIA_RULES)
1200 # Evaluate media rules (or include media rules files)
1203 ifneq ($(MEDIA_RULES),)
1204 ifneq ($(HAVE_EVAL),)
1205 $(foreach MEDIUM,$(MEDIA),$(eval $(call media_template,$(MEDIUM))))
1207 -include $(MEDIA_RULES)
1214 $(BIN)/etherboot.% : $(BIN)/ipxe.%
1215 ln -sf $(notdir $<) $@
1217 endif # defined(BIN)
1219 ###############################################################################
1221 # The compression utilities
1224 ZBIN_LDFLAGS := -llzma
1226 $(ZBIN) : util/zbin.c $(MAKEDEPS)
1227 $(QM)$(ECHO) " [HOSTCC] $@"
1228 $(Q)$(HOST_CC) $(HOST_CFLAGS) $< $(ZBIN_LDFLAGS) -o $@
1231 ###############################################################################
1233 # The EFI image converter
1235 ELF2EFI_CFLAGS := -I$(BINUTILS_DIR)/include -I$(BFD_DIR)/include \
1236 -I$(ZLIB_DIR)/include -idirafter include
1237 ELF2EFI_LDFLAGS := -L$(BINUTILS_DIR)/lib -L$(BFD_DIR)/lib -L$(ZLIB_DIR)/lib \
1238 -lbfd -ldl -liberty -lz -Wl,--no-warn-search-mismatch
1240 $(ELF2EFI32) : util/elf2efi.c $(MAKEDEPS)
1241 $(QM)$(ECHO) " [HOSTCC] $@"
1242 $(Q)$(HOST_CC) $(HOST_CFLAGS) $(ELF2EFI_CFLAGS) -DEFI_TARGET_IA32 $< \
1243 $(ELF2EFI_LDFLAGS) -o $@
1244 CLEANUP += $(ELF2EFI32)
1246 $(ELF2EFI64) : util/elf2efi.c $(MAKEDEPS)
1247 $(QM)$(ECHO) " [HOSTCC] $@"
1248 $(Q)$(HOST_CC) $(HOST_CFLAGS) $(ELF2EFI_CFLAGS) -DEFI_TARGET_X64 $< \
1249 $(ELF2EFI_LDFLAGS) -o $@
1250 CLEANUP += $(ELF2EFI64)
1252 $(EFIROM) : util/efirom.c $(MAKEDEPS)
1253 $(QM)$(ECHO) " [HOSTCC] $@"
1254 $(Q)$(HOST_CC) $(HOST_CFLAGS) -idirafter include -o $@ $<
1255 CLEANUP += $(EFIROM)
1257 $(EFIFATBIN) : util/efifatbin.c $(MAKEDEPS)
1258 $(QM)$(ECHO) " [HOSTCC] $@"
1259 $(Q)$(HOST_CC) $(HOST_CFLAGS) -idirafter include -o $@ $<
1260 CLEANUP += $(EFIFATBIN)
1262 ###############################################################################
1264 # The ICC fixup utility
1266 $(ICCFIX) : util/iccfix.c $(MAKEDEPS)
1267 $(QM)$(ECHO) " [HOSTCC] $@"
1268 $(Q)$(HOST_CC) $(HOST_CFLAGS) -idirafter include -o $@ $<
1269 CLEANUP += $(ICCFIX)
1271 ###############################################################################
1273 # The error usage information utility
1275 $(EINFO) : util/einfo.c $(MAKEDEPS)
1276 $(QM)$(ECHO) " [HOSTCC] $@"
1277 $(Q)$(HOST_CC) $(HOST_CFLAGS) -idirafter include -o $@ $<
1280 ###############################################################################
1284 CONFIG_HEADERS := $(patsubst config/%,%,$(wildcard config/*.h))
1285 CONFIG_LOCAL_HEADERS := $(foreach HEADER,$(CONFIG_HEADERS),\
1286 config/local/$(HEADER))
1288 $(CONFIG_LOCAL_HEADERS) :
1291 .PRECIOUS : $(CONFIG_LOCAL_HEADERS)
1295 CONFIG_LOCAL_NAMED_HEADERS := $(foreach HEADER,$(CONFIG_HEADERS),\
1296 config/local/$(CONFIG)/$(HEADER))
1298 $(CONFIG_LOCAL_NAMED_HEADERS) :
1299 $(Q)$(MKDIR) -p $(dir $@)
1302 .PRECIOUS : $(CONFIG_LOCAL_NAMED_HEADERS)
1306 ###############################################################################
1308 # Build the TAGS file(s) for emacs
1311 ctags -e -R -f $@ --exclude=bin
1315 ###############################################################################
1317 # Force rebuild for any given target
1323 ###############################################################################
1325 # Symbol table checks
1330 SYMTAB = $(BIN)/symtab
1332 $(OBJDUMP) -w -t $< > $@
1334 CLEANUP += $(BIN)/symtab
1336 symcheck : $(SYMTAB)
1337 $(PERL) $(SYMCHECK) $<
1339 endif # defined(BIN)
1341 ###############################################################################
1343 # Build bochs symbol table
1348 $(BIN)/%.bxs : $(BIN)/%.tmp
1349 $(NM) $< | cut -d" " -f1,3 > $@
1351 endif # defined(BIN)
1353 ###############################################################################
1360 $(BIN)/doxygen.cfg : doxygen.cfg $(MAKEDEPS)
1361 $(Q)$(PERL) -pe 's{\@SRCDIRS\@}{$(SRCDIRS)}; ' \
1362 -e 's{\@INCDIRS\@}{$(filter-out .,$(INCDIRS))}; ' \
1363 -e 's{\@BIN\@}{$(BIN)}; ' \
1364 -e 's{\@ARCH\@}{$(ARCH)}; ' \
1367 $(BIN)/doc : $(BIN)/doxygen.cfg
1375 $(Q)$(RM) -r $(BIN)/doc
1377 VERYCLEANUP += $(BIN)/doc
1380 @[ -f $(BIN)/doc/html/index.html ] || $(MAKE) $(BIN)/doc
1381 @if [ -n "$$BROWSER" ] ; then \
1382 ( $$BROWSER $(BIN)/doc/html/index.html & ) ; \
1384 $(ECHO) "Documentation index in $(BIN)/doc/html/index.html" ; \
1387 endif # defined(BIN)
1389 ###############################################################################
1394 hci/keymap/keymap_%.c :
1395 $(Q)$(PERL) $(GENKEYMAP) $* > $@
1397 ###############################################################################
1399 # Force deletion of incomplete targets
1404 ###############################################################################
1409 ifeq ($(NUM_BINS),0)
1411 CLEANUP := $(patsubst $(BIN)/%,$(ALLBINS)/%,$(CLEANUP))
1412 VERYCLEANUP := $(patsubst $(BIN)/%,$(ALLBINS)/%,$(VERYCLEANUP))
1419 $(RM) -r $(VERYCLEANUP)