#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

PYVERS  := $(shell pyversions -d)
PY3VERS := $(shell py3versions -d)

%:
	dh $@ --with python2,python3


override_dh_auto_build:
	$(PYVERS) setup.py build --build-base=build2 && \
	$(PY3VERS) setup.py build --build-base=build3

override_dh_auto_test:
	nosetests -d build2 && \
	nosetests3 -d build3

override_dh_auto_install:
	$(PYVERS) setup.py install --no-compile -O0 --install-layout=deb \
	--root $(CURDIR)/debian/python-pystache && \
	$(PY3VERS) setup.py install --no-compile -O0 --install-layout=deb \
	--root $(CURDIR)/debian/python3-pystache && \
	2to3 -w $(CURDIR)/debian/python3-pystache

override_dh_python2:
	dh_python2 && \
	rm -f $(CURDIR)/debian/python-pystache/usr/bin/pystache-test && \
	rm -rf $(CURDIR)/debian/python-pystache/usr/share/pyshared/pystache/tests && \
	rm -rf $(CURDIR)/debian/python-pystache/usr/lib/$(PYVERS)/dist-packages/pystache/tests

override_dh_python3:
	dh_python3 && \
	mv -f $(CURDIR)/debian/python3-pystache/usr/bin/pystache $(CURDIR)/debian/python3-pystache/usr/bin/pystache3 && \
	rm -rf $(CURDIR)/debian/python3-pystache/usr/bin/pystache-test && \
	rm -rf $(CURDIR)/debian/python3-pystache/usr/share/pyshared/pystache/tests && \
	rm -rf $(CURDIR)/debian/python3-pystache/usr/lib/python3/dist-packages/pystache/tests/

override_dh_auto_clean:
	$(PYVERS) setup.py clean --build-temp=build && \
	$(PYVERS) setup.py clean --build-temp=build2 && \
	$(PY3VERS) setup.py clean --build-temp=build3 && \
	dh_clean

