]> git.proxmox.com Git - proxmox-backup.git/blame - Makefile
drive config cleanup: derive and use Updater
[proxmox-backup.git] / Makefile
CommitLineData
da0e1e40 1include /usr/share/dpkg/default.mk
6285b251 2include defines.mk
de779814 3
e881b8a5 4PACKAGE := proxmox-backup
da0e1e40 5ARCH := $(DEB_BUILD_ARCH)
209bb433 6
bb5c7707 7SUBDIRS := etc www docs
13b77d10 8
6285b251
WB
9# Binaries usable by users
10USR_BIN := \
c9727044 11 proxmox-backup-client \
76425d84 12 proxmox-file-restore \
c9727044 13 pxar \
cc2c5c77 14 proxmox-tape \
4c209d6b
DM
15 pmtx \
16 pmt
6285b251
WB
17
18# Binaries usable by admins
b69b8af2
TL
19USR_SBIN := \
20 proxmox-backup-manager
6285b251
WB
21
22# Binaries for services:
23SERVICE_BIN := \
24 proxmox-backup-api \
b69b8af2 25 proxmox-backup-banner \
bc00289b 26 proxmox-backup-proxy \
b27c3282 27 proxmox-daily-update
6285b251 28
dd9cef56
SR
29# Single file restore daemon
30RESTORE_BIN := \
31 proxmox-restore-daemon
32
01fd2447 33SUBCRATES := \
86fb3877 34 pbs-api-types \
d420962f 35 pbs-buildcfg \
2b7f8dd5 36 pbs-client \
f323e906 37 pbs-datastore \
eb5e0ae6 38 pbs-fuse-loop \
770a36e5 39 pbs-runtime \
067dc06d 40 pbs-systemd \
b9c5cd82 41 pbs-tools \
58a3fae7
WB
42 proxmox-backup-banner \
43 pxar-bin
01fd2447 44
13b77d10
WB
45ifeq ($(BUILD_MODE), release)
46CARGO_BUILD_ARGS += --release
6285b251 47COMPILEDIR := target/release
13b77d10
WB
48else
49COMPILEDIR := target/debug
50endif
51
6f0069ae
WB
52ifeq ($(valgrind), yes)
53CARGO_BUILD_ARGS += --features valgrind
54endif
55
da0e1e40
FG
56CARGO ?= cargo
57
6285b251 58COMPILED_BINS := \
dd9cef56 59 $(addprefix $(COMPILEDIR)/,$(USR_BIN) $(USR_SBIN) $(SERVICE_BIN) $(RESTORE_BIN))
6285b251 60
1f6a4f58
TL
61export DEB_VERSION DEB_VERSION_UPSTREAM
62
10426c17 63SERVER_DEB=${PACKAGE}-server_${DEB_VERSION}_${ARCH}.deb
3ec6e249 64SERVER_DBG_DEB=${PACKAGE}-server-dbgsym_${DEB_VERSION}_${ARCH}.deb
10426c17 65CLIENT_DEB=${PACKAGE}-client_${DEB_VERSION}_${ARCH}.deb
3ec6e249 66CLIENT_DBG_DEB=${PACKAGE}-client-dbgsym_${DEB_VERSION}_${ARCH}.deb
a5322f3c
TL
67RESTORE_DEB=proxmox-backup-file-restore_${DEB_VERSION}_${ARCH}.deb
68RESTORE_DBG_DEB=proxmox-backup-file-restore-dbgsym_${DEB_VERSION}_${ARCH}.deb
da0e1e40 69DOC_DEB=${PACKAGE}-docs_${DEB_VERSION}_all.deb
36d74cd6 70
76425d84
DC
71DEBS=${SERVER_DEB} ${SERVER_DBG_DEB} ${CLIENT_DEB} ${CLIENT_DBG_DEB} \
72 ${RESTORE_DEB} ${RESTORE_DBG_DEB}
10426c17 73
e881b8a5 74DSC = rust-${PACKAGE}_${DEB_VERSION}.dsc
209bb433
DM
75
76DESTDIR=
de779814 77
314d360f
WB
78tests ?= --workspace
79
424d2d68 80all: $(SUBDIRS)
13b77d10
WB
81
82.PHONY: $(SUBDIRS)
83$(SUBDIRS):
84 $(MAKE) -C $@
de779814 85
cd3b9a06 86test:
cc119edb 87 #cargo test test_broadcast_future
3dceb9b3 88 #cargo test $(CARGO_BUILD_ARGS)
c47a900c 89 $(CARGO) test $(tests) $(CARGO_BUILD_ARGS)
f7dd683b 90
cd3b9a06 91doc:
314d360f 92 $(CARGO) doc --workspace --no-deps $(CARGO_BUILD_ARGS)
d78345bc 93
13b77d10
WB
94# always re-create this dir
95.PHONY: build
96build:
de779814 97 rm -rf build
01fd2447
WB
98 mkdir build
99 cp -a debian \
a6eac535 100 Cargo.toml src \
01fd2447
WB
101 $(SUBCRATES) \
102 docs etc examples tests www zsh-completions \
103 defines.mk Makefile \
104 ./build/
105 rm -f build/Cargo.lock
e881b8a5 106 find build/debian -name "*.hint" -delete
b369f720
WB
107 $(foreach i,$(SUBDIRS), \
108 $(MAKE) -C build/$(i) clean ;)
de779814 109
e881b8a5 110
720776b8 111.PHONY: proxmox-backup-docs
37e53b4c
TL
112$(DOC_DEB) $(DEBS): proxmox-backup-docs
113proxmox-backup-docs: build
720776b8
DM
114 cd build; dpkg-buildpackage -b -us -uc --no-pre-clean
115 lintian $(DOC_DEB)
116
da0e1e40 117# copy the local target/ dir as a build-cache
13b77d10 118.PHONY: deb
37e53b4c
TL
119$(DEBS): deb
120deb: build
720776b8 121 cd build; dpkg-buildpackage -b -us -uc --no-pre-clean --build-profiles=nodoc
36d74cd6 122 lintian $(DEBS)
18fad344 123
37e53b4c 124.PHONY: deb-all
a2c73c78
TL
125deb-all: build
126 cd build; dpkg-buildpackage -b -us -uc --no-pre-clean
127 lintian $(DEBS) $(DOC_DEB)
37e53b4c 128
18fad344
WB
129.PHONY: dsc
130dsc: $(DSC)
131$(DSC): build
132 cd build; dpkg-buildpackage -S -us -uc -d -nc
133 lintian $(DSC)
de779814 134
1900d781 135.PHONY: clean distclean deb clean
209bb433 136distclean: clean
6b85671d 137clean: clean-deb
b369f720
WB
138 $(foreach i,$(SUBDIRS), \
139 $(MAKE) -C $(i) clean ;)
da0e1e40 140 $(CARGO) clean
424d2d68 141 rm -f .do-cargo-build
d3cb69c4
DM
142 find . -name '*~' -exec rm {} ';'
143
1900d781
TL
144# allows one to avoid running cargo clean when one just wants to tidy up after a packgae build
145clean-deb:
146 rm -rf *.deb *.dsc *.tar.gz *.buildinfo *.changes build/
147
209bb433 148.PHONY: dinstall
c287b287
TL
149dinstall: ${SERVER_DEB} ${SERVER_DBG_DEB} ${CLIENT_DEB} ${CLIENT_DBG_DEB}
150 dpkg -i $^
6285b251 151
bb5c7707 152# make sure we build binaries before docs
424d2d68 153docs: $(COMPILEDIR)/dump-catalog-shell-cli $(COMPILEDIR)/docgen
bb5c7707 154
13b77d10 155.PHONY: cargo-build
cd3b9a06 156cargo-build:
424d2d68
TL
157 rm -f .do-cargo-build
158 $(MAKE) $(COMPILED_BINS)
159
160$(COMPILED_BINS) $(COMPILEDIR)/dump-catalog-shell-cli $(COMPILEDIR)/docgen: .do-cargo-build
161.do-cargo-build:
991be99c 162 RUSTFLAGS="--cfg openid" $(CARGO) build $(CARGO_BUILD_ARGS) \
f726e1e0
TL
163 --bin proxmox-backup-api \
164 --bin proxmox-backup-proxy \
165 --bin proxmox-backup-manager \
166 --bin docgen
991be99c 167 $(CARGO) build $(CARGO_BUILD_ARGS) \
b9c5cd82
WB
168 --package proxmox-backup-banner \
169 --bin proxmox-backup-banner \
58a3fae7
WB
170 --package pxar-bin \
171 --bin pxar \
b9c5cd82 172 --package proxmox-backup \
991be99c
TL
173 --bin dump-catalog-shell-cli \
174 --bin pmt --bin pmtx \
991be99c
TL
175 --bin proxmox-backup-client \
176 --bin proxmox-daily-update \
177 --bin proxmox-file-restore \
178 --bin proxmox-restore-daemon \
179 --bin proxmox-tape \
180 --bin pxar \
181 --bin sg-tape-cmd
424d2d68 182 touch "$@"
6285b251 183
6285b251 184
d1596102
WB
185.PHONY: lint
186lint:
187 cargo clippy -- -A clippy::all -D clippy::correctness
188
6285b251
WB
189install: $(COMPILED_BINS)
190 install -dm755 $(DESTDIR)$(BINDIR)
6dea60aa 191 install -dm755 $(DESTDIR)$(ZSH_COMPL_DEST)
6285b251 192 $(foreach i,$(USR_BIN), \
6dea60aa
CE
193 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(BINDIR)/ ; \
194 install -m644 zsh-completions/_$(i) $(DESTDIR)$(ZSH_COMPL_DEST)/ ;)
6285b251
WB
195 install -dm755 $(DESTDIR)$(SBINDIR)
196 $(foreach i,$(USR_SBIN), \
6dea60aa
CE
197 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(SBINDIR)/ ; \
198 install -m644 zsh-completions/_$(i) $(DESTDIR)$(ZSH_COMPL_DEST)/ ;)
304db5da 199 install -dm755 $(DESTDIR)$(LIBEXECDIR)/proxmox-backup
dd9cef56
SR
200 install -dm755 $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/file-restore
201 $(foreach i,$(RESTORE_BIN), \
202 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/file-restore/ ;)
b27c3282 203 # install sg-tape-cmd as setuid binary
df3a74d7 204 install -m4755 -o root -g root $(COMPILEDIR)/sg-tape-cmd $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/sg-tape-cmd
6285b251 205 $(foreach i,$(SERVICE_BIN), \
304db5da 206 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/ ;)
6285b251 207 $(MAKE) -C www install
bb5c7707 208 $(MAKE) -C docs install
b29292a8 209ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
7190cbf2 210 $(MAKE) test # HACK, only test now to avoid clobbering build files with wrong config
b29292a8 211endif
729e38f4
DM
212
213.PHONY: upload
76425d84 214upload: ${SERVER_DEB} ${CLIENT_DEB} ${RESTORE_DEB} ${DOC_DEB}
729e38f4
DM
215 # check if working directory is clean
216 git diff --exit-code --stat && git diff --exit-code --stat --staged
59648eac 217 tar cf - ${SERVER_DEB} ${SERVER_DBG_DEB} ${DOC_DEB} ${CLIENT_DEB} ${CLIENT_DBG_DEB} | \
d9d81741
TL
218 ssh -X repoman@repo.proxmox.com upload --product pbs --dist bullseye
219 tar cf - ${CLIENT_DEB} ${CLIENT_DBG_DEB} | ssh -X repoman@repo.proxmox.com upload --product "pve,pmg,pbs-client" --dist bullseye
220 tar cf - ${RESTORE_DEB} ${RESTORE_DBG_DEB} | ssh -X repoman@repo.proxmox.com upload --product "pve" --dist bullseye