]> git.proxmox.com Git - proxmox-perl-rs.git/blob - pve-rs/Makefile
d04868da75676f515a22a801f310d467690698c1
[proxmox-perl-rs.git] / pve-rs / Makefile
1 include ../defines.mk
2 include /usr/share/dpkg/default.mk
3
4 PACKAGE=libpve-rs-perl
5 export PERLMOD_PRODUCT=PVE
6
7 ARCH:=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
8 export GITVERSION:=$(shell git rev-parse HEAD)
9
10 PERL_INSTALLVENDORARCH != perl -MConfig -e 'print $$Config{installvendorarch};'
11 PERL_INSTALLVENDORLIB != perl -MConfig -e 'print $$Config{installvendorlib};'
12
13 MAIN_DEB=${PACKAGE}_${DEB_VERSION}_${ARCH}.deb
14 DBGSYM_DEB=${PACKAGE}-dbgsym_${DEB_VERSION}_${ARCH}.deb
15 DEBS=$(MAIN_DEB) $(DBGSYM_DEB)
16
17 DESTDIR=
18
19 PM_DIR := PVE
20
21 ifeq ($(BUILD_MODE), release)
22 CARGO_BUILD_ARGS += --release
23 TARGET_DIR=release
24 else
25 TARGET_DIR=debug
26 endif
27
28 all: PVE Proxmox/Lib/PVE.pm
29 ifneq ($(BUILD_MODE), skip)
30 cargo build $(CARGO_BUILD_ARGS)
31 mkdir -p test/Proxmox/Lib
32 sed -r -e \
33 's@^sub libdirs.*$$@sub libdirs { return ("../target/$(TARGET_DIR)", "../../target/$(TARGET_DIR)"); }@' \
34 Proxmox/Lib/PVE.pm >test/Proxmox/Lib/PVE.pm
35 endif
36
37 PVE: ../scripts/genpackage.pl
38 perl ../scripts/genpackage.pl PVE \
39 PVE::RS::APT::Repositories \
40 PVE::RS::OpenId \
41 PVE::RS::ResourceScheduling::Static \
42 PVE::RS::TFA
43
44 Proxmox/Lib/PVE.pm: ../Proxmox/Lib/template.pm
45 mkdir -p Proxmox/Lib
46 $(call package_template,PVE,pve_rs,../)
47
48 check: all
49 $(MAKE) -C test test
50
51 # always re-create this dir
52 # but also copy the local target/ and PVE/ dirs as a build-cache
53 .PHONY: build
54 build:
55 rm -rf build
56 cargo build --release
57 rsync -a debian Makefile Cargo.toml Cargo.lock src target PVE build/
58
59 .PHONY: install
60 install: ../target/release/libpve_rs.so Proxmox/Lib/PVE.pm PVE
61 install -d -m755 $(DESTDIR)$(PERL_INSTALLVENDORARCH)/auto
62 install -m644 ../target/release/libpve_rs.so $(DESTDIR)$(PERL_INSTALLVENDORARCH)/auto/libpve_rs.so
63 install -d -m755 $(DESTDIR)$(PERL_INSTALLVENDORLIB)
64 install -d -m755 $(DESTDIR)$(PERL_INSTALLVENDORLIB)/Proxmox/Lib
65 install -m644 Proxmox/Lib/PVE.pm $(DESTDIR)$(PERL_INSTALLVENDORLIB)/Proxmox/Lib/PVE.pm
66 find $(PM_DIR) \! -type d -print -exec install -Dm644 '{}' $(DESTDIR)$(PERL_INSTALLVENDORLIB)'/{}' ';'
67
68 .PHONY: deb
69 deb: $(MAIN_DEB)
70 $(MAIN_DEB): build
71 cd build; dpkg-buildpackage -b -us -uc --no-pre-clean
72 lintian $(DEBS)
73
74 distclean: clean
75
76 clean:
77 cargo clean
78 rm -rf *.deb *.dsc *.tar.gz *.buildinfo *.changes Cargo.lock build
79 find . -name '*~' -exec rm {} ';'
80
81 .PHONY: dinstall
82 dinstall: ${DEBS}
83 dpkg -i ${DEBS}
84
85 .PHONY: upload
86 upload: ${DEBS}
87 # check if working directory is clean
88 git diff --exit-code --stat && git diff --exit-code --stat --staged
89 tar cf - ${DEBS} | ssh -X repoman@repo.proxmox.com upload --product pve --dist bullseye