#!/usr/bin/make -f

PY2VERSIONS = $(shell pyversions -vr)
PY3VERSIONS = $(shell py3versions -vr)

%:
	dh $@ --with python2,python3

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

override_dh_auto_install:
	dh_auto_install
	set -e; for version in $(PY3VERSIONS); do \
		python$$version setup.py install --no-compile -O0 --install-layout=deb \
					--root $(CURDIR)/debian/tmp; \
	done

override_dh_auto_clean:
	dh_auto_clean
	set -e; for version in $(PY3VERSIONS); do \
		python$$version setup.py clean; \
	done
	rm -rf xlrd/__pycache__/

override_dh_install:
	dh_install --fail-missing
	mv debian/python-xlrd/usr/bin/runxlrd.py debian/python-xlrd/usr/bin/runxlrd

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
	set -e; for version in $(PY2VERSIONS) $(PY3VERSIONS); do \
		python$$version -m unittest discover ; \
	done
endif
