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