add support for building 32 and 64 bit targets
authorBdale Garbee <bdale@gag.com>
Mon, 2 Nov 2009 03:44:16 +0000 (20:44 -0700)
committerBdale Garbee <bdale@gag.com>
Mon, 2 Nov 2009 03:44:16 +0000 (20:44 -0700)
12 files changed:
Make.defaults
Makefile
choosers/Makefile
debian/changelog
debian/control
debian/rules
devschemes/Makefile
fs/Makefile
ia32/Makefile
ia64/Makefile
tools/Makefile
x86_64/Makefile

index f5dca13b103f023f405dad5c9a7783117630c6fe..1f3d989287d2f416283e8fe51e3fe0071828022b 100644 (file)
@@ -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'.')
 
index 613b597ee890ac7d8c4b0034702cb74be251ac57..98d032391fadc03e7dfaab1c8ed239e700f56b60 100644 (file)
--- a/Makefile
+++ b/Makefile
 # 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
index 31b10d09a48af693ffc21a26dd0820aa460c0768..7860cc84ed5ad9ac047759e124da01027cbee06a 100644 (file)
 # 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; \
index 2b5545cefe56bfa4b8247271a088bb775b96561d..9241392f9134beb195524d30a7c12cd11ac7ffd7 100644 (file)
@@ -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 <bdale@gag.com>  Sun, 01 Nov 2009 20:24:12 -0700
 
index 1e0d2687da3c7571d383242bbe53f81f6cdc3b39..20d098ea0ec665873f7f6e493492b4edcb41ba17 100644 (file)
@@ -2,7 +2,7 @@ Source: elilo
 Section: admin
 Priority: optional
 Maintainer: Bdale Garbee <bdale@gag.com>
-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
index 17877d2a0b30e3635e6da7f11c59eb26328f6dca..9dfd151a3205d72df710755aae4de11a349ce727 100755 (executable)
@@ -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
index 6ac05af77a83f29ab2a138528cb1144c68d07ff5..5328cb1a46cf0c6ab9573817a1cc093366bbb0ad 100644 (file)
 # 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)
index 1829d967cee4edfd9b50389c58b82e14b4fd4b13..4c26f713ea9f4563b77916605c276eadb088ac94 100644 (file)
 # 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)
index 353ae6791dffb98d8803a5ee148d313d01e09fee..dadffac96724c99787cd65badd49189df8ac1d35 100644 (file)
 # 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 >rmswitch.h
 
 $(TARGET): $(FILES)
-       $(LD) -r -o $@ $(FILES)
+       $(LD) $(LD3264) -r -o $@ $(FILES)
 
 clean:
        $(RM) -f $(TARGET) $(FILES)
index a243d0f5bbaf360a7d0e39863917bb43680840c3..bee0a2bbd9615311bf00ff89fa0933ad1985e503 100644 (file)
 # 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
index 88582242ad26921b9e515d96e9eca9875ce94bfd..97083d79a1999337e1dd37f9aaeb349578e8360d 100644 (file)
 # 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
index 4af4b8d9448cec31ac7fe906d2fdef5903ca6ac1..7ade312780dedf7f4ad9ceb20f7c448c92ea3f44 100644 (file)
 # 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 >rmswitch.h
 
 $(TARGET): $(FILES)
-       $(LD) -r -o $@ $(FILES)
+       $(LD) $(LD3264) -r -o $@ $(FILES)
 
 clean:
        $(RM) -f $(TARGET) $(FILES)