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