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