4 ARCH_DIR
= $(if
$(filter $(ARCH
),x86_64 i386
),x86
,$(ARCH
))
5 ARCH_CONFIG
:= $(shell echo
$(ARCH_DIR
) | tr
'[:lower:]' '[:upper:]')
7 KVERREL
= $(patsubst /lib
/modules
/%/build
,%,$(KERNELDIR
))
11 MAKEFILE_PRE
= $(ARCH_DIR
)/Makefile.pre
13 INSTALLDIR
= $(patsubst %/build
,%/extra
,$(KERNELDIR
))
14 ORIGMODDIR
= $(patsubst %/build
,%/kernel
,$(KERNELDIR
))
20 version
= $(shell cd
$(LINUX
); git describe
)
22 _hack
= mv
$1 $1.orig
&& \
23 gawk
-v version
=$(version
) -f
$(ARCH_DIR
)/hack-module.awk
$1.orig \
24 | sed
'/\#include/! s/\blapic\b/l_apic/g' > $1 && rm $1.orig
26 unifdef
= mv
$1 $1.orig
&& \
27 unifdef
-DCONFIG_
$(ARCH_CONFIG
) $1.orig
> $1; \
28 [ $$?
-le
1 ] && rm $1.orig
30 hack
= $(call _hack
,$T/$(strip $1))
32 hack-files-x86
= kvm_main.c mmu.c vmx.c svm.c x86.c irq.h lapic.c i8254.c kvm_trace.c
33 hack-files-ia64
= kvm_main.c kvm_fw.c
35 hack-files
= $(hack-files-
$(ARCH_DIR
))
37 ifeq ($(CONFIG_KVM_TRACE
),y
)
38 module_defines
+= -DEXT_CONFIG_KVM_TRACE
=y
41 all:: header-link prerequisite
42 # include header priority 1) $LINUX 2) $KERNELDIR 3) include-compat
43 $(MAKE
) -C
$(KERNELDIR
) M
=`pwd` \
44 LINUXINCLUDE
="-I`pwd`/include -Iinclude \
45 $(if $(KERNELSOURCEDIR),-Iinclude2 -I$(KERNELSOURCEDIR)/include) \
46 -Iarch/${ARCH_DIR}/include -I`pwd`/include-compat \
47 -include include/linux/autoconf.h \
48 -include `pwd`/$(ARCH_DIR)/external-module-compat.h $(module_defines)"
51 sync
: header-sync source-sync header-link
54 rm -f
include/asm include-compat
/asm
55 ln
-sf asm-
$(ARCH_DIR
) include/asm
56 ln
-sf asm-
$(ARCH_DIR
) include-compat
/asm
58 T
= $(subst -sync
,,$@
)-tmp
63 "$(LINUX)"/.
/include/linux
/kvm
*.h \
64 "$(LINUX)"/.
/include/asm-
*/kvm
*.h \
67 "$(LINUX)"/arch
/$(ARCH_DIR
)/include/asm
/.
/kvm
*.h \
68 $T/include/asm-
$(ARCH_DIR
)/
70 set
-e
&& for i in
$(find
$T -name
'*.h'); do \
71 $(call unifdef
,$$i); done
72 $(call hack
, include/linux
/kvm.h
)
73 set
-e
&& for i in
$$(find
$T -type f
-printf
'%P '); \
74 do mkdir
-p
$$(dirname
$$i); cmp
-s
$$i $T/$$i || cp
$T/$$i $$i; done
79 rsync
--exclude
='*.mod.c' -R \
80 "$(LINUX)"/arch
/$(ARCH_DIR
)/kvm
/.
/*.
[cSh
] \
81 "$(LINUX)"/virt
/kvm
/.
/*.
[cSh
] \
84 set
-e
&& for i in
$(find
$T -name
'*.c'); do \
85 $(call unifdef
,$$i); done
87 for i in
$(hack-files
); \
88 do
$(call hack
, $$i); done
90 for i in
$$(find
$T -type f
-printf
'%P '); \
91 do cmp
-s
$(ARCH_DIR
)/$$i $T/$$i || cp
$T/$$i $(ARCH_DIR
)/$$i; done
94 include $(MAKEFILE_PRE
)
97 mkdir
-p
$(DESTDIR
)/$(INSTALLDIR
)
98 cp
$(ARCH_DIR
)/*.ko
$(DESTDIR
)/$(INSTALLDIR
)
99 for i in
$(ORIGMODDIR
)/drivers
/kvm
/*.ko \
100 $(ORIGMODDIR
)/arch
/$(ARCH_DIR
)/kvm
/*.ko
; do \
101 if
[ -f
"$$i" ]; then mv
"$$i" "$$i.orig"; fi
; \
105 tmpspec
= .tmp.kvm-kmod.spec
107 rpm-topdir
:= $$(pwd
)/..
/rpmtop
109 RPMDIR
= $(rpm-topdir
)/RPMS
112 mkdir
-p
$(rpm-topdir
)/BUILD
$(RPMDIR
)/$$(uname
-i
)
113 sed
's/^Release:.*/Release: $(rpmrelease)/; s/^%define kverrel.*/%define kverrel $(KVERREL)/' \
114 kvm-kmod.spec
> $(tmpspec
)
115 rpmbuild
--define="kverrel $(KVERREL)" \
116 --define="objdir $$(pwd)/$(ARCH_DIR)" \
117 --define="_rpmdir $(RPMDIR)" \
118 --define="_topdir $(rpm-topdir)" \
122 $(MAKE
) -C
$(KERNELDIR
) M
=`pwd` $@