-
Notifications
You must be signed in to change notification settings - Fork 65
/
Makefile
105 lines (81 loc) · 3.31 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
$(if $(wildcard config.mak),,$(error Please run configure first))
include config.mak
ARCH_DIR = $(if $(filter $(ARCH),x86_64 i386),x86,$(ARCH))
ARCH_CONFIG := $(shell echo $(ARCH_DIR) | tr '[:lower:]' '[:upper:]')
# NONARCH_CONFIG used for unifdef, and only cover X86 and IA64 now
NONARCH_CONFIG = $(filter-out $(ARCH_CONFIG),X86 IA64)
PREFIX = /usr/local
DESTDIR = /
MAKEFILE_PRE = $(ARCH_DIR)/Makefile.pre
export INSTALL_MOD_DIR=updates
HEADERDIR = $(PREFIX)/include/kvm-kmod
PKGCONFIGDIR = $(PREFIX)/lib/pkgconfig
rpmrelease = devel
LINUX = ./linux-2.6
all:: prerequisite
# include header priority 1) $LINUX 2) $KERNELDIR 3) include-compat
$(MAKE) -C $(KERNELDIR) M=`pwd` \
LINUXINCLUDE="-I`pwd`/include -Iinclude \
$(if $(KERNELSOURCEDIR),\
-Iinclude2 -I$(KERNELSOURCEDIR)/include -I$(KERNELSOURCEDIR)/arch/${ARCH_DIR}/include, \
-Iarch/${ARCH_DIR}/include) \
-I`pwd`/include-compat -I`pwd`/${ARCH_DIR} \
-include $(if $(wildcard $(KERNELDIR)/include/generated), \
include/generated/autoconf.h, \
include/linux/autoconf.h) \
-include `pwd`/$(ARCH_DIR)/external-module-compat.h" \
"$$@"
include $(MAKEFILE_PRE)
KVM_VERSION_GIT = $(if $(and $(filter kvm-devel,$(KVM_VERSION)), \
$(wildcard $(LINUX)/.git)), \
$(shell git --git-dir=$(LINUX)/.git describe), \
$(KVM_VERSION))
sync-kmod:
./sync -v $(KVM_VERSION_GIT) -l $(LINUX)
sync-hdr:
for a in ia64 x86; do \
$(MAKE) -C $(LINUX) INSTALL_HDR_PATH=`pwd`/.tmp-hdrs SRCARCH="$$a" headers_install; \
mkdir -p usr/include/asm-"$$a"; \
cp .tmp-hdrs/include/asm/kvm.h .tmp-hdrs/include/asm/kvm_para.h usr/include/asm-"$$a"; \
if test $$a == x86; then \
cp .tmp-hdrs/include/asm/hyperv.h usr/include/asm-x86; \
fi \
done
mkdir -p usr/include/linux
cp .tmp-hdrs/include/linux/kvm.h .tmp-hdrs/include/linux/kvm_para.h usr/include/linux
rm -rf .tmp-hdrs
sync: sync-kmod sync-hdr
tmppc = .tmp.kvm-kmod.pc
KVM_KMOD_VERSION = $(strip $(if $(wildcard KVM_VERSION), \
$(shell cat KVM_VERSION), \
$(if $(wildcard .git), \
$(shell git describe), \
kvm-devel)))
install-hdr:
mkdir -p $(DESTDIR)/$(HEADERDIR)/asm/
install -m 644 usr/include/asm-$(ARCH_DIR)/*.h $(DESTDIR)/$(HEADERDIR)/asm/
mkdir -p $(DESTDIR)/$(HEADERDIR)/linux/
install -m 644 usr/include/linux/*.h $(DESTDIR)/$(HEADERDIR)/linux/
sed 's|PREFIX|$(PREFIX)|; s/VERSION/$(KVM_KMOD_VERSION)/' kvm-kmod.pc > $(tmppc)
install -m 644 -D $(tmppc) $(DESTDIR)/$(PKGCONFIGDIR)/kvm-kmod.pc
modules_install:
$(MAKE) -C $(KERNELDIR) M=`pwd` INSTALL_MOD_PATH=$(DESTDIR)/$(INSTALL_MOD_PATH) $@
install: install-hdr modules_install
install -m 644 -D scripts/65-kvm.rules $(DESTDIR)/etc/udev/rules.d/65-kvm.rules
tmpspec = .tmp.kvm-kmod.spec
rpm-topdir := $$(pwd)/rpmtop
RPMDIR = $(rpm-topdir)/RPMS
rpm: all
mkdir -p $(rpm-topdir)/BUILD $(RPMDIR)/$$(uname -i)
sed 's/^Release:.*/Release: $(rpmrelease)/; s/^%define kverrel.*/%define kverrel $(KERNELVERSION)/' \
kvm-kmod.spec > $(tmpspec)
rpmbuild --define="kverrel $(KERNELVERSION)" \
--define="objdir $$(pwd)/$(ARCH_DIR)" \
--define="_rpmdir $(RPMDIR)" \
--define="_topdir $(rpm-topdir)" \
-bb $(tmpspec)
clean:
$(MAKE) -C $(KERNELDIR) M=`pwd` $@
distclean: clean
rm -f config.mak kvm-kmod-config.h include/asm include-compat/asm $(tmppc) $(tmpspec)
.PHONY: all sync sync-kmod sync-hdr install install-hdr rpm clean distclean