]> git.proxmox.com Git - proxmox-backup.git/blob - Makefile
debcargo.toml: reflow dependencies
[proxmox-backup.git] / Makefile
1 include /usr/share/dpkg/default.mk
2 include defines.mk
3
4 PACKAGE := proxmox-backup
5 ARCH := $(DEB_BUILD_ARCH)
6
7 SUBDIRS := etc www docs
8
9 # Binaries usable by users
10 USR_BIN := \
11 proxmox-backup-client \
12 pxar
13
14 # Binaries usable by admins
15 USR_SBIN := \
16 proxmox-backup-manager
17
18 # Binaries for services:
19 SERVICE_BIN := \
20 proxmox-backup-api \
21 proxmox-backup-banner \
22 proxmox-backup-proxy
23
24 ifeq ($(BUILD_MODE), release)
25 CARGO_BUILD_ARGS += --release
26 COMPILEDIR := target/release
27 else
28 COMPILEDIR := target/debug
29 endif
30
31 ifeq ($(valgrind), yes)
32 CARGO_BUILD_ARGS += --features valgrind
33 endif
34
35 CARGO ?= cargo
36
37 COMPILED_BINS := \
38 $(addprefix $(COMPILEDIR)/,$(USR_BIN) $(USR_SBIN) $(SERVICE_BIN))
39
40 SERVER_DEB=${PACKAGE}-server_${DEB_VERSION}_${ARCH}.deb
41 CLIENT_DEB=${PACKAGE}-client_${DEB_VERSION}_${ARCH}.deb
42 DOC_DEB=${PACKAGE}-docs_${DEB_VERSION}_all.deb
43
44 DEBS=${SERVER_DEB} ${CLIENT_DEB}
45
46 DSC = rust-${PACKAGE}_${DEB_VERSION}.dsc
47
48 DESTDIR=
49
50 all: cargo-build $(SUBDIRS)
51
52 .PHONY: $(SUBDIRS)
53 $(SUBDIRS):
54 $(MAKE) -C $@
55
56 test:
57 #cargo test test_broadcast_future
58 #cargo test $(CARGO_BUILD_ARGS)
59 $(CARGO) test $(tests) $(CARGO_BUILD_ARGS)
60
61 doc:
62 $(CARGO) doc --no-deps $(CARGO_BUILD_ARGS)
63
64 # always re-create this dir
65 .PHONY: build
66 build:
67 rm -rf build
68 debcargo package --config debian/debcargo.toml --changelog-ready --no-overlay-write-back --directory build proxmox-backup $(shell dpkg-parsechangelog -l debian/changelog -SVersion | sed -e 's/-.*//')
69 sed -e '1,/^$$/ ! d' build/debian/control > build/debian/control.src
70 cat build/debian/control.src build/debian/control.in > build/debian/control
71 rm build/debian/control.in build/debian/control.src
72 rm build/Cargo.lock
73 find build/debian -name "*.hint" -delete
74 $(foreach i,$(SUBDIRS), \
75 $(MAKE) -C build/$(i) clean ;)
76
77
78 .PHONY: proxmox-backup-docs
79 proxmox-backup-docs: $(DOC_DEB)
80 $(DOC_DEB): build
81 cd build; dpkg-buildpackage -b -us -uc --no-pre-clean
82 lintian $(DOC_DEB)
83
84 # copy the local target/ dir as a build-cache
85 .PHONY: deb
86 deb: $(DEBS)
87 $(DEBS): build
88 cd build; dpkg-buildpackage -b -us -uc --no-pre-clean --build-profiles=nodoc
89 lintian $(DEBS)
90
91 .PHONY: dsc
92 dsc: $(DSC)
93 $(DSC): build
94 cd build; dpkg-buildpackage -S -us -uc -d -nc
95 lintian $(DSC)
96
97 distclean: clean
98
99 clean:
100 $(foreach i,$(SUBDIRS), \
101 $(MAKE) -C $(i) clean ;)
102 $(CARGO) clean
103 rm -rf *.deb *.dsc *.tar.gz *.buildinfo *.changes build
104 find . -name '*~' -exec rm {} ';'
105
106 .PHONY: dinstall
107 dinstall: ${DEBS}
108 dpkg -i ${DEBS}
109
110 # make sure we build binaries before docs
111 docs: cargo-build
112
113 .PHONY: cargo-build
114 cargo-build:
115 $(CARGO) build $(CARGO_BUILD_ARGS)
116
117 $(COMPILED_BINS): cargo-build
118
119 .PHONY: lint
120 lint:
121 cargo clippy -- -A clippy::all -D clippy::correctness
122
123 install: $(COMPILED_BINS)
124 install -dm755 $(DESTDIR)$(BINDIR)
125 install -dm755 $(DESTDIR)$(ZSH_COMPL_DEST)
126 $(foreach i,$(USR_BIN), \
127 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(BINDIR)/ ; \
128 install -m644 zsh-completions/_$(i) $(DESTDIR)$(ZSH_COMPL_DEST)/ ;)
129 install -dm755 $(DESTDIR)$(SBINDIR)
130 $(foreach i,$(USR_SBIN), \
131 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(SBINDIR)/ ; \
132 install -m644 zsh-completions/_$(i) $(DESTDIR)$(ZSH_COMPL_DEST)/ ;)
133 install -dm755 $(DESTDIR)$(LIBEXECDIR)/proxmox-backup
134 $(foreach i,$(SERVICE_BIN), \
135 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/ ;)
136 $(MAKE) -C www install
137 $(MAKE) -C docs install
138
139 .PHONY: upload
140 upload: ${SERVER_DEB} ${CLIENT_DEB} ${DOC_DEB}
141 # check if working directory is clean
142 git diff --exit-code --stat && git diff --exit-code --stat --staged
143 tar cf - ${SERVER_DEB} ${DOC_DEB} | ssh -X repoman@repo.proxmox.com upload --product pbs --dist buster
144 tar cf - ${CLIENT_DEB} | ssh -X repoman@repo.proxmox.com upload --product "pbs,pve" --dist buster