]> git.proxmox.com Git - proxmox-backup.git/blob - Makefile
1d04eb65ea0a9c4f94ad37a3e673f39fc717a36c
[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 proxmox-file-restore \
13 pxar \
14 proxmox-tape \
15 pmtx \
16 pmt
17
18 # Binaries usable by admins
19 USR_SBIN := \
20 proxmox-backup-manager \
21 proxmox-backup-debug \
22
23 # Binaries for services:
24 SERVICE_BIN := \
25 proxmox-backup-api \
26 proxmox-backup-banner \
27 proxmox-backup-proxy \
28 proxmox-daily-update
29
30 # Single file restore daemon
31 RESTORE_BIN := \
32 proxmox-restore-daemon
33
34 SUBCRATES != cargo metadata --no-deps --format-version=1 \
35 | jq -r .workspace_members'[]' \
36 | awk '!/^proxmox-backup\s/ { printf "%s ", $$1 }'
37
38 ifeq ($(BUILD_MODE), release)
39 CARGO_BUILD_ARGS += --release
40 COMPILEDIR := target/release
41 else
42 COMPILEDIR := target/debug
43 endif
44
45 ifeq ($(valgrind), yes)
46 CARGO_BUILD_ARGS += --features valgrind
47 endif
48
49 CARGO ?= cargo
50
51 COMPILED_BINS := \
52 $(addprefix $(COMPILEDIR)/,$(USR_BIN) $(USR_SBIN) $(SERVICE_BIN) $(RESTORE_BIN))
53
54 export DEB_VERSION DEB_VERSION_UPSTREAM
55
56 SERVER_DEB=${PACKAGE}-server_${DEB_VERSION}_${ARCH}.deb
57 SERVER_DBG_DEB=${PACKAGE}-server-dbgsym_${DEB_VERSION}_${ARCH}.deb
58 CLIENT_DEB=${PACKAGE}-client_${DEB_VERSION}_${ARCH}.deb
59 CLIENT_DBG_DEB=${PACKAGE}-client-dbgsym_${DEB_VERSION}_${ARCH}.deb
60 RESTORE_DEB=proxmox-backup-file-restore_${DEB_VERSION}_${ARCH}.deb
61 RESTORE_DBG_DEB=proxmox-backup-file-restore-dbgsym_${DEB_VERSION}_${ARCH}.deb
62 DOC_DEB=${PACKAGE}-docs_${DEB_VERSION}_all.deb
63
64 DEBS=${SERVER_DEB} ${SERVER_DBG_DEB} ${CLIENT_DEB} ${CLIENT_DBG_DEB} \
65 ${RESTORE_DEB} ${RESTORE_DBG_DEB} ${DEBUG_DEB} ${DEBUG_DBG_DEB}
66
67 DSC = rust-${PACKAGE}_${DEB_VERSION}.dsc
68
69 DESTDIR=
70
71 tests ?= --workspace
72
73 all: $(SUBDIRS)
74
75 .PHONY: $(SUBDIRS)
76 $(SUBDIRS):
77 $(MAKE) -C $@
78
79 test:
80 #cargo test test_broadcast_future
81 #cargo test $(CARGO_BUILD_ARGS)
82 $(CARGO) test $(tests) $(CARGO_BUILD_ARGS)
83
84 doc:
85 $(CARGO) doc --workspace --no-deps $(CARGO_BUILD_ARGS)
86
87 # always re-create this dir
88 .PHONY: build
89 build:
90 rm -rf build
91 mkdir build
92 cp -a debian \
93 Cargo.toml src \
94 $(SUBCRATES) \
95 docs etc examples tests www zsh-completions \
96 defines.mk Makefile \
97 ./build/
98 rm -f build/Cargo.lock
99 find build/debian -name "*.hint" -delete
100 $(foreach i,$(SUBDIRS), \
101 $(MAKE) -C build/$(i) clean ;)
102
103
104 .PHONY: proxmox-backup-docs
105 $(DOC_DEB) $(DEBS): proxmox-backup-docs
106 proxmox-backup-docs: build
107 cd build; dpkg-buildpackage -b -us -uc --no-pre-clean
108 lintian $(DOC_DEB)
109
110 # copy the local target/ dir as a build-cache
111 .PHONY: deb dsc deb-nodoc
112 deb-nodoc: build
113 cd build; dpkg-buildpackage -b -us -uc --no-pre-clean --build-profiles=nodoc
114 lintian $(DEBS)
115
116 $(DEBS): deb
117 deb: build
118 cd build; dpkg-buildpackage -b -us -uc
119 lintian $(DEBS) $(DOC_DEB)
120
121 .PHONY: dsc
122 dsc: $(DSC)
123 $(DSC): build
124 cd build; dpkg-buildpackage -S -us -uc -d
125 lintian $(DSC)
126
127 .PHONY: clean distclean deb clean
128 distclean: clean
129 clean: clean-deb
130 $(foreach i,$(SUBDIRS), \
131 $(MAKE) -C $(i) clean ;)
132 $(CARGO) clean
133 rm -f .do-cargo-build
134 find . -name '*~' -exec rm {} ';'
135
136 # allows one to avoid running cargo clean when one just wants to tidy up after a packgae build
137 clean-deb:
138 rm -rf *.deb *.dsc *.tar.gz *.buildinfo *.changes build/
139
140 .PHONY: dinstall
141 dinstall: ${SERVER_DEB} ${SERVER_DBG_DEB} ${CLIENT_DEB} ${CLIENT_DBG_DEB} \
142 ${DEBUG_DEB} ${DEBUG_DBG_DEB}
143 dpkg -i $^
144
145 # make sure we build binaries before docs
146 docs: $(COMPILEDIR)/dump-catalog-shell-cli $(COMPILEDIR)/docgen
147
148 .PHONY: cargo-build
149 cargo-build:
150 rm -f .do-cargo-build
151 $(MAKE) $(COMPILED_BINS)
152
153 $(COMPILED_BINS) $(COMPILEDIR)/dump-catalog-shell-cli $(COMPILEDIR)/docgen: .do-cargo-build
154 .do-cargo-build:
155 $(CARGO) build $(CARGO_BUILD_ARGS) \
156 --package proxmox-backup-banner \
157 --bin proxmox-backup-banner \
158 --package proxmox-backup-client \
159 --bin proxmox-backup-client \
160 --bin dump-catalog-shell-cli \
161 --bin proxmox-backup-debug \
162 --package proxmox-file-restore \
163 --bin proxmox-file-restore \
164 --package pxar-bin \
165 --bin pxar \
166 --package pbs-tape \
167 --bin pmt \
168 --bin pmtx \
169 --package proxmox-restore-daemon \
170 --bin proxmox-restore-daemon \
171 --package proxmox-backup \
172 --bin docgen \
173 --bin proxmox-backup-api \
174 --bin proxmox-backup-manager \
175 --bin proxmox-backup-proxy \
176 --bin proxmox-daily-update \
177 --bin proxmox-file-restore \
178 --bin proxmox-tape \
179 --bin sg-tape-cmd
180 touch "$@"
181
182
183 .PHONY: lint
184 lint:
185 cargo clippy -- -A clippy::all -D clippy::correctness
186
187 install: $(COMPILED_BINS)
188 install -dm755 $(DESTDIR)$(BINDIR)
189 install -dm755 $(DESTDIR)$(ZSH_COMPL_DEST)
190 $(foreach i,$(USR_BIN), \
191 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(BINDIR)/ ; \
192 install -m644 zsh-completions/_$(i) $(DESTDIR)$(ZSH_COMPL_DEST)/ ;)
193 install -dm755 $(DESTDIR)$(SBINDIR)
194 $(foreach i,$(USR_SBIN), \
195 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(SBINDIR)/ ; \
196 install -m644 zsh-completions/_$(i) $(DESTDIR)$(ZSH_COMPL_DEST)/ ;)
197 install -dm755 $(DESTDIR)$(LIBEXECDIR)/proxmox-backup
198 install -dm755 $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/file-restore
199 $(foreach i,$(RESTORE_BIN), \
200 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/file-restore/ ;)
201 # install sg-tape-cmd as setuid binary
202 install -m4755 -o root -g root $(COMPILEDIR)/sg-tape-cmd $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/sg-tape-cmd
203 $(foreach i,$(SERVICE_BIN), \
204 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/ ;)
205 $(MAKE) -C www install
206 $(MAKE) -C docs install
207
208 .PHONY: upload
209 upload: ${SERVER_DEB} ${CLIENT_DEB} ${RESTORE_DEB} ${DOC_DEB} ${DEBUG_DEB}
210 # check if working directory is clean
211 git diff --exit-code --stat && git diff --exit-code --stat --staged
212 tar cf - ${SERVER_DEB} ${SERVER_DBG_DEB} ${DOC_DEB} ${CLIENT_DEB} \
213 ${CLIENT_DBG_DEB} ${DEBUG_DEB} ${DEBUG_DBG_DEB} \
214 | ssh -X repoman@repo.proxmox.com upload --product pbs --dist bullseye
215 tar cf - ${CLIENT_DEB} ${CLIENT_DBG_DEB} | ssh -X repoman@repo.proxmox.com upload --product "pve,pmg,pbs-client" --dist bullseye
216 tar cf - ${RESTORE_DEB} ${RESTORE_DBG_DEB} | ssh -X repoman@repo.proxmox.com upload --product "pve" --dist bullseye