#!/usr/bin/make -f

#export DH_VERBOSE=1
#export PYBUILD_VERBOSE=1
export PYBUILD_NAME=tox

PYTHON3=$(shell py3versions -d)

BUILD_DATE=$(\
    shell dpkg-parsechangelog -S Date | LC_ALL=C date -u "+%B %d, %Y" -f -)

%:
	dh $@ --with=python3,sphinxdoc --buildsystem=pybuild

# The tests are not runnable during package build because many invoke the tox
# command line.  It's too much work to make the test suite run partially here
# because upstream always changes the mix.
override_dh_auto_test:

override_dh_install:
	dh_install
	dh_install debian/python3-tox/usr/bin usr
	dh_install debian/python3-tox/usr/lib/$(PYTHON3)/dist-packages \
		   usr/lib/python3

override_dh_installdocs:
	python3 setup.py build_sphinx
	dh_installdocs doc/build/html

override_dh_installman:
	(cd debian/manpage; \
	 sphinx-build \
		-b man -D today="$(BUILD_DATE)" \
		-d _build/doctrees . _build/man)
	dh_installman debian/manpage/_build/man/tox.1

override_dh_installchangelogs:
	dh_installchangelogs CHANGELOG

override_dh_auto_clean:
	dh_auto_clean
	rm -rf build
	rm -rf *.egg-info
	rm -rf .tox
	rm -rf debian/manpage/_build
