aboutsummaryrefslogtreecommitdiffstats
path: root/mk
diff options
context:
space:
mode:
Diffstat (limited to 'mk')
-rw-r--r--mk/com32.mk42
-rw-r--r--mk/devel.mk2
-rw-r--r--mk/efi.mk69
-rw-r--r--mk/elf.mk46
-rw-r--r--mk/embedded.mk31
-rw-r--r--mk/lib.mk190
-rw-r--r--mk/syslinux.mk6
7 files changed, 341 insertions, 45 deletions
diff --git a/mk/com32.mk b/mk/com32.mk
index bfba0e1b..55dc10c2 100644
--- a/mk/com32.mk
+++ b/mk/com32.mk
@@ -17,13 +17,29 @@
include $(MAKEDIR)/syslinux.mk
+# Support IA32 and x86_64 platforms with one build
+# Set up architecture specifics; for cross compilation, set ARCH as apt
GCCOPT := $(call gcc_ok,-std=gnu99,)
-GCCOPT += $(call gcc_ok,-m32,)
+ifeq ($(strip $(ARCH)),i386)
+ GCCOPT += $(call gcc_ok,-m32,)
+ GCCOPT += $(call gcc_ok,-march=i386)
+ GCCOPT += $(call gcc_ok,-mpreferred-stack-boundary=2,)
+ GCCOPT += $(call gcc_ok,-incoming-stack-boundary=2,)
+endif
+ifeq ($(strip $(ARCH)),x86_64)
+ GCCOPT += $(call gcc_ok,-m64,)
+ GCCOPT += $(call gcc_ok,-march=x86-64)
+ #let the stack-boundary default to whatever it is on 64bit
+ #GCCOPT += $(call gcc_ok,-mpreferred-stack-boundary=8,)
+ #GCCOPT += $(call gcc_ok,-incoming-stack-boundary=8,)
+endif
GCCOPT += $(call gcc_ok,-fno-stack-protector,)
GCCOPT += $(call gcc_ok,-fwrapv,)
GCCOPT += $(call gcc_ok,-freg-struct-return,)
-GCCOPT += -mregparm=3 -DREGPARM=3 -march=i386 -Os
-GCCOPT += $(call gcc_ok,-fPIE,-fPIC)
+GCCOPT += -Os
+# Note -fPIE does not work with ld on x86_64, try -fPIC instead
+# Does BIOS build require -fPIE?
+GCCOPT += $(call gcc_ok,-fPIC)
GCCOPT += $(call gcc_ok,-fno-exceptions,)
GCCOPT += $(call gcc_ok,-fno-asynchronous-unwind-tables,)
GCCOPT += $(call gcc_ok,-fno-strict-aliasing,)
@@ -31,8 +47,10 @@ GCCOPT += $(call gcc_ok,-falign-functions=0,-malign-functions=0)
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)
-GCCOPT += $(call gcc_ok,-mpreferred-stack-boundary=2,)
-GCCOPT += $(call gcc_ok,-incoming-stack-boundary=2,)
+
+ifndef EFI_BUILD
+GCCOPT += -mregparm=3 -DREGPARM=3
+endif
com32 := $(topdir)/com32
RELOCS := $(com32)/tools/relocs
@@ -45,17 +63,19 @@ GPLLIB =
GPLINCLUDE =
endif
-CFLAGS = $(GCCOPT) $(GCCWARN) -march=i386 \
+CFLAGS = $(GCCOPT) $(GCCWARN) \
-fomit-frame-pointer -D__COM32__ \
-nostdinc -iwithprefix include \
- -I$(com32)/libutil/include -I$(com32)/include $(GPLINCLUDE)
-SFLAGS = $(GCCOPT) $(GCCWARN) -march=i386 \
+ -I$(com32)/libutil/include -I$(com32)/include \
+ -I$(com32)/include/sys $(GPLINCLUDE)
+SFLAGS = $(GCCOPT) $(GCCWARN) \
-fomit-frame-pointer -D__COM32__ \
-nostdinc -iwithprefix include \
- -I$(com32)/libutil/include -I$(com32)/include $(GPLINCLUDE)
+ -I$(com32)/libutil/include -I$(com32)/include \
+ -I$(com32)/include/sys $(GPLINCLUDE)
-COM32LD = $(com32)/lib/elf32.ld
-LDFLAGS = -m elf_i386 -shared --hash-style=gnu -T $(COM32LD)
+COM32LD = $(com32)/lib/$(ARCH)/elf.ld
+LDFLAGS = -m elf_$(ARCH) -shared --hash-style=gnu -T $(COM32LD)
LIBGCC := $(shell $(CC) $(GCCOPT) --print-libgcc)
LNXCFLAGS = -I$(com32)/libutil/include $(GCCWARN) -O -g \
diff --git a/mk/devel.mk b/mk/devel.mk
index 421c2e45..b1fca87e 100644
--- a/mk/devel.mk
+++ b/mk/devel.mk
@@ -1,7 +1,7 @@
# Useful while doing development, but not for production.
GCCWARN += -Wno-clobbered
#GCCWARN += -DDEBUG_MALLOC
-# GCCWARN += -DDEBUG_PORT=0x3f8 -DDEBUG=1
+# GCCWARN += -DDEBUG_PORT=0x3f8 -DCORE_DEBUG=1
GCCWARN += -DDYNAMIC_DEBUG
## The following will enable printing ethernet/arp/ip/icmp/tcp/udp headers
diff --git a/mk/efi.mk b/mk/efi.mk
new file mode 100644
index 00000000..a0c33ac4
--- /dev/null
+++ b/mk/efi.mk
@@ -0,0 +1,69 @@
+include $(MAKEDIR)/syslinux.mk
+
+com32 = $(topdir)/com32
+core = $(topdir)/core
+
+# Support IA32 and x86_64 platforms with one build
+# Set up architecture specifics; for cross compilation, set ARCH as apt
+# gnuefi sets up architecture specifics in ia32 or x86_64 sub directories
+# set up the LIBDIR and EFIINC for building for the appropriate architecture
+# For now, the following assumptions are made:
+# 1. gnu-efi lib for IA32 is installed in /usr/local/lib
+# and the include files in /usr/local/include/efi.
+# 2. gnu-efi lib for x86_64 is installed in /usr/lib
+# and the include files in /usr/include/efi.
+ifeq ($(ARCH),i386)
+ SARCHOPT = -march=i386
+ CARCHOPT = -m32 -march=i386
+ EFI_SUBARCH = ia32
+endif
+ifeq ($(ARCH),x86_64)
+ SARCHOPT = -march=x86-64
+ CARCHOPT = -m64 -march=x86-64
+ EFI_SUBARCH = $(ARCH)
+endif
+
+EFIINC = $(shell $(topdir)/efi//find-gnu-efi.sh include $(EFI_SUBARCH))
+$(if $(EFIINC),, \
+ $(error Missing $(EFI_SUBARCH) gnu-efi header files))
+
+LIBDIR = $(shell $(topdir)/efi/find-gnu-efi.sh lib $(EFI_SUBARCH))
+$(if $(LIBDIR),, \
+ $(error Missing $(EFI_SUBARCH) gnu-efi libraries))
+
+#LIBDIR=/usr/lib
+FORMAT=efi-app-$(EFI_SUBARCH)
+
+CFLAGS = -I$(EFIINC) -I$(EFIINC)/$(EFI_SUBARCH) \
+ -DEFI_FUNCTION_WRAPPER -fPIC -fshort-wchar -ffreestanding \
+ -Wall -I$(com32)/include -I$(com32)/include/sys \
+ -I$(core)/include -I$(core)/ $(CARCHOPT) \
+ -I$(com32)/lib/ -I$(com32)/libutil/include -std=gnu99 \
+ -DELF_DEBUG -DSYSLINUX_EFI -I$(objdir) \
+ $(GCCWARN) -D__COM32__ -mno-red-zone \
+ -DLDLINUX=\"$(LDLINUX)\" -fvisibility=hidden \
+ -Wno-unused-parameter
+
+# gnuefi sometimes installs these under a gnuefi/ directory, and sometimes not
+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 $(SRC)/$(ARCH)/syslinux.ld -Bsymbolic -pie -nostdlib -znocombreloc \
+ -L$(LIBDIR) --hash-style=gnu -m elf_$(ARCH) $(CRT0) -E
+
+SFLAGS = $(GCCOPT) $(GCCWARN) $(SARCHOPT) \
+ -fomit-frame-pointer -D__COM32__ \
+ -nostdinc -iwithprefix include \
+ -I$(com32)/libutil/include -I$(com32)/include -I$(com32)/include/sys $(GPLINCLUDE)
+
+.PRECIOUS: %.o
+%.o: %.S
+ $(CC) $(SFLAGS) -c -o $@ $<
+
+.PRECIOUS: %.o
+%.o: %.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+#%.efi: %.so
+# $(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \
+# -j .rela -j .reloc --target=$(FORMAT) $*.so $@
diff --git a/mk/elf.mk b/mk/elf.mk
index 8bc6be08..1ec9b2d9 100644
--- a/mk/elf.mk
+++ b/mk/elf.mk
@@ -16,48 +16,66 @@
include $(MAKEDIR)/syslinux.mk
+# Support IA32 and x86_64 platforms with one build
+# Set up architecture specifics; for cross compilation, set ARCH as apt
GCCOPT := $(call gcc_ok,-std=gnu99,)
-GCCOPT += $(call gcc_ok,-m32,)
+ifeq ($(ARCH),i386)
+ GCCOPT += $(call gcc_ok,-m32,)
+ GCCOPT += $(call gcc_ok,-march=i386)
+ GCCOPT += $(call gcc_ok,-mpreferred-stack-boundary=2,)
+endif
+ifeq ($(ARCH),x86_64)
+ GCCOPT += $(call gcc_ok,-m64,)
+ GCCOPT += $(call gcc_ok,-march=x86-64)
+ #let preferred-stack-boundary be default (=4)
+endif
+GCCOPT += -Os -fomit-frame-pointer
GCCOPT += $(call gcc_ok,-fno-stack-protector,)
GCCOPT += $(call gcc_ok,-fwrapv,)
GCCOPT += $(call gcc_ok,-freg-struct-return,)
-GCCOPT += -march=i386 -Os -fomit-frame-pointer -mregparm=3 -DREGPARM=3
GCCOPT += $(call gcc_ok,-fno-exceptions,)
GCCOPT += $(call gcc_ok,-fno-asynchronous-unwind-tables,)
-GCCOPT += $(call gcc_ok,-fPIE,-fPIC)
+# Note -fPIE does not work with ld on x86_64, try -fPIC instead
+# Does BIOS build depend on -fPIE?
+GCCOPT += $(call gcc_ok,-fPIC)
GCCOPT += $(call gcc_ok,-falign-functions=0,-malign-functions=0)
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)
-GCCOPT += $(call gcc_ok,-mpreferred-stack-boundary=2,)
com32 = $(topdir)/com32
core = $(topdir)/core
ifneq ($(NOGPL),1)
-GPLLIB = $(com32)/gpllib/libgpl.c32
+GPLLIB = $(objdir)/com32/gpllib/libgpl.c32
GPLINCLUDE = -I$(com32)/gplinclude
else
GPLLIB =
GPLINCLUDE =
endif
-CFLAGS = $(GCCOPT) $(GCCWARN) -W -Wall -march=i386 \
+CFLAGS = $(GCCOPT) $(GCCWARN) -W -Wall \
-fomit-frame-pointer -D__COM32__ -DDYNAMIC_MODULE \
-nostdinc -iwithprefix include \
- -I$(com32)/libutil/include -I$(com32)/include $(GPLINCLUDE) \
- -I$(core)/include
-SFLAGS = $(GCCOPT) -D__COM32__ -march=i386
-LDFLAGS = -m elf_i386 -shared --hash-style=gnu -T $(com32)/lib/elf32.ld --as-needed
+ -I$(com32)/libutil/include -I$(com32)/include \
+ -I$(com32)/include/sys $(GPLINCLUDE) -I$(core)/include \
+ -I$(objdir) -DLDLINUX=\"$(LDLINUX)\"
+ifndef EFI_BUILD
+CFLAGS += -mregparm=3 -DREGPARM=3
+endif
+
+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)
LNXCFLAGS = -I$(com32)/libutil/include -W -Wall -O -g -D_GNU_SOURCE
LNXSFLAGS = -g
LNXLDFLAGS = -g
-C_LIBS = $(com32)/libutil/libutil.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.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
diff --git a/mk/embedded.mk b/mk/embedded.mk
index c2f4edf3..1614d8bc 100644
--- a/mk/embedded.mk
+++ b/mk/embedded.mk
@@ -16,13 +16,34 @@
include $(MAKEDIR)/syslinux.mk
-GCCOPT := $(call gcc_ok,-m32,)
+# Support IA32 and x86_64 platforms with one build
+# Set up architecture specifics; for cross compilation, set ARCH as apt
+# Initialize GCCOPT to null to begin with. Without this, make generates
+# recursive error for GCCOPT
+GCCOPT :=
+ifeq ($(ARCH),i386)
+ GCCOPT := $(call gcc_ok,-m32)
+ GCCOPT += $(call gcc_ok,-march=i386)
+ GCCOPT += $(call gcc_ok,-mpreferred-stack-boundary=2,)
+ GCCOPT += $(call gcc_ok,-mincoming-stack-boundary=2,)
+endif
+ifeq ($(ARCH),x86_64)
+ GCCOPT := $(call gcc_ok,-m64)
+ GCCOPT += $(call gcc_ok,-march=x86-64)
+ #let preferred-stack-boundary and incoming-stack-boundary be default(=4)
+# Somewhere down the line ld barfs requiring -fPIC
+ GCCOPT += $(call gcc_ok,-fPIC)
+endif
GCCOPT += $(call gcc_ok,-ffreestanding,)
GCCOPT += $(call gcc_ok,-fno-stack-protector,)
GCCOPT += $(call gcc_ok,-fwrapv,)
GCCOPT += $(call gcc_ok,-freg-struct-return,)
-GCCOPT += -march=i386 -Os -fomit-frame-pointer -mregparm=3 -DREGPARM=3 \
- -msoft-float
+ifdef EFI_BUILD
+GCCOPT += -Os -fomit-frame-pointer -msoft-float
+else
+GCCOPT += -Os -fomit-frame-pointer -mregparm=3 -DREGPARM=3 \
+ -msoft-float
+endif
GCCOPT += $(call gcc_ok,-fno-exceptions,)
GCCOPT += $(call gcc_ok,-fno-asynchronous-unwind-tables,)
GCCOPT += $(call gcc_ok,-fno-strict-aliasing,)
@@ -30,13 +51,11 @@ GCCOPT += $(call gcc_ok,-falign-functions=0,-malign-functions=0)
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)
-GCCOPT += $(call gcc_ok,-mpreferred-stack-boundary=2,)
-GCCOPT += $(call gcc_ok,-mincoming-stack-boundary=2,)
GCCOPT += $(call gcc_ok,-fvisibility=hidden)
LIBGCC := $(shell $(CC) $(GCCOPT) --print-libgcc)
-LD += -m elf_i386
+LD += -m elf_$(ARCH)
# Note: use += for CFLAGS and SFLAGS in case something is set in MCONFIG.local
CFLAGS += $(GCCOPT) -g $(GCCWARN) -Wno-sign-compare $(OPTFLAGS) $(INCLUDES)
diff --git a/mk/lib.mk b/mk/lib.mk
index ca8e41ba..bc516c2c 100644
--- a/mk/lib.mk
+++ b/mk/lib.mk
@@ -2,12 +2,25 @@
include $(MAKEDIR)/syslinux.mk
+# Support IA32 and x86_64 platforms with one build
+# Set up architecture specifics; for cross compilation, set ARCH as apt
GCCOPT := $(call gcc_ok,-std=gnu99,)
-GCCOPT += $(call gcc_ok,-m32,)
+ifeq ($(ARCH),i386)
+ GCCOPT += $(call gcc_ok,-m32,)
+ GCCOPT += $(call gcc_ok,-mpreferred-stack-boundary=2,)
+ MARCH = i386
+endif
+ifeq ($(ARCH),x86_64)
+ GCCOPT += $(call gcc_ok,-m64,)
+ #let preferred-stack-boundary be default(=4)
+ MARCH = x86-64
+endif
GCCOPT += $(call gcc_ok,-fno-stack-protector,)
GCCOPT += $(call gcc_ok,-fwrapv,)
GCCOPT += $(call gcc_ok,-freg-struct-return,)
-GCCOPT += $(call gcc_ok,-fPIE,-fPIC)
+# Note -fPIE does not work with ld on x86_64, try -fPIC instead
+# Does BIOS build require -fPIE?
+GCCOPT += $(call gcc_ok,-fPIC)
GCCOPT += $(call gcc_ok,-fno-exceptions,)
GCCOPT += $(call gcc_ok,-fno-asynchronous-unwind-tables,)
GCCOPT += $(call gcc_ok,-fno-strict-aliasing,)
@@ -15,9 +28,8 @@ GCCOPT += $(call gcc_ok,-falign-functions=0,-malign-functions=0)
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)
-GCCOPT += $(call gcc_ok,-mpreferred-stack-boundary=2,)
-INCLUDE = -I.
+INCLUDE = -I$(SRC)
STRIP = strip --strip-all -R .comment -R .note
# zlib and libpng configuration flags
@@ -31,15 +43,167 @@ LIBFLAGS = -DDYNAMIC_CRC_TABLE -DPNG_NO_CONSOLE_IO \
# fallback anyway, just use that on old machines...
# LIBFLAGS += -DPNG_NO_FLOATING_POINT_SUPPORTED
-REQFLAGS = $(GCCOPT) -g -mregparm=3 -DREGPARM=3 -D__COM32__ \
- -nostdinc -iwithprefix include -I. -I./sys -I../include \
- -I../../core/include
-OPTFLAGS = -Os -march=i386 -falign-functions=0 -falign-jumps=0 \
+REQFLAGS = $(GCCOPT) -g -D__COM32__ \
+ -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
CFLAGS = $(OPTFLAGS) $(REQFLAGS) $(WARNFLAGS) $(LIBFLAGS)
-LDFLAGS = -m elf_i386 --hash-style=gnu -T $(com32)/lib/elf32.ld
+
+ifndef EFI_BUILD
+CFLAGS += -mregparm=3 -DREGPARM=3
+endif
+
+VPATH = $(SRC)
+LIBOTHER_OBJS = \
+ atoi.o atol.o atoll.o calloc.o creat.o \
+ fgets.o fprintf.o fputc.o \
+ putchar.o \
+ getopt.o getopt_long.o \
+ lrand48.o stack.o memccpy.o memchr.o \
+ mempcpy.o memmem.o memmove.o memswap.o \
+ perror.o qsort.o seed48.o \
+ srand48.o sscanf.o \
+ strerror.o errlist.o \
+ strnlen.o \
+ strncat.o strndup.o \
+ stpncpy.o \
+ strntoimax.o strsep.o strspn.o strstr.o \
+ strtoimax.o strtok.o strtol.o strtoll.o strtoull.o \
+ strtoumax.o vprintf.o vsprintf.o \
+ asprintf.o vasprintf.o \
+ vsscanf.o \
+ skipspace.o \
+ chrreplace.o \
+ bufprintf.o \
+ inet.o dhcppack.o dhcpunpack.o \
+ strreplace.o \
+ lstrdup.o \
+ \
+ suffix_number.o \
+ \
+ getcwd.o fdopendir.o \
+ \
+ sys/line_input.o \
+ sys/colortable.o sys/screensize.o \
+ \
+ sys/stdcon_read.o sys/stdcon_write.o sys/rawcon_read.o \
+ sys/rawcon_write.o \
+ sys/null_read.o sys/null_write.o sys/serial_write.o \
+ \
+ sys/xserial_write.o \
+ \
+ sys/ansi.o \
+ \
+ sys/ansicon_write.o sys/ansiserial_write.o \
+ \
+ pci/cfgtype.o pci/scan.o pci/bios.o \
+ pci/readb.o pci/readw.o pci/readl.o \
+ pci/writeb.o pci/writew.o pci/writel.o \
+ \
+ sys/x86_init_fpu.o math/pow.o math/strtod.o \
+ syslinux/disk.o \
+ \
+ syslinux/setup_data.o
+
+## CORE OBJECTS, INCLUDED IN THE ROOT COM32 MODULE
+LIBENTRY_OBJS = \
+ sys/intcall.o sys/farcall.o sys/cfarcall.o sys/zeroregs.o \
+ sys/argv.o sys/sleep.o \
+ sys/fileinfo.o sys/opendev.o sys/read.o sys/write.o sys/ftell.o \
+ sys/close.o sys/open.o sys/fileread.o sys/fileclose.o \
+ sys/openmem.o \
+ sys/isatty.o sys/fstat.o \
+ \
+ dprintf.o vdprintf.o \
+ \
+ syslinux/idle.o \
+ \
+ exit.o
+
+LIBGCC_OBJS = \
+ libgcc/__ashldi3.o libgcc/__udivdi3.o \
+ libgcc/__negdi2.o libgcc/__ashrdi3.o libgcc/__lshrdi3.o \
+ libgcc/__muldi3.o libgcc/__udivmoddi4.o libgcc/__umoddi3.o \
+ libgcc/__divdi3.o libgcc/__moddi3.o
+
+LIBCONSOLE_OBJS = \
+ \
+ sys/openconsole.o sys/line_input.o \
+ sys/colortable.o sys/screensize.o \
+ \
+ sys/stdcon_read.o sys/rawcon_read.o \
+ sys/rawcon_write.o \
+ sys/null_write.o sys/serial_write.o \
+ \
+ sys/xserial_write.o \
+ \
+ sys/ansi.o \
+ \
+ sys/ansicon_write.o sys/ansiserial_write.o \
+ \
+ syslinux/serial.o
+
+LIBLOAD_OBJS = \
+ syslinux/addlist.o syslinux/freelist.o syslinux/memmap.o \
+ syslinux/movebits.o syslinux/shuffle.o syslinux/shuffle_pm.o \
+ syslinux/shuffle_rm.o syslinux/zonelist.o \
+ syslinux/dump_mmap.o syslinux/dump_movelist.o \
+ \
+ syslinux/run_default.o syslinux/run_command.o \
+ syslinux/cleanup.o syslinux/localboot.o syslinux/runimage.o \
+ \
+ syslinux/loadfile.o syslinux/floadfile.o syslinux/zloadfile.o \
+ \
+ syslinux/load_linux.o syslinux/initramfs.o \
+ syslinux/initramfs_file.o syslinux/initramfs_loadfile.o \
+ syslinux/initramfs_archive.o
+
+LIBMODULE_OBJS = \
+ sys/module/common.o sys/module/$(ARCH)/elf_module.o \
+ sys/module/elfutils.o \
+ sys/module/exec.o sys/module/elf_module.o
+
+# ZIP library object files
+LIBZLIB_OBJS = \
+ zlib/adler32.o zlib/compress.o zlib/crc32.o \
+ zlib/uncompr.o zlib/deflate.o zlib/trees.o zlib/zutil.o \
+ zlib/inflate.o zlib/infback.o zlib/inftrees.o zlib/inffast.o \
+ sys/zfile.o sys/zfopen.o
+
+MINLIBOBJS = \
+ $(addprefix $(OBJ)/,syslinux/ipappend.o \
+ syslinux/dsinfo.o \
+ $(LIBOTHER_OBJS) \
+ $(LIBGCC_OBJS) \
+ $(LIBCONSOLE_OBJS) \
+ $(LIBLOAD_OBJS) \
+ $(LIBZLIB_OBJS))
+# $(LIBVESA_OBJS)
+
+CORELIBOBJS = \
+ memcpy.o memset.o memcmp.o printf.o strncmp.o vfprintf.o \
+ strlen.o vsnprintf.o snprintf.o stpcpy.o strcmp.o strdup.o \
+ strcpy.o strncpy.o setjmp.o fopen.o fread.o fread2.o puts.o \
+ strtoul.o strntoumax.o strcasecmp.o \
+ sprintf.o strlcat.o strchr.o strlcpy.o strncasecmp.o ctypes.o \
+ fputs.o fwrite2.o fwrite.o fgetc.o fclose.o lmalloc.o \
+ sys/err_read.o sys/err_write.o sys/null_read.o \
+ sys/stdcon_write.o \
+ syslinux/memscan.o strrchr.o strcat.o \
+ libgcc/__ashldi3.o libgcc/__udivdi3.o \
+ libgcc/__negdi2.o libgcc/__ashrdi3.o libgcc/__lshrdi3.o \
+ libgcc/__muldi3.o libgcc/__udivmoddi4.o libgcc/__umoddi3.o \
+ libgcc/__divdi3.o libgcc/__moddi3.o \
+ syslinux/debug.o \
+ $(LIBENTRY_OBJS) \
+ $(LIBMODULE_OBJS)
+
+LDFLAGS = -m elf_$(ARCH) --hash-style=gnu -T $(com32)/lib/$(ARCH)/elf.ld
.SUFFIXES: .c .o .a .so .lo .i .S .s .ls .ss .lss
@@ -47,16 +211,16 @@ LDFLAGS = -m elf_i386 --hash-style=gnu -T $(com32)/lib/elf32.ld
% : %.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:
@@ -68,7 +232,7 @@ LDFLAGS = -m elf_i386 --hash-style=gnu -T $(com32)/lib/elf32.ld
.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:
diff --git a/mk/syslinux.mk b/mk/syslinux.mk
index 2e12072e..337560bb 100644
--- a/mk/syslinux.mk
+++ b/mk/syslinux.mk
@@ -72,6 +72,12 @@ WGET = wget
com32 = $(topdir)/com32
+# Architecture definition
+SUBARCH := $(shell uname -m | sed -e s/i.86/i386/)
+# on x86_64, ARCH has trailing whitespace
+# strip white spaces in ARCH
+ARCH ?= $(strip $(SUBARCH))
+
# Common warnings we want for all gcc-generated code
GCCWARN = -W -Wall -Wstrict-prototypes $(DEBUGOPT)