]> git.proxmox.com Git - proxmox-backup.git/blob - Makefile
buildsys: make valgrind=1 to enable valgrind support
[proxmox-backup.git] / Makefile
1 include defines.mk
2
3 ARCH:=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
4 GITVERSION:=$(shell git rev-parse HEAD)
5
6 SUBDIRS := etc www docs
7
8 # Binaries usable by users
9 USR_BIN := \
10 proxmox-backup-client \
11 pxar
12
13 # Binaries usable by admins
14 USR_SBIN := proxmox-backup-manager
15
16 # Binaries for services:
17 SERVICE_BIN := \
18 proxmox-backup-api \
19 proxmox-backup-proxy
20
21 ifeq ($(BUILD_MODE), release)
22 CARGO_BUILD_ARGS += --release
23 COMPILEDIR := target/release
24 else
25 COMPILEDIR := target/debug
26 endif
27
28 ifeq ($(valgrind), yes)
29 CARGO_BUILD_ARGS += --features valgrind
30 endif
31
32 COMPILED_BINS := \
33 $(addprefix $(COMPILEDIR)/,$(USR_BIN) $(USR_SBIN) $(SERVICE_BIN))
34
35 export PROXMOX_PKG_VERSION=${PKGVER}
36 export PROXMOX_PKG_RELEASE=${PKGREL}
37 export PROXMOX_PKG_REPOID=${GITVERSION}
38
39 export PROXMOX_JSDIR := $(JSDIR)
40 export PROXMOX_CONFIGDIR := $(SYSCONFDIR)/proxmox-backup
41
42 DEB=${PACKAGE}_${PKGVER}-${PKGREL}_${ARCH}.deb
43 DSC=${PACKAGE}_${PKGVER}-${PKGREL}.dsc
44
45 DESTDIR=
46
47 all: cargo-build $(SUBDIRS)
48
49 .PHONY: $(SUBDIRS)
50 $(SUBDIRS):
51 $(MAKE) -C $@
52
53 test:
54 #cargo test test_broadcast_future
55 #cargo test $(CARGO_BUILD_ARGS)
56 cargo test $(tests) $(CARGO_BUILD_ARGS)
57
58 doc:
59 cargo doc --no-deps $(CARGO_BUILD_ARGS)
60
61 # always re-create this dir
62 # but also copy the local target/ dir as a build-cache
63 .PHONY: build
64 build:
65 rm -rf build
66 cargo build --release
67 rsync -a debian Makefile defines.mk Cargo.toml Cargo.lock \
68 src proxmox-protocol zstd-sys $(SUBDIRS) \
69 target tests build/
70 $(foreach i,$(SUBDIRS), \
71 $(MAKE) -C build/$(i) clean ;)
72
73 .PHONY: deb
74 deb: $(DEB)
75 $(DEB): build
76 cd build; dpkg-buildpackage -b -us -uc --no-pre-clean
77 lintian $(DEB)
78
79 .PHONY: dsc
80 dsc: $(DSC)
81 $(DSC): build
82 cd build; dpkg-buildpackage -S -us -uc -d -nc
83 lintian $(DSC)
84
85 distclean: clean
86
87 clean:
88 $(foreach i,$(SUBDIRS), \
89 $(MAKE) -C $(i) clean ;)
90 cargo clean
91 rm -rf *.deb *.dsc *.tar.gz *.buildinfo *.changes build
92 find . -name '*~' -exec rm {} ';'
93
94 .PHONY: dinstall
95 dinstall: ${DEB}
96 dpkg -i ${DEB}
97
98 # make sure we build binaries before docs
99 docs: cargo-build
100
101 .PHONY: cargo-build
102 cargo-build:
103 cargo build $(CARGO_BUILD_ARGS)
104
105 $(COMPILED_BINS): cargo-build
106
107 install: $(COMPILED_BINS)
108 install -dm755 $(DESTDIR)$(BINDIR)
109 $(foreach i,$(USR_BIN), \
110 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(BINDIR)/ ;)
111 install -dm755 $(DESTDIR)$(SBINDIR)
112 $(foreach i,$(USR_SBIN), \
113 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(SBINDIR)/ ;)
114 install -dm755 $(DESTDIR)$(LIBEXECDIR)/proxmox-backup
115 $(foreach i,$(SERVICE_BIN), \
116 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/ ;)
117 $(MAKE) -C www install
118 $(MAKE) -C docs install