]> git.proxmox.com Git - proxmox-backup.git/blob - Makefile
Makefile: Allow to pass parameter tests=pattern to make test
[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 COMPILED_BINS := \
29 $(addprefix $(COMPILEDIR)/,$(USR_BIN) $(USR_SBIN) $(SERVICE_BIN))
30
31 export PROXMOX_PKG_VERSION=${PKGVER}
32 export PROXMOX_PKG_RELEASE=${PKGREL}
33 export PROXMOX_PKG_REPOID=${GITVERSION}
34
35 export PROXMOX_JSDIR := $(JSDIR)
36 export PROXMOX_CONFIGDIR := $(SYSCONFDIR)/proxmox-backup
37
38 DEB=${PACKAGE}_${PKGVER}-${PKGREL}_${ARCH}.deb
39 DSC=${PACKAGE}_${PKGVER}-${PKGREL}.dsc
40
41 DESTDIR=
42
43 all: cargo-build $(SUBDIRS)
44
45 .PHONY: $(SUBDIRS)
46 $(SUBDIRS):
47 $(MAKE) -C $@
48
49 test:
50 #cargo test test_broadcast_future
51 #cargo test $(CARGO_BUILD_ARGS)
52 cargo test $(tests) $(CARGO_BUILD_ARGS)
53
54 doc:
55 cargo doc --no-deps $(CARGO_BUILD_ARGS)
56
57 # always re-create this dir
58 # but also copy the local target/ dir as a build-cache
59 .PHONY: build
60 build:
61 rm -rf build
62 cargo build --release
63 rsync -a debian Makefile defines.mk Cargo.toml Cargo.lock \
64 src proxmox-protocol zstd-sys $(SUBDIRS) \
65 target build/
66 $(foreach i,$(SUBDIRS), \
67 $(MAKE) -C build/$(i) clean ;)
68
69 .PHONY: deb
70 deb: $(DEB)
71 $(DEB): build
72 cd build; dpkg-buildpackage -b -us -uc --no-pre-clean
73 lintian $(DEB)
74
75 .PHONY: dsc
76 dsc: $(DSC)
77 $(DSC): build
78 cd build; dpkg-buildpackage -S -us -uc -d -nc
79 lintian $(DSC)
80
81 distclean: clean
82
83 clean:
84 $(foreach i,$(SUBDIRS), \
85 $(MAKE) -C $(i) clean ;)
86 cargo clean
87 rm -rf *.deb *.dsc *.tar.gz *.buildinfo *.changes build
88 find . -name '*~' -exec rm {} ';'
89
90 .PHONY: dinstall
91 dinstall: ${DEB}
92 dpkg -i ${DEB}
93
94 # make sure we build binaries before docs
95 docs: cargo-build
96
97 .PHONY: cargo-build
98 cargo-build:
99 cargo build $(CARGO_BUILD_ARGS)
100
101 $(COMPILED_BINS): cargo-build
102
103 install: $(COMPILED_BINS)
104 install -dm755 $(DESTDIR)$(BINDIR)
105 $(foreach i,$(USR_BIN), \
106 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(BINDIR)/ ;)
107 install -dm755 $(DESTDIR)$(SBINDIR)
108 $(foreach i,$(USR_SBIN), \
109 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(SBINDIR)/ ;)
110 install -dm755 $(DESTDIR)$(LIBEXECDIR)/proxmox-backup
111 $(foreach i,$(SERVICE_BIN), \
112 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/ ;)
113 $(MAKE) -C www install
114 $(MAKE) -C docs install