aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2016-02-09 18:13:20 -0800
committerH. Peter Anvin <hpa@zytor.com>2016-02-09 18:13:20 -0800
commitc7e6d511df730b26336ea2c24020a058aad6be1d (patch)
tree2f85c6f863221d0be304074dc36ad8faf20d5119
parentf2f897a1762fab84d2905f32b1c15dd7b42abb56 (diff)
downloadsyslinux-c7e6d511df730b26336ea2c24020a058aad6be1d.tar.gz
syslinux-c7e6d511df730b26336ea2c24020a058aad6be1d.tar.xz
syslinux-c7e6d511df730b26336ea2c24020a058aad6be1d.zip
Makefile: make the handling of firmware selection a little saner
Clean up the handling of firmware selection inside the Makefiles. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--Makefile55
-rw-r--r--com32/Makefile2
-rw-r--r--com32/elflink/ldlinux/Makefile2
-rw-r--r--com32/lib/Makefile2
-rw-r--r--core/Makefile53
-rw-r--r--mk/com32.mk4
-rw-r--r--mk/elf.mk2
-rw-r--r--mk/embedded.mk2
-rw-r--r--mk/lib.mk2
-rw-r--r--tests/Makefile6
10 files changed, 63 insertions, 67 deletions
diff --git a/Makefile b/Makefile
index 4710b60f..b472945b 100644
--- a/Makefile
+++ b/Makefile
@@ -86,9 +86,8 @@ endif
# creating. Which means that we always need a *real* target, such as
# 'all', appended to the make goals.
#
-firmware = $(all_firmware)
-real-target := $(filter-out $(firmware), $(MAKECMDGOALS))
-real-firmware := $(filter $(firmware), $(MAKECMDGOALS))
+real-target := $(filter-out $(all_firmware), $(MAKECMDGOALS))
+real-firmware := $(filter $(all_firmware), $(MAKECMDGOALS))
ifeq ($(real-target),)
real-target = all
@@ -101,7 +100,7 @@ endif
.PHONY: $(filter-out $(private-targets), $(MAKECMDGOALS))
$(filter-out $(private-targets), $(MAKECMDGOALS)):
$(MAKE) -C $(OBJDIR) -f $(CURDIR)/Makefile SRC="$(topdir)" \
- OBJ=$(OBJDIR) objdir=$(OBJDIR) EFI_BUILD=$(EFI_BUILD) \
+ OBJ=$(OBJDIR) objdir=$(OBJDIR) $(BUILDOPTS) \
$(MAKECMDGOALS)
unittest:
@@ -111,7 +110,7 @@ unittest:
regression:
$(MAKE) -C tests SRC="$(topdir)/tests" OBJ="$(topdir)/tests" \
- objdir=$(OBJDIR) EFI_BUILD=$(EFI_BUILD) \
+ objdir=$(OBJDIR) $(BUILDOPTS) \
-f $(topdir)/tests/Makefile all
test: unittest regression
@@ -137,7 +136,7 @@ include $(MAKEDIR)/syslinux.mk
# directories.
#
-ifndef EFI_BUILD
+ifeq ($(FWCLASS),BIOS)
MODULES = memdisk/memdisk \
com32/menu/*.c32 com32/modules/*.c32 com32/mboot/*.c32 \
com32/hdt/*.c32 com32/rosh/*.c32 com32/gfxboot/*.c32 \
@@ -153,6 +152,8 @@ MODULES = com32/menu/*.c32 com32/modules/*.c32 com32/mboot/*.c32 \
com32/cmenu/libmenu/*.c32 com32/elflink/ldlinux/$(LDLINUX)
endif
+export FIRMWARE FWCLASS ARCH BITS
+
# List of module objects that should be installed for all derivatives
INSTALLABLE_MODULES = $(MODULES)
@@ -175,7 +176,7 @@ BOBJECTS = $(BTARGET) \
# files that depend only on the B phase, but may have to be regenerated
# for "make installer".
-ifdef EFI_BUILD
+ifeq ($(FWCLASS),EFI)
BSUBDIRS = codepage com32 lzo core mbr sample efi txt
ISUBDIRS =
@@ -218,11 +219,11 @@ EXTBOOTINSTALL = $(INSTALLABLE_MODULES)
NETINSTALLABLE = core/pxelinux.0 core/lpxelinux.0 \
$(INSTALLABLE_MODULES)
-endif # ifdef EFI_BUILD
+endif # ifeq ($(FWCLASS),EFI)
.PHONY: subdirs $(BSUBDIRS) $(ISUBDIRS) test
-ifeq ($(HAVE_FIRMWARE),)
+ifeq ($(FIRMWARE),)
firmware = $(all_firmware)
@@ -254,27 +255,27 @@ endif
bios:
@mkdir -p $(OBJ)/bios
$(MAKE) -C $(OBJ)/bios -f $(SRC)/Makefile SRC="$(SRC)" \
- objdir=$(OBJ)/bios OBJ=$(OBJ)/bios HAVE_FIRMWARE=1 \
- FIRMWARE=BIOS \
+ objdir=$(OBJ)/bios OBJ=$(OBJ)/bios \
+ FIRMWARE=BIOS FWCLASS=BIOS \
ARCH=i386 LDLINUX=ldlinux.c32 $(MAKECMDGOALS)
efi32:
@mkdir -p $(OBJ)/efi32
$(MAKE) -C $(OBJ)/efi32 -f $(SRC)/Makefile SRC="$(SRC)" \
- objdir=$(OBJ)/efi32 OBJ=$(OBJ)/efi32 HAVE_FIRMWARE=1 \
- ARCH=i386 BITS=32 EFI_BUILD=1 LDLINUX=ldlinux.e32 \
- FIRMWARE=EFI32 \
+ objdir=$(OBJ)/efi32 OBJ=$(OBJ)/efi32 \
+ ARCH=i386 BITS=32 LDLINUX=ldlinux.e32 \
+ FIRMWARE=EFI32 FWCLASS=EFI \
$(MAKECMDGOALS)
efi64:
@mkdir -p $(OBJ)/efi64
$(MAKE) -C $(OBJ)/efi64 -f $(SRC)/Makefile SRC="$(SRC)" \
- objdir=$(OBJ)/efi64 OBJ=$(OBJ)/efi64 HAVE_FIRMWARE=1 \
- ARCH=x86_64 BITS=64 EFI_BUILD=1 LDLINUX=ldlinux.e64 \
- FIRMWARE=EFI64 \
+ objdir=$(OBJ)/efi64 OBJ=$(OBJ)/efi64 \
+ ARCH=x86_64 BITS=64 LDLINUX=ldlinux.e64 \
+ FIRMWARE=EFI64 FWCLASS=EFI \
$(MAKECMDGOALS)
-else # ifeq($(HAVE_FIRMWARE),)
+else # FIRMWARE
all: all-local subdirs
@@ -284,17 +285,17 @@ subdirs: $(BSUBDIRS) $(ISUBDIRS)
$(sort $(ISUBDIRS) $(BSUBDIRS)):
@mkdir -p $@
- $(MAKE) -C $@ SRC="$(SRC)/$@" OBJ="$(OBJ)/$@" EFI_BUILD=$(EFI_BUILD) \
+ $(MAKE) -C $@ SRC="$(SRC)/$@" OBJ="$(OBJ)/$@" \
-f $(SRC)/$@/Makefile $(MAKECMDGOALS)
$(ITARGET):
@mkdir -p $@
- $(MAKE) -C $@ SRC="$(SRC)/$@" OBJ="$(OBJ)/$@" EFI_BUILD=$(EFI_BUILD) \
+ $(MAKE) -C $@ SRC="$(SRC)/$@" OBJ="$(OBJ)/$@" \
-f $(SRC)/$@/Makefile $(MAKECMDGOALS)
$(BINFILES):
@mkdir -p $@
- $(MAKE) -C $@ SRC="$(SRC)/$@" OBJ="$(OBJ)/$@" EFI_BUILD=$(EFI_BUILD) \
+ $(MAKE) -C $@ SRC="$(SRC)/$@" OBJ="$(OBJ)/$@" \
-f $(SRC)/$@/Makefile $(MAKECMDGOALS)
#
@@ -308,7 +309,7 @@ efi: core
installer: installer-local
set -e; for i in $(ISUBDIRS); \
do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
- EFI_BUILD=$(EFI_BUILD) -f $(SRC)/$$i/Makefile all; done
+ -f $(SRC)/$$i/Makefile all; done
installer-local: $(ITARGET) $(BINFILES)
@@ -316,7 +317,7 @@ installer-local: $(ITARGET) $(BINFILES)
strip: strip-local
set -e; for i in $(ISUBDIRS); \
do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
- EFI_BUILD=$(EFI_BUILD) -f $(SRC)/$$i/Makefile strip; done
+ -f $(SRC)/$$i/Makefile strip; done
-ls -l $(BOBJECTS) $(IOBJECTS)
strip-local:
@@ -341,7 +342,7 @@ local-install: installer
: mkdir -m 755 -p $(INSTALLROOT)$(MANDIR)/man8
: install -m 644 -c man/*.8 $(INSTALLROOT)$(MANDIR)/man8
-ifndef EFI_BUILD
+ifneq ($(FWCLASS),EFI)
install: local-install
set -e ; for i in $(INSTALLSUBDIRS) ; \
do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
@@ -352,12 +353,12 @@ install:
set -e ; for i in $(INSTALLSUBDIRS) ; \
do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
BITS="$(BITS)" AUXDIR="$(AUXDIR)/efi$(BITS)" \
- EFI_BUILD=$(EFI_BUILD) -f $(SRC)/$$i/Makefile $@; done
+ -f $(SRC)/$$i/Makefile $@; done
-install -m 644 $(INSTALLABLE_MODULES) $(INSTALLROOT)$(AUXDIR)/efi$(BITS)
install -m 644 com32/elflink/ldlinux/$(LDLINUX) $(INSTALLROOT)$(AUXDIR)/efi$(BITS)
endif
-ifdef EFI_BUILD
+ifeq ($(FWCLASS),EFI)
netinstall:
mkdir -p $(INSTALLROOT)$(TFTPBOOT)/efi$(BITS)
install -m 644 $(NETINSTALLABLE) $(INSTALLROOT)$(TFTPBOOT)/efi$(BITS)
@@ -396,7 +397,7 @@ dist: local-dist local-tidy $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS)
klibc:
$(MAKE) clean
$(MAKE) CC=klcc ITARGET= ISUBDIRS='linux extlinux' BSUBDIRS=
-endif # ifeq ($(HAVE_FIRMWARE),)
+endif # ifeq ($(FIRMWARE),)
endif # ifeq ($(topdir),)
diff --git a/com32/Makefile b/com32/Makefile
index 3e7a7700..5efda1ce 100644
--- a/com32/Makefile
+++ b/com32/Makefile
@@ -6,7 +6,7 @@ subdirs: $(SUBDIRS)
$(SUBDIRS):
@mkdir -p $(OBJ)/$@
$(MAKE) -C $(OBJ)/$@ SRC="$(SRC)"/$@ OBJ="$(OBJ)"/$@/ \
- EFI_BUILD=$(EFI_BUILD) -f $(SRC)/$@/Makefile $(MAKECMDGOALS)
+ -f $(SRC)/$@/Makefile $(MAKECMDGOALS)
all tidy dist clean spotless install: subdirs
diff --git a/com32/elflink/ldlinux/Makefile b/com32/elflink/ldlinux/Makefile
index d948da43..87c0d362 100644
--- a/com32/elflink/ldlinux/Makefile
+++ b/com32/elflink/ldlinux/Makefile
@@ -22,7 +22,7 @@ OBJS = ldlinux.o cli.o readconfig.o refstr.o colors.o getadv.o adv.o \
BTARGET = $(LDLINUX)
-ifdef EFI_BUILD
+ifeq ($(FWCLASS),EFI)
%.e$(BITS): %.elf
$(OBJCOPY) --strip-debug --strip-unneeded $< $@
SONAME = $(patsubst %.elf,%.e$(BITS),$(@F))
diff --git a/com32/lib/Makefile b/com32/lib/Makefile
index 1624ae78..8865224e 100644
--- a/com32/lib/Makefile
+++ b/com32/lib/Makefile
@@ -22,7 +22,7 @@ LIBJPG_OBJS = \
jpeg/rgb24.o jpeg/bgr24.o jpeg/yuv420p.o jpeg/grey.o \
jpeg/rgba32.o jpeg/bgra32.o
-ifdef EFI_BUILD
+ifeq ($(FWCLASS),EFI)
I915VESA_OBJ =
else
I915VESA_OBJ = sys/vesa/i915resolution.o
diff --git a/core/Makefile b/core/Makefile
index 26302fd6..b87007f3 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -1,7 +1,7 @@
## -----------------------------------------------------------------------
##
## Copyright 1998-2009 H. Peter Anvin - All Rights Reserved
-## Copyright 2009-2014 Intel Corporation; author: H. Peter Anvin
+## Copyright 2009-2016 Intel Corporation; author: H. Peter Anvin
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
@@ -77,18 +77,20 @@ FILTER_OBJS = %rawcon.o %plaincon.o %pxelinux-c.o %ldlinux-c.o \
$(subst $(OBJ)/,,$(LPXELINUX_OBJS)) \
$(subst $(OBJ)/,,$(PXELINUX_OBJS))
-ifdef EFI_BUILD
+ifeq ($(FWCLASS),EFI)
# EFI is single-threaded, and doesn't use the LZO assembly decoder
FILTER_OBJS += $(subst $(SRC)/,, \
$(patsubst %.S,%.o, $(sort $(wildcard $(SRC)/lzo/*.S))) \
$(patsubst %.c,%.o, $(sort $(wildcard $(SRC)/thread/*.c))) \
- $(patsubst %.S,%.o, $(sort $(wildcard $(SRC)/thread/*.S))))
+ $(patsubst %.S,%.o, $(sort $(wildcard $(SRC)/thread/*.S)))) \
+ $(patsubst %.asm,%.o, $(sort $(wildcard $(SRC)/*.asm))) \
+ $(patsubst %.c,%.o, $(sort $(wildcard $(SRC)/bios*.c)))
endif
COBJS = $(filter-out $(FILTER_OBJS),$(COBJ))
SOBJS = $(filter-out $(FILTER_OBJS),$(SOBJ))
-ifdef EFI_BUILD
+ifeq ($(FWCLASS),EFI)
COBJS += $(subst $(SRC)/,,$(CORE_PXE_CSRC:%.c=%.o) fs/pxe/ftp.o fs/pxe/ftp_readdir.o \
fs/pxe/http.o fs/pxe/http_readdir.o)
endif
@@ -116,20 +118,7 @@ ifndef DATE
DATE := $(shell sh $(SRC)/../gen-id.sh $(VERSION) $(HEXDATE))
endif
-# Set up the NASM and LD options for the architecture
-NASM_ELF = "unknown"
-LD_PIE = "unknown"
-ifeq ($(ARCH),i386)
- NASM_ELF = elf
- LD_PIE = -pie
-endif
-ifeq ($(ARCH),x86_64)
- NASM_ELF = elf64
- #LD_PIE = --pic-executable
- LD_PIE =
-endif
-
-ifdef EFI_BUILD
+ifeq ($(FWCLASS),EFI)
all: makeoutputdirs $(filter-out %bios.o,$(COBJS) $(SOBJS)) codepage.o
else
all: makeoutputdirs $(BTARGET)
@@ -141,14 +130,14 @@ makeoutputdirs:
kwdhash.gen: keywords genhash.pl
$(PERL) $(SRC)/genhash.pl < $(SRC)/keywords > $(OBJ)/kwdhash.gen
-.PRECIOUS: %.elf
+ifeq ($(FWCLASS),BIOS)
+.PRECIOUS: %.elf
%.raw: %.elf
$(OBJCOPY) -O binary -S $< $(@:.bin=.raw)
-# GNU make 3.82 gets confused by the first form
-.PRECIOUS: $(OBJ)/%.raw
-
+# GNU make 3.82 gets confused by plain %.raw; make 4.0 requires it
+.PRECIOUS: $(OBJ)/%.raw %.raw
%.bin: %.raw $(PREPCORE)
$(PREPCORE) $< $@
@@ -161,10 +150,16 @@ kwdhash.gen: keywords genhash.pl
AUXLIBS = libisolinux.a libisolinux-debug.a libldlinux.a \
libpxelinux.a liblpxelinux.a
+
LDSCRIPT = $(SRC)/$(ARCH)/syslinux.ld
+NASM_ELF = elf
+
%.elf: %.o $(LIBDEP) $(LDSCRIPT) $(AUXLIBS)
- $(LD) $(LDFLAGS) -Bsymbolic $(LD_PIE) -E --hash-style=gnu -T $(LDSCRIPT) -M -o $@ $< \
+ $(LD) $(LDFLAGS) -pie -Bsymbolic \
+ -T $(LDSCRIPT) \
+ --unresolved-symbols=report-all \
+ -E --hash-style=gnu -M -o $@ $< \
--start-group $(LIBS) $(subst $(*F).elf,lib$(*F).a,$@) --end-group \
> $(@:.elf=.map)
$(OBJDUMP) -h $@ > $(@:.elf=.sec)
@@ -195,11 +190,6 @@ libldlinux.a: plaincon.o localboot.o ldlinux-c.o
$(AR) cq $@ $^
$(RANLIB) $@
-$(LIB): $(LIBOBJS)
- rm -f $@
- $(AR) cq $@ $^
- $(RANLIB) $@
-
pxelinux.o: pxelinux.asm kwdhash.gen ../version.gen
$(NASM) -f $(NASM_ELF) $(NASMOPT) -DDATE_STR="'$(DATE)'" \
-DHEXDATE="$(HEXDATE)" \
@@ -228,6 +218,13 @@ ldlinux.bss: ldlinux.bin
ldlinux.sys: ldlinux.bin
dd if=$< of=$@ bs=512 skip=2
+endif # BIOS
+
+$(LIB): $(LIBOBJS)
+ rm -f $@
+ $(AR) cq $@ $^
+ $(RANLIB) $@
+
codepage.cp: $(OBJ)/../codepage/$(CODEPAGE).cp
cp -f $< $@
diff --git a/mk/com32.mk b/mk/com32.mk
index d32069dd..aeb8a2cc 100644
--- a/mk/com32.mk
+++ b/mk/com32.mk
@@ -48,7 +48,7 @@ GCCOPT += $(call gcc_ok,-falign-jumps=0,-malign-jumps=0)
GCCOPT += $(call gcc_ok,-falign-labels=0,-malign-labels=0)
GCCOPT += $(call gcc_ok,-falign-loops=0,-malign-loops=0)
-ifdef EFI_BUILD
+ifeq ($(FWCLASS),EFI)
GCCOPT += -mno-red-zone
else
GCCOPT += -mregparm=3 -DREGPARM=3
@@ -119,5 +119,3 @@ C_LNXLIBS = $(com32)/libutil/libutil_lnx.a
%.c32: %.elf
$(OBJCOPY) --strip-debug --strip-unneeded $< $@
- ##$(OBJCOPY) -O binary $< $@
- ##$(RELOCS) $< >> $@ || ( rm -f $@ ; false )
diff --git a/mk/elf.mk b/mk/elf.mk
index 54fd4ce2..b46dbd06 100644
--- a/mk/elf.mk
+++ b/mk/elf.mk
@@ -60,7 +60,7 @@ CFLAGS = $(GCCOPT) $(GCCWARN) -W -Wall \
-I$(com32)/libutil/include -I$(com32)/include \
-I$(com32)/include/sys $(GPLINCLUDE) -I$(core)/include \
-I$(objdir) -DLDLINUX=\"$(LDLINUX)\"
-ifdef EFI_BUILD
+ifeq ($(FWCLASS),EFI)
GCCOPT += -mno-red-zone
else
GCCOPT += -mregparm=3 -DREGPARM=3
diff --git a/mk/embedded.mk b/mk/embedded.mk
index df8e85f3..488dc0fc 100644
--- a/mk/embedded.mk
+++ b/mk/embedded.mk
@@ -38,7 +38,7 @@ GCCOPT += $(call gcc_ok,-ffreestanding,)
GCCOPT += $(call gcc_ok,-fno-stack-protector,)
GCCOPT += $(call gcc_ok,-fwrapv,)
GCCOPT += $(call gcc_ok,-freg-struct-return,)
-ifdef EFI_BUILD
+ifeq ($(FWCLASS),EFI)
GCCOPT += -Os -fomit-frame-pointer -msoft-float -mno-red-zone
else
GCCOPT += -Os -fomit-frame-pointer -mregparm=3 -DREGPARM=3 -msoft-float
diff --git a/mk/lib.mk b/mk/lib.mk
index 7a48756c..54f1fd54 100644
--- a/mk/lib.mk
+++ b/mk/lib.mk
@@ -54,7 +54,7 @@ WARNFLAGS = $(GCCWARN) -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Winl
CFLAGS = $(OPTFLAGS) $(REQFLAGS) $(WARNFLAGS) $(LIBFLAGS)
-ifdef EFI_BUILD
+ifeq ($(FWCLASS),EFI)
CFLAGS += -mno-red-zone
else
CFLAGS += -mregparm=3 -DREGPARM=3
diff --git a/tests/Makefile b/tests/Makefile
index 7c0f9794..99b1618f 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -39,7 +39,7 @@ QEMU = qemu-system-i386
all: syslinux-tests pxelinux-tests
syslinux-tests:
- $(MAKE) SRC="$(SRC)" OBJ="$(OBJ)" objdir="$(objdir)" EFI_BUILD=$(EFI_BUILD) \
+ $(MAKE) SRC="$(SRC)" OBJ="$(OBJ)" objdir="$(objdir)" \
INITIAL="$(INITIAL)" INSTALL_DIR="$(SYSLINUX_INSTALL_DIR)" \
CONFIG_FILE="$(SYSLINUX_CONFIG_FILE)" \
DERIVATIVE=SYSLINUX
@@ -47,7 +47,7 @@ syslinux-tests:
$(SYSLINUX_LOOPDEV) test.cfg
pxelinux-tests:
- $(MAKE) SRC="$(SRC)" OBJ="$(OBJ)" objdir="$(objdir)" EFI_BUILD=$(EFI_BUILD) \
+ $(MAKE) SRC="$(SRC)" OBJ="$(OBJ)" objdir="$(objdir)" \
INITIAL="$(INITIAL)" INSTALL_DIR="$(PXELINUX_INSTALL_DIR)" \
CONFIG_FILE="$(PXELINUX_CONFIG_FILE)" \
DERIVATIVE=PXELINUX
@@ -71,7 +71,7 @@ SUBDIRS = linux com32
subdirs: $(SUBDIRS)
$(SUBDIRS):
mkdir -p $(OBJ)/$@
- $(MAKE) -C $(OBJ)/$@ SRC="$(SRC)"/$@ OBJ="$(OBJ)"/$@/ EFI_BUILD=$(EFI_BUILD) \
+ $(MAKE) -C $(OBJ)/$@ SRC="$(SRC)"/$@ OBJ="$(OBJ)"/$@/ \
-f $(SRC)/$@/Makefile objdir="$(objdir)/tests" \
INSTALL_DIR="$(INSTALL_DIR)" CONFIG_FILE="$(CONFIG_FILE)" \
DERIVATIVE="$(DERIVATIVE)"