From 13b77d10603b24c2c04e9d89ad85f67bdb320439 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 31 Jan 2019 15:42:47 +0100 Subject: [PATCH] buildsys: fixup package building Signed-off-by: Wolfgang Bumiller --- Makefile | 38 +++++++++++++++++++++++++------------- debian/rules | 11 +++++++++-- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 79247898..439e4abb 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,8 @@ include defines.mk ARCH:=$(shell dpkg-architecture -qDEB_BUILD_ARCH) GITVERSION:=$(shell git rev-parse HEAD) +SUBDIRS := etc www + # Binaries usable by users USR_BIN := \ proxmox-backup-client \ @@ -16,7 +18,13 @@ SERVICE_BIN := \ proxmox-backup-api \ proxmox-backup-proxy +ifeq ($(BUILD_MODE), release) +CARGO_BUILD_ARGS += --release COMPILEDIR := target/release +else +COMPILEDIR := target/debug +endif + COMPILED_BINS := \ $(addprefix $(COMPILEDIR)/,$(USR_BIN) $(USR_SBIN) $(SERVICE_BIN)) @@ -30,21 +38,25 @@ DEB=${PACKAGE}_${PKGVER}-${PKGREL}_${ARCH}.deb DESTDIR= -all: - cargo build +all: cargo-build $(SUBDIRS) + +.PHONY: $(SUBDIRS) +$(SUBDIRS): + $(MAKE) -C $@ test: cargo test -.PHONY: deb -deb ${DEB}: +# always re-create this dir +.PHONY: build +build: rm -rf build - # build here to cache results - cargo build --release - $(MAKE) -C www - rsync -a debian Cargo.toml src www etc target build - cd build; dpkg-buildpackage -b -us -uc + rsync -a debian Makefile defines.mk Cargo.toml src $(SUBDIRS) build/ +.PHONY: deb +deb: $(DEB) +$(DEB): build + cd build; dpkg-buildpackage -b -us -uc distclean: clean @@ -58,11 +70,11 @@ clean: dinstall: ${DEB} dpkg -i ${DEB} -.PHONY: build-release -build-release: - cargo build --release +.PHONY: cargo-build +cargo-build: + cargo build $(CARGO_BUILD_ARGS) -$(COMPILED_BINS): build-release +$(COMPILED_BINS): cargo-build install: $(COMPILED_BINS) install -dm755 $(DESTDIR)$(BINDIR) diff --git a/debian/rules b/debian/rules index e9d60d9e..6ec8d893 100755 --- a/debian/rules +++ b/debian/rules @@ -7,8 +7,15 @@ %: dh $@ --with=systemd --with=bash-completion -override_dh_autobuild: - make PROXY_USER=www-data +override_dh_auto_build: + dh_auto_build -- \ + PROXY_USER=www-data BUILD_MODE=release \ + LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH) + +override_dh_auto_install: + dh_auto_install -- \ + PROXY_USER=www-data BUILD_MODE=release \ + LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH) override_dh_installinit: dh_installinit