]> git.proxmox.com Git - proxmox-backup.git/blob - Makefile
move remote config into pbs-config workspace
[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 DEBUG_DEB=${PACKAGE}-debug_${DEB_VERSION}_${ARCH}.deb
75 DEBUG_DBG_DEB=${PACKAGE}-debug-dbgsym_${DEB_VERSION}_${ARCH}.deb
76 DOC_DEB=${PACKAGE}-docs_${DEB_VERSION}_all.deb
77
78 DEBS=${SERVER_DEB} ${SERVER_DBG_DEB} ${CLIENT_DEB} ${CLIENT_DBG_DEB} \
79 ${RESTORE_DEB} ${RESTORE_DBG_DEB} ${DEBUG_DEB} ${DEBUG_DBG_DEB}
80
81 DSC = rust-${PACKAGE}_${DEB_VERSION}.dsc
82
83 DESTDIR=
84
85 tests ?= --workspace
86
87 all: $(SUBDIRS)
88
89 .PHONY: $(SUBDIRS)
90 $(SUBDIRS):
91 $(MAKE) -C $@
92
93 test:
94 #cargo test test_broadcast_future
95 #cargo test $(CARGO_BUILD_ARGS)
96 $(CARGO) test $(tests) $(CARGO_BUILD_ARGS)
97
98 doc:
99 $(CARGO) doc --workspace --no-deps $(CARGO_BUILD_ARGS)
100
101 # always re-create this dir
102 .PHONY: build
103 build:
104 rm -rf build
105 mkdir build
106 cp -a debian \
107 Cargo.toml src \
108 $(SUBCRATES) \
109 docs etc examples tests www zsh-completions \
110 defines.mk Makefile \
111 ./build/
112 rm -f build/Cargo.lock
113 find build/debian -name "*.hint" -delete
114 $(foreach i,$(SUBDIRS), \
115 $(MAKE) -C build/$(i) clean ;)
116
117
118 .PHONY: proxmox-backup-docs
119 $(DOC_DEB) $(DEBS): proxmox-backup-docs
120 proxmox-backup-docs: build
121 cd build; dpkg-buildpackage -b -us -uc --no-pre-clean
122 lintian $(DOC_DEB)
123
124 # copy the local target/ dir as a build-cache
125 .PHONY: deb
126 $(DEBS): deb
127 deb: build
128 cd build; dpkg-buildpackage -b -us -uc --no-pre-clean --build-profiles=nodoc
129 lintian $(DEBS)
130
131 .PHONY: deb-all
132 deb-all: build
133 cd build; dpkg-buildpackage -b -us -uc --no-pre-clean
134 lintian $(DEBS) $(DOC_DEB)
135
136 .PHONY: dsc
137 dsc: $(DSC)
138 $(DSC): build
139 cd build; dpkg-buildpackage -S -us -uc -d -nc
140 lintian $(DSC)
141
142 .PHONY: clean distclean deb clean
143 distclean: clean
144 clean: clean-deb
145 $(foreach i,$(SUBDIRS), \
146 $(MAKE) -C $(i) clean ;)
147 $(CARGO) clean
148 rm -f .do-cargo-build
149 find . -name '*~' -exec rm {} ';'
150
151 # allows one to avoid running cargo clean when one just wants to tidy up after a packgae build
152 clean-deb:
153 rm -rf *.deb *.dsc *.tar.gz *.buildinfo *.changes build/
154
155 .PHONY: dinstall
156 dinstall: ${SERVER_DEB} ${SERVER_DBG_DEB} ${CLIENT_DEB} ${CLIENT_DBG_DEB} \
157 ${DEBUG_DEB} ${DEBUG_DBG_DEB}
158 dpkg -i $^
159
160 # make sure we build binaries before docs
161 docs: $(COMPILEDIR)/dump-catalog-shell-cli $(COMPILEDIR)/docgen
162
163 .PHONY: cargo-build
164 cargo-build:
165 rm -f .do-cargo-build
166 $(MAKE) $(COMPILED_BINS)
167
168 $(COMPILED_BINS) $(COMPILEDIR)/dump-catalog-shell-cli $(COMPILEDIR)/docgen: .do-cargo-build
169 .do-cargo-build:
170 RUSTFLAGS="--cfg openid" $(CARGO) build $(CARGO_BUILD_ARGS) \
171 --bin proxmox-backup-api \
172 --bin proxmox-backup-proxy \
173 --bin proxmox-backup-manager \
174 --bin docgen
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 --package proxmox-backup-debug \
181 --bin proxmox-backup-debug \
182 --package proxmox-file-restore \
183 --bin proxmox-file-restore \
184 --package pxar-bin \
185 --bin pxar \
186 --package proxmox-backup \
187 --bin dump-catalog-shell-cli \
188 --bin pmt --bin pmtx \
189 --bin proxmox-daily-update \
190 --bin proxmox-file-restore \
191 --bin proxmox-restore-daemon \
192 --bin proxmox-tape \
193 --bin pxar \
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