#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

PYVERS :=  python2.7
PY3VERS := $(shell py3versions -s)

%:
	dh $@ --with bash-completion --with sphinxdoc --with python2,python3

override_dh_auto_build:
	cp bash_completion_doit debian/bash_completion_doit3
	sed -i 's@doit@doit3@g' debian/bash_completion_doit3

override_dh_auto_clean:
	dh_auto_clean -- --all
	rm -rf build
	rm -rf doc/_build
	rm -rf doit.egg-info
	rm -f debian/doit.1
	rm -f debian/doit3.1
	rm -f debian/bash_completion_doit3
	rm -f tests/data/stop
	rm -f tests/data/dependency*
	rm -f tests/data/target
	rm -f tests/data/w*.txt

override_dh_auto_install:
	rm -rf __pycache__
	set -ex; \
	for py in $(PYVERS); do \
		$$py setup.py install --root debian/python-doit \
				      --install-layout=deb; \
	done
	set -ex; \
	for py in $(PY3VERS); do \
		$$py setup.py install --root debian/python3-doit \
				      --install-layout=deb; \
	done
	mv debian/python3-doit/usr/bin/doit debian/python3-doit/usr/bin/doit3
	rst2man debian/doit.rst debian/doit.1
	rst2man debian/doit3.rst debian/doit3.1
	set -ex; \
		cd doc; \
		make html; \
		cd -;
