1 diff --git a/Make.defaults b/Make.defaults
2 index e541ea8..7812807 100644
5 @@ -62,13 +62,15 @@ EFICRT0 = /usr/lib
6 CDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
9 -ARCH = $(shell uname -m | sed s,i[3456789]86,ia32,)
10 +HOSTARCH = $(shell dpkg-architecture -qDEB_BUILD_ARCH | sed s,i[3456789]86,ia32, | sed s,amd64,x86_64, )
11 +ARCH := $(shell dpkg-architecture -qDEB_BUILD_ARCH | sed s,i[3456789]86,ia32, | sed s,amd64,x86_64, )
12 INCDIR = -I. -I$(TOPDIR) -I$(EFIINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol -I$(TOPDIR)/efi110
13 CPPFLAGS = -DCONFIG_$(ARCH)
17 -CFLAGS = $(OPTIMFLAGS) -fno-stack-protector -fno-strict-aliasing -fpic -fshort-wchar $(DEBUGFLAGS)
18 +CFLAGS = $(ARCH3264) $(OPTIMFLAGS) -fpic -fshort-wchar $(DEBUGFLAGS)
19 +ASFLAGS = $(ARCH3264)
20 LDFLAGS = -nostdlib -znocombreloc
23 @@ -108,10 +110,30 @@ OBJCOPY = $(prefix)objcopy
25 # Use Modified binutils that supports x86_64 using UEFI ABI
26 ifeq ($(ARCH), x86_64)
27 + ifeq ($(HOSTARCH), ia32)
29 + LD3264 = -melf_x86_64
31 + GNUEFILIB := $(GNUEFILIB)64
32 + EFILIB := $(EFILIB)64
33 + EFICRT0 := $(EFICRT0)64
36 CFLAGS += -DEFI_FUNCTION_WRAPPER
37 OBJCOPY = /usr/bin/objcopy
41 + ifeq ($(HOSTARCH), x86_64)
45 + GNUEFILIB := /usr/lib32
46 + EFILIB := /usr/lib32
47 + EFICRT0 := /usr/lib32
52 GCC_VERSION=$(shell $(CROSS_COMPILE)$(CC) -v 2>&1 | fgrep 'gcc version' | cut -f3 -d' ' | cut -f1 -d'.')
54 diff --git a/Makefile b/Makefile
55 index f0efebd..9d82cbf 100644
59 # to use this program.
62 -include Make.defaults
68 +include $(SRCDIR)/Make.defaults
72 CRTOBJS = $(EFICRT0)/crt0-efi-$(ARCH).o
73 LDSCRIPT = $(EFICRT0)/elf_$(ARCH)_efi.lds
75 LDFLAGS += -T $(LDSCRIPT) -shared -Bsymbolic -L$(EFILIB) -L$(GNUEFILIB) $(CRTOBJS)
76 -LOADLIBES = -lefi -lgnuefi $(shell $(CC) -print-libgcc-file-name)
77 +LOADLIBES = -lefi -lgnuefi $(shell $(CC) $(ARCH3264) -print-libgcc-file-name)
78 FORMAT = efi-app-$(ARCH)
81 @@ -87,7 +91,8 @@ fileops.o : Make.defaults
82 chooser.o : Make.defaults
87 + $(MAKE) -C $@ -f $(SRCDIR)/../$@/Makefile SRCDIR=$(SRCDIR)/../$@ ARCH=$(ARCH)
91 @@ -106,4 +111,4 @@ ifeq ($(GCC_VERSION),2)
96 +include $(SRCDIR)/Make.rules
97 diff --git a/choosers/Makefile b/choosers/Makefile
98 index 9915f48..85d31c7 100644
99 --- a/choosers/Makefile
100 +++ b/choosers/Makefile
102 # to use this program.
105 -include ../Make.defaults
106 -include ../Make.rules
111 +include $(SRCDIR)/../Make.defaults
112 +include $(SRCDIR)/../Make.rules
120 @@ -47,7 +52,8 @@ $(TARGET): $(TOPDIR)/Make.defaults $(FILES)
121 echo "You need to define at least one chooser in Make.defaults"; \
124 - $(LD) -o $@ -r $(FILES)
125 + $(LD) $(LD3264) -o $@ -r $(FILES)
129 $(RM) -f $(TARGET) $(FILES)
130 diff --git a/devschemes/Makefile b/devschemes/Makefile
131 index 6ac05af..5328cb1 100644
132 --- a/devschemes/Makefile
133 +++ b/devschemes/Makefile
135 # to use this program.
138 -include ../Make.defaults
139 -include ../Make.rules
144 +include $(SRCDIR)/../Make.defaults
145 +include $(SRCDIR)/../Make.rules
153 @@ -40,7 +45,7 @@ all: $(TARGET)
154 # without doing make clean.
157 - $(LD) -r -o $@ $(FILES)
158 + $(LD) $(LD3264) -r -o $@ $(FILES)
161 $(RM) -f $(TARGET) $(FILES)
162 diff --git a/fs/Makefile b/fs/Makefile
163 index 8e422b2..0bb303f 100644
167 # to use this program.
170 -include ../Make.defaults
171 -include ../Make.rules
176 +include $(SRCDIR)/../Make.defaults
177 +include $(SRCDIR)/../Make.rules
184 ifeq ($(CONFIG_localfs),y)
185 @@ -59,7 +64,7 @@ $(TARGET): $(TOPDIR)/Make.defaults $(FILES)
186 echo "You need to define at least one filesystem in Make.defaults"; \
189 - $(LD) -r -o $@ $(FILES)
190 + $(LD) $(LD3264) -r -o $@ $(FILES)
193 $(RM) -f $(TARGET) $(FILES)
194 diff --git a/ia32/Makefile b/ia32/Makefile
195 index 353ae67..c5f421b 100644
199 # to use this program.
202 -include ../Make.defaults
203 -include ../Make.rules
208 +include $(SRCDIR)/../Make.defaults
209 +include $(SRCDIR)/../Make.rules
215 FILES=system.o config.o bzimage.o plain_loader.o gzip_loader.o gzip.o
217 @@ -37,13 +42,13 @@ all: $(TARGET)
220 rmswitch.h: bin_to_h.c rmswitch.S
221 - $(CC) -o bin_to_h bin_to_h.c
222 - $(AS) -o rmswitch.o rmswitch.S
223 + $(CC) -o bin_to_h $(SRCDIR)/bin_to_h.c
224 + $(AS) -o rmswitch.o $(SRCDIR)/rmswitch.S
225 $(LD) -Ttext 0x0 -s --oformat binary -o rmswitch rmswitch.o
226 ./bin_to_h <rmswitch >rmswitch.h
229 - $(LD) -r -o $@ $(FILES)
230 + $(LD) $(LD3264) -r -o $@ $(FILES)
233 $(RM) -f $(TARGET) $(FILES)
234 diff --git a/ia64/Makefile b/ia64/Makefile
235 index a243d0f..bee0a2b 100644
239 # to use this program.
242 -include ../Make.defaults
243 -include ../Make.rules
248 +include $(SRCDIR)/../Make.defaults
249 +include $(SRCDIR)/../Make.rules
255 FILES=system.o config.o fpswa.o plain_loader.o gzip_loader.o \
256 gzip.o memset.o memcpy.o setjmp.o longjmp.o
257 diff --git a/tools/Makefile b/tools/Makefile
258 index 8858224..97083d7 100644
262 # to use this program.
265 -include ../Make.defaults
266 -include ../Make.rules
271 +include $(SRCDIR)/../Make.defaults
272 +include $(SRCDIR)/../Make.rules
280 diff --git a/x86_64/Makefile b/x86_64/Makefile
281 index 4af4b8d..7ade312 100644
282 --- a/x86_64/Makefile
283 +++ b/x86_64/Makefile
285 # to use this program.
288 -include ../Make.defaults
289 -include ../Make.rules
294 +include $(SRCDIR)/../Make.defaults
295 +include $(SRCDIR)/../Make.rules
301 FILES=system.o config.o bzimage.o plain_loader.o gzip_loader.o gzip.o
302 #FILES=system.o config.o plain_loader.o
303 @@ -38,13 +43,13 @@ all: $(TARGET)
306 rmswitch.h: bin_to_h.c rmswitch.S
307 - $(CC) -o bin_to_h bin_to_h.c
308 - $(AS) -o rmswitch.o rmswitch.S
309 + $(CC) -o bin_to_h $(SRCDIR)/bin_to_h.c
310 + $(AS) -o rmswitch.o $(SRCDIR)/rmswitch.S
311 $(LD) -Ttext 0x0 -s --oformat binary -o rmswitch rmswitch.o
312 ./bin_to_h <rmswitch >rmswitch.h
315 - $(LD) -r -o $@ $(FILES)
316 + $(LD) $(LD3264) -r -o $@ $(FILES)
319 $(RM) -f $(TARGET) $(FILES)