diff options
author | Michael Brown <mcb30@ipxe.org> | 2024-10-29 12:50:37 +0000 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2024-10-29 14:11:08 +0000 |
commit | 8fc11d8a4ad41f15af3d081250865f971312d871 (patch) | |
tree | a8c7cb048a52f2d53c8391da7ae63d86799f73dd /src/Makefile.housekeeping | |
parent | 19f44d2998f6197b70fa2726c551bc8fe6956fa2 (diff) | |
download | ipxe-master.zip ipxe-master.tar.gz ipxe-master.tar.bz2 |
We currently require the variable CROSS (or CROSS_COMPILE) to be set
to specify the global cross-compilation prefix. This becomes
cumbersome when developing across multiple CPU architectures,
requiring frequent editing of build command lines and preventing
incompatible architectures from being built with a single command.
Allow a default cross-compilation prefix for each architecture to be
specified via the CROSS_COMPILE_<arch> variables. These may then be
provided as environment variables, e.g. using
export CROSS_COMPILE_arm32=arm-linux-gnu-
export CROSS_COMPILE_arm64=aarch64-linux-gnu-
export CROSS_COMPILE_loong64=loongarch64-linux-gnu-
export CROSS_COMPILE_riscv32=riscv64-linux-gnu-
export CROSS_COMPILE_riscv64=riscv64-linux-gnu-
This change requires some portions of the Makefile to be rearranged,
to allow for the fact that $(CROSS_COMPILE) may not have been set
until the build directory has been parsed to determine the CPU
architecture.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/Makefile.housekeeping')
-rw-r--r-- | src/Makefile.housekeeping | 247 |
1 files changed, 129 insertions, 118 deletions
diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping index 2b4356d..1926920 100644 --- a/src/Makefile.housekeeping +++ b/src/Makefile.housekeeping @@ -5,6 +5,20 @@ ############################################################################### # +# Make syntax does not allow use of comma or space in certain places. +# This ugly workaround is suggested in the manual. +# +COMMA := , +EMPTY := +SPACE := $(EMPTY) $(EMPTY) +HASH := \# +define NEWLINE + + +endef + +############################################################################### +# # Find a usable "echo -e" substitute. # TAB := $(shell $(PRINTF) '\t') @@ -70,56 +84,6 @@ hostos : ############################################################################### # -# Determine compiler - -CCDEFS := $(shell $(CC) -E -x c -c /dev/null -dM | cut -d" " -f2) -ccdefs: - @$(ECHO) $(CCDEFS) - -ifeq ($(filter __GNUC__,$(CCDEFS)),__GNUC__) -CCTYPE := gcc -endif -cctype: - @$(ECHO) $(CCTYPE) - -############################################################################### -# -# Check for tools that can cause failed builds -# - -ifeq ($(CCTYPE),gcc) -GCC_2_96_BANNER := $(shell $(CC) -v 2>&1 | grep -is 'gcc version 2\.96') -ifneq ($(GCC_2_96_BANNER),) -$(warning gcc 2.96 is unsuitable for compiling iPXE) -$(warning Use gcc 2.95 or a newer version instead) -$(error Unsuitable build environment found) -endif -endif - -PERL_UNICODE_CHECK := $(shell $(PERL) -e 'use bytes; print chr(255)' | wc -c) -ifeq ($(PERL_UNICODE_CHECK),2) -$(warning Your Perl version has a Unicode handling bug) -$(warning Execute this command before building iPXE:) -$(warning export LANG=$${LANG%.UTF-8}) -$(error Unsuitable build environment found) -endif - -LD_GOLD_BANNER := $(shell $(LD) -v 2>&1 | grep 'GNU gold') -ifneq ($(LD_GOLD_BANNER),) -$(warning GNU gold is unsuitable for building iPXE) -$(warning Use GNU ld instead) -$(error Unsuitable build environment found) -endif - -OBJCOPY_ETC_BANNER := $(shell $(OBJCOPY) --version | grep 'elftoolchain') -ifneq ($(OBJCOPY_ETC_BANNER),) -$(warning The elftoolchain objcopy is unsuitable for building iPXE) -$(warning Use binutils objcopy instead) -$(error Unsuitable build environment found) -endif - -############################################################################### -# # Check if $(eval ...) is available to use # @@ -132,74 +96,6 @@ eval : ############################################################################### # -# Check for various tool workarounds -# - -WORKAROUND_CFLAGS := -WORKAROUND_ASFLAGS := -WORKAROUND_LDFLAGS := - -# Make syntax does not allow use of comma or space in certain places. -# This ugly workaround is suggested in the manual. -# -COMMA := , -EMPTY := -SPACE := $(EMPTY) $(EMPTY) -HASH := \# -define NEWLINE - - -endef - -# gcc 4.4 generates .eh_frame sections by default, which distort the -# output of "size". Inhibit this. -# -ifeq ($(CCTYPE),gcc) -CFI_TEST = $(CC) -fno-dwarf2-cfi-asm -fno-exceptions -fno-unwind-tables \ - -fno-asynchronous-unwind-tables -x c -c /dev/null \ - -o /dev/null >/dev/null 2>&1 -CFI_FLAGS := $(shell $(CFI_TEST) && \ - $(ECHO) '-fno-dwarf2-cfi-asm -fno-exceptions ' \ - '-fno-unwind-tables -fno-asynchronous-unwind-tables') -WORKAROUND_CFLAGS += $(CFI_FLAGS) -endif - -# gcc 4.6 generates spurious warnings if -Waddress is in force. -# Inhibit this. -# -ifeq ($(CCTYPE),gcc) -WNA_TEST = $(CC) -Waddress -x c -c /dev/null -o /dev/null >/dev/null 2>&1 -WNA_FLAGS := $(shell $(WNA_TEST) && $(ECHO) '-Wno-address') -WORKAROUND_CFLAGS += $(WNA_FLAGS) - -# gcc 8.0 generates warnings for certain suspect string operations. Our -# sources have been vetted for correct usage. Turn off these warnings. -# -WNST_TEST = $(CC) -Wstringop-truncation -x c -c /dev/null -o /dev/null \ - >/dev/null 2>&1 -WNST_FLAGS := $(shell $(WNST_TEST) && $(ECHO) '-Wno-stringop-truncation') -WORKAROUND_CFLAGS += $(WNST_FLAGS) - -# gcc 9.1 generates warnings for taking address of packed member which -# may result in an unaligned pointer value. Inhibit the warnings. -# -WNAPM_TEST = $(CC) -Wno-address-of-packed-member -x c -c /dev/null \ - -o /dev/null >/dev/null 2>&1 -WNAPM_FLAGS := $(shell $(WNAPM_TEST) && \ - $(ECHO) '-Wno-address-of-packed-member') -WORKAROUND_CFLAGS += $(WNAPM_FLAGS) -endif - -# Some versions of gas choke on division operators, treating them as -# comment markers. Specifying --divide will work around this problem, -# but isn't available on older gas versions. -# -DIVIDE_TEST = $(AS) --divide /dev/null -o /dev/null 2>/dev/null -DIVIDE_FLAGS := $(shell $(DIVIDE_TEST) && $(ECHO) '--divide') -WORKAROUND_ASFLAGS += $(DIVIDE_FLAGS) - -############################################################################### -# # Build verbosity # ifeq ($(V),1) @@ -367,9 +263,124 @@ CFLAGS += -DSECUREBOOT=$(SECUREBOOT) secureboot : @$(ECHO) $(SECUREBOOT) +# Set cross-compilation prefix automatically if not specified +ifeq ($(CROSS_COMPILE),) +CROSS_COMPILE := $(CROSS_COMPILE_$(ARCH)) +endif + endif # defined(BIN) +############################################################################### +# +# Determine compiler + +CCDEFS := $(shell $(CC) -E -x c -c /dev/null -dM | cut -d" " -f2) +ccdefs: + @$(ECHO) $(CCDEFS) + +ifeq ($(filter __GNUC__,$(CCDEFS)),__GNUC__) +CCTYPE := gcc +endif +cctype: + @$(ECHO) $(CCTYPE) + +############################################################################### +# +# Check for tools that can cause failed builds +# + +ifeq ($(CCTYPE),gcc) +GCC_2_96_BANNER := $(shell $(CC) -v 2>&1 | grep -is 'gcc version 2\.96') +ifneq ($(GCC_2_96_BANNER),) +$(warning gcc 2.96 is unsuitable for compiling iPXE) +$(warning Use gcc 2.95 or a newer version instead) +$(error Unsuitable build environment found) +endif +endif + +PERL_UNICODE_CHECK := $(shell $(PERL) -e 'use bytes; print chr(255)' | wc -c) +ifeq ($(PERL_UNICODE_CHECK),2) +$(warning Your Perl version has a Unicode handling bug) +$(warning Execute this command before building iPXE:) +$(warning export LANG=$${LANG%.UTF-8}) +$(error Unsuitable build environment found) +endif + +LD_GOLD_BANNER := $(shell $(LD) -v 2>&1 | grep 'GNU gold') +ifneq ($(LD_GOLD_BANNER),) +$(warning GNU gold is unsuitable for building iPXE) +$(warning Use GNU ld instead) +$(error Unsuitable build environment found) +endif + +OBJCOPY_ETC_BANNER := $(shell $(OBJCOPY) --version | grep 'elftoolchain') +ifneq ($(OBJCOPY_ETC_BANNER),) +$(warning The elftoolchain objcopy is unsuitable for building iPXE) +$(warning Use binutils objcopy instead) +$(error Unsuitable build environment found) +endif + +############################################################################### +# +# Check for various tool workarounds +# + +WORKAROUND_CFLAGS := +WORKAROUND_ASFLAGS := +WORKAROUND_LDFLAGS := + +# gcc 4.4 generates .eh_frame sections by default, which distort the +# output of "size". Inhibit this. +# +ifeq ($(CCTYPE),gcc) +CFI_TEST = $(CC) -fno-dwarf2-cfi-asm -fno-exceptions -fno-unwind-tables \ + -fno-asynchronous-unwind-tables -x c -c /dev/null \ + -o /dev/null >/dev/null 2>&1 +CFI_FLAGS := $(shell $(CFI_TEST) && \ + $(ECHO) '-fno-dwarf2-cfi-asm -fno-exceptions ' \ + '-fno-unwind-tables -fno-asynchronous-unwind-tables') +WORKAROUND_CFLAGS += $(CFI_FLAGS) +endif + +# gcc 4.6 generates spurious warnings if -Waddress is in force. +# Inhibit this. +# +ifeq ($(CCTYPE),gcc) +WNA_TEST = $(CC) -Waddress -x c -c /dev/null -o /dev/null >/dev/null 2>&1 +WNA_FLAGS := $(shell $(WNA_TEST) && $(ECHO) '-Wno-address') +WORKAROUND_CFLAGS += $(WNA_FLAGS) + +# gcc 8.0 generates warnings for certain suspect string operations. Our +# sources have been vetted for correct usage. Turn off these warnings. +# +WNST_TEST = $(CC) -Wstringop-truncation -x c -c /dev/null -o /dev/null \ + >/dev/null 2>&1 +WNST_FLAGS := $(shell $(WNST_TEST) && $(ECHO) '-Wno-stringop-truncation') +WORKAROUND_CFLAGS += $(WNST_FLAGS) + +# gcc 9.1 generates warnings for taking address of packed member which +# may result in an unaligned pointer value. Inhibit the warnings. +# +WNAPM_TEST = $(CC) -Wno-address-of-packed-member -x c -c /dev/null \ + -o /dev/null >/dev/null 2>&1 +WNAPM_FLAGS := $(shell $(WNAPM_TEST) && \ + $(ECHO) '-Wno-address-of-packed-member') +WORKAROUND_CFLAGS += $(WNAPM_FLAGS) +endif + +# Some versions of gas choke on division operators, treating them as +# comment markers. Specifying --divide will work around this problem, +# but isn't available on older gas versions. +# +DIVIDE_TEST = $(AS) --divide /dev/null -o /dev/null 2>/dev/null +DIVIDE_FLAGS := $(shell $(DIVIDE_TEST) && $(ECHO) '--divide') +WORKAROUND_ASFLAGS += $(DIVIDE_FLAGS) + +############################################################################### +# # Include architecture-specific Makefile +# + ifdef ARCH MAKEDEPS += arch/$(ARCH)/Makefile include arch/$(ARCH)/Makefile |