# directories.
#
- # List of module objects that should be installed for all derivatives
+ifndef EFI_BUILD
MODULES = memdisk/memdisk memdump/memdump.com modules/*.com \
com32/menu/*.c32 com32/modules/*.c32 com32/mboot/*.c32 \
com32/hdt/*.c32 com32/rosh/*.c32 com32/gfxboot/*.c32 \
com32/sysdump/*.c32 com32/lua/src/*.c32 com32/chain/*.c32 \
com32/lib/*.c32 com32/libutil/*.c32 com32/gpllib/*.c32 \
com32/elflink/ldlinux/*.c32
+else
+# memdump is BIOS specific code exclude it for EFI
+# FIXME: Prune other BIOS-centric modules
+MODULES = com32/menu/*.c32 com32/modules/*.c32 com32/mboot/*.c32 \
+ com32/hdt/*.c32 com32/rosh/*.c32 com32/gfxboot/*.c32 \
+ com32/sysdump/*.c32 com32/lua/src/*.c32 com32/chain/*.c32 \
+ com32/lib/*.c32 com32/libutil/*.c32 com32/gpllib/*.c32 \
+ com32/elflink/ldlinux/*.c32
+endif
+ # List of module objects that should be installed for all derivatives
+ INSTALLABLE_MODULES = $(filter-out com32/gpllib%,$(MODULES))
+
# syslinux.exe is BTARGET so as to not require everyone to have the
# mingw suite installed
BTARGET = version.gen version.h version.mk
# Things to install in /tftpboot
NETINSTALLABLE = core/pxelinux.0 gpxe/gpxelinux.0 \
- $(MODULES)
+ $(INSTALLABLE_MODULES)
-all:
- $(MAKE) all-local
- set -e ; for i in $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
- -ls -l $(BOBJECTS) $(IOBJECTS)
+endif # ifdef EFI_BUILD
-all-local: $(BTARGET) $(ITARGET)
+.PHONY: subdirs $(BSUBDIRS) $(ISUBDIRS)
+
+ifeq ($(HAVE_FIRMWARE),)
+
+firmware = bios efi32 efi64
+
+# If no firmware was specified the rest of MAKECMDGOALS applies to all
+# firmware.
+ifeq ($(filter $(firmware),$(MAKECMDGOALS)),)
+all strip tidy clean dist spotless install installer: bios efi32 efi64
+
+else
+
+# Don't do anything for the rest of MAKECMDGOALS at this level. It
+# will be handled for each of $(firmware).
+strip tidy clean dist spotless install installer:
+
+endif
+
+# Convert 'make bios strip' to 'make strip', etc for rest of the Makefiles.
+MAKECMDGOALS := $(filter-out $(firmware),$(MAKECMDGOALS))
+ifeq ($(MAKECMDGOALS),)
+ MAKECMDGOALS += all
+endif
+
+#
+# You'd think that we'd be able to use the 'define' directive to
+# abstract the code for invoking make(1) in the output directory, but
+# by using 'define' we lose the ability to build in parallel.
+#
+.PHONY: $(firmware)
+bios:
+ @mkdir -p $(OBJ)/bios
+ $(MAKE) -C $(OBJ)/bios -f $(SRC)/Makefile SRC="$(SRC)" \
+ objdir=$(OBJ)/bios OBJ=$(OBJ)/bios HAVE_FIRMWARE=1 \
+ ARCH=i386 $(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 $(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 $(MAKECMDGOALS)
-installer:
- $(MAKE) installer-local
- set -e ; for i in $(ISUBDIRS); do $(MAKE) -C $$i all ; done
+else # ifeq($(HAVE_FIRMWARE),)
+
+all: all-local subdirs
+
+all-local: $(BTARGET) $(ITARGET)
-ls -l $(BOBJECTS) $(IOBJECTS)
+subdirs: $(BSUBDIRS) $(ISUBDIRS)
+
+$(sort $(ISUBDIRS) $(BSUBDIRS)):
+ @mkdir -p $@
+ $(MAKE) -C $@ SRC="$(SRC)/$@" OBJ="$(OBJ)/$@" \
+ -f $(SRC)/$@/Makefile $(MAKECMDGOALS)
+
+$(ITARGET):
+ @mkdir -p $@
+ $(MAKE) -C $@ SRC="$(SRC)/$@" OBJ="$(OBJ)/$@" \
+ -f $(SRC)/$@/Makefile $(MAKECMDGOALS)
+
+$(BINFILES):
+ @mkdir -p $@
+ $(MAKE) -C $@ SRC="$(SRC)/$@" OBJ="$(OBJ)/$@" \
+ -f $(SRC)/$@/Makefile $(MAKECMDGOALS)
+
+#
+# List the dependencies to help out parallel builds.
+dos extlinux linux mtools win32 win64: libinstaller
+libinstaller: core
+utils: mbr
+core: com32
+efi: core
+
+installer: installer-local
+ set -e; for i in $(ISUBDIRS); \
+ do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
+ -f $(SRC)/$$i/Makefile all; done
+
installer-local: $(ITARGET) $(BINFILES)
PERL = perl
-all: $(BINFILES)
+VPATH = $(SRC)
-bootsect_bin.c: ../core/ldlinux.bss bin2c.pl
- $(PERL) bin2c.pl syslinux_bootsect < $< > $@
+all: installer
-ldlinux_bin.c: ../core/ldlinux.sys bin2c.pl
- $(PERL) bin2c.pl syslinux_ldlinux 512 < $< > $@
+bootsect_bin.c: $(OBJ)/../core/ldlinux.bss bin2c.pl
+ $(PERL) $(SRC)/bin2c.pl syslinux_bootsect < $< > $@
-mbr_bin.c: ../mbr/mbr.bin bin2c.pl
- $(PERL) bin2c.pl syslinux_mbr < $< > $@
+ldlinux_bin.c: $(OBJ)/../core/ldlinux.sys bin2c.pl
+ $(PERL) $(SRC)/bin2c.pl syslinux_ldlinux 512 < $< > $@
-gptmbr_bin.c: ../mbr/gptmbr.bin bin2c.pl
- $(PERL) bin2c.pl syslinux_gptmbr < $< > $@
+mbr_bin.c: $(OBJ)/../mbr/mbr.bin bin2c.pl
+ $(PERL) $(SRC)/bin2c.pl syslinux_mbr < $< > $@
+
+gptmbr_bin.c: $(OBJ)/../mbr/gptmbr.bin bin2c.pl
+ $(PERL) $(SRC)/bin2c.pl syslinux_gptmbr < $< > $@
+
+installer: $(BINFILES)
+ ldlinuxc32_bin.c: ../com32/elflink/ldlinux/ldlinux.c32 bin2c.pl
+ $(PERL) bin2c.pl syslinux_ldlinuxc32 < $< > $@
+
tidy:
rm -f $(BINFILES)