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