]> git.proxmox.com Git - proxmox-backup.git/blob - Makefile
buildsys: add 'make lint'
[proxmox-backup.git] / Makefile
1 include defines.mk
2
3 ARCH:=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
4 GITVERSION:=$(shell git rev-parse HEAD)
5
6 SUBDIRS := etc www docs
7
8 # Binaries usable by users
9 USR_BIN := \
10 proxmox-backup-client \
11 pxar
12
13 # Binaries usable by admins
14 USR_SBIN := proxmox-backup-manager
15
16 # Binaries for services:
17 SERVICE_BIN := \
18 proxmox-backup-api \
19 proxmox-backup-proxy
20
21 ifeq ($(BUILD_MODE), release)
22 CARGO_BUILD_ARGS += --release
23 COMPILEDIR := target/release
24 else
25 COMPILEDIR := target/debug
26 endif
27
28 ifeq ($(valgrind), yes)
29 CARGO_BUILD_ARGS += --features valgrind
30 endif
31
32 COMPILED_BINS := \
33 $(addprefix $(COMPILEDIR)/,$(USR_BIN) $(USR_SBIN) $(SERVICE_BIN))
34
35 DEB=${PACKAGE}_${PKGVER}-${PKGREL}_${ARCH}.deb
36 DSC=${PACKAGE}_${PKGVER}-${PKGREL}.dsc
37
38 DESTDIR=
39
40 all: cargo-build $(SUBDIRS)
41
42 .PHONY: $(SUBDIRS)
43 $(SUBDIRS):
44 $(MAKE) -C $@
45
46 test:
47 #cargo test test_broadcast_future
48 #cargo test $(CARGO_BUILD_ARGS)
49 cargo test $(tests) $(CARGO_BUILD_ARGS)
50
51 doc:
52 cargo doc --no-deps $(CARGO_BUILD_ARGS)
53
54 # always re-create this dir
55 # but also copy the local target/ dir as a build-cache
56 .PHONY: build
57 build:
58 rm -rf build
59 cargo build --release
60 rsync -a debian Makefile defines.mk Cargo.toml Cargo.lock \
61 src zstd-sys $(SUBDIRS) \
62 target tests build/
63 $(foreach i,$(SUBDIRS), \
64 $(MAKE) -C build/$(i) clean ;)
65
66 .PHONY: deb
67 deb: $(DEB)
68 $(DEB): build
69 cd build; dpkg-buildpackage -b -us -uc --no-pre-clean
70 lintian $(DEB)
71
72 .PHONY: dsc
73 dsc: $(DSC)
74 $(DSC): build
75 cd build; dpkg-buildpackage -S -us -uc -d -nc
76 lintian $(DSC)
77
78 distclean: clean
79
80 clean:
81 $(foreach i,$(SUBDIRS), \
82 $(MAKE) -C $(i) clean ;)
83 cargo clean
84 rm -rf *.deb *.dsc *.tar.gz *.buildinfo *.changes build
85 find . -name '*~' -exec rm {} ';'
86
87 .PHONY: dinstall
88 dinstall: ${DEB}
89 dpkg -i ${DEB}
90
91 # make sure we build binaries before docs
92 docs: cargo-build
93
94 .PHONY: cargo-build
95 cargo-build:
96 cargo build $(CARGO_BUILD_ARGS)
97
98 $(COMPILED_BINS): cargo-build
99
100 .PHONY: lint
101 lint:
102 cargo clippy -- -A clippy::all -D clippy::correctness
103
104 install: $(COMPILED_BINS)
105 install -dm755 $(DESTDIR)$(BINDIR)
106 $(foreach i,$(USR_BIN), \
107 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(BINDIR)/ ;)
108 install -dm755 $(DESTDIR)$(SBINDIR)
109 $(foreach i,$(USR_SBIN), \
110 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(SBINDIR)/ ;)
111 install -dm755 $(DESTDIR)$(LIBEXECDIR)/proxmox-backup
112 $(foreach i,$(SERVICE_BIN), \
113 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/ ;)
114 $(MAKE) -C www install
115 $(MAKE) -C docs install