Annotation of qemu/roms/ipxe/src/Makefile.housekeeping, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.