#!/usr/bin/make -f

# Supported Python versions
PYVERS = $(shell pyversions -vr)

# Callable functions to determine the correct PYTHONPATH
pythonpath = $$(ls -d $(CURDIR)/build/lib.*-$(1))

%:
	dh $@ --with=python2,sphinxdoc

override_dh_clean:
	dh_clean
	rm -rf docs/_build

override_dh_auto_build:
	dh_auto_build
	python setup.py build_sphinx

override_dh_auto_install:
	dh_auto_install
	rm debian/tmp/usr/lib/python*/*-packages/Flask_AutoIndex-*.egg-info/SOURCES.txt

override_dh_auto_test:
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
	set -ex && for py in $(PYVERS); do \
		PYTHONPATH=$(call pythonpath,$$py) python$$py setup.py test ;\
	done
endif
