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