#!/usr/bin/make -f

#DH_VERBOSE=1

PYTHON2=$(shell pyversions -vs)
PYTHON3=$(shell py3versions -vs)
PYTHON2MJ=$(shell pyversions -vr | cut -c1-1)
PYTHON3MJ=$(shell py3versions -vs | cut -c1-1)

%:
	dh $@ --with python2,python3

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
test-python%:
	(cd tests; PYTHONPATH=.. ./run$*)
override_dh_auto_test: $(PYTHON2MJ:%=test-python%) $(PYTHON3MJ:%=test-python%)
endif

build-python%:
	python$* setup.py build

override_dh_auto_build: $(PYTHON3:%=build-python%)
	dh_auto_build

install-python%:
	python$* setup.py install --root=$(CURDIR)/debian/tmp --install-layout=deb

override_dh_auto_install: $(PYTHON3:%=install-python%)
	dh_auto_install

#override_dh_installchangelogs:
#	dh_installchangelogs -k foo/NEWS.rst

#override_dh_installdocs:
#	python setup.py build_sphinx
#	dh_installdocs build/sphinx/html

override_dh_auto_clean:
	dh_auto_clean
	rm -rf build
	rm -rf *.egg-info
	rm -f settings.py tests/xkittest-*.txt

