2019-12-20 11:34:14 +03:00
i n c l u d e / u s r / s h a r e / d p k g / d e f a u l t . m k
2019-01-31 15:43:09 +03:00
i n c l u d e d e f i n e s . m k
2018-11-30 15:39:40 +03:00
2019-12-20 11:34:14 +03:00
PACKAGE := $( DEB_SOURCE)
ARCH := $( DEB_BUILD_ARCH)
2018-12-01 15:44:13 +03:00
2019-02-24 11:51:10 +03:00
SUBDIRS := etc www docs
2019-01-31 17:42:47 +03:00
2019-01-31 15:43:09 +03:00
# Binaries usable by users
USR_BIN := \
proxmox-backup-client \
2019-03-14 12:14:32 +03:00
pxar
2019-01-31 15:43:09 +03:00
# Binaries usable by admins
USR_SBIN := proxmox-backup-manager
# Binaries for services:
SERVICE_BIN := \
proxmox-backup-api \
proxmox-backup-proxy
2019-01-31 17:42:47 +03:00
i f e q ( $( BUILD_MODE ) , r e l e a s e )
CARGO_BUILD_ARGS += --release
2019-01-31 15:43:09 +03:00
COMPILEDIR := target/release
2019-01-31 17:42:47 +03:00
e l s e
COMPILEDIR := target/debug
e n d i f
2019-05-22 16:41:20 +03:00
i f e q ( $( valgrind ) , y e s )
CARGO_BUILD_ARGS += --features valgrind
e n d i f
2019-12-20 11:34:14 +03:00
CARGO ?= cargo
2019-01-31 15:43:09 +03:00
COMPILED_BINS := \
$( addprefix $( COMPILEDIR) /,$( USR_BIN) $( USR_SBIN) $( SERVICE_BIN) )
2019-12-20 11:34:14 +03:00
DEBS = ${ PACKAGE } -server_${ DEB_VERSION } _${ ARCH } .deb ${ PACKAGE } -client_${ DEB_VERSION } _${ ARCH } .deb
DOC_DEB = ${ PACKAGE } -docs_${ DEB_VERSION } _all.deb
2019-11-11 10:35:33 +03:00
2019-12-20 11:34:14 +03:00
DSC = ${ PACKAGE } _${ DEB_VERSION } .dsc
2018-12-01 15:44:13 +03:00
DESTDIR =
2018-11-30 15:39:40 +03:00
2019-01-31 17:42:47 +03:00
all : cargo -build $( SUBDIRS )
.PHONY : $( SUBDIRS )
$(SUBDIRS) :
$( MAKE) -C $@
2018-11-30 15:39:40 +03:00
2019-03-07 13:44:48 +03:00
test :
2019-05-21 18:54:49 +03:00
#cargo test test_broadcast_future
2019-04-27 11:56:49 +03:00
#cargo test $(CARGO_BUILD_ARGS)
2019-12-20 11:34:14 +03:00
$( CARGO) test $( tests) $( CARGO_BUILD_ARGS)
2018-12-19 15:54:22 +03:00
2019-03-07 13:44:48 +03:00
doc :
2019-12-20 11:34:14 +03:00
$( CARGO) doc --no-deps $( CARGO_BUILD_ARGS)
2019-02-12 15:27:11 +03:00
2019-01-31 17:42:47 +03:00
# always re-create this dir
.PHONY : build
build :
2018-11-30 15:39:40 +03:00
rm -rf build
2019-12-20 11:34:14 +03:00
rsync -a debian Makefile defines.mk Cargo.toml \
2019-12-18 15:11:02 +03:00
src $( SUBDIRS) \
2019-12-20 11:34:14 +03:00
tests build/
2019-02-01 13:08:36 +03:00
$( foreach i,$( SUBDIRS) , \
$( MAKE) -C build/$( i) clean ; )
2018-11-30 15:39:40 +03:00
2019-12-13 16:14:28 +03:00
.PHONY : proxmox -backup -docs
proxmox-backup-docs : $( DOC_DEB )
$(DOC_DEB) : build
cd build; dpkg-buildpackage -b -us -uc --no-pre-clean
lintian $( DOC_DEB)
2019-12-20 11:34:14 +03:00
# copy the local target/ dir as a build-cache
2019-01-31 17:42:47 +03:00
.PHONY : deb
2019-11-11 10:35:33 +03:00
deb : $( DEBS )
$(DEBS) : build
2019-12-13 16:14:28 +03:00
cd build; dpkg-buildpackage -b -us -uc --no-pre-clean --build-profiles= nodoc
2019-11-11 10:35:33 +03:00
lintian $( DEBS)
2019-02-01 12:07:22 +03:00
.PHONY : dsc
dsc : $( DSC )
$(DSC) : build
cd build; dpkg-buildpackage -S -us -uc -d -nc
lintian $( DSC)
2018-11-30 15:39:40 +03:00
2018-12-01 15:44:13 +03:00
distclean : clean
2018-11-30 15:39:40 +03:00
clean :
2019-02-01 13:08:36 +03:00
$( foreach i,$( SUBDIRS) , \
$( MAKE) -C $( i) clean ; )
2019-12-20 11:34:14 +03:00
$( CARGO) clean
2019-02-01 12:36:28 +03:00
rm -rf *.deb *.dsc *.tar.gz *.buildinfo *.changes build
2018-11-30 19:09:50 +03:00
find . -name '*~' -exec rm { } ';'
2018-12-01 15:44:13 +03:00
.PHONY : dinstall
2019-11-11 10:35:33 +03:00
dinstall : ${DEBS }
dpkg -i ${ DEBS }
2019-01-31 15:43:09 +03:00
2019-02-24 11:51:10 +03:00
# make sure we build binaries before docs
docs : cargo -build
2019-01-31 17:42:47 +03:00
.PHONY : cargo -build
2019-03-07 13:44:48 +03:00
cargo-build :
2019-12-20 11:34:14 +03:00
$( CARGO) build $( CARGO_BUILD_ARGS)
2019-01-31 15:43:09 +03:00
2019-01-31 17:42:47 +03:00
$(COMPILED_BINS) : cargo -build
2019-01-31 15:43:09 +03:00
2019-09-11 14:59:56 +03:00
.PHONY : lint
lint :
cargo clippy -- -A clippy::all -D clippy::correctness
2019-01-31 15:43:09 +03:00
install : $( COMPILED_BINS )
install -dm755 $( DESTDIR) $( BINDIR)
$( foreach i,$( USR_BIN) , \
install -m755 $( COMPILEDIR) /$( i) $( DESTDIR) $( BINDIR) / ; )
install -dm755 $( DESTDIR) $( SBINDIR)
$( foreach i,$( USR_SBIN) , \
install -m755 $( COMPILEDIR) /$( i) $( DESTDIR) $( SBINDIR) / ; )
2019-02-01 12:05:14 +03:00
install -dm755 $( DESTDIR) $( LIBEXECDIR) /proxmox-backup
2019-01-31 15:43:09 +03:00
$( foreach i,$( SERVICE_BIN) , \
2019-02-01 12:05:14 +03:00
install -m755 $( COMPILEDIR) /$( i) $( DESTDIR) $( LIBEXECDIR) /proxmox-backup/ ; )
2019-01-31 15:43:09 +03:00
$( MAKE) -C www install
2019-02-24 11:51:10 +03:00
$( MAKE) -C docs install
2019-12-13 12:35:43 +03:00
.PHONY : upload
upload : ${DEBS }
# check if working directory is clean
git diff --exit-code --stat && git diff --exit-code --stat --staged
tar cf - ${ DEBS } | ssh -X repoman@repo.proxmox.com upload --product pbs --dist buster