kvm: libkvm: fix NULL pointer dereference in kvm_destroy_phys_mem()
[kvm-userspace.git] / kernel / Makefile
blobd409a0af4d69f2e14ce421b2e3b440eddb7b5fab
1 include ../config.mak
3 KVERREL = $(patsubst /lib/modules/%/build,%,$(KERNELDIR))
5 DESTDIR=
7 INSTALLDIR = $(patsubst %/build,%/extra,$(KERNELDIR))
8 ORIGMODDIR = $(patsubst %/build,%/kernel,$(KERNELDIR))
10 rpmrelease = devel
12 LINUX = ../linux-2.6
14 version = $(shell cd $(LINUX); git describe)
16 _hack = mv $1 $1.orig && \
17 awk -v version=$(version) -f hack-module.awk $1.orig \
18 | sed '/\#include/! s/\blapic\b/l_apic/g' > $1 && rm $1.orig
20 _unifdef = mv $1 $1.orig && \
21 unifdef -DCONFIG_X86 $1.orig > $1; \
22 [ $$? -le 1 ] && rm $1.orig
24 hack = $(call _hack,tmp/$(strip $1))
25 unifdef = $(call _unifdef,tmp/$(strip $1))
27 all::
28 $(MAKE) -C $(KERNELDIR) M=`pwd` "$$@"
30 sync:
31 rm -rf tmp
32 rsync --exclude='*.mod.c' -R \
33 "$(LINUX)"/arch/x86/kvm/./*.[ch] \
34 "$(LINUX)"/virt/kvm/./*.[ch] \
35 "$(LINUX)"/./include/linux/kvm*.h \
36 "$(LINUX)"/./include/asm-x86/kvm*.h \
37 tmp/
38 ln -sf asm-x86 include/asm
40 $(call unifdef, include/linux/kvm.h)
41 $(call unifdef, include/linux/kvm_para.h)
42 $(call unifdef, include/asm-x86/kvm.h)
43 $(call unifdef, include/asm-x86/kvm_para.h)
44 $(call hack, kvm_main.c)
45 $(call hack, mmu.c)
46 $(call hack, vmx.c)
47 $(call hack, svm.c)
48 $(call hack, x86.c)
49 $(call hack, irq.h)
50 for i in $$(find tmp -type f -printf '%P '); \
51 do cmp -s $$i tmp/$$i || cp tmp/$$i $$i; done
53 install:
54 mkdir -p $(DESTDIR)/$(INSTALLDIR)
55 cp *.ko $(DESTDIR)/$(INSTALLDIR)
56 for i in $(ORIGMODDIR)/drivers/kvm/*.ko; do \
57 if [ -f "$$i" ]; then mv "$$i" "$$i.orig"; fi; \
58 done
59 /sbin/depmod -a
61 tmpspec = .tmp.kvm-kmod.spec
63 rpm-topdir := $$(pwd)/../rpmtop
65 RPMDIR = $(rpm-topdir)/RPMS
67 rpm: all
68 mkdir -p $(rpm-topdir)/BUILD $(RPMDIR)/$$(uname -i)
69 sed 's/^Release:.*/Release: $(rpmrelease)/; s/^%define kverrel.*/%define kverrel $(KVERREL)/' \
70 kvm-kmod.spec > $(tmpspec)
71 rpmbuild --define="kverrel $(KVERREL)" \
72 --define="objdir $$(pwd)" \
73 --define="_rpmdir $(RPMDIR)" \
74 --define="_topdir $(rpm-topdir)" \
75 -bb $(tmpspec)
77 clean:
78 $(MAKE) -C $(KERNELDIR) M=`pwd` $@
80 svnclean:
81 svn st | grep '^\?' | awk '{print $2}' | xargs rm -rf