Skip to contentSkip to conversation

Split arch specific makefile code out

PATCH Applied Jerone Young 2 participants 3 messages Oct 2, 2007 – Oct 8, 2007 1 message not in the archive KVM

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 Split arch specific makefile code out

This patch makes things better for cross compiling. It also makes adding a new architecture to the current make system much easier.

user/Makefile +11 -24
index 26eb530..9567e8f 100644
@@ -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
 
user/config-x86.mak new file +7 -0
new file mode 100644
index 0000000..d2d181b
@@ -0,0 +1,7 @@
+LIBDIR = /lib
+cstart.o = test/cstart.o
+bits = 32
+ldarch = elf32-i386
+CFLAGS += -m32
+
+flatfiles=
user/config-x86_64.mak new file +7 -0
new file mode 100644
index 0000000..19ebc46
@@ -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

-------------------------------------------------------------------------
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/

_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel

#1 lore raw

user/Makefile

Quoted 9 lines · Jerone Young

This patch makes things better for cross compiling. It also makes adding a new architecture to the current make system much easier.

user/Makefile +4 -0
+CFLAGS += -I $(KERNELDIR)/include $(autodepend-flags) -g -fomit-frame-pointer \
+	-Wall
+CFLAGS += -m32
+CFLAGS += -m64

Nowhere is CFLAGS defined, that I can see. This means that a stray CFLAGS environment variable will affect the build (this is the cause of my dislike to ?= as well).

Please change so that make variables cannot be affected by the environment.

Signature · 8 lines
Any sufficiently difficult bug is indistinguishable from a feature.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

A message that is not in the archive (sent off-list or not yet received): 4708C81E.8090701-atKUWr5tajBWk0Htik3J/[email protected]

#3 lore raw
Quoted 9 lines · Avi Kivity

user/Makefile

Quoted 8 lines · Jerone Young

This patch makes things better for cross compiling. It also makes adding a new architecture to the current make system much easier.

user/Makefile +4 -0
+CFLAGS += -I $(KERNELDIR)/include $(autodepend-flags) -g -fomit-frame-pointer \
+	-Wall
+CFLAGS += -m32
+CFLAGS += -m64

Hmm.. if this is in my patch this is probably a mistake on my part. Shouldn't be adding -m32 & -m64 on the same CFLAGS.

Quoted 5 lines
Quoted 1 line

Nowhere is CFLAGS defined, that I can see. This means that a stray CFLAGS environment variable will affect the build (this is the cause of my dislike to ?= as well).

I believe I was thinking that you might for a specific arch in config-$ARCH first declare any CFLAGS that other architectures wouldn't use. So probably a better way to do this is to have CFLAGS declaration begin at the point you describe, and then include config-$ARCH after this point.

I'll submit some new patches shortly.

Quoted 6 lines

Please change so that make variables cannot be affected by the environment.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/