]> git.proxmox.com Git - pve-lxc-syscalld.git/blob - Makefile
buildsys: add CARGO_BUILD_ARGS to test target to avoid full rebuild
[pve-lxc-syscalld.git] / Makefile
1 include /usr/share/dpkg/architecture.mk
2 include /usr/share/dpkg/pkg-info.mk
3
4 include defines.mk
5
6 GITVERSION:=$(shell git rev-parse HEAD)
7
8 SUBDIRS := etc
9
10 ifeq ($(BUILD_MODE), release)
11 CARGO_BUILD_ARGS += --release
12 COMPILEDIR := target/release
13 else
14 COMPILEDIR := target/debug
15 endif
16
17 SERVICE_BIN := pve-lxc-syscalld
18
19 COMPILED_BINS := \
20 $(addprefix $(COMPILEDIR)/,$(SERVICE_BIN))
21
22 DEB=$(PACKAGE)_$(DEB_VERSION)_$(DEB_HOST_ARCH).deb
23 DSC=rust-$(PACKAGE)_$(DEB_VERSION).dsc
24
25 all: cargo-build $(SUBDIRS)
26
27 .PHONY: $(SUBDIRS)
28 $(SUBDIRS):
29 $(MAKE) -C $@
30
31 .PHONY: cargo-build
32 cargo-build:
33 cargo build $(CARGO_BUILD_ARGS)
34
35 .PHONY: test
36 test:
37 cargo test $(CARGO_BUILD_ARGS)
38
39 .PHONY: check
40 check: test
41
42 .PHONY: san
43 san:
44 cargo +nightly fmt -- --check
45 cargo clippy
46 cargo test
47
48 $(COMPILED_BINS): cargo-build
49
50 install: $(COMPILED_BINS)
51 install -dm755 $(DESTDIR)$(LIBEXECDIR)/pve-lxc-syscalld
52 $(foreach i,$(SERVICE_BIN), \
53 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(LIBEXECDIR)/pve-lxc-syscalld/ ;)
54
55 .PHONY: build
56 build:
57 rm -rf build
58 debcargo package \
59 --config debian/debcargo.toml \
60 --changelog-ready \
61 --no-overlay-write-back \
62 --directory build \
63 pve-lxc-syscalld \
64 $(shell dpkg-parsechangelog -l debian/changelog -SVersion | sed -e 's/-.*//')
65 sed -e '1,/^$$/ ! d' build/debian/control > build/debian/control.src
66 cat build/debian/control.src build/debian/control.in > build/debian/control
67 rm build/debian/control.in build/debian/control.src
68 rm build/Cargo.lock
69 find build/debian -name "*.hint" -delete
70 echo system >build/rust-toolchain
71 $(foreach i,$(SUBDIRS), \
72 $(MAKE) -C build/$(i) clean ;)
73
74 .PHONY: deb
75 deb: $(DEB)
76 $(DEB): build
77 cd build; dpkg-buildpackage -b -us -uc --no-pre-clean --build-profiles=nodoc
78 lintian $(DEB)
79
80 .PHONY: dsc
81 dsc: $(DSC)
82 $(DSC): build
83 cd build; dpkg-buildpackage -S -us -uc -d -nc
84 lintian $(DSC)
85
86 .PHONY: dinstall
87 dinstall:
88 $(MAKE) deb
89 sudo -k dpkg -i $(DEB)
90
91 clean:
92 $(foreach i,$(SUBDIRS), \
93 $(MAKE) -C $(i) clean ;)
94 cargo clean
95 rm -rf *.deb *.dsc *.tar.gz *.buildinfo *.changes build