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