]> git.proxmox.com Git - proxmox-backup.git/blob - Makefile
introduce buildcfg module and PROXMOX_CONFIGDIR
[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
7
8 # Binaries usable by users
9 USR_BIN := \
10 proxmox-backup-client \
11 catar
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 $(CARGO_BUILD_ARGS)
51
52 # always re-create this dir
53 # but also copy the local target/ dir as a build-cache
54 .PHONY: build
55 build:
56 rm -rf build
57 rsync -a debian Makefile defines.mk Cargo.toml src $(SUBDIRS) build/
58 test -d target && rsync -a target build/ || true
59 $(foreach i,$(SUBDIRS), \
60 $(MAKE) -C build/$(i) clean ;)
61
62 .PHONY: deb
63 deb: $(DEB)
64 $(DEB): build
65 cd build; dpkg-buildpackage -b -us -uc --no-pre-clean
66 lintian $(DEB)
67
68 .PHONY: dsc
69 dsc: $(DSC)
70 $(DSC): build
71 cd build; dpkg-buildpackage -S -us -uc -d -nc
72 lintian $(DSC)
73
74 distclean: clean
75
76 clean:
77 $(foreach i,$(SUBDIRS), \
78 $(MAKE) -C $(i) clean ;)
79 cargo clean
80 rm -rf *.deb *.dsc *.tar.gz *.buildinfo *.changes build
81 find . -name '*~' -exec rm {} ';'
82
83 .PHONY: dinstall
84 dinstall: ${DEB}
85 dpkg -i ${DEB}
86
87 .PHONY: cargo-build
88 cargo-build:
89 cargo build $(CARGO_BUILD_ARGS)
90
91 $(COMPILED_BINS): cargo-build
92
93 install: $(COMPILED_BINS)
94 install -dm755 $(DESTDIR)$(BINDIR)
95 $(foreach i,$(USR_BIN), \
96 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(BINDIR)/ ;)
97 install -dm755 $(DESTDIR)$(SBINDIR)
98 $(foreach i,$(USR_SBIN), \
99 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(SBINDIR)/ ;)
100 install -dm755 $(DESTDIR)$(LIBEXECDIR)/proxmox-backup
101 $(foreach i,$(SERVICE_BIN), \
102 install -m755 $(COMPILEDIR)/$(i) $(DESTDIR)$(LIBEXECDIR)/proxmox-backup/ ;)
103 $(MAKE) -C www install