From b99b311775052d2e6175b3be10a374cf939d15a2 Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Sun, 1 Nov 2009 20:44:16 -0700 Subject: [PATCH] add support for building 32 and 64 bit targets --- Make.defaults | 26 ++++++++++++++++++++++++-- Makefile | 15 ++++++++++----- choosers/Makefile | 15 ++++++++++----- debian/changelog | 1 + debian/control | 2 +- debian/rules | 29 +++++++++++++++++++++++++++-- devschemes/Makefile | 13 +++++++++---- fs/Makefile | 13 +++++++++---- ia32/Makefile | 13 +++++++++---- ia64/Makefile | 11 ++++++++--- tools/Makefile | 11 ++++++++--- x86_64/Makefile | 17 +++++++++++------ 12 files changed, 127 insertions(+), 39 deletions(-) diff --git a/Make.defaults b/Make.defaults index f5dca13..1f3d989 100644 --- a/Make.defaults +++ b/Make.defaults @@ -62,13 +62,15 @@ EFICRT0 = /usr/lib CDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) TOPDIR = -ARCH = $(shell uname -m | sed s,i[3456789]86,ia32,) +HOSTARCH = $(shell uname -m | sed s,i[3456789]86,ia32,) +ARCH := $(shell uname -m | sed s,i[3456789]86,ia32,) INCDIR = -I. -I$(TOPDIR) -I$(EFIINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol -I$(TOPDIR)/efi110 CPPFLAGS = -DCONFIG_$(ARCH) OPTIMFLAGS = -O2 DEBUGFLAGS = -Wall -CFLAGS = $(OPTIMFLAGS) -fno-strict-aliasing -fpic -fshort-wchar $(DEBUGFLAGS) +CFLAGS = $(ARCH3264) $(OPTIMFLAGS) -fpic -fshort-wchar $(DEBUGFLAGS) +ASFLAGS = $(ARCH3264) LDFLAGS = -nostdlib -znocombreloc INSTALL = install @@ -108,10 +110,30 @@ OBJCOPY = $(prefix)objcopy # Use Modified binutils that supports x86_64 using UEFI ABI ifeq ($(ARCH), x86_64) + ifeq ($(HOSTARCH), ia32) + ARCH3264 = -m64 + LD3264 = -melf_x86_64 + + GNUEFILIB := $(GNUEFILIB)64 + EFILIB := $(EFILIB)64 + EFICRT0 := $(EFICRT0)64 + endif + CFLAGS += -DEFI_FUNCTION_WRAPPER OBJCOPY = /usr/bin/objcopy endif +ifeq ($(ARCH), ia32) + ifeq ($(HOSTARCH), x86_64) + ARCH3264 = -m32 + LD3264 = -melf_i386 + + GNUEFILIB := /emul/ia32-linux$(GNUEFILIB) + EFILIB := /emul/ia32-linux$(EFILIB) + EFICRT0 := /emul/ia32-linux$(EFICRT0) + endif +endif + ifeq ($(ARCH),ia64) GCC_VERSION=$(shell $(CROSS_COMPILE)$(CC) -v 2>&1 | fgrep 'gcc version' | cut -f3 -d' ' | cut -f1 -d'.') diff --git a/Makefile b/Makefile index 613b597..98d0323 100644 --- a/Makefile +++ b/Makefile @@ -25,15 +25,19 @@ # to use this program. # -include Make.defaults -TOPDIR=. +SRCDIR = . + +VPATH = $(SRCDIR) + +include $(SRCDIR)/Make.defaults +TOPDIR = $(SRCDIR) CRTOBJS = $(EFICRT0)/crt0-efi-$(ARCH).o LDSCRIPT = $(EFICRT0)/elf_$(ARCH)_efi.lds LDFLAGS += -T $(LDSCRIPT) -shared -Bsymbolic -L$(EFILIB) -L$(GNUEFILIB) $(CRTOBJS) -LOADLIBES = -lefi -lgnuefi $(shell $(CC) -print-libgcc-file-name) +LOADLIBES = -lefi -lgnuefi $(shell $(CC) $(ARCH3264) -print-libgcc-file-name) FORMAT = efi-app-$(ARCH) FILESYSTEM = @@ -87,7 +91,8 @@ fileops.o : Make.defaults chooser.o : Make.defaults $(SUBDIRS): dummy - $(MAKE) -C $@ + mkdir -p $@ + $(MAKE) -C $@ -f $(SRCDIR)/../$@/Makefile SRCDIR=$(SRCDIR)/../$@ ARCH=$(ARCH) dummy: @@ -106,4 +111,4 @@ ifeq ($(GCC_VERSION),2) @exit 1 endif -include Make.rules +include $(SRCDIR)/Make.rules diff --git a/choosers/Makefile b/choosers/Makefile index 31b10d0..7860cc8 100644 --- a/choosers/Makefile +++ b/choosers/Makefile @@ -23,10 +23,15 @@ # to use this program. # -include ../Make.defaults -include ../Make.rules +SRCDIR = . + +VPATH = $(SRCDIR) + +include $(SRCDIR)/../Make.defaults +include $(SRCDIR)/../Make.rules + +TOPDIR=$(SRCDIR)/.. -TOPDIR=$(CDIR)/.. FILES= @@ -43,11 +48,11 @@ TARGET=choosers.o all: $(TARGET) $(TARGET): check-choosers $(TOPDIR)/Make.defaults $(FILES) - $(LD) -o $@ -r $(FILES) + $(LD) $(LD3264) -o $@ -r $(FILES) clean: $(RM) -f $(TARGET) $(FILES) - + check-choosers: @if [ -n "$(FILES)" ]; then \ exit 0; \ diff --git a/debian/changelog b/debian/changelog index 2b5545c..9241392 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,7 @@ elilo (3.12-1) UNRELEASED; urgency=low * new upstream version, closes: #376002 * patch for dpkg option --print-installation-architecture going obsolete from Dann Frazier, closes: #550090 + * support building 32 and 64 bit targets on each host, closes: #483045 -- Bdale Garbee Sun, 01 Nov 2009 20:24:12 -0700 diff --git a/debian/control b/debian/control index 1e0d268..20d098e 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: elilo Section: admin Priority: optional Maintainer: Bdale Garbee -Build-Depends: debhelper (>> 5), binutils (>= 2.17.50.0.14), gnu-efi (>=3.0d), po-debconf +Build-Depends: debhelper (>> 5), binutils (>= 2.17.50.0.14), gcc-multilib [i386 amd64], gnu-efi (>=3.0d), po-debconf Standards-Version: 3.8.3 Package: elilo diff --git a/debian/rules b/debian/rules index 17877d2..9dfd151 100755 --- a/debian/rules +++ b/debian/rules @@ -5,6 +5,8 @@ # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 +buildarch := $(shell dpkg-architecture -qDEB_BUILD_ARCH) + configure: configure-stamp configure-stamp: dh_testdir @@ -15,6 +17,16 @@ build: configure-stamp build-stamp build-stamp: dh_testdir +ifeq ($(buildarch), i386) + mkdir debian/build64 + $(MAKE) -C debian/build64 -f ../../Makefile SRCDIR=../.. ARCH=x86_64 +endif + +ifeq ($(buildarch), amd64) + mkdir debian/build32 + $(MAKE) -C debian/build32 -f ../../Makefile SRCDIR=../.. ARCH=ia32 +endif + $(MAKE) touch build-stamp @@ -26,6 +38,8 @@ clean: [ ! -f Makefile ] || $(MAKE) clean + rm -rf debian/build32 debian/build64 + debconf-updatepo dh_clean @@ -35,7 +49,20 @@ install: build dh_clean -k dh_installdirs +ifeq ($(buildarch), i386) + mkdir -p debian/elilo/usr/lib64/elilo + cp debian/build64/elilo.efi debian/elilo/usr/lib64/elilo/elilo.efi + chmod 0644 debian/elilo/usr/lib64/elilo/elilo.efi +endif + +ifeq ($(buildarch), amd64) + mkdir -p debian/elilo/emul/ia32-linux/usr/lib/elilo + cp debian/build32/elilo.efi debian/elilo/emul/ia32-linux/usr/lib/elilo/elilo.efi + chmod 0644 debian/elilo/emul/ia32-linux/usr/lib/elilo/elilo.efi +endif + cp elilo.efi debian/elilo/usr/lib/elilo/elilo.efi + chmod 0644 debian/elilo/usr/lib/elilo/elilo.efi # dynamically determine version string from changelog sed s/'##VERSION##'/"`IFS=\"()\" read pkg ver other < \ @@ -46,8 +73,6 @@ install: build cp tools/eliloalt debian/elilo/usr/sbin/eliloalt chmod 0755 debian/elilo/usr/sbin/eliloalt - chmod 0644 debian/elilo/usr/lib/elilo/elilo.efi - binary-indep: build install binary-arch: build install diff --git a/devschemes/Makefile b/devschemes/Makefile index 6ac05af..5328cb1 100644 --- a/devschemes/Makefile +++ b/devschemes/Makefile @@ -23,10 +23,15 @@ # to use this program. # -include ../Make.defaults -include ../Make.rules +SRCDIR = . + +VPATH = $(SRCDIR) + +include $(SRCDIR)/../Make.defaults +include $(SRCDIR)/../Make.rules + +TOPDIR=$(SRCDIR)/.. -TOPDIR=$(CDIR)/.. FILES=simple.o @@ -40,7 +45,7 @@ all: $(TARGET) # without doing make clean. # $(TARGET): $(FILES) - $(LD) -r -o $@ $(FILES) + $(LD) $(LD3264) -r -o $@ $(FILES) clean: $(RM) -f $(TARGET) $(FILES) diff --git a/fs/Makefile b/fs/Makefile index 1829d96..4c26f71 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -23,10 +23,15 @@ # to use this program. # -include ../Make.defaults -include ../Make.rules +SRCDIR = . + +VPATH = $(SRCDIR) + +include $(SRCDIR)/../Make.defaults +include $(SRCDIR)/../Make.rules + +TOPDIR=$(SRCDIR)/.. -TOPDIR=$(CDIR)/.. FILES= ifeq ($(CONFIG_localfs),y) @@ -55,7 +60,7 @@ all: $(TARGET) # without doing make clean. # $(TARGET): check-filesystems $(TOPDIR)/Make.defaults $(FILES) - $(LD) -r -o $@ $(FILES) + $(LD) $(LD3264) -r -o $@ $(FILES) clean: $(RM) -f $(TARGET) $(FILES) diff --git a/ia32/Makefile b/ia32/Makefile index 353ae67..dadffac 100644 --- a/ia32/Makefile +++ b/ia32/Makefile @@ -23,10 +23,15 @@ # to use this program. # -include ../Make.defaults -include ../Make.rules +SRCDIR = . + +VPATH = $(SRCDIR) + +include $(SRCDIR)/../Make.defaults +include $(SRCDIR)/../Make.rules + +TOPDIR=$(SRCDIR)/.. -TOPDIR=$(CDIR)/.. FILES=system.o config.o bzimage.o plain_loader.o gzip_loader.o gzip.o @@ -43,7 +48,7 @@ rmswitch.h: bin_to_h.c rmswitch.S ./bin_to_h rmswitch.h $(TARGET): $(FILES) - $(LD) -r -o $@ $(FILES) + $(LD) $(LD3264) -r -o $@ $(FILES) clean: $(RM) -f $(TARGET) $(FILES) diff --git a/ia64/Makefile b/ia64/Makefile index a243d0f..bee0a2b 100644 --- a/ia64/Makefile +++ b/ia64/Makefile @@ -23,10 +23,15 @@ # to use this program. # -include ../Make.defaults -include ../Make.rules +SRCDIR = . + +VPATH = $(SRCDIR) + +include $(SRCDIR)/../Make.defaults +include $(SRCDIR)/../Make.rules + +TOPDIR=$(SRCDIR)/.. -TOPDIR=$(CDIR)/.. FILES=system.o config.o fpswa.o plain_loader.o gzip_loader.o \ gzip.o memset.o memcpy.o setjmp.o longjmp.o diff --git a/tools/Makefile b/tools/Makefile index 8858224..97083d7 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -23,10 +23,15 @@ # to use this program. # -include ../Make.defaults -include ../Make.rules +SRCDIR = . + +VPATH = $(SRCDIR) + +include $(SRCDIR)/../Make.defaults +include $(SRCDIR)/../Make.rules + +TOPDIR=$(SRCDIR)/.. -TOPDIR=$(CDIR)/.. FILES=eliloalt.o TARGET=eliloalt diff --git a/x86_64/Makefile b/x86_64/Makefile index 4af4b8d..7ade312 100644 --- a/x86_64/Makefile +++ b/x86_64/Makefile @@ -23,10 +23,15 @@ # to use this program. # -include ../Make.defaults -include ../Make.rules +SRCDIR = . + +VPATH = $(SRCDIR) + +include $(SRCDIR)/../Make.defaults +include $(SRCDIR)/../Make.rules + +TOPDIR=$(SRCDIR)/.. -TOPDIR=$(CDIR)/.. FILES=system.o config.o bzimage.o plain_loader.o gzip_loader.o gzip.o #FILES=system.o config.o plain_loader.o @@ -38,13 +43,13 @@ all: $(TARGET) system.o: rmswitch.h rmswitch.h: bin_to_h.c rmswitch.S - $(CC) -o bin_to_h bin_to_h.c - $(AS) -o rmswitch.o rmswitch.S + $(CC) -o bin_to_h $(SRCDIR)/bin_to_h.c + $(AS) -o rmswitch.o $(SRCDIR)/rmswitch.S $(LD) -Ttext 0x0 -s --oformat binary -o rmswitch rmswitch.o ./bin_to_h rmswitch.h $(TARGET): $(FILES) - $(LD) -r -o $@ $(FILES) + $(LD) $(LD3264) -r -o $@ $(FILES) clean: $(RM) -f $(TARGET) $(FILES) -- 2.47.2