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