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