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