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