#!/usr/bin/make -f

PY2VERS := $(shell pyversions -s)

%:
	dh $@ --with python2 --buildsystem=python_distutils

override_dh_auto_build:
	set -e; for python in $(PY2VERS); do \
		$$python setup.py build; \
	done

# pybuild's PYBUILD_EXT_DESTDIR did the pure-python/C-extension split in Debian.
# Under python_distutils everything installs into one staging tree and the split
# is done by debian/python-cffi{,-backend}.install instead.
override_dh_auto_install:
	set -e; for python in $(PY2VERS); do \
		$$python setup.py install --install-layout=deb --root $(CURDIR)/debian/tmp; \
	done

# The test suite needs python-pytest, which is not packaged for python2 here.
override_dh_auto_test:

override_dh_install:
	debian/gen-backend-versions.py
	dh_install

override_dh_installchangelogs:
	dh_installchangelogs doc/source/whatsnew.rst

override_dh_clean:
	dh_clean
	rm -rf $(wildcard testing/*/snippets/*/build testing/*/snippets/*/dist testing/*/snippets/*/*.egg-info)
