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