aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2011-09-01 11:32:46 +0100
committerMatt Fleming <matt.fleming@intel.com>2011-09-22 12:37:51 +0100
commitdca494296205647d92d13eb8aa44252ab0eab30e (patch)
tree4afc2237ea0fedcf9af08d948bfdf412a6f0e163
parentf8499ce85cb082e07fb28019a39cfb920dc4301f (diff)
downloadefilinux-dca494296205647d92d13eb8aa44252ab0eab30e.tar.gz
Makefile: Make cross-building possible
Add support for building ia32 efilinux on an x86-64 host. Cross-building can be turned on by specifying $ARCH when building efilinux, e.g. (assuming an x86-64 host) $ make ARCH=ia32 Also, delete $MACHINE from the Makefile and use $ARCH instead as ARCH seems to be more commonly used for specifying the target architecture; gnu-efi uses $ARCH for example. Note that $(CFLAGS) is now passed to $(CC) when looking up the path for libgcc.a, $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) This change is required because if we're cross-building $(CFLAGS) will include -m32, which makes -print-libgcc-file-name return the filename of the 32-bit version of libgcc.a, not the host's version. Reported-by: Darren Hart <dvhart@linux.intel.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
-rw-r--r--Makefile15
1 files changed, 11 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 3ddf8b9..58619ed 100644
--- a/Makefile
+++ b/Makefile
@@ -36,10 +36,10 @@
OBJCOPY=objcopy
-MACHINE=$(shell $(CC) -dumpmachine | sed "s/\(-\).*$$//")
+HOST = $(shell $(CC) -dumpmachine | sed "s/\(-\).*$$//")
+ARCH := $(shell $(CC) -dumpmachine | sed "s/\(-\).*$$//")
-ifeq ($(MACHINE),x86_64)
- ARCH=$(MACHINE)
+ifeq ($(ARCH),x86_64)
LIBDIR=/usr/lib64
FORMAT=efi-app-x86-64
else
@@ -54,6 +54,13 @@ LDSCRIPT=$(LIBDIR)/gnuefi/elf_$(ARCH)_efi.lds
CFLAGS=-I. -I/usr/include/efi -I/usr/include/efi/$(ARCH) \
-DEFI_FUNCTION_WRAPPER -fPIC -fshort-wchar -ffreestanding \
-Wall -Ifs/ -Iloaders/ -D$(ARCH) -Werror
+
+ifeq ($(ARCH),ia32)
+ ifeq ($(HOST),x86_64)
+ CFLAGS += -m32
+ endif
+endif
+
LDFLAGS=-T $(LDSCRIPT) -Bsymbolic -shared -nostdlib -znocombreloc \
-L$(LIBDIR) $(CRT0)
@@ -70,7 +77,7 @@ all: $(IMAGE)
efilinux.efi: efilinux.so
efilinux.so: $(OBJS) $(FS) $(LOADERS)
- $(LD) $(LDFLAGS) -o $@ $^ -lgnuefi -lefi $(shell $(CC) -print-libgcc-file-name)
+ $(LD) $(LDFLAGS) -o $@ $^ -lgnuefi -lefi $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
clean:
rm -f $(IMAGE) efilinux.so $(OBJS) $(FS) $(LOADERS)