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