#
# Main Makefile for SYSLINUX
#
-topdir = .
+
+#
+# topdir is only set when we are doing a recursive make. Do a bunch of
+# initialisation if it's unset since this is the first invocation.
+#
+ifeq ($(topdir),)
+
+topdir = $(CURDIR)
+
+#
+# Because we need to build modules multiple times, e.g. for BIOS,
+# efi32, efi64, we output all object and executable files to a
+# separate object directory for each firmware.
+#
+# The output directory can be customised by setting the O=/obj/path/
+# variable when invoking make. If no value is specified the default
+# directory is 'obj'.
+#
+ifeq ("$(origin O)", "command line")
+ OBJDIR := $(O)
+else
+ OBJDIR = $(CURDIR)/obj
+ foo := $(shell mkdir -p $(OBJDIR) && /bin/true)
+endif
+
+# If the output directory does not exist we bail because that is the
+# least surprising thing to do.
+cd-output := $(shell cd $(OBJDIR) && /bin/pwd)
+$(if $(cd-output),, \
+ $(error output directory "$(OBJDIR)" does not exist))
+
+#
+# These environment variables are exported to every invocation of
+# make,
+#
+# 'topdir' - the top-level directory containing the Syslinux source
+# 'objdir' - the top-level directory of output files
+# 'MAKEDIR' - contains Makefile fragments
+#
+# There are also a handful of variables that are passed to each
+# sub-make,
+#
+# SRC - source tree location of the module being compiled
+# OBJ - output tree location of the module being compiled
+#
+# A couple of rules for writing Makefiles,
+#
+# - Do not use relative paths, use the above variables
+# - You can write $(SRC) a lot less if you add it to VPATH
+#
+
MAKEDIR = $(topdir)/mk
+export MAKEDIR topdir
+
+ifeq ($(MAKECMDGOALS),)
+ MAKECMDGOALS += all
+endif
+
+#
+# The 'bios', 'efi32' and 'efi64' are dummy targets. Their only
+# purpose is to instruct us which output directories need
+# creating. Which means that we always need a *real* target, such as
+# 'all', appended to the make goals.
+#
+firmware = bios efi32 efi64
+real-target := $(filter-out $(firmware), $(MAKECMDGOALS))
+real-firmware := $(filter $(firmware), $(MAKECMDGOALS))
+
+ifeq ($(real-target),)
+ real-target = all
+endif
+
+ifeq ($(real-firmware),)
+ real-firmware = $(firmware)
+endif
+
+.PHONY: $(MAKECMDGOALS)
+$(MAKECMDGOALS):
+ $(MAKE) -C $(OBJDIR) -f $(CURDIR)/Makefile SRC="$(topdir)" \
+ OBJ=$(OBJDIR) objdir=$(OBJDIR) $(MAKECMDGOALS)
+
+else # ifeq ($(topdir),)
+
include $(MAKEDIR)/syslinux.mk
-include $(topdir)/version.mk
else
# memdump is BIOS specific code exclude it for EFI
# FIXME: Prune other BIOS-centric modules
-MODULES = memdisk/memdisk modules/*.com \
- com32/menu/*.c32 com32/modules/*.c32 com32/mboot/*.c32 \
+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 \
# Note: libinstaller is both a BSUBDIR and an ISUBDIR. It contains
# files that depend only on the B phase, but may have to be regenerated
# for "make installer".
-ifndef EFI_BUILD
-BSUBDIRS = codepage com32 lzo core memdisk modules mbr memdump gpxe sample \
- diag libinstaller dos win32 win64 dosutil efi
+
+ifdef EFI_BUILD
+
+BSUBDIRS = codepage com32 lzo core modules mbr sample efi
+ISUBDIRS = efi utils
+
+INSTALLSUBDIRS = efi
+
else
-# memdump is BIOS specific code exclude it for EFI
-# FIXME: Prune other BIOS-centric modules
-BSUBDIRS = codepage com32 lzo core memdisk modules mbr gpxe sample \
- diag libinstaller win32 win64 dosutil efi
-endif
+
+BSUBDIRS = codepage com32 lzo core memdisk sample diag mbr memdump dos \
+ modules gpxe libinstaller win32 win64 dosutil
+
ITARGET =
IOBJECTS = $(ITARGET) \
utils/gethostip utils/isohybrid utils/mkdiskimage \
NETINSTALLABLE = core/pxelinux.0 gpxe/gpxelinux.0 \
$(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)
+
+else # ifeq($(HAVE_FIRMWARE),)
+
+all: all-local subdirs
-installer:
- $(MAKE) installer-local
- set -e ; for i in $(ISUBDIRS); do $(MAKE) -C $$i all ; done
+all-local: $(BTARGET) $(ITARGET)
-ls -l $(BOBJECTS) $(IOBJECTS)
+subdirs: $(BSUBDIRS) $(ISUBDIRS)
+
+# Note the double-colon which avoids the make warning about redefining
+# a rule for libinstaller.
+$(BSUBDIRS):
+ @mkdir -p $@
+ $(MAKE) -C $@ SRC="$(SRC)/$@" OBJ="$(OBJ)/$@" \
+ -f $(SRC)/$@/Makefile $(MAKECMDGOALS)
+
+$(ISUBDIRS):
+ @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)
-strip:
- $(MAKE) strip-local
- set -e ; for i in $(ISUBDIRS); do $(MAKE) -C $$i strip ; done
+strip: strip-local
+ set -e; for i in $(ISUBDIRS); \
+ do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
+ -f $(SRC)/$$i/Makefile strip; done
-ls -l $(BOBJECTS) $(IOBJECTS)
strip-local:
-version.gen: version version.pl
- $(PERL) version.pl $< $@ '%define < @'
-version.h: version version.pl
- $(PERL) version.pl $< $@ '#define < @'
-version.mk: version version.pl
- $(PERL) version.pl $< $@ '< := @'
+version.gen: $(topdir)/version $(topdir)/version.pl
+ $(PERL) $(topdir)/version.pl $< $@ '%define < @'
+version.h: $(topdir)/version $(topdir)/version.pl
+ $(PERL) $(topdir)/version.pl $< $@ '#define < @'
+version.mk: $(topdir)/version $(topdir)/version.pl
+ $(PERL) $(topdir)/version.pl $< $@ '< := @'
local-install: installer
mkdir -m 755 -p $(INSTALLROOT)$(BINDIR)
mkdir -m 755 -p $(INSTALLROOT)$(DIAGDIR)
install -m 644 -c $(INSTALL_DIAG) $(INSTALLROOT)$(DIAGDIR)
mkdir -m 755 -p $(INSTALLROOT)$(MANDIR)/man1
- install -m 644 -c man/*.1 $(INSTALLROOT)$(MANDIR)/man1
+ install -m 644 -c $(topdir)/man/*.1 $(INSTALLROOT)$(MANDIR)/man1
: mkdir -m 755 -p $(INSTALLROOT)$(MANDIR)/man8
: install -m 644 -c man/*.8 $(INSTALLROOT)$(MANDIR)/man8
+ifndef EFI_BUILD
install: local-install
- set -e ; for i in $(INSTALLSUBDIRS) ; do $(MAKE) -C $$i $@ ; done
+ set -e ; for i in $(INSTALLSUBDIRS) ; \
+ do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
+ -f $(SRC)/$$i/Makefile $@; done
+else
+install:
+ set -e ; for i in $(INSTALLSUBDIRS) ; \
+ do $(MAKE) -C $$i SRC="$(SRC)/$$i" OBJ="$(OBJ)/$$i" \
+ BITS="$(BITS)" -f $(SRC)/$$i/Makefile $@; done
+
+ mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)/efi$(BITS)
+ install -m 755 $(MODULES) $(INSTALLROOT)$(AUXDIR)/efi$(BITS)
+endif
netinstall: installer
mkdir -p $(INSTALLROOT)$(TFTPBOOT)
rm -f *.lsr *.lst *.map *.sec *.tmp
rm -f $(OBSOLETE)
-tidy: local-tidy
- set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
+tidy: local-tidy $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS)
local-clean:
rm -f $(ITARGET)
-clean: local-tidy local-clean
- set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
+clean: local-tidy local-clean $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS)
local-dist:
find . \( -name '*~' -o -name '#*' -o -name core \
-o -name '.*.d' -o -name .depend \) -type f -print0 \
| xargs -0rt rm -f
-dist: local-dist local-tidy
- set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
+dist: local-dist local-tidy $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS)
local-spotless:
rm -f $(BTARGET) .depend *.so.*
-spotless: local-clean local-dist local-spotless
- set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
+spotless: local-clean local-dist local-spotless $(BESUBDIRS) $(IESUBDIRS) $(ISUBDIRS) $(BSUBDIRS)
# Shortcut to build linux/syslinux using klibc
klibc:
$(MAKE) clean
$(MAKE) CC=klcc ITARGET= ISUBDIRS='linux extlinux' BSUBDIRS=
+endif # ifeq ($(HAVE_FIRMWARE),)
# Hook to add private Makefile targets for the maintainer.
-include Makefile.private
+
+endif # ifeq ($(topdir),)
+VPATH = $(SRC)
PERL = perl
-CPSRC = $(wildcard *.txt)
-GENFILES = $(patsubst %.txt,%.cp,$(CPSRC))
+CPSRC = $(wildcard $(SRC)/*.txt)
+CPOBJ = $(notdir $(CPSRC))
+GENFILES = $(patsubst %.txt,%.cp,$(CPOBJ))
.SUFFIXES: .txt .cp
# This generates codepage files where the display and filesystem
# codepages are both the same.
%.cp: %.txt cptable.pl UnicodeData
- $(PERL) cptable.pl UnicodeData $< $< $@
+ $(PERL) $(SRC)/cptable.pl $(SRC)/UnicodeData $< $< $@
tidy:
rm -f *.cp *.bin
SUBDIRS = libupload tools lib elflink/ldlinux gpllib libutil modules mboot \
menu samples elflink rosh cmenu hdt gfxboot sysdump lua/src chain
-all tidy dist clean spotless install:
- set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
+.PHONY: subdirs $(SUBDIRS)
+subdirs: $(SUBDIRS)
+$(SUBDIRS):
+ @mkdir -p $(OBJ)/$@
+ $(MAKE) -C $(OBJ)/$@ SRC="$(SRC)"/$@ OBJ="$(OBJ)"/$@/ \
+ -f $(SRC)/$@/Makefile $(MAKECMDGOALS)
+
+all tidy dist clean spotless install: subdirs
+
+# Parallel dependencies
+chain lua/src mboot menu: libutil gpllib
+cmenu: lib libutil
+elflink/ldlinux: lib
+gfxboot: libutil
+hdt: lib libupload cmenu gpllib libutil
+modules: lib libutil gpllib
+rosh: lib libutil
+samples: libutil elflink/ldlinux
+sysdump: libupload gpllib
##
## -----------------------------------------------------------------------
-
-topdir = ../..
-MAKEDIR = $(topdir)/mk
+VPATH = $(SRC)
include $(MAKEDIR)/elf.mk
OBJS = chain.o partiter.o utility.o options.o mangle.o
NOGPL := 1
LIBS = libmenu/libmenu.c32 \
- $(com32)/libutil/libutil_com.c32 \
- $(com32)/lib/libcom32.c32
+ $(objdir)/com32/libutil/libutil_com.c32 \
+ $(objdir)/com32/lib/libcom32.c32
-topdir = ../..
-MAKEDIR = $(topdir)/mk
+VPATH = $(SRC)
include $(MAKEDIR)/elf.mk
-CFLAGS += -I./libmenu
+CFLAGS += -I$(SRC)/libmenu
-LIBMENU = libmenu/syslnx.o libmenu/com32io.o libmenu/tui.o \
- libmenu/menu.o libmenu/passwords.o libmenu/des.o libmenu/help.o \
- $(com32)/libutil/libutil_com.c32 $(com32)/lib/libcom32.c32
+LIBMENU = $(objdir)/com32/libutil/libutil_com.c32 \
+ $(objdir)/com32/lib/libcom32.c32 \
+ libmenu/syslnx.o libmenu/com32io.o libmenu/tui.o \
+ libmenu/menu.o libmenu/passwords.o libmenu/des.o libmenu/help.o
-CMENUS = $(patsubst %.c,%.c32,$(wildcard *.c))
-IMENUS = $(patsubst %.menu,%.c32,$(wildcard *.menu))
+CMENUS = $(patsubst %.c,%.c32,$(wildcard $(SRC)/*.c))
+IMENUS = $(patsubst %.menu,%.c32,$(wildcard $(SRC)/*.menu))
-MENUS = $(LIBS) $(CMENUS) $(IMENUS)
+MENUS = $(LIBS) $(subst $(SRC)/,,$(CMENUS) $(IMENUS))
.SUFFIXES: .S .c .o .elf .c32 .menu
.PRECIOUS: %.c
%.c: %.menu adv_menu.tpl
- python menugen.py --input=$< --output=$@ --template=adv_menu.tpl
+ python $(SRC)/menugen.py --input=$< --output=$@ --template=$(SRC)/adv_menu.tpl
-all: menus
+all: makeoutputdirs menus
+
+makeoutputdirs:
+ @mkdir -p $(OBJ)/libmenu
libmenu/libmenu.c32: $(LIBMENU)
$(LD) -shared $(LDFLAGS) -o $@ $^
##
## -----------------------------------------------------------------------
-topdir = ../../..
-MAKEDIR = $(topdir)/mk
+VPATH = $(SRC)
include $(MAKEDIR)/elf.mk
CFLAGS += -I$(topdir)/core/elflink -I$(topdir)/core/include
-LIBS = --whole-archive $(com32)/lib/libcom32min.a
+LIBS = --whole-archive $(objdir)/com32/lib/libcom32min.a
+
+OBJS = ldlinux.o cli.o readconfig.o refstr.o colors.o getadv.o adv.o \
+ execute.o chainboot.o kernel.o get_key.o advwrite.o setadv.o \
+ eprintf.o loadhigh.o
all: ldlinux.c32 ldlinux_lnx.a
-ldlinux.c32 : ldlinux.o cli.o readconfig.o refstr.o colors.o getadv.o \
- adv.o execute.o chainboot.o kernel.o get_key.o \
- advwrite.o setadv.o eprintf.o loadhigh.o
+ldlinux.c32 : $(OBJS)
$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
LNXLIBOBJS = get_key.lo
##
## -----------------------------------------------------------------------
-topdir = ../..
-MAKEDIR = $(topdir)/mk
+VPATH = $(SRC)
include $(MAKEDIR)/elf.mk
MODULES = gfxboot.c32
all: $(MODULES)
-gfxboot.c32 : gfxboot.o realmode_callback.o $(LIBS) $(C_LIBS)
+OBJS = gfxboot.o realmode_callback.o
+
+gfxboot.c32 : $(OBJS) $(LIBS) $(C_LIBS)
$(LD) $(LDFLAGS) -o $@ $^
realmode_callback.o: realmode_callback.asm
#
# Include configuration rules
-topdir = ../..
-MAKEDIR = $(topdir)/mk
include $(MAKEDIR)/lib.mk
-REQFLAGS += -I../gplinclude -I../gplinclude/zzjson
+REQFLAGS += -I$(SRC)/../gplinclude -I$(SRC)/../gplinclude/zzjson
-GPLDIRS := . disk dmi vpd acpi zzjson
-LIBOBJS := $(foreach dir,$(GPLDIRS),$(patsubst %.c,%.o,$(wildcard $(dir)/*.c)))
+GPLDIRS := $(SRC) $(addprefix $(SRC)/,disk dmi vpd acpi zzjson)
+LIBOBJS := $(subst $(SRC)/,,$(foreach dir,$(GPLDIRS),$(patsubst %.c,%.o,$(wildcard $(dir)/*.c))))
BINDIR = /usr/bin
LIBDIR = /usr/lib
INCDIR = /usr/include
COM32DIR = $(AUXDIR)/com32
-all: libcom32gpl.c32
+all: makeoutputdirs libcom32gpl.c32
+
+makeoutputdirs:
+ @mkdir -p $(foreach b, \
+ $(addprefix $(OBJ),$(sort $(dir $(LIBOBJS)))),$(b))
libcom32gpl.c32 : $(LIBOBJS)
$(LD) -shared $(LDFLAGS) -o $@ $^
mkdir -m 755 -p $(INSTALLROOT)$(COM32DIR)
install -m 644 libcom32gpl.c32 $(INSTALLROOT)$(COM32DIR)
mkdir -p $(INSTALLROOT)$(COM32DIR)/include/
- cp -r ../gplinclude $(INSTALLROOT)$(COM32DIR)/include/
+ cp -r $(SRC)/../gplinclude $(INSTALLROOT)$(COM32DIR)/include/
-include .*.d */.*.d */*/.*.d
## Hardware Detection Tool
##
-topdir = ../..
-MAKEDIR = $(topdir)/mk
+VPATH = $(SRC)
include $(MAKEDIR)/elf.mk
-LIBS = ../libupload/libcom32upload.a
-C_LIBS += $(com32)/cmenu/libmenu/libmenu.c32 \
- $(com32)/libutil/libutil_com.c32 \
- $(com32)/lib/libcom32.c32 $(com32)/gpllib/libcom32gpl.c32
+LIBS = $(objdir)/com32/libupload/libcom32upload.a
+C_LIBS += $(objdir)/com32/cmenu/libmenu/libmenu.c32 \
+ $(objdir)/com32/libutil/libutil_com.c32 \
+ $(objdir)/com32/lib/libcom32.c32 \
+ $(objdir)/com32/gpllib/libcom32gpl.c32
CFLAGS += -I$(com32)/cmenu/libmenu -I$(com32)
MODULES = hdt.c32
TESTFILES =
-OBJS = $(patsubst %.c,%.o,$(wildcard *.c))
+OBJS = $(subst $(SRC)/,,$(patsubst %.c,%.o,$(wildcard $(SRC)/*.c)))
VERSION = $(shell $(SED) -n 's/\#define VERSION \"\(.*\)\"/\1/p' hdt.h)
CODENAME = $(shell $(SED) -n 's/\#define CODENAME \"\(.*\)\"/\1/p' hdt.h)
NODASH_VERSION = $(shell echo $(VERSION) | $(SED) -e 's/-/_/g' | $(SED) -e 's/\./_/g')
# Include configuration rules
NOGPL := 1
-topdir = ../../
-MAKEDIR = $(topdir)/mk
+VPATH = $(SRC)
include $(MAKEDIR)/lib.mk
## OPTIONAL OBJECTS, AVAILABLE AS DYNAMIC LINKED MODULES
$(DYNENTRY_OBJS)
-LIBOBJS = \
- $(DYNLIBOBJS)
+LIBOBJS = $(DYNLIBOBJS)
BINDIR = /usr/bin
LIBDIR = /usr/lib
INCDIR = /usr/include
COM32DIR = $(AUXDIR)/com32
-all: libcom32.c32 libcom32min.a libcom32core.a
+all: makeoutputdirs libcom32.c32 libcom32min.a libcom32core.a
+
+makeoutputdirs:
+ @mkdir -p $(foreach b, \
+ $(addprefix $(OBJ)/,$(sort $(dir $(LIBOBJS) $(MINLIBOBJS) $(CORELIBOBJS)))),$(b))
libcom32.c32 : $(LIBOBJS)
rm -f $@
install: all
mkdir -m 755 -p $(INSTALLROOT)$(COM32DIR)
- install -m 644 com32.ld $(INSTALLROOT)$(COM32DIR)
+ install -m 644 $(SRC)/com32.ld $(INSTALLROOT)$(COM32DIR)
-rm -rf $(INSTALLROOT)$(COM32DIR)/include
- cp -r ../include $(INSTALLROOT)$(COM32DIR)
+ cp -r $(SRC)/../include $(INSTALLROOT)$(COM32DIR)
# These files are performance critical, and doesn't compile well with -Os
#FIXME: determine if drawtxt.c is really EFI-dependent
#include <syslinux/config.h>
#include <klibc/compiler.h>
#include <core.h>
-#include <../../../version.h>
+#include <version.h>
struct syslinux_version __syslinux_version;
# Include configuration rules
-topdir = ../..
-MAKEDIR = $(topdir)/mk
+VPATH = $(SRC)
include $(MAKEDIR)/com32.mk
-REQFLAGS += -I./
+REQFLAGS += -I$(SRC)
-SUBDIRS := .
-LIBOBJS := $(foreach dir,$(SUBDIRS),$(patsubst %.c,%.o,$(wildcard $(dir)/*.c)))
+LIBOBJS := $(notdir $(patsubst %.c,%.o,$(wildcard $(SRC)/*.c)))
BINDIR = /usr/bin
LIBDIR = /usr/lib
mkdir -m 755 -p $(INSTALLROOT)$(COM32DIR)
install -m 644 libcom32upload.a $(INSTALLROOT)$(COM32DIR)
mkdir -p $(INSTALLROOT)$(COM32DIR)/include/
- cp -r *.h $(INSTALLROOT)$(COM32DIR)/include/
+ cp -r $(SRC)/*.h $(INSTALLROOT)$(COM32DIR)/include/
-include .*.d */.*.d */*/.*.d
## Utility companion library for the COM32 library
##
-topdir = ../..
-MAKEDIR = $(topdir)/mk
+VPATH = $(SRC)
include $(MAKEDIR)/elf.mk
LIBOBJS = ansiline.o ansiraw.o keyname.o \
## Lua Makefile
##
-topdir = ../../..
-MAKEDIR = $(topdir)/mk
+VPATH = $(SRC)
include $(MAKEDIR)/elf.mk
LNXLIBS =
## Multiboot module
##
-topdir = ../..
-MAKEDIR = $(topdir)/mk
+VPATH = $(SRC)
include $(MAKEDIR)/elf.mk
-LNXLIBS = ../libutil/libutil_lnx.a
+LNXLIBS = $(objdir)/com32/libutil/libutil_lnx.a
MODULES = mboot.c32
TESTFILES =
## Simple menu system
##
-topdir = ../..
-MAKEDIR = $(topdir)/mk
+VPATH = $(SRC)
include $(MAKEDIR)/elf.mk
-LNXLIBS = ../libutil/libutil_lnx.a
+LNXLIBS = $(objdir)/com32/libutil/libutil_lnx.a
MODULES = menu.c32 vesamenu.c32
TESTFILES =
-COMMONOBJS = menumain.o readconfig.o passwd.o drain.o printmsg.o colors.o \
- background.o refstr.o
+COMMONOBJS = menumain.o readconfig.o passwd.o drain.o \
+ printmsg.o colors.o background.o refstr.o
all: $(MODULES) $(TESTFILES)
-menu.c32 : menu.o $(COMMONOBJS) $(C_LIBS)
- $(LD) $(LDFLAGS) -o $@ $^
-
-vesamenu.c32 : vesamenu.o $(COMMONOBJS) $(C_LIBS)
- $(LD) $(LDFLAGS) -o $@ $^
-
vesamenu.c32: vesamenu.o $(COMMONOBJS) $(C_LIBS)
$(LD) $(LDFLAGS) -o $@ $^
## COM32 standard modules
##
-LIBS = $(com32)/gpllib/libcom32gpl.c32 $(com32)/lib/libcom32.c32 \
- $(com32)/libutil/libutil_com.c32
+LIBS = $(objdir)/com32/gpllib/libcom32gpl.c32 \
+ $(objdir)/com32/lib/libcom32.c32 \
+ $(objdir)/com32/libutil/libutil_com.c32
-topdir = ../..
-MAKEDIR = $(topdir)/mk
+VPATH = $(SRC)
include $(MAKEDIR)/elf.mk
MODULES = config.c32 ethersel.c32 dmitest.c32 cpuidtest.c32 \
dmitest.o: dmitest.c
$(CC) $(CFLAGS) $(GPLINCLUDE) -c -o $@ $<
-dmitest.c32 : dmi_utils.o dmitest.o $(GPLLIB) $(LIBS) $(C_LIBS)
+dmitest.c32 : dmi_utils.o dmitest.o $(GPLLIB) $(LIBS) $(C_LIBS)
$(LD) $(LDFLAGS) -o $@ $^
tidy dist:
## ROSH Read Only Shell
##
-LIBS = $(com32)/libutil/libutil_com.c32 $(com32)/lib/libcom32.c32
+LIBS = $(objdir)/com32/libutil/libutil_com.c32 \
+ $(objdir)/com32/lib/libcom32.c32
-topdir = ../..
-MAKEDIR = $(topdir)/mk
+VPATH = $(SRC)
include $(MAKEDIR)/rosh.mk
# from com32/sysdump/Makefile
* debugging enabled; Comment to remove.
*/
#include "rosh.h"
-#include "../../version.h"
+#include "version.h"
#define APP_LONGNAME "Read-Only Shell"
#define APP_NAME "rosh"
## samples for syslinux users
##
-LIBS = $(com32)/libutil/libutil_com.c32
+LIBS = $(objdir)/com32/libutil/libutil_com.c32
-topdir = ../..
-MAKEDIR = $(topdir)/mk
+VPATH = $(SRC)
include $(MAKEDIR)/elf.mk
all: hello.c32 resolv.c32 serialinfo.c32 \
- localboot.c32 \
- fancyhello.c32 fancyhello.lnx \
- keytest.c32 keytest.lnx \
- advdump.c32 entrydump.c32
+ localboot.c32 \
+ fancyhello.c32 fancyhello.lnx \
+ keytest.c32 keytest.lnx \
+ advdump.c32 entrydump.c32
tidy dist:
rm -f *.o *.lo *.a *.lst *.elf .*.d *.tmp
## Simple menu system
##
-topdir = ../..
-MAKEDIR = $(topdir)/mk
+VPATH = $(SRC)
include $(MAKEDIR)/elf.mk
-include $(topdir)/version.mk
-LIBS = ../libupload/libcom32upload.a
-LNXLIBS = ../libutil/libutil_lnx.a
+LIBS = $(objdir)/com32/libupload/libcom32upload.a
+LNXLIBS = $(objdir)/com32/libutil/libutil_lnx.a
CFLAGS += -I$(com32) -I$(topdir)
MODULES = sysdump.c32
TESTFILES =
-SRCS = $(wildcard *.c)
-OBJS = $(patsubst %.c,%.o,$(SRCS))
+SRCS = $(wildcard $(SRC)/*.c)
+OBJS = $(subst $(SRC)/,,$(patsubst %.c,%.o,$(SRCS)))
# The DATE is set on the make command line when building binaries for
# official release. Otherwise, substitute a hex string that is pretty much
##
## -----------------------------------------------------------------------
-MAKEDIR = ../../mk
+VPATH = $(SRC)
include $(MAKEDIR)/build.mk
BINS = relocs
-INCLUDES += -I./include
+INCLUDES += -I$(SRC)/include
all : $(BINS)
# Makefile for the SYSLINUX core
#
+VPATH = $(SRC)
+
# No builtin rules
MAKEFLAGS += -r
MAKE += -r
-topdir = ..
-MAKEDIR = $(topdir)/mk
+ifdef EFI_BUILD
+include $(MAKEDIR)/lib.mk
+include $(MAKEDIR)/efi.mk
+else
include $(MAKEDIR)/embedded.mk
--include $(topdir)/version.mk
+-include $(objdir)/version.mk
+endif
OPTFLAGS =
-INCLUDES = -I./include -I$(com32)/include -I$(com32)/include/sys -I$(com32)/lib
+INCLUDES = -I$(SRC)/include -I$(com32)/include -I$(com32)/include/sys -I$(com32)/lib
# This is very similar to cp437; technically it's for Norway and Denmark,
# but it's unlikely the characters that are different will be used in
isolinux.bin isolinux-debug.bin pxelinux.0
# All primary source files for the main syslinux files
-NASMSRC := $(wildcard *.asm)
-NASMHDR := $(wildcard *.inc)
-CSRC := $(wildcard *.c */*.c */*/*.c)
-SSRC := $(wildcard *.S */*.S */*/*.S)
-CHDR := $(wildcard *.h */*.h */*/*.h)
+NASMSRC := $(wildcard $(SRC)/*.asm)
+NASMHDR := $(wildcard $(SRC)/*.inc)
+CSRC := $(wildcard $(SRC)/*.c $(SRC)/*/*.c $(SRC)/*/*/*.c)
+SSRC := $(wildcard $(SRC)/*.S $(SRC)/*/*.S $(SRC)/*/*/*.S)
+CHDR := $(wildcard $(SRC)/*.h $(SRC)/*/*.h $(SRC)/*/*/*.h)
OTHERSRC := keywords
ALLSRC = $(NASMSRC) $(NASMHDR) $(CSRC) $(SSRC) $(CHDR) $(OTHERSRC)
-COBJ := $(patsubst %.c,%.o,$(CSRC))
-SOBJ := $(patsubst %.S,%.o,$(SSRC))
+COBJ := $(subst $(SRC)/,,$(patsubst %.c,%.o,$(CSRC)))
+SOBJ := $(subst $(SRC)/,,$(patsubst %.S,%.o,$(SSRC)))
# Don't include derivative-specific objects
-COBJS = $(filter-out rawcon.o plaincon.o pxelinux-c.o ldlinux-c.o isolinux-c.o,$(COBJ))
+COBJS = $(filter-out %rawcon.o %plaincon.o %pxelinux-c.o %ldlinux-c.o %isolinux-c.o,$(COBJ))
LIB = libcom32.a
-LIBS = $(LIB) --whole-archive $(com32)/lib/libcom32core.a
+LIBS = $(LIB) --whole-archive $(objdir)/com32/lib/libcom32core.a
LIBDEP = $(filter-out -% %start%,$(LIBS))
LIBOBJS = $(COBJS) $(SOBJ)
NASMDEBUG = -g -F dwarf
NASMOPT += $(NASMDEBUG)
-PREPCORE = ../lzo/prepcore
+PREPCORE = $(OBJ)/../lzo/prepcore
CFLAGS += -D__SYSLINUX_CORE__
# official release. Otherwise, substitute a hex string that is pretty much
# guaranteed to be unique to be unique from build to build.
ifndef HEXDATE
-HEXDATE := $(shell $(PERL) ../now.pl $(SRCS))
+HEXDATE := $(shell $(PERL) $(SRC)/../now.pl $(SRCS))
endif
ifndef DATE
-DATE := $(shell sh ../gen-id.sh $(VERSION) $(HEXDATE))
+DATE := $(shell sh $(SRC)/../gen-id.sh $(VERSION) $(HEXDATE))
endif
# Set up the NASM and LD options for the architecture
LD_PIE =
endif
-all: $(BTARGET) clean
+ifdef EFI_BUILD
+all: makeoutputdirs $(filter-out %bios.o,$(COBJS)) codepage.o
+else
+all: makeoutputdirs $(BTARGET)
+endif
+
+makeoutputdirs:
+ @mkdir -p $(sort $(dir $(COBJ) $(SOBJ)))
kwdhash.gen: keywords genhash.pl
- $(PERL) genhash.pl < keywords > kwdhash.gen
+ $(PERL) $(SRC)/genhash.pl < $(SRC)/keywords > $(OBJ)/kwdhash.gen
.PRECIOUS: %.elf
$(OBJCOPY) -O binary -S $< $(@:.bin=.raw)
# GNU make 3.82 gets confused by the first form
-.PRECIOUS: %.raw
+.PRECIOUS: $(OBJ)/%.raw
%.bin: %.raw $(PREPCORE)
$(PREPCORE) $< $@
-%.o: %.asm kwdhash.gen ../version.gen
+%.o: %.asm kwdhash.gen $(OBJ)/../version.gen
$(NASM) -f $(NASM_ELF) $(NASMOPT) -DDATE_STR="'$(DATE)'" \
-DHEXDATE="$(HEXDATE)" \
-D$(ARCH) \
- -l $(@:.o=.lsr) -o $@ -MP -MD .$@.d $<
+ -I$(SRC)/ \
+ -l $(@:.o=.lsr) -o $@ -MP -MD $(dir $@).$(notdir $@).d $<
AUXLIBS = libisolinux.a libisolinux-debug.a libldlinux.a libpxelinux.a
+LDSCRIPT = $(SRC)/$(ARCH)/syslinux.ld
-%.elf: %.o $(LIBDEP) $(ARCH)/syslinux.ld $(AUXLIBS)
- $(LD) $(LDFLAGS) -Bsymbolic $(LD_PIE) -E --hash-style=gnu -T $(ARCH)/syslinux.ld -M -o $@ $< \
- --start-group $(LIBS) lib$(patsubst %.elf,%.a,$@) --end-group \
+%.elf: %.o $(LIBDEP) $(LDSCRIPT) $(AUXLIBS)
+ $(LD) $(LDFLAGS) -Bsymbolic $(LD_PIE) -E --hash-style=gnu -T $(LDSCRIPT) -M -o $@ $< \
+ --start-group $(LIBS) $(subst $(*F).elf,lib$(*F).a,$@) --end-group \
> $(@:.elf=.map)
$(OBJDUMP) -h $@ > $(@:.elf=.sec)
- $(PERL) lstadjust.pl $(@:.elf=.lsr) $(@:.elf=.sec) $(@:.elf=.lst)
+ $(PERL) $(SRC)/lstadjust.pl $(@:.elf=.lsr) $(@:.elf=.sec) $(@:.elf=.lst)
libisolinux.a: rawcon.o isolinux-c.o
rm -f $@
ldlinux.sys: ldlinux.bin
dd if=$< of=$@ bs=512 skip=2
-codepage.cp: ../codepage/$(CODEPAGE).cp
+codepage.cp: $(OBJ)/../codepage/$(CODEPAGE).cp
cp -f $< $@
codepage.o: codepage.S codepage.cp
SUBDIRS = mbr geodsp
all tidy dist clean spotless install:
- set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
+ @mkdir -p $(addprefix $(OBJ)/,$(SUBDIRS))
+ set -e; for d in $(SUBDIRS); \
+ do $(MAKE) -C $(OBJ)/$$d -f $(SRC)/$$d/Makefile \
+ SRC="$(SRC)"/$$d OBJ="$(OBJ)"/$$d $@; done
# Makefile for the SYSLINUX geometry display for diagnostics
#
-topdir = ../..
-MAKEDIR = $(topdir)/mk
include $(MAKEDIR)/embedded.mk
coredir = $(topdir)/core
+VPATH = $(SRC)
BTARGET = geodsp1s.bin geodspms.bin \
geodsp1s.img.xz geodspms.img.xz
-NASMOPT = -i $(coredir)/ -Ox -f bin
+NASMOPT = -i $(coredir)/ -i $(SRC)/ -Ox -f bin
NASMOPT += -w+orphan-labels
CFLAGS = -g -O
# Higher compression levels result in larger files
%.img.xz: %.bin mk-lba-img.pl
- $(PERL) mk-lba-img $< | $(XZ) -0 > $@ || ( rm -f $@ ; false )
+ $(PERL) $(SRC)/mk-lba-img $< | $(XZ) -0 > $@ || ( rm -f $@ ; false )
%.img.gz: %.bin mk-lba-img.pl
- $(PERL) mk-lba-img $< | $(GZIPPROG) -9 > $@ || ( rm -f $@ ; false )
+ $(PERL) $(SRC)/mk-lba-img $< | $(GZIPPROG) -9 > $@ || ( rm -f $@ ; false )
# in case someone really wants these without needing a decompressor
%.img: %.bin mk-lba-img.pl
# Makefile for MBR
#
-topdir = ../..
mbrdir = $(topdir)/mbr
-MAKEDIR = $(topdir)/mk
include $(MAKEDIR)/embedded.mk
+VPATH = $(SRC)
all: handoff.bin
--- /dev/null
+ Building Syslinux
+
+From Syslinux 6.0 onwards there is support for three different
+firmware backends, BIOS, 32-bit EFI and 64-bit EFI. To allow users the
+flexibility to build only the firmware they need the Syslinux make
+infrastructure has become more complex.
+
+The Syslinux make infrastructure understands the following syntax,
+
+ make [firmware[,firwmware]] [target[,target]]
+
+If no firmware is specified then any targets will be applied to all
+three firmware backends. If no target is specified then the 'all'
+target is implicitly built.
+
+For example, to build the installers for BIOS, 32-bit EFI and 64-bit
+EFI type,
+
+ make installer
+
+TO build the BIOS and 64-bit EFI installers type,
+
+ make bios efi64 installer
+
+To delete all object files and build the installer for 32-bit EFI
+type,
+
+ make efi32 spotless installer
+
+
+ ++++ THE OBJECT DIRECTORY ++++
+
+A custom top-level object directory can be specified on the make
+command-line by using the O= variable, e.g.
+
+ make O=/tmp/syslinux-obj efi32
+
+will build the 32-bit object files under /tmp/syslinux-obj/efi32. If
+no object directory is specified then object files will be written to
+an 'obj' directory in the top-level of the Syslinux source.
## MS-DOS FAT installer
##
-topdir = ..
-MAKEDIR = $(topdir)/mk
include $(MAKEDIR)/embedded.mk
CFLAGS += -D__MSDOS__
# CFLAGS += -DDEBUG
-LDFLAGS = -T dosexe.ld
+LDFLAGS = -T $(SRC)/dosexe.ld
OPTFLAGS = -g
INCLUDES = -include code16.h -nostdinc -iwithprefix include \
- -I. -I.. -I../libfat -I ../libinstaller -I ../libinstaller/getopt
+ -I$(SRC) -I$(SRC)/.. -I$(SRC)/../libfat \
+ -I $(SRC)/../libinstaller -I $(SRC)/../libinstaller/getopt \
+ -I$(objdir)
SRCS = syslinux.c \
../libinstaller/fs.c \
../libinstaller/getopt/getopt_long.c \
../libinstaller/bootsect_bin.c \
../libinstaller/mbr_bin.c \
- $(wildcard ../libfat/*.c)
+ $(wildcard $(SRC)/../libfat/*.c)
OBJS = header.o crt0.o ldlinux.o \
$(patsubst %.c,%.o,$(notdir $(SRCS)))
LIBOBJS = int2526.o conio.o memcpy.o memset.o memmove.o skipatou.o atou.o \
malloc.o free.o getopt_long.o getsetsl.o strchr.o strtoul.o \
strntoumax.o argv.o printf.o __divdi3.o __udivmoddi4.o
-VPATH = .:../libfat:../libinstaller:../libinstaller/getopt
+VPATH = $(SRC):$(SRC)/../libfat:$(SRC)/../libinstaller:$(SRC)/../libinstaller/getopt:$(OBJ)/../libinstaller
TARGETS = syslinux.com
%.com: %.asm
$(NASM) $(NASMOPT) -f bin -o $@ -MP -MD .$@.d -l $*.lst $<
-ldlinux.o: ldlinux.S ../core/ldlinux.sys
+ldlinux.o: ldlinux.S $(OBJ)/../core/ldlinux.sys
-include .*.d *.tmp
#
# OpenWatcom compile and link utility
#
-topdir = ..
-MAKEDIR = $(topdir)/mk
+VPATH = $(SRC)
include $(MAKEDIR)/syslinux.mk
WCL = wcl
WCTARGETS = mdiskchk.com
NSTARGETS = eltorito.sys copybs.com
+WCOBJS = $(addprefix $(SRC)/,$(WCTARGETS))
+NSOBJS = $(addprefix $(OBJ)/,$(NSTARGETS))
TARGETS = $(WCTARGETS) $(NSTARGETS)
%.obj: %.c
install: installer
mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)/dosutil
- install -m 644 $(TARGETS) $(INSTALLROOT)$(AUXDIR)/dosutil
+ install -m 644 $(WCOBJS) $(INSTALLROOT)$(AUXDIR)/dosutil
+ install -m 644 $(NSOBJS) $(INSTALLROOT)$(AUXDIR)/dosutil
##
## -----------------------------------------------------------------------
-topdir = ..
-MAKEDIR = $(topdir)/mk
+VPATH = $(SRC)
include $(MAKEDIR)/lib.mk
include $(MAKEDIR)/efi.mk
CORE_CSRC := $(wildcard $(core)/*.c $(core)/*/*.c $(core)/*/*/*.c)
-CORE_COBJ := $(patsubst %.c,%.o,$(CORE_CSRC))
+CORE_COBJ := $(subst $(core),$(OBJ)/../core/,$(patsubst %.c,%.o,$(CORE_CSRC)))
# Don't include console objects
-CORE_OBJS = $(filter-out $(core)/hello.o $(core)/rawcon.o \
- $(core)/plaincon.o $(core)/strcasecmp.o $(core)/bios.o \
- $(core)/fs/diskio_bios.o $(core)/ldlinux-c.o $(core)/isolinux-c.o \
- $(core)/pxelinux-c.o,$(CORE_COBJ))
-LIB_OBJS = $(addprefix $(com32)/lib/,$(CORELIBOBJS))
+CORE_OBJS = $(filter-out %hello.o %rawcon.o %plaincon.o %strcasecmp.o %bios.o \
+ %diskio_bios.o %ldlinux-c.o %isolinux-c.o %pxelinux-c.o,$(CORE_COBJ))
-CSRC = $(wildcard *.c)
-OBJ = $(patsubst %.c,%.o,$(CSRC))
-OBJS = $(filter-out wrapper.o,$(OBJ))
+LIB_OBJS = $(addprefix $(objdir)/com32/lib/,$(CORELIBOBJS))
-OBJS += $(core)/codepage.o
+CSRC = $(wildcard $(SRC)/*.c)
+OBJS = $(subst $(SRC)/,,$(filter-out %wrapper.o, $(patsubst %.c,%.o,$(CSRC))))
+
+OBJS += $(objdir)/core/codepage.o
# The targets to build in this directory
BTARGET = syslinux.efi
#
# Build the wrapper app and wrap our .so to produce a .efi
syslinux.efi: syslinux.so wrapper
- ./wrapper syslinux.so $@
+ $(OBJ)/wrapper syslinux.so $@
all: $(BTARGET)
-$(core)/codepage.o: ../codepage/cp865.cp
- cp ../codepage/cp865.cp codepage.cp
+codepage.o: ../codepage/cp865.cp
+ cp $(objdir)/../codepage/cp865.cp codepage.cp
$(CC) $(SFLAGS) -c -o $@ $(core)/codepage.S
+installer: syslinux.efi
+
+install: all
+ mkdir -m 755 -p $(INSTALLROOT)$(AUXDIR)/efi$(BITS)
+ install -m 755 $(BTARGET) $(INSTALLROOT)$(AUXDIR)/efi$(BITS)
+
tidy dist:
rm -f *.so *.o
find . \( -name \*.o -o -name \*.a -o -name .\*.d -o -name \*.tmp \) -print0 | \
## Linux vfat, ntfs, ext2/ext3/ext4 and btrfs installer
##
-topdir = ..
-MAKEDIR = $(topdir)/mk
include $(MAKEDIR)/syslinux.mk
OPTFLAGS = -g -Os
-INCLUDES = -I. -I.. -I../libinstaller
+INCLUDES = -I$(SRC) -I$(objdir) -I$(SRC)/../libinstaller
CFLAGS = $(GCCWARN) -Wno-sign-compare -D_FILE_OFFSET_BITS=64 \
$(OPTFLAGS) $(INCLUDES)
LDFLAGS =
.SUFFIXES: .c .o .i .s .S
-VPATH = .:../libinstaller
+VPATH = $(SRC):$(SRC)/../libinstaller:$(OBJ)/../libinstaller
all: installer
#include "btrfs.h"
#include "fat.h"
#include "ntfs.h"
-#include "../version.h"
+#include "version.h"
#include "syslxint.h"
#include "syslxcom.h" /* common functions shared with extlinux and syslinux */
#include "syslxfs.h"
# Very simple, really...
#
+VPATH = $(SRC)
TARGETS = gpxelinux.0 gpxelinuxk.0
-PXEMAKE = $(MAKE) -C src NO_WERROR=1
+PXEMAKE = $(MAKE) -C $(SRC)/src NO_WERROR=1
all: $(TARGETS)
clean: tidy
dist:
- $(MAKE) -C src veryclean > /dev/null 2>&1
+ $(MAKE) -C $(SRC)/src veryclean > /dev/null 2>&1
#spotless: clean dist
#Including 'dist' errors out for make ARCH=x86_64 spotless
src/bin/blib.a:
$(PXEMAKE) bin/blib.a
-src/bin/undionly.kkpxe: src/bin/blib.a pxelinux.gpxe ../core/pxelinux.0
- $(PXEMAKE) bin/undionly.kkpxe EMBEDDED_IMAGE=../pxelinux.gpxe,../../core/pxelinux.0
+src/bin/undionly.kkpxe: src/bin/blib.a pxelinux.gpxe $(objdir)/core/pxelinux.0
+ $(PXEMAKE) bin/undionly.kkpxe EMBEDDED_IMAGE=$(SRC)/pxelinux.gpxe,$(objdir)/core/pxelinux.0
gpxelinux.0: src/bin/undionly.kkpxe
- cp -f $< $@
+ cp -f $(SRC)/$< $@
-src/bin/undionly.kpxe: src/bin/blib.a pxelinuxk.gpxe ../core/pxelinux.0
- $(PXEMAKE) bin/undionly.kpxe EMBEDDED_IMAGE=../pxelinuxk.gpxe,../../core/pxelinux.0
+src/bin/undionly.kpxe: src/bin/blib.a pxelinuxk.gpxe $(objdir)/core/pxelinux.0
+ $(PXEMAKE) bin/undionly.kpxe EMBEDDED_IMAGE=$(SRC)/pxelinuxk.gpxe,$(objdir)/core/pxelinux.0
gpxelinuxk.0: src/bin/undionly.kpxe
- cp -f $< $@
+ cp -f $(SRC)/$< $@
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)
tidy:
rm -f $(BINFILES)
#include <string.h>
#include <getopt.h>
#include <sysexits.h>
-#include "../version.h"
+#include "version.h"
#include "syslxcom.h"
#include "syslxfs.h"
#include "syslxopt.h"
## Linux FAT/NTFS installer
##
-topdir = ..
-MAKEDIR = $(topdir)/mk
include $(MAKEDIR)/syslinux.mk
OPTFLAGS = -g -Os
-INCLUDES = -I. -I.. -I../libinstaller
+INCLUDES = -I$(SRC) -I$(objdir) -I$(SRC)/../libinstaller
CFLAGS = $(GCCWARN) -D_FILE_OFFSET_BITS=64 $(OPTFLAGS) $(INCLUDES)
LDFLAGS =
.SUFFIXES: .c .o .i .s .S
-VPATH = .:../libinstaller
+VPATH = $(SRC):$(SRC)/../libinstaller:$(OBJ)/../libinstaller
all: installer
##
## -----------------------------------------------------------------------
-topdir = ..
-MAKEDIR = $(topdir)/mk
+VPATH = $(SRC)
include $(MAKEDIR)/build.mk
-INCLUDES += -I./include
+INCLUDES += -I$(SRC)/include
-LIBOBJS = $(patsubst %.c,%.o,$(wildcard src/*.c))
+LIBOBJS = $(patsubst %.c,%.o,$(subst $(SRC)/,,$(wildcard $(SRC)/src/*.c)))
LIB = lzo.a
BINS = prepcore
-all : $(BINS)
+all : makeoutputdirs $(BINS)
+
+makeoutputdirs:
+ @mkdir -p $(OBJ)/src
$(LIB) : $(LIBOBJS)
rm -f $@
# Makefile for MBR
#
-topdir = ..
-MAKEDIR = $(topdir)/mk
+VPATH = $(SRC)
+
include $(MAKEDIR)/embedded.mk
all: mbr.bin altmbr.bin gptmbr.bin isohdpfx.bin isohdppx.bin \
.PRECIOUS: %.elf
#%.elf: %.o mbr.ld
-%.elf: %.o $(ARCH)/mbr.ld
- $(LD) $(LDFLAGS) -T $(ARCH)/mbr.ld -e _start -o $@ $<
+%.elf: %.o $(SRC)/$(ARCH)/mbr.ld
+ $(LD) $(LDFLAGS) -T $(SRC)/$(ARCH)/mbr.ld -e _start -o $@ $<
-%.bin: %.elf checksize.pl
+%.bin: %.elf $(SRC)/checksize.pl
$(OBJCOPY) -O binary $< $@
- $(PERL) checksize.pl $@
+ $(PERL) $(SRC)/checksize.pl $@
$(CHMOD) -x $@
mbr_bin.c: mbr.bin
+install:
+
tidy dist:
rm -f *.o *.elf *.lst .*.d
##
## -----------------------------------------------------------------------
-topdir = ..
-MAKEDIR = $(topdir)/mk
include $(MAKEDIR)/embedded.mk
-include $(topdir)/version.mk
-INCLUDES = -I$(topdir)/com32/include
+INCLUDES = -I$(topdir)/com32/include -I$(objdir)
CFLAGS += -D__MEMDISK__ -DDATE='"$(DATE)"'
LDFLAGS = $(GCCOPT) -g
NASM = nasm
NASMOPT = -Ox
NFLAGS = -dDATE='"$(DATE)"'
-NINCLUDE =
+NINCLUDE = -I$(SRC)/
+VPATH = $(SRC)
SRCS = $(wildcard *.asm *.c *.h)
# The DATE is set on the make command line when building binaries for
# official release. Otherwise, substitute a hex string that is pretty much
# guaranteed to be unique to be unique from build to build.
ifndef HEXDATE
-HEXDATE := $(shell $(PERL) ../now.pl $(SRCS))
+HEXDATE := $(shell $(PERL) $(SRC)/../now.pl $(SRCS))
endif
ifndef DATE
-DATE := $(shell sh ../gen-id.sh $(VERSION) $(HEXDATE))
+DATE := $(shell sh $(SRC)/../gen-id.sh $(VERSION) $(HEXDATE))
endif
# Important: init.o16 must be first!!
$(OBJCOPY) -O binary $< $@
memdisk: memdisk16.bin memdisk32.bin postprocess.pl
- $(PERL) postprocess.pl $@ memdisk16.bin memdisk32.bin
+ $(PERL) $(SRC)/postprocess.pl $@ memdisk16.bin memdisk32.bin
e820test: e820test.c e820func.c msetup.c
$(CC) -m32 -g $(GCCWARN) -DTEST -o $@ $^
#include "conio.h"
#include "version.h"
#include "memdisk.h"
-#include "../version.h"
+#include <version.h>
const char memdisk_version[] = "MEMDISK " VERSION_STR " " DATE;
const char copyright[] =
## memory dump utility
##
-topdir = ..
-MAKEDIR = $(topdir)/mk
+VPATH = $(SRC)
include $(MAKEDIR)/embedded.mk
OPTFLAGS =
-INCLUDES = -include code16.h -I.
-LDFLAGS = -T com16.ld
+INCLUDES = -include $(SRC)/code16.h -I$(SRC)
+LDFLAGS = -T $(SRC)/com16.ld
SRCS = main.c serial.c ymsend.c srecsend.c
OBJS = crt0.o $(patsubst %.c,%.o,$(notdir $(SRCS)))
CRT0 := $(shell find $(LIBDIR) -name crt0-efi-$(EFI_SUBARCH).o 2>/dev/null | tail -n1)
LDSCRIPT := $(shell find $(LIBDIR) -name elf_$(EFI_SUBARCH)_efi.lds 2>/dev/null | tail -n1)
-LDFLAGS = -T $(ARCH)/syslinux.ld -Bsymbolic -pie -nostdlib -znocombreloc \
+LDFLAGS = -T $(SRC)/$(ARCH)/syslinux.ld -Bsymbolic -pie -nostdlib -znocombreloc \
-L$(LIBDIR) --hash-style=gnu -m elf_$(ARCH) $(CRT0) -E
SFLAGS = $(GCCOPT) $(GCCWARN) $(SARCHOPT) \
core = $(topdir)/core
ifneq ($(NOGPL),1)
-GPLLIB = $(com32)/gpllib/libcom32gpl.c32
+GPLLIB = $(objdir)/com32/gpllib/libcom32gpl.c32
GPLINCLUDE = -I$(com32)/gplinclude
else
GPLLIB =
-fomit-frame-pointer -D__COM32__ -DDYNAMIC_MODULE \
-nostdinc -iwithprefix include \
-I$(com32)/libutil/include -I$(com32)/include \
- -I$(com32)/include/sys $(GPLINCLUDE) -I$(core)/include
+ -I$(com32)/include/sys $(GPLINCLUDE) -I$(core)/include \
+ -I$(objdir)
SFLAGS = $(GCCOPT) -D__COM32__
LDFLAGS = -m elf_$(ARCH) -shared --hash-style=gnu -T $(com32)/lib/$(ARCH)/elf.ld --as-needed
LIBGCC := $(shell $(CC) $(GCCOPT) --print-libgcc)
LNXSFLAGS = -g
LNXLDFLAGS = -g
-C_LIBS = $(com32)/libutil/libutil_com.c32 $(GPLLIB) \
- $(com32)/lib/libcom32.c32
-C_LNXLIBS = $(com32)/libutil/libutil_lnx.a \
- $(com32)/elflink/ldlinux/ldlinux_lnx.a
+C_LIBS = $(objdir)/com32/libutil/libutil_com.c32 $(GPLLIB) \
+ $(objdir)/com32/lib/libcom32.c32
+C_LNXLIBS = $(objdir)/com32/libutil/libutil_lnx.a \
+ $(objdir)/com32/elflink/ldlinux/ldlinux_lnx.a
.SUFFIXES: .lss .c .o
GCCOPT += $(call gcc_ok,-falign-labels=0,-malign-labels=0)
GCCOPT += $(call gcc_ok,-falign-loops=0,-malign-loops=0)
-INCLUDE = -I.
+INCLUDE = -I$(SRC)
STRIP = strip --strip-all -R .comment -R .note
# zlib and libpng configuration flags
# LIBFLAGS += -DPNG_NO_FLOATING_POINT_SUPPORTED
REQFLAGS = $(GCCOPT) -g -D__COM32__ \
- -nostdinc -iwithprefix include -I. -I./sys -I../include \
- -I../include/sys -I../../core/include -I$(com32)/lib/ \
- -I$(com32)/lib/sys/module
+ -nostdinc -iwithprefix include -I. -I$(SRC)/sys \
+ -I$(SRC)/../include -I$(com32)/include/sys \
+ -I$(topdir)/core/include -I$(com32)/lib/ \
+ -I$(com32)/lib/sys/module -I$(OBJ)/../..
OPTFLAGS = -Os -march=$(MARCH) -falign-functions=0 -falign-jumps=0 \
-falign-labels=0 -ffast-math -fomit-frame-pointer
WARNFLAGS = $(GCCWARN) -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Winline
endif
CFLAGS = $(OPTFLAGS) $(REQFLAGS) $(WARNFLAGS) $(LIBFLAGS)
+VPATH = $(SRC)
LIBOTHER_OBJS = \
atoi.o atol.o atoll.o calloc.o creat.o \
fgets.o fprintf.o fputc.o \
sys/zfile.o sys/zfopen.o
MINLIBOBJS = \
- syslinux/ipappend.o \
+ $(addprefix $(OBJ)/,syslinux/ipappend.o \
syslinux/dsinfo.o \
$(LIBOTHER_OBJS) \
$(LIBGCC_OBJS) \
$(LIBCONSOLE_OBJS) \
$(LIBLOAD_OBJS) \
- $(LIBZLIB_OBJS)
+ $(LIBZLIB_OBJS))
# $(LIBVESA_OBJS)
CORELIBOBJS = \
% : %.S
-.c.o:
+%.o: %.c
$(CC) $(MAKEDEPS) $(CFLAGS) -c -o $@ $<
.c.i:
$(CC) $(MAKEDEPS) $(CFLAGS) -E -o $@ $<
-.c.s:
+%.s: %.c
$(CC) $(MAKEDEPS) $(CFLAGS) -S -o $@ $<
-.S.o:
+%.o: %.S
$(CC) $(MAKEDEPS) $(CFLAGS) -D__ASSEMBLY__ -c -o $@ $<
.S.s:
.S.ls:
$(CC) $(MAKEDEPS) $(CFLAGS) $(SOFLAGS) -D__ASSEMBLY__ -E -o $@ $<
-.s.o:
+%(OBJ)/%.o: $(SRC)/%.s
$(CC) $(MAKEDEPS) $(CFLAGS) -x assembler -c -o $@ $<
.ls.lo:
## Non-COM32 simple Syslinux modules
##
-topdir = ..
-MAKEDIR = $(topdir)/mk
+VPATH = $(SRC)
include $(MAKEDIR)/embedded.mk
INCLUDES = -I$(com32)/include
+NASMOPT = -I$(SRC)/ -I$(SRC)/../core/
BINS = pxechain.com poweroff.com int18.com ver.com
-topdir = ..
-MAKEDIR = $(topdir)/mk
include $(MAKEDIR)/syslinux.mk
OPTFLAGS = -g -Os
-INCLUDES = -I. -I.. -I../libfat -I../libinstaller
+INCLUDES = -I$(SRC) -I$(objdir) -I$(SRC)/../libfat -I$(SRC)/../libinstaller
CFLAGS = $(GCCWARN) -D_FILE_OFFSET_BITS=64 $(OPTFLAGS) $(INCLUDES)
LDFLAGS =
../libinstaller/setadv.c \
../libinstaller/bootsect_bin.c \
../libinstaller/ldlinux_bin.c \
- $(wildcard ../libfat/*.c)
+ $(wildcard $(SRC)/../libfat/*.c)
OBJS = $(patsubst %.c,%.o,$(notdir $(SRCS)))
.SUFFIXES: .c .o .i .s .S
-VPATH = .:../libfat:../libinstaller
+VPATH = $(SRC):$(SRC)/../libfat:$(SRC)/../libinstaller:$(OBJ)/../libinstaller
all: installer
## samples for syslinux users
##
-topdir = ..
-MAKEDIR = $(topdir)/mk
include $(MAKEDIR)/embedded.mk
+VPATH = $(SRC)
PPMTOLSS16 = $(topdir)/utils/ppmtolss16
# SYSLINUX utilities
#
-topdir = ..
-MAKEDIR = $(topdir)/mk
+VPATH = $(SRC)
include $(MAKEDIR)/syslinux.mk
-CFLAGS = $(GCCWARN) -Os -fomit-frame-pointer -D_FILE_OFFSET_BITS=64
+CFLAGS = $(GCCWARN) -Os -fomit-frame-pointer -D_FILE_OFFSET_BITS=64 -I$(SRC)
LDFLAGS = -O2
C_TARGETS = isohybrid gethostip memdiskfind
SCRIPT_TARGETS = mkdiskimage
SCRIPT_TARGETS += isohybrid.pl # about to be obsoleted
-ASIS = keytab-lilo lss16toppm md5pass ppmtolss16 sha1pass \
- syslinux2ansi pxelinux-options
+ASIS = $(addprefix $(SRC)/,keytab-lilo lss16toppm md5pass \
+ ppmtolss16 sha1pass syslinux2ansi pxelinux-options)
TARGETS = $(C_TARGETS) $(SCRIPT_TARGETS)
-ISOHDPFX = ../mbr/isohdpfx.bin ../mbr/isohdpfx_f.bin ../mbr/isohdpfx_c.bin \
- ../mbr/isohdppx.bin ../mbr/isohdppx_f.bin ../mbr/isohdppx_c.bin
+ISOHDPFX = $(addprefix $(OBJ)/,../mbr/isohdpfx.bin ../mbr/isohdpfx_f.bin \
+ ../mbr/isohdpfx_c.bin \
+ ../mbr/isohdppx.bin ../mbr/isohdppx_f.bin ../mbr/isohdppx_c.bin)
all: $(TARGETS)
$(CC) $(UMAKEDEPS) $(CFLAGS) -c -o $@ $<
mkdiskimage: mkdiskimage.in ../mbr/mbr.bin bin2hex.pl
- $(PERL) bin2hex.pl < ../mbr/mbr.bin | cat mkdiskimage.in - > $@
+ $(PERL) $(SRC)/bin2hex.pl < $(OBJ)/../mbr/mbr.bin | cat $(SRC)/mkdiskimage.in - > $@
chmod a+x $@
# Works on anything with a Perl interpreter...
isohybrid.pl: isohybrid.in $(ISOHDPFX) bin2hex.pl
- cp -f isohybrid.in $@
- for f in $(ISOHDPFX) ; do $(PERL) bin2hex.pl < $$f >> $@ ; done
+ cp -f $(SRC)/isohybrid.in $@
+ for f in $(ISOHDPFX) ; do $(PERL) $(SRC)/bin2hex.pl < $$f >> $@ ; done
chmod a+x $@
isohdpfx.c: $(ISOHDPFX) isohdpfxarray.pl
- $(PERL) isohdpfxarray.pl $(ISOHDPFX) > $@
+ $(PERL) $(SRC)/isohdpfxarray.pl $(ISOHDPFX) > $@
isohybrid: isohybrid.o isohdpfx.o
$(CC) $(LDFLAGS) -o $@ $^ -luuid
ifeq ($(findstring MINGW32,$(OSTYPE)),MINGW32)
WINPREFIX :=
else
-WINPREFIX := $(shell ./find-mingw32.sh gcc)
+WINPREFIX := $(shell $(SRC)/find-mingw32.sh gcc)
endif
WINCFLAGS := $(GCCWARN) -Wno-sign-compare -Os -fomit-frame-pointer \
-D_FILE_OFFSET_BITS=64
WINLDFLAGS := -Os -s
endif
-WINCFLAGS += -I. -I../win -I.. -I../libfat -I../libinstaller \
- -I../libinstaller/getopt
+WINCFLAGS += -I$(SRC) -I$(SRC)/../win -I$(objdir) \
+ -I$(SRC)/../libfat -I$(SRC)/../libinstaller \
+ -I$(SRC)/../libinstaller/getopt
WINCC := $(WINPREFIX)gcc
WINAR := $(WINPREFIX)ar
WINRANLIB := $(WINPREFIX)ranlib
WINCC_IS_GOOD := $(shell $(WINCC) $(WINCFLAGS) $(WINLDFLAGS) \
- -o hello.exe ../win/hello.c >/dev/null 2>&1 ; echo $$?)
+ -o hello.exe $(SRC)/../win/hello.c >/dev/null 2>&1 ; echo $$?)
.SUFFIXES: .c .obj .lib .exe .i .s .S
../libinstaller/bootsect_bin.c \
../libinstaller/ldlinux_bin.c \
../libinstaller/mbr_bin.c \
- $(wildcard ../libfat/*.c)
+ $(wildcard $(SRC)/../libfat/*.c)
LIBOBJS = $(patsubst %.c,%.obj,$(notdir $(LIBSRC)))
LIB = syslinux.lib
-VPATH = .:../win:../libfat:../libinstaller:../libinstaller/getopt
+VPATH = $(SRC):$(SRC)/../win:$(SRC)/../libfat:$(SRC)/../libinstaller:$(SRC)/../libinstaller/getopt:$(OBJ)/../libinstaller
TARGETS = syslinux.exe
OSTYPE = $(shell uname -msr)
# Don't know how to do a native compile here...
-WINPREFIX := $(shell ./find-mingw64.sh gcc)
+WINPREFIX := $(shell $(SRC)/find-mingw64.sh gcc)
WINCFLAGS := $(GCCWARN) -Wno-sign-compare -Os -fomit-frame-pointer \
-D_FILE_OFFSET_BITS=64
WINLDFLAGS := -Os -s
-WINCFLAGS += -I. -I../win -I.. -I../libfat -I../libinstaller \
- -I../libinstaller/getopt
+WINCFLAGS += -I$(SRC) -I$(SRC)/../win -I$(objdir) \
+ -I$(SRC)/../libfat -I$(SRC)/../libinstaller \
+ -I$(SRC)/../libinstaller/getopt
WINCC := $(WINPREFIX)gcc
WINAR := $(WINPREFIX)ar
WINRANLIB := $(WINPREFIX)ranlib
WINCC_IS_GOOD := $(shell $(WINCC) $(WINCFLAGS) $(WINLDFLAGS) \
- -o hello.exe ../win/hello.c >/dev/null 2>&1 ; echo $$?)
+ -o hello.exe $(SRC)/../win/hello.c >/dev/null 2>&1 ; echo $$?)
.SUFFIXES: .c .obj .lib .exe .i .s .S
../libinstaller/bootsect_bin.c \
../libinstaller/ldlinux_bin.c \
../libinstaller/mbr_bin.c \
- $(wildcard ../libfat/*.c)
+ $(wildcard $(SRC)/../libfat/*.c)
LIBOBJS = $(patsubst %.c,%.obj,$(notdir $(LIBSRC)))
LIB = syslinux.lib
-VPATH = .:../win:../libfat:../libinstaller:../libinstaller/getopt
+VPATH = $(SRC):$(SRC)/../win:$(SRC)/../libfat:$(SRC)/../libinstaller:$(SRC)/../libinstaller/getopt:$(OBJ)/../libinstaller
TARGETS = syslinux64.exe