From a0ffa11e3ff3e12e61f1eb9f6e426df57efc417c Mon Sep 17 00:00:00 2001
From: Xiantao Zhang <xiantao.zhang@intel.com>
Date: Fri, 1 Feb 2008 17:18:03 +0800
Subject: [PATCH] Make non-x86 arch partially support make sync.

Make non-x86 arch partially support make sync, and other arch
can get right header files.
Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
---
 kernel/Makefile |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/kernel/Makefile b/kernel/Makefile
index 7a435b5..2f0d7d5 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -13,6 +13,17 @@ LINUX = ../linux-2.6
 
 version = $(shell cd $(LINUX); git describe)
 
+ARCH := $(shell uname -m | sed -e s/i.86/i386/)
+SRCARCH 	:= $(ARCH)
+
+# Additional ARCH settings for x86
+ifeq ($(ARCH),i386)
+        SRCARCH := x86
+endif
+ifeq ($(ARCH),x86_64)
+        SRCARCH := x86
+endif
+
 _hack = mv $1 $1.orig && \
 	gawk -v version=$(version) -f hack-module.awk $1.orig \
 	    | sed '/\#include/! s/\blapic\b/l_apic/g' > $1 && rm $1.orig
@@ -30,14 +41,15 @@ all::
 sync:
 	rm -rf tmp
 	rsync --exclude='*.mod.c' -R \
-             "$(LINUX)"/arch/x86/kvm/./*.[ch] \
+             "$(LINUX)"/arch/$(SRCARCH)/kvm/./*.[cSh] \
              "$(LINUX)"/virt/kvm/./*.[ch] \
 	     "$(LINUX)"/./include/linux/kvm*.h \
-	     "$(LINUX)"/./include/asm-x86/kvm*.h \
+	     "$(LINUX)"/./include/asm-$(SRCARCH)/kvm*.h \
              tmp/
 	rm -rf include/asm
-	ln -s asm-x86 include/asm
+	ln -s asm-$(SRCARCH) include/asm
 
+ifeq ($(SRCARCH),x86)
 	$(call unifdef, include/linux/kvm.h)
 	$(call unifdef, include/linux/kvm_para.h)
 	$(call unifdef, include/asm-x86/kvm.h)
@@ -48,6 +60,7 @@ sync:
 	$(call hack, svm.c)
 	$(call hack, x86.c)
 	$(call hack, irq.h)
+endif
 	for i in $$(find tmp -type f -printf '%P '); \
 		do cmp -s $$i tmp/$$i || cp tmp/$$i $$i; done
 	rm -rf tmp
-- 
1.5.2

