]> git.proxmox.com Git - proxmox-backup.git/blob - Makefile
tape: documentation language fixup
[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 pxar \
13 proxmox-tape \
14 pmtx \
15 pmt
16
17 # Binaries usable by admins
18 USR_SBIN := \
19 proxmox-backup-manager
20
21 # Binaries for services:
22 SERVICE_BIN := \
23 proxmox-backup-api \
24 proxmox-backup-banner \
25 proxmox-backup-proxy \
26 proxmox-daily-update
27
28 ifeq ($(BUILD_MODE), release)
29 CARGO_BUILD_ARGS += --release
30 COMPILEDIR := target/release
31 else
32 COMPILEDIR := target/debug
33 endif
34
35 ifeq ($(valgrind), yes)
36 CARGO_BUILD_ARGS += --features valgrind
37 endif
38
39 CARGO ?= cargo
40
41 COMPILED_BINS := \
42 $(addprefix $(COMPILEDIR)/,$(USR_BIN) $(USR_SBIN) $(SERVICE_BIN))
43
44 export DEB_VERSION DEB_VERSION_UPSTREAM
45
46 SERVER_DEB=${PACKAGE}-server_${DEB_VERSION}_${ARCH}.deb
47 SERVER_DBG_DEB=${PACKAGE}-server-dbgsym_${DEB_VERSION}_${ARCH}.deb
48 CLIENT_DEB=${PACKAGE}-client_${DEB_VERSION}_${ARCH}.deb
49 CLIENT_DBG_DEB=${PACKAGE}-client-dbgsym_${DEB_VERSION}_${ARCH}.deb
50 DOC_DEB=${PACKAGE}-docs_${DEB_VERSION}_all.deb
51
52 DEBS=${SERVER_DEB} ${SERVER_DBG_DEB} ${CLIENT_DEB} ${CLIENT_DBG_DEB}
53
54 DSC = rust-${PACKAGE}_${DEB_VERSION}.dsc
55
56 DESTDIR=
57
58 all: cargo-build $(SUBDIRS)
59
60 .PHONY: $(SUBDIRS)
61 $(SUBDIRS):
62 $(MAKE) -C $@
63
64 test:
65 #cargo test test_broadcast_future
66 #cargo test $(CARGO_BUILD_ARGS)
67 $(CARGO) test $(tests) $(CARGO_BUILD_ARGS)
68
69 doc:
70 $(CARGO) doc --no-deps $(CARGO_BUILD_ARGS)
71
72 # always re-create this dir
73 .PHONY: build
74 build:
75 rm -rf build
76 rm -f debian/control
77 debcargo package --config debian/debcargo.toml --changelog-ready --no-overlay-write-back --directory build proxmox-backup $(shell dpkg-parsechangelog -l debian/changelog -SVersion | sed -e 's/-.*//')
78 sed -e '1,/^$$/ ! d' build/debian/control > build/debian/control.src
79 cat build/debian/control.src build/debian/control.in > build/debian/control
80 rm build/debian/control.in build/debian/control.src
81 cp build/debian/control debian/control
82 rm build/Cargo.lock
83 find build/debian -name "*.hint" -delete
84 $(foreach i,$(SUBDIRS), \
85 $(MAKE) -C build/$(i) clean ;)
86
87
88 .PHONY: proxmox-backup-docs
89 $(DOC_DEB) $(DEBS): proxmox-backup-docs
90 proxmox-backup-docs: build
91 cd build; dpkg-buildpackage -b -us -uc --no-pre-clean
92 lintian $(DOC_DEB)
93
94 # copy the local target/ dir as a build-cache
95 .PHONY: deb
96 $(DEBS): deb
97 deb: build
98 cd build; dpkg-buildpackage -b -us -uc --no-pre-clean --build-profiles=nodoc
99 lintian $(DEBS)
100
101 .PHONY: deb-all
102 deb-all: $(DOC_DEB) $(DEBS)
103
104 .PHONY: dsc
105 dsc: $(DSC)
106 $(DSC): build
107 cd build; dpkg-buildpackage -S -us -uc -d -nc
108 lintian $(DSC)
109
110 distclean: clean
111
112 clean:
113 $(foreach i,$(SUBDIRS), \
114 $(MAKE) -C $(i) clean ;)
115 $(CARGO) clean
116 rm -rf *.deb *.dsc *.tar.gz *.buildinfo *.changes build
117 find . -name '*~' -exec rm {} ';'
118
119 .PHONY: dinstall
120 dinstall: ${DEBS}
121 dpkg -i ${DEBS}
122
123 # make sure we build binaries before docs
124 docs: cargo-build
125
126 .PHONY: cargo-build
127 cargo-build:
128 $(CARGO) build $(CARGO_BUILD_ARGS)
129
130 $(COMPILED_BINS): cargo-build
131
132 .PHONY: lint
133 lint:
134 cargo clippy -- -A clippy::all -D clippy::correctness
135
136 install: $(COMPILED_BINS)
137 install -dm755 $(DESTDIR)$(BINDIR)
138 install -dm755 $(DESTDIR)$(ZSH_COMPL_DEST)
139 $(foreach i,$(USR_BIN), \
140 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(BINDIR)/ ; \
141 install -m644 zsh-completions/_$(i) $(DESTDIR)$(ZSH_COMPL_DEST)/ ;)
142 install -dm755 $(DESTDIR)$(SBINDIR)
143 $(foreach i,$(USR_SBIN), \
144 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(SBINDIR)/ ; \
145 install -m644 zsh-completions/_$(i) $(DESTDIR)$(ZSH_COMPL_DEST)/ ;)
146 install -dm755 $(DESTDIR)$(LIBEXECDIR)/proxmox-backup
147 # install sg-tape-cmd as setuid binary
148 install -m4755 -o root -g root $(COMPILEDIR)/sg-tape-cmd $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/sg-tape-cmd
149 $(foreach i,$(SERVICE_BIN), \
150 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/ ;)
151 $(MAKE) -C www install
152 $(MAKE) -C docs install
153
154 .PHONY: upload
155 upload: ${SERVER_DEB} ${CLIENT_DEB} ${DOC_DEB}
156 # check if working directory is clean
157 git diff --exit-code --stat && git diff --exit-code --stat --staged
158 tar cf - ${SERVER_DEB} ${SERVER_DBG_DEB} ${DOC_DEB} | ssh -X repoman@repo.proxmox.com upload --product pbs --dist buster
159 tar cf - ${CLIENT_DEB} ${CLIENT_DBG_DEB} | ssh -X repoman@repo.proxmox.com upload --product "pbs,pve,pmg" --dist buster