path: root/mk/com32.mk
diff options
authorchandramouli narayanan <mouli@linux.intel.com>2012-06-25 12:45:26 -0700
committerchandramouli narayanan <mouli@linux.intel.com>2012-06-25 12:45:26 -0700
commit38e58635d3868c23537fc5dce87b152a52df34ad (patch)
treef5677ef70b952068e8ebcd0f20daf06f50f8c178 /mk/com32.mk
parentd8eede3f2a360163235fad222a0190cd7c5bef38 (diff)
The make files have undergone changes to support both i386 and x86_64 platforms.
Pertinent changes are sprinkled through *.mk and Makefile in the syslinux tree. Build architecture is specified at the command line via ARCH macro. This is to enable whether one is building for the native platform or cross-building for a different architecture. Currently, the only supported architectures via ARCH macro are i386 and x86_64. There are some modules (e.g. memdump) that don't build under the EFI environment. To go forward with efi boot support, a separate EFI_BUILD=1 macro has been added and is required to be specified while building. This is a temporary solution for the current build environment. example build: On a x86_64 platform, the following cross-builds syslinux for i386 To build for i386: make EFI_BUILD=1 ARCH=i386 On a x86_64 platform, the following builds syslinux for x86_64 To build natively: make EFI_BUILD=1 Changes specific to GCC and LD options: Architecture specific flags and include/search directories are set up for GCC and LD commands. Internally, GCC options such as stack-boundary, PIC and machine architecture are set up based on ARCH macro. While stack-boundary=2 is fine for i386, it does not work for x86_64 and so it is left to the default value. Using -fPIE with gcc does not work with ld on x86_64, but -fPIC works fine. Similarly, target and elf options are set up for linking as approrpriate for architecture. Assumption about gnu-efi install path: Since the EFI build supports both EFI32 and EFI64, the following assumptions are made with regard to the installed location of gnu-efi on the build platform. 1. gnu-efi-ia32: assumed installed in /usr/local [ EFI-32 include files in /usr/local/include/efi and gnu-efi library in /usr/local/lib/ ] 2. gnu-efi-x86_64: assumed installed in /usr [ EFI-64 include files in /usr/include/efi and gnu-efi library in /usr/lib64/ ] Remanants of the unused old i386-only files, if any, need to be pruned.
Diffstat (limited to 'mk/com32.mk')
1 files changed, 27 insertions, 11 deletions
diff --git a/mk/com32.mk b/mk/com32.mk
index db716c0d..32973407 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,)
+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,)
GCCOPT += $(call gcc_ok,-fno-stack-protector,)
GCCOPT += $(call gcc_ok,-fwrapv,)
GCCOPT += $(call gcc_ok,-freg-struct-return,)
-GCCOPT += -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,6 @@ 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,)
com32 := $(topdir)/com32
RELOCS := $(com32)/tools/relocs
@@ -45,17 +59,19 @@ GPLLIB =
-CFLAGS = $(GCCOPT) $(GCCWARN) -march=i386 \
-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)
-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 \