aboutsummaryrefslogtreecommitdiffstats
path: root/mk/elf.mk
diff options
context:
space:
mode:
Diffstat (limited to 'mk/elf.mk')
-rw-r--r--mk/elf.mk42
1 files changed, 28 insertions, 14 deletions
diff --git a/mk/elf.mk b/mk/elf.mk
index 160dadcc..76b5487e 100644
--- a/mk/elf.mk
+++ b/mk/elf.mk
@@ -16,48 +16,62 @@
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/libcom32gpl.c32
+GPLLIB = $(objdir)/com32/gpllib/libcom32gpl.c32
GPLINCLUDE = -I$(com32)/gplinclude
else
GPLLIB =
GPLINCLUDE =
endif
-CFLAGS = $(GCCOPT) -W -Wall -march=i386 \
+CFLAGS = $(GCCOPT) -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)
+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_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