summaryrefslogtreecommitdiff
path: root/Makefile
blob: 4a3745607a07c6b93943f5ec122f913a72995c40 (plain)
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

include config.mak

DESTDIR=

rpmrelease = devel

.PHONY: kernel user libkvm qemu bios vgabios extboot clean

all: $(if $(WANT_MODULE), kernel) user libkvm qemu

kcmd = $(if $(WANT_MODULE),,@\#)

qemu kernel user libkvm:
	$(MAKE) -C $@

qemu: libkvm extboot
user: libkvm

bios:
	$(MAKE) -C $@
	cp bios/BIOS-bochs-latest qemu/pc-bios/bios.bin

vgabios:
	$(MAKE) -C $@
	cp vgabios/VGABIOS-lgpl-latest.bin qemu/pc-bios/vgabios.bin
	cp vgabios/VGABIOS-lgpl-latest.cirrus.bin qemu/pc-bios/vgabios-cirrus.bin

extboot:
	$(MAKE) -C $@
	if ! [ -f qemu/pc-bios/extboot.bin ] \
           || ! cmp -s qemu/pc-bios/extboot.bin extboot/extboot.bin; then \
		cp extboot/extboot.bin qemu/pc-bios/extboot.bin; \
	fi


bindir = /usr/bin
bin = $(bindir)/kvm
initdir = /etc/init.d
confdir = /etc/kvm
utilsdir = /etc/kvm/utils

install-rpm:
	mkdir -p $(DESTDIR)/$(bindir)
	mkdir -p $(DESTDIR)/$(confdir)
	mkdir -p $(DESTDIR)/$(initdir)
	mkdir -p $(DESTDIR)/$(utilsdir)
	mkdir -p $(DESTDIR)/etc/udev/rules.d
	make -C qemu DESTDIR=$(DESTDIR)/ install
	ln -sf /usr/kvm/bin/qemu-system-x86_64 $(DESTDIR)/$(bin)
	install -m 755 kvm_stat $(DESTDIR)/$(bindir)/kvm_stat
	cp scripts/kvm $(DESTDIR)/$(initdir)/kvm
	cp scripts/qemu-ifup $(DESTDIR)/$(confdir)/qemu-ifup
	install -t $(DESTDIR)/etc/udev/rules.d scripts/*kvm*.rules

install:
	$(kcmd)make -C kernel DESTDIR="$(DESTDIR)" install
	make -C libkvm DESTDIR="$(DESTDIR)" install
	make -C qemu DESTDIR="$(DESTDIR)" install

tmpspec = .tmp.kvm.spec
RPMTOPDIR = $$(pwd)/rpmtop

rpm:	srpm
	rm -rf $(RPMTOPDIR)/BUILD
	mkdir -p $(RPMTOPDIR)/{BUILD,RPMS/$$(uname -i)}
	rpmbuild --rebuild \
		 --define="_topdir $(RPMTOPDIR)" \
		$(RPMTOPDIR)/SRPMS/kvm-0.0-$(rpmrelease).src.rpm

srpm:
	mkdir -p $(RPMTOPDIR)/{SOURCES,SRPMS}
	sed 's/^Release:.*/Release: $(rpmrelease)/' kvm.spec > $(tmpspec)
	tar czf $(RPMTOPDIR)/SOURCES/kvm.tar.gz qemu
	tar czf $(RPMTOPDIR)/SOURCES/user.tar.gz user
	tar czf $(RPMTOPDIR)/SOURCES/libkvm.tar.gz libkvm
	tar czf $(RPMTOPDIR)/SOURCES/kernel.tar.gz kernel
	tar czf $(RPMTOPDIR)/SOURCES/scripts.tar.gz scripts
	tar czf $(RPMTOPDIR)/SOURCES/extboot.tar.gz extboot
	cp Makefile configure kvm_stat $(RPMTOPDIR)/SOURCES
	rpmbuild  --define="_topdir $(RPMTOPDIR)" -bs $(tmpspec)
	$(RM) $(tmpspec)

clean:
	for i in $(if $(WANT_MODULE), kernel) user libkvm qemu; do \
		make -C $$i clean; \
	done
	rm -f config.mak user/config.mak