Add update-pve-common make target to move code to PVE/APIClient.
[pve-client.git] / Makefile
1 PACKAGE=pve-client
2 PKGVER=0.1
3 PKGREL=1
4
5 DEB=${PACKAGE}_${PKGVER}-${PKGREL}_all.deb
6
7 DESTDIR=
8
9 PERL5_DIR=${DESTDIR}/usr/share/perl5
10 LIB_DIR=${DESTDIR}/usr/share/${PACKAGE}
11 DOCDIR=${DESTDIR}/usr/share/doc/${PACKAGE}
12 BASHCOMPLDIR=${DESTDIR}/usr/share/bash-completion/completions/
13
14 PVE_COMMON_FILES=               \
15         CLIHandler.pm           \
16         JSONSchema.pm           \
17         PTY.pm                  \
18         RESTHandler.pm          \
19         SafeSyslog.pm           \
20         SectionConfig.pm        \
21
22 all: ${DEB}
23
24 .PHONY: deb
25 deb ${DEB}:
26         rm -rf build
27         rsync -a debian build
28         make DESTDIR=./build install
29         cd build; dpkg-buildpackage -rfakeroot -b -us -uc
30         lintian ${DEB}
31
32 install:  pve-api-definition.dat
33         install -d -m 0755 ${PERL5_DIR}/PVE/APIClient
34         # install library tools from pve-common
35         for i in ${PVE_COMMON_FILES}; do install -m 0644 PVE/APIClient/$$i ${PERL5_DIR}/PVE/APIClient; done
36         # install pveclient
37         install -D -m 0644 PVE/APIClient/Tools.pm ${PERL5_DIR}/PVE/APIClient/Tools.pm
38         install -D -m 0644 PVE/APIClient/Helpers.pm ${PERL5_DIR}/PVE/APIClient/Helpers.pm
39         install -D -m 0644 PVE/APIClient/Config.pm ${PERL5_DIR}/PVE/APIClient/Config.pm
40         install -D -m 0644 PVE/APIClient/Commands/remote.pm ${PERL5_DIR}/PVE/APIClient/Commands/remote.pm
41         install -D -m 0644 PVE/APIClient/Commands/lxc.pm ${PERL5_DIR}/PVE/APIClient/Commands/lxc.pm
42         install -D -m 0644 PVE/APIClient/Commands/config.pm ${PERL5_DIR}/PVE/APIClient/Commands/config.pm
43         install -D -m 0644 PVE/APIClient/Commands/list.pm ${PERL5_DIR}/PVE/APIClient/Commands/list.pm
44         install -D -m 0644 PVE/APIClient/Commands/GuestStatus.pm ${PERL5_DIR}/PVE/APIClient/Commands/GuestStatus.pm
45         install -D -m 0644 pve-api-definition.dat ${LIB_DIR}/pve-api-definition.dat
46         install -D -m 0755 pveclient ${DESTDIR}/usr/bin/pveclient
47         install -D -m 0644 pveclient.bash-completion ${BASHCOMPLDIR}/pveclient
48
49
50 update-pve-common:
51         for i in ${PVE_COMMON_FILES}; do cp ../pve-common/src/PVE/$$i PVE/APIClient/; done
52         for i in ${PVE_COMMON_FILES}; do sed -i 's/PVE::/PVE::APIClient::/g' PVE/APIClient/$$i; done
53         # Remove INotify from CLIHandler.pm
54         sed -i 's/use PVE::APIClient::INotify;//' PVE/APIClient/CLIHandler.pm
55
56
57 pve-api-definition.dat:
58         ./extractapi.pl > pve-api-definition.dat.tmp
59         mv pve-api-definition.dat.tmp pve-api-definition.dat
60
61 #.PHONY: upload
62 #upload: ${DEB}
63 #       tar cf - ${DEB} | ssh -X repoman@repo.proxmox.com upload --product pmg,pve --dist stretch
64
65 distclean: clean
66
67 clean:
68         rm -rf ./build *.deb *.changes *.buildinfo
69         find . -name '*~' -exec rm {} ';'
70
71 .PHONY: dinstall
72 dinstall: ${DEB}
73         dpkg -i ${DEB}