From: Jerone Young Subject: [PATCH] [2/2] Split arch specific makefile code out Date: Tue, 02 Oct 2007 15:25:38 -0500 Message-ID: <1191356738.15279.8.camel@laptop> Reply-To: jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-Ufw3HVoZKuOyqxeijrws" To: kvm-devel Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org --=-Ufw3HVoZKuOyqxeijrws Content-Type: text/plain Content-Transfer-Encoding: 7bit This patch makes things better for cross compiling. It also makes adding a new architecture to the current make system much easier. Signed-off-by: Jerone Young --=-Ufw3HVoZKuOyqxeijrws Content-Disposition: attachment; filename=cross_makefile_config.patch Content-Type: text/x-patch; name=cross_makefile_config.patch; charset=UTF-8 Content-Transfer-Encoding: 7bit diff --git a/user/Makefile b/user/Makefile index 26eb530..9567e8f 100644 --- a/user/Makefile +++ b/user/Makefile @@ -1,14 +1,19 @@ include config.mak +DESTDIR := + +#include architecure specific make rules +include config-$(ARCH).mak + # cc-option # Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0) cc-option = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null \ > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;) -CFLAGS = -I $(KERNELDIR)/include $(autodepend-flags) -g -fomit-frame-pointer \ - -Wall -m$(bits) +CFLAGS += -I $(KERNELDIR)/include $(autodepend-flags) -g -fomit-frame-pointer \ + -Wall CFLAGS += $(call cc-option, -fno-stack-protector, "") CFLAGS += $(call cc-option, -fno-stack-protector-all, "") @@ -18,20 +23,6 @@ CXXFLAGS = $(autodepend-flags) autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d -DESTDIR = - -ifeq ($(shell uname -m), x86_64) -LIBDIR = /lib64 -cstart.o = test/cstart64.o -bits = 64 -ldarch = elf64-x86-64 -else -LIBDIR = /lib -cstart.o = test/cstart.o -bits = 32 -ldarch = elf32-i386 -endif - all: kvmctl libkvm.a flatfiles kvmctl: LDFLAGS += -pthread -lrt @@ -45,11 +36,7 @@ libkvm.a: kvmctl.o flatfiles-common = test/bootstrap test/vmexit.flat test/smp.flat -flatfiles-32 = - -flatfiles-64 = test/access.flat test/irq.flat test/sieve.flat test/simple.flat test/stringio.flat test/memtest1.flat - -flatfiles: $(flatfiles-common) $(flatfiles-$(bits)) +flatfiles: $(flatfiles-common) $(flatfiles) install: install -D kvmctl.h $(DESTDIR)/$(PREFIX)/include/kvmctl.h @@ -60,13 +47,13 @@ install: install -D libkvm.a $(DESTDIR)/$(PREFIX)/$(LIBDIR)/libkvm.a %.flat: %.o - gcc $(CFLAGS) -nostdlib -o $@ -Wl,-T,flat.lds $^ + $(CC) $(CFLAGS) -nostdlib -o $@ -Wl,-T,flat.lds $^ test/bootstrap: test/bootstrap.o - gcc -nostdlib -o $@ -Wl,-T,bootstrap.lds $^ + $(CC) -nostdlib -o $@ -Wl,-T,bootstrap.lds $^ %.o: %.S - gcc $(CFLAGS) -c -nostdlib -o $@ $^ + $(CC) $(CFLAGS) -c -nostdlib -o $@ $^ test/irq.flat: test/print.o diff --git a/user/config-x86.mak b/user/config-x86.mak new file mode 100644 index 0000000..d2d181b --- /dev/null +++ b/user/config-x86.mak @@ -0,0 +1,7 @@ +LIBDIR = /lib +cstart.o = test/cstart.o +bits = 32 +ldarch = elf32-i386 +CFLAGS += -m32 + +flatfiles= diff --git a/user/config-x86_64.mak b/user/config-x86_64.mak new file mode 100644 index 0000000..19ebc46 --- /dev/null +++ b/user/config-x86_64.mak @@ -0,0 +1,7 @@ +LIBDIR = /lib64 +cstart.o = test/cstart64.o +bits = 64 +ldarch = elf64-x86-64 +CFLAGS += -m64 + +flatfiles = test/access.flat test/irq.flat test/sieve.flat test/simple.flat test/stringio.flat test/memtest1.flat --=-Ufw3HVoZKuOyqxeijrws Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ --=-Ufw3HVoZKuOyqxeijrws Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ kvm-devel mailing list kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/kvm-devel --=-Ufw3HVoZKuOyqxeijrws--