]> git.proxmox.com Git - proxmox-backup.git/blame - Makefile
buildsys: install templates for test notifications
[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
d9f0ec57 7SUBDIRS := etc www docs templates
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 19USR_SBIN := \
7c72ae04 20 proxmox-backup-manager \
6afda74c 21 proxmox-backup-debug
6285b251
WB
22
23# Binaries for services:
24SERVICE_BIN := \
25 proxmox-backup-api \
b69b8af2 26 proxmox-backup-banner \
bc00289b 27 proxmox-backup-proxy \
b27c3282 28 proxmox-daily-update
6285b251 29
dd9cef56
SR
30# Single file restore daemon
31RESTORE_BIN := \
32 proxmox-restore-daemon
33
86e4ad8a
TL
34SUBCRATES != cargo metadata --no-deps --format-version=1 \
35 | jq -r .workspace_members'[]' \
70754964 36 | awk '!/^proxmox-backup[[:space:]]/ { printf "%s ", $$1 }'
01fd2447 37
13b77d10
WB
38ifeq ($(BUILD_MODE), release)
39CARGO_BUILD_ARGS += --release
6285b251 40COMPILEDIR := target/release
13b77d10
WB
41else
42COMPILEDIR := target/debug
43endif
44
6f0069ae
WB
45ifeq ($(valgrind), yes)
46CARGO_BUILD_ARGS += --features valgrind
47endif
48
da0e1e40
FG
49CARGO ?= cargo
50
6285b251 51COMPILED_BINS := \
dd9cef56 52 $(addprefix $(COMPILEDIR)/,$(USR_BIN) $(USR_SBIN) $(SERVICE_BIN) $(RESTORE_BIN))
6285b251 53
1f6a4f58
TL
54export DEB_VERSION DEB_VERSION_UPSTREAM
55
b3be7929
TL
56SERVER_DEB=$(PACKAGE)-server_$(DEB_VERSION)_$(ARCH).deb
57SERVER_DBG_DEB=$(PACKAGE)-server-dbgsym_$(DEB_VERSION)_$(ARCH).deb
58CLIENT_DEB=$(PACKAGE)-client_$(DEB_VERSION)_$(ARCH).deb
59CLIENT_DBG_DEB=$(PACKAGE)-client-dbgsym_$(DEB_VERSION)_$(ARCH).deb
60RESTORE_DEB=proxmox-backup-file-restore_$(DEB_VERSION)_$(ARCH).deb
61RESTORE_DBG_DEB=proxmox-backup-file-restore-dbgsym_$(DEB_VERSION)_$(ARCH).deb
62DOC_DEB=$(PACKAGE)-docs_$(DEB_VERSION)_all.deb
36d74cd6 63
b3be7929 64DEBS=$(SERVER_DEB) $(SERVER_DBG_DEB) $(CLIENT_DEB) $(CLIENT_DBG_DEB) \
6ee22cdd 65 $(RESTORE_DEB) $(RESTORE_DBG_DEB)
10426c17 66
b3be7929 67DSC = rust-$(PACKAGE)_$(DEB_VERSION).dsc
209bb433
DM
68
69DESTDIR=
de779814 70
314d360f
WB
71tests ?= --workspace
72
424d2d68 73all: $(SUBDIRS)
13b77d10
WB
74
75.PHONY: $(SUBDIRS)
76$(SUBDIRS):
77 $(MAKE) -C $@
de779814 78
cd3b9a06 79test:
cc119edb 80 #cargo test test_broadcast_future
3dceb9b3 81 #cargo test $(CARGO_BUILD_ARGS)
c47a900c 82 $(CARGO) test $(tests) $(CARGO_BUILD_ARGS)
f7dd683b 83
cd3b9a06 84doc:
314d360f 85 $(CARGO) doc --workspace --no-deps $(CARGO_BUILD_ARGS)
d78345bc 86
13b77d10
WB
87# always re-create this dir
88.PHONY: build
89build:
de779814 90 rm -rf build
01fd2447 91 mkdir build
6213ca1e 92 git rev-parse HEAD > build/.repoid
01fd2447 93 cp -a debian \
a6eac535 94 Cargo.toml src \
01fd2447 95 $(SUBCRATES) \
d9f0ec57 96 docs etc examples tests www zsh-completions templates \
01fd2447
WB
97 defines.mk Makefile \
98 ./build/
99 rm -f build/Cargo.lock
e881b8a5 100 find build/debian -name "*.hint" -delete
b369f720
WB
101 $(foreach i,$(SUBDIRS), \
102 $(MAKE) -C build/$(i) clean ;)
de779814 103
e881b8a5 104
720776b8 105.PHONY: proxmox-backup-docs
37e53b4c
TL
106$(DOC_DEB) $(DEBS): proxmox-backup-docs
107proxmox-backup-docs: build
720776b8
DM
108 cd build; dpkg-buildpackage -b -us -uc --no-pre-clean
109 lintian $(DOC_DEB)
110
da0e1e40 111# copy the local target/ dir as a build-cache
8f8faa45
TL
112.PHONY: deb dsc deb-nodoc
113deb-nodoc: build
720776b8 114 cd build; dpkg-buildpackage -b -us -uc --no-pre-clean --build-profiles=nodoc
36d74cd6 115 lintian $(DEBS)
18fad344 116
8f8faa45
TL
117$(DEBS): deb
118deb: build
37697060 119 cd build; dpkg-buildpackage -b -us -uc
a2c73c78 120 lintian $(DEBS) $(DOC_DEB)
37e53b4c 121
18fad344 122.PHONY: dsc
6602e33c
TL
123dsc:
124 rm -rf $(DSC) build/
125 $(MAKE) $(DSC)
126 lintian $(DSC)
127
18fad344 128$(DSC): build
37697060 129 cd build; dpkg-buildpackage -S -us -uc -d
6602e33c
TL
130
131sbuild: $(DSC)
132 sbuild $<
de779814 133
1900d781 134.PHONY: clean distclean deb clean
209bb433 135distclean: clean
6b85671d 136clean: clean-deb
b369f720
WB
137 $(foreach i,$(SUBDIRS), \
138 $(MAKE) -C $(i) clean ;)
da0e1e40 139 $(CARGO) clean
424d2d68 140 rm -f .do-cargo-build
d3cb69c4 141
21520860 142# allows one to avoid running cargo clean when one just wants to tidy up after a package build
1900d781 143clean-deb:
21520860
TL
144 rm -rf build/
145 rm -f *.deb *.dsc *.tar.* *.buildinfo *.build *.changes
1900d781 146
209bb433 147.PHONY: dinstall
6ee22cdd 148dinstall: $(SERVER_DEB) $(SERVER_DBG_DEB) $(CLIENT_DEB) $(CLIENT_DBG_DEB)
c287b287 149 dpkg -i $^
6285b251 150
bb5c7707 151# make sure we build binaries before docs
424d2d68 152docs: $(COMPILEDIR)/dump-catalog-shell-cli $(COMPILEDIR)/docgen
bb5c7707 153
13b77d10 154.PHONY: cargo-build
cd3b9a06 155cargo-build:
424d2d68
TL
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:
e678a50e 161 $(CARGO) build $(CARGO_BUILD_ARGS) \
b9c5cd82
WB
162 --package proxmox-backup-banner \
163 --bin proxmox-backup-banner \
e351ac78
WB
164 --package proxmox-backup-client \
165 --bin proxmox-backup-client \
a844fa0b 166 --bin dump-catalog-shell-cli \
e5f9b7f7 167 --bin proxmox-backup-debug \
6c76aa43
WB
168 --package proxmox-file-restore \
169 --bin proxmox-file-restore \
58a3fae7
WB
170 --package pxar-bin \
171 --bin pxar \
048b43af
DM
172 --package pbs-tape \
173 --bin pmt \
174 --bin pmtx \
6523588c
DM
175 --package proxmox-restore-daemon \
176 --bin proxmox-restore-daemon \
b9c5cd82 177 --package proxmox-backup \
4d4f94de
TL
178 --bin docgen \
179 --bin proxmox-backup-api \
180 --bin proxmox-backup-manager \
181 --bin proxmox-backup-proxy \
991be99c
TL
182 --bin proxmox-daily-update \
183 --bin proxmox-file-restore \
991be99c 184 --bin proxmox-tape \
991be99c 185 --bin sg-tape-cmd
424d2d68 186 touch "$@"
6285b251 187
6285b251 188
d1596102
WB
189.PHONY: lint
190lint:
191 cargo clippy -- -A clippy::all -D clippy::correctness
192
6285b251
WB
193install: $(COMPILED_BINS)
194 install -dm755 $(DESTDIR)$(BINDIR)
6dea60aa 195 install -dm755 $(DESTDIR)$(ZSH_COMPL_DEST)
6285b251 196 $(foreach i,$(USR_BIN), \
6dea60aa
CE
197 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(BINDIR)/ ; \
198 install -m644 zsh-completions/_$(i) $(DESTDIR)$(ZSH_COMPL_DEST)/ ;)
6285b251
WB
199 install -dm755 $(DESTDIR)$(SBINDIR)
200 $(foreach i,$(USR_SBIN), \
6dea60aa
CE
201 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(SBINDIR)/ ; \
202 install -m644 zsh-completions/_$(i) $(DESTDIR)$(ZSH_COMPL_DEST)/ ;)
6afda74c 203 install -m755 $(COMPILEDIR)/pbs2to3 $(DESTDIR)$(SBINDIR)/
304db5da 204 install -dm755 $(DESTDIR)$(LIBEXECDIR)/proxmox-backup
dd9cef56
SR
205 install -dm755 $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/file-restore
206 $(foreach i,$(RESTORE_BIN), \
207 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/file-restore/ ;)
b27c3282 208 # install sg-tape-cmd as setuid binary
df3a74d7 209 install -m4755 -o root -g root $(COMPILEDIR)/sg-tape-cmd $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/sg-tape-cmd
6285b251 210 $(foreach i,$(SERVICE_BIN), \
304db5da 211 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/ ;)
6285b251 212 $(MAKE) -C www install
bb5c7707 213 $(MAKE) -C docs install
d9f0ec57 214 $(MAKE) -C templates install
729e38f4
DM
215
216.PHONY: upload
8ccdeb21 217upload: UPLOAD_DIST ?= $(DEB_DISTRIBUTION)
6ee22cdd 218upload: $(SERVER_DEB) $(CLIENT_DEB) $(RESTORE_DEB) $(DOC_DEB)
729e38f4
DM
219 # check if working directory is clean
220 git diff --exit-code --stat && git diff --exit-code --stat --staged
6ee22cdd 221 tar cf - $(SERVER_DEB) $(SERVER_DBG_DEB) $(DOC_DEB) $(CLIENT_DEB) $(CLIENT_DBG_DEB) \
8ccdeb21
TL
222 | ssh -X repoman@repo.proxmox.com upload --product pbs --dist $(UPLOAD_DIST)
223 tar cf - $(CLIENT_DEB) $(CLIENT_DBG_DEB) | ssh -X repoman@repo.proxmox.com upload --product "pve,pmg,pbs-client" --dist $(UPLOAD_DIST)
224 tar cf - $(RESTORE_DEB) $(RESTORE_DBG_DEB) | ssh -X repoman@repo.proxmox.com upload --product "pve" --dist $(UPLOAD_DIST)