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