From: Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: [PATCH] Allow for Cross compile of user tools
Date: Mon, 01 Oct 2007 13:56:29 -0500 [thread overview]
Message-ID: <1191264989.18461.12.camel@laptop> (raw)
[-- Attachment #1: Type: text/plain, Size: 856 bytes --]
This is the first of many patches to begin to make kvm source a lot
better for compiling for other architecture support (that is not x86 or
x86-64).
This patch makes it possible so that someone on an x86 machine can cross
compile for an x86-64 machine and vice versa. So now you will have
config-$(arch).mak for each architecture, with specific architecture
rules.
An example of this is for compiling x86-64 on an x86 machine is:
make KERNELDIR=~/tmp/kvm ARCH=x86_64
This allows for someone with an x86 machine to compile for x86_64. Later
patches that I will be submitting will be for ppc and will make a few
more changes.
What I would like though is comments on how everyone feels about this
approach. We are need of something like this to start ading ppc related
code.
Signed-off-by: Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
[-- Attachment #2: kvm_user_cross_comp.patch --]
[-- Type: text/x-patch, Size: 2823 bytes --]
diff --git a/user/Makefile b/user/Makefile
index 26eb530..aebba58 100644
--- a/user/Makefile
+++ b/user/Makefile
@@ -1,5 +1,12 @@
-include config.mak
+ARCH ?= $(shell uname -m | sed -e s/i.86/x86/)
+
+KERNELDIR ?= /lib/modules/$(shell uname -r)/build/
+
+DESTDIR ?=
+
+#include architecure specific make rules
+include config-$(ARCH).mak
# cc-option
# Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
@@ -7,8 +14,8 @@ include config.mak
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 +25,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 +38,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 +49,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
[-- Attachment #3: Type: text/plain, Size: 228 bytes --]
-------------------------------------------------------------------------
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/
[-- Attachment #4: Type: text/plain, Size: 186 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel
next reply other threads:[~2007-10-01 18:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-01 18:56 Jerone Young [this message]
2007-10-02 5:59 ` [PATCH] Allow for Cross compile of user tools Avi Kivity
[not found] ` <4701DE24.4030109-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-02 16:48 ` Jerone Young
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1191264989.18461.12.camel@laptop \
--to=jyoung5-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox