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