kvm: external module: ia64 compatibility with 2.6.26 hosts
[qemu-kvm/fedora.git] / kvm / kernel / Makefile
blob3f5f6da9afd564f15a6b391ac75b8997f10f19ea
1 include ../config.mak
3 ARCH_DIR = $(if $(filter $(ARCH),x86_64 i386),x86,$(ARCH))
4 ARCH_CONFIG := $(shell echo $(ARCH_DIR) | tr '[:lower:]' '[:upper:]')
6 KVERREL = $(patsubst /lib/modules/%/build,%,$(KERNELDIR))
8 DESTDIR=
10 MAKEFILE_PRE = $(ARCH_DIR)/Makefile.pre
12 INSTALLDIR = $(patsubst %/build,%/extra,$(KERNELDIR))
13 ORIGMODDIR = $(patsubst %/build,%/kernel,$(KERNELDIR))
15 rpmrelease = devel
17 LINUX = ../linux-2.6
19 version = $(shell cd $(LINUX); git describe)
21 _hack = mv $1 $1.orig && \
22 gawk -v version=$(version) -f $(ARCH_DIR)/hack-module.awk $1.orig \
23 | sed '/\#include/! s/\blapic\b/l_apic/g' > $1 && rm $1.orig
25 unifdef = mv $1 $1.orig && \
26 unifdef -DCONFIG_$(ARCH_CONFIG) $1.orig > $1; \
27 [ $$? -le 1 ] && rm $1.orig
29 hack = $(call _hack,$T/$(strip $1))
31 hack-files-x86 = kvm_main.c mmu.c vmx.c svm.c x86.c irq.h lapic.c i8254.c
32 hack-files-ia64 = kvm_main.c kvm_fw.c
34 hack-files = $(hack-files-$(ARCH_DIR))
36 all:: header-link prerequisite
37 # include header priority 1) $LINUX 2) $KERNELDIR 3) include-compat
38 $(MAKE) -C $(KERNELDIR) M=`pwd` \
39 LINUXINCLUDE="-I`pwd`/include -Iinclude -Iarch/${ARCH_DIR}/include -I`pwd`/include-compat \
40 -include include/linux/autoconf.h \
41 -include `pwd`/$(ARCH_DIR)/external-module-compat.h"
42 "$$@"
44 sync: header-sync source-sync header-link
46 header-link:
47 rm -f include/asm
48 ln -sf asm-$(ARCH_DIR) include/asm
49 ln -sf asm-$(ARCH_DIR) include-compat/asm
51 T = $(subst -sync,,$@)-tmp
53 header-sync:
54 rm -rf $T
55 rsync -R \
56 "$(LINUX)"/./include/linux/kvm*.h \
57 "$(LINUX)"/./include/asm-*/kvm*.h \
58 $T/
59 -rsync -R \
60 "$(LINUX)"/arch/$(ARCH_DIR)/include/asm/./kvm*.h \
61 $T/include/asm-$(ARCH_DIR)/
63 set -e && for i in $(find $T -name '*.h'); do \
64 $(call unifdef,$$i); done
65 $(call hack, include/linux/kvm.h)
66 set -e && for i in $$(find $T -type f -printf '%P '); \
67 do mkdir -p $$(dirname $$i); cmp -s $$i $T/$$i || cp $T/$$i $$i; done
68 rm -rf $T
70 source-sync:
71 rm -rf $T
72 rsync --exclude='*.mod.c' -R \
73 "$(LINUX)"/arch/$(ARCH_DIR)/kvm/./*.[cSh] \
74 "$(LINUX)"/virt/kvm/./*.[cSh] \
75 $T/
77 set -e && for i in $(find $T -name '*.c'); do \
78 $(call unifdef,$$i); done
80 for i in $(hack-files); \
81 do $(call hack, $$i); done
83 for i in $$(find $T -type f -printf '%P '); \
84 do cmp -s $(ARCH_DIR)/$$i $T/$$i || cp $T/$$i $(ARCH_DIR)/$$i; done
85 rm -rf $T
87 include $(MAKEFILE_PRE)
89 install:
90 mkdir -p $(DESTDIR)/$(INSTALLDIR)
91 cp $(ARCH_DIR)/*.ko $(DESTDIR)/$(INSTALLDIR)
92 for i in $(ORIGMODDIR)/drivers/kvm/*.ko \
93 $(ORIGMODDIR)/arch/$(ARCH_DIR)/kvm/*.ko; do \
94 if [ -f "$$i" ]; then mv "$$i" "$$i.orig"; fi; \
95 done
96 /sbin/depmod -a
98 tmpspec = .tmp.kvm-kmod.spec
100 rpm-topdir := $$(pwd)/../rpmtop
102 RPMDIR = $(rpm-topdir)/RPMS
104 rpm: all
105 mkdir -p $(rpm-topdir)/BUILD $(RPMDIR)/$$(uname -i)
106 sed 's/^Release:.*/Release: $(rpmrelease)/; s/^%define kverrel.*/%define kverrel $(KVERREL)/' \
107 kvm-kmod.spec > $(tmpspec)
108 rpmbuild --define="kverrel $(KVERREL)" \
109 --define="objdir $$(pwd)/$(ARCH_DIR)" \
110 --define="_rpmdir $(RPMDIR)" \
111 --define="_topdir $(rpm-topdir)" \
112 -bb $(tmpspec)
114 clean:
115 $(MAKE) -C $(KERNELDIR) M=`pwd` $@