#!/usr/bin/make -f

PKG = $(firstword $(shell dh_listpackages))
DOCPKG = $(lastword $(shell dh_listpackages))
PKG_DIR = $(CURDIR)/debian/$(PKG)
DOCPKG_DIR = $(CURDIR)/debian/$(DOCPKG)

%:
	dh $@

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	t/run-tests.sh
endif

override_dh_auto_install:
	$(MAKE) install PREFIX=/usr DESTDIR=$(PKG_DIR) \
	    LIBDIR=/usr/share/backup-manager \
	    PERL5DIR=/usr/share/perl5
	$(MAKE) -C $(CURDIR)/doc install DESTDIR=$(DOCPKG_DIR)

override_dh_installcron:
	dh_installcron
	dh_installcron --name=backup-manager-clean-upload-db
