Skip to contentSkip to conversation

Update kernel/Makefile and remove x86 only entries

PATCH Superseded Jerone Young 3 participants 3 messages Apr 28, 2008 – Apr 30, 2008 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Update kernel/Makefile and remove x86 only entries

1 file changed, 25 insertions(+), 13 deletions(-)

kernel/Makefile | 38 +++++++++++++++++++++++++-------------

This patch removes static x86 entries and makes things work for multiple archs.

kernel/Makefile +25 -13
@@ -1,5 +1,10 @@ include ../config.mak
 include ../config.mak
 
+ARCH_DIR=$(ARCH)
+ifneq '$(filter $(ARCH_DIR), x86_64 i386)' ''
+	ARCH_DIR=x86
+endif
+ 
 KVERREL = $(patsubst /lib/modules/%/build,%,$(KERNELDIR))
 
 DESTDIR=
@@ -18,10 +23,19 @@ _hack = mv $1 $1.orig && \
 	    | sed '/\#include/! s/\blapic\b/l_apic/g' > $1 && rm $1.orig
 
 unifdef = mv $1 $1.orig && \
-	  unifdef -DCONFIG_X86 $1.orig > $1; \
+	  unifdef -DCONFIG_$(shell echo $(ARCH_DIR)|tr '[:lower:]' '[:upper:]') $1.orig > $1; \
           [ $$? -le 1 ] && rm $1.orig
 
 hack = $(call _hack,$T/$(strip $1))
+
+ifneq '$(filter $(ARCH_DIR), x86)' ''
+HACK_FILES = kvm_main.c \
+		mmu.c \
+		vmx.c \
+		svm.c \
+		x86.c \
+		irq.h 
+endif
 
 all::
 #	include header priority 1) $LINUX 2) $KERNELDIR 3) include-compat
@@ -49,21 +63,19 @@ header-sync:
 	rm -rf $T
 
 	rm -f include/asm
-	ln -sf asm-x86 include/asm
-	ln -sf asm-x86 include-compat/asm
+	ln -sf asm-$(ARCH_DIR) include/asm
+	ln -sf asm-$(ARCH_DIR) include-compat/asm
 
 source-sync:
 	rm -rf $T
 	rsync --exclude='*.mod.c' -R \
-             "$(LINUX)"/arch/x86/kvm/./*.[ch] \
-             "$(LINUX)"/virt/kvm/./*.[ch] \
-             $T/
-	$(call hack, kvm_main.c)
-	$(call hack, mmu.c)
-	$(call hack, vmx.c)
-	$(call hack, svm.c)
-	$(call hack, x86.c)
-	$(call hack, irq.h)
+	     "$(LINUX)"/arch/$(ARCH_DIR)/kvm/./*.[ch] \
+	     "$(LINUX)"/virt/kvm/./*.[ch] \
+	     $T/
+
+	for i in $(HACK_FILES); \
+		do $(call hack, $$i); done
+
 	for i in $$(find $T -type f -printf '%P '); \
 		do cmp -s $$i $T/$$i || cp $T/$$i $$i; done
 	rm -rf $T
@@ -72,7 +84,7 @@ install:
 	mkdir -p $(DESTDIR)/$(INSTALLDIR)
 	cp *.ko $(DESTDIR)/$(INSTALLDIR)
 	for i in $(ORIGMODDIR)/drivers/kvm/*.ko \
-		 $(ORIGMODDIR)/arch/x86/kvm/*.ko; do \
+		 $(ORIGMODDIR)/arch/$(ARCH_DIR)/kvm/*.ko; do \
 		if [ -f "$$i" ]; then mv "$$i" "$$i.orig"; fi; \
 	done
 	/sbin/depmod -a

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone

#1 lore raw
Quoted 8 lines · Jerone Young

This patch removes static x86 entries and makes things work for multiple archs.

kernel/Makefile include ../config.mak · line 8

Quoted 8 lines
kernel/Makefile +5 -0
@@ -1,5 +1,10 @@ include ../config.mak
 include ../config.mak
 
+ARCH_DIR=$(ARCH)
+ifneq '$(filter $(ARCH_DIR), x86_64 i386)' ''
+	ARCH_DIR=x86
+endif
+ 
 

Let's be consistent with functions and directives:

  ARCH_DIR=$(if $(filter $(ARCH),x86_64 i386),x86,$(ARCH))

kernel/Makefile _hack = mv $1 $1.orig && \ · line 28

Quoted 11 lines
kernel/Makefile +0 -0
 KVERREL = $(patsubst /lib/modules/%/build,%,$(KERNELDIR))
 

DESTDIR=

kernel/Makefile +1 -1
@@ -18,10 +23,19 @@ _hack = mv $1 $1.orig && \
 	    | sed '/\#include/! s/\blapic\b/l_apic/g' > $1 && rm $1.orig
 
 unifdef = mv $1 $1.orig && \
-	  unifdef -DCONFIG_X86 $1.orig > $1; \
+	  unifdef -DCONFIG_$(shell echo $(ARCH_DIR)|tr '[:lower:]' '[:upper:]') $1.orig > $1; \
           [ $$? -le 1 ] && rm $1.orig
 

My eyes hurt. A new variable please (and assign with := to avoid the shell being called too often).

kernel/Makefile _hack = mv $1 $1.orig && \

Quoted 13 lines
kernel/Makefile +9 -0
 hack = $(call _hack,$T/$(strip $1))
+
+ifneq '$(filter $(ARCH_DIR), x86)' ''
+HACK_FILES = kvm_main.c \
+		mmu.c \
+		vmx.c \
+		svm.c \
+		x86.c \
+		irq.h 
+endif
 
 

hack-files-x86 = ...
hack-files-ppc = ...

hack-files = $(hack-files-$(ARCH_DIR))

(yeah, someone else is now gauging their eyes out)

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


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
#2 lore raw
Quoted 16 lines · On Wednesday 30 April 2008 15:16:09 Avi Kivity wrote:
Quoted 10 lines

 hack = $(call _hack,$T/$(strip $1))

kernel/Makefile +9 -0
+
+ifneq '$(filter $(ARCH_DIR), x86)' ''
+HACK_FILES = kvm_main.c \
+             mmu.c \
+             vmx.c \
+             svm.c \
+             x86.c \
+             irq.h 
+endif
Quoted 2 lines


hack-files-x86 = ...
hack-files-ppc = ...

Quoted 1 line

hack-files = $(hack-files-$(ARCH_DIR))

Agreed; this is exactly what I had suggested previously.

Signature · 7 lines
Hollis Blanchard
IBM Linux Technology Center
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone