#!/usr/bin/make -f

PYTHONS:=$(shell pyversions -vr)
PYTHON3S:=$(shell py3versions -vr)

UPSTREAM_GIT = git://github.com/Kronuz/pyScss.git
-include /usr/share/openstack-pkg-tools/pkgos.make

MANPAGES=python2-pyscss.1 python3-pyscss.1
DB2MAN=http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl
XP=xsltproc --nonet --novalid

export PYBUILD_NAME=pyscss

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

override_dh_install: $(MANPAGES)
	dh_install -ppython-pyscss
	mv $(CURDIR)/debian/python-pyscss/usr/bin/pyscss $(CURDIR)/debian/python-pyscss/usr/bin/python2-pyscss
	dh_install -ppython3-pyscss
	mv $(CURDIR)/debian/python3-pyscss/usr/bin/pyscss $(CURDIR)/debian/python3-pyscss/usr/bin/python3-pyscss

$(MANPAGES): debian/pyscss.dbk
	$(XP) $(DB2MAN) $< && mv pyscss.1 $@

override_dh_clean:
	dh_clean
	rm -f $(MANPAGES)
	rm -rf build
	find . -iname '*.pyc' -delete

override_dh_auto_test:
ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
	set -e ; for pyvers in 2.7 3.4; do \
		py.test-$$pyvers ; \
	done
endif
