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