add qmeventd
[qemu-server.git] / Makefile
1 VERSION=5.0
2 PACKAGE=qemu-server
3 PKGREL=40
4
5 CFLAGS=-O2 -Werror -Wall -Wextra -Wpedantic -Wtype-limits -Wl,-z,relro -std=gnu11
6 JSON_CFLAGS=$(shell pkg-config --cflags json-c)
7 JSON_LIBS=$(shell pkg-config --libs json-c)
8
9 DESTDIR=
10 PREFIX=/usr
11 BINDIR=${PREFIX}/bin
12 SBINDIR=${PREFIX}/sbin
13 BINDIR=${PREFIX}/bin
14 LIBDIR=${PREFIX}/lib/${PACKAGE}
15 SERVICEDIR=/lib/systemd/system
16 VARLIBDIR=/var/lib/${PACKAGE}
17 MANDIR=${PREFIX}/share/man
18 DOCDIR=${PREFIX}/share/doc
19 MAN1DIR=${MANDIR}/man1/
20 MAN5DIR=${MANDIR}/man5/
21 MAN8DIR=${MANDIR}/man8/
22 BASHCOMPLDIR=${PREFIX}/share/bash-completion/completions/
23 export PERLDIR=${PREFIX}/share/perl5
24 PERLINCDIR=${PERLDIR}/asm-x86_64
25
26 ARCH:=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
27 GITVERSION:=$(shell git rev-parse HEAD)
28
29 DEB=${PACKAGE}_${VERSION}-${PKGREL}_${ARCH}.deb
30
31 # this requires package pve-doc-generator
32 export NOVIEW=1
33 include /usr/share/pve-doc-generator/pve-doc-generator.mk
34
35 export SOURCE_DATE_EPOCH ?= $(shell dpkg-parsechangelog -STimestamp)
36
37 all:
38
39 .PHONY: dinstall
40 dinstall: deb
41         dpkg -i ${DEB}
42
43 qmeventd: qmeventd.c
44         $(CC) $(CFLAGS) ${JSON_CFLAGS} -o $@ $< ${JSON_LIBS}
45
46 qm.bash-completion:
47         PVE_GENERATING_DOCS=1 perl -I. -T -e "use PVE::CLI::qm; PVE::CLI::qm->generate_bash_completions();" >$@.tmp
48         mv $@.tmp $@
49
50 qmrestore.bash-completion:
51         PVE_GENERATING_DOCS=1 perl -I. -T -e "use PVE::CLI::qmrestore; PVE::CLI::qmrestore->generate_bash_completions();" >$@.tmp
52         mv $@.tmp $@
53
54 PKGSOURCES=qm qm.1 qmrestore qmrestore.1 qmextract qm.conf.5 qm.bash-completion qmrestore.bash-completion qmeventd qmeventd.8
55
56 .PHONY: install
57 install: ${PKGSOURCES}
58         install -d ${DESTDIR}/${SBINDIR}
59         install -d ${DESTDIR}${LIBDIR}
60         install -d ${DESTDIR}${VARLIBDIR}
61         install -d ${DESTDIR}${SERVICEDIR}
62         install -d ${DESTDIR}/${MAN1DIR}
63         install -d ${DESTDIR}/${MAN5DIR}
64         install -d ${DESTDIR}/${MAN8DIR}
65         install -d ${DESTDIR}/usr/share/man/man5
66         install -d ${DESTDIR}/usr/share/${PACKAGE}
67         install -m 0644 pve-usb.cfg ${DESTDIR}/usr/share/${PACKAGE}
68         install -m 0644 pve-q35.cfg ${DESTDIR}/usr/share/${PACKAGE}
69         install -m 0644 -D qm.bash-completion ${DESTDIR}/${BASHCOMPLDIR}/qm
70         install -m 0644 -D qmrestore.bash-completion ${DESTDIR}/${BASHCOMPLDIR}/qmrestore
71         install -m 0644 -D bootsplash.jpg ${DESTDIR}/usr/share/${PACKAGE}
72         make -C PVE install
73         install -m 0755 qm ${DESTDIR}${SBINDIR}
74         install -m 0755 qmrestore ${DESTDIR}${SBINDIR}
75         install -m 0755 qmeventd ${DESTDIR}${SBINDIR}
76         install -m 0644 qmeventd.service ${DESTDIR}${SERVICEDIR}
77         install -m 0755 pve-bridge ${DESTDIR}${VARLIBDIR}/pve-bridge
78         install -m 0755 pve-bridge-hotplug ${DESTDIR}${VARLIBDIR}/pve-bridge-hotplug
79         install -m 0755 pve-bridgedown ${DESTDIR}${VARLIBDIR}/pve-bridgedown
80         install -D -m 0644 modules-load.conf ${DESTDIR}/etc/modules-load.d/qemu-server.conf
81         install -m 0755 qmextract ${DESTDIR}${LIBDIR}
82         install -m 0644 qm.1 ${DESTDIR}/${MAN1DIR}
83         gzip -9 -n -f ${DESTDIR}/${MAN1DIR}/qm.1
84         install -m 0644 qmeventd.8 ${DESTDIR}/${MAN8DIR}
85         gzip -9 -n -f ${DESTDIR}/${MAN8DIR}/qmeventd.8
86         install -m 0644 qmrestore.1 ${DESTDIR}/${MAN1DIR}
87         gzip -9 -n -f ${DESTDIR}/${MAN1DIR}/qmrestore.1
88         install -m 0644 qm.conf.5 ${DESTDIR}/${MAN5DIR}
89         gzip -9 -n -f ${DESTDIR}/${MAN5DIR}/qm.conf.5
90         cd ${DESTDIR}/${MAN5DIR}; ln -s -f qm.conf.5.gz vm.conf.5.gz
91
92 .PHONY: deb
93 deb: ${DEB}
94 ${DEB}:
95         rm -rf build
96         rsync -a * build
97         echo "git clone git://git.proxmox.com/git/qemu-server.git\\ngit checkout ${GITVERSION}" > build/debian/SOURCE
98         cd build; dpkg-buildpackage -b -us -uc
99         lintian ${DEB}
100
101 .PHONY: test
102 test:
103         PVE_GENERATING_DOCS=1 perl -I. ./qm verifyapi
104         make -C test
105
106 .PHONY: upload
107 upload: ${DEB}
108         tar cf - ${DEB} | ssh repoman@repo.proxmox.com upload --product pve --dist stretch
109
110 .PHONY: clean
111 clean:
112         make cleanup-docgen
113         rm -rf build *.deb *.buildinfo *.changes qmeventd
114         find . -name '*~' -exec rm {} ';'
115
116
117 .PHONY: distclean
118 distclean: clean