#!/usr/bin/make -f
PYTHON2:=$(shell pyversions -r)
PYTHON3:=$(shell py3versions -r)
py3sdo=set -e; $(foreach py, $(PYTHON3), $(py) $(1);)
pyalldo=set -e; $(foreach py, $(PYTHON2) $(PYTHON3), $(py) $(1);)

%:
	dh $@ --with python2,python3

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
	$(call pyalldo, -m unittest discover -vv test/)
endif

override_dh_auto_build:
	dh_auto_build
	$(call py3sdo, setup.py build)

override_dh_auto_install:
	dh_auto_install
	$(call py3sdo, setup.py install --root=$(CURDIR)/debian/apt-btrfs-snapshot --install-layout=deb)

override_dh_auto_clean:
	dh_auto_clean
	rm -rf build
	rm -rf *.egg-info

override_dh_python3:
	dh_python3 --shebang=/usr/bin/python3
