#!/usr/bin/make -f

PY2VERS = $(shell pyversions -r -v)

# to build without sphinxdoc
WITH_SPHINXDOC = $(shell if [ -x /usr/bin/dh_sphinxdoc ]; then echo "--with sphinxdoc"; fi)

%:
	dh $@ --with python2 $(WITH_SPHINXDOC)

override_dh_clean:
        # remove the cython generated files distributed by upstream
	rm -f $(patsubst %.pyx,%.c,$(wildcard src/*.pyx))
	rm -rf build/sphinx
	rm -rf *.egg-info
	dh_clean

override_dh_auto_build-indep:
	dh_auto_build
	# build the documentation
	set -e -x;\
	for py in $(PY2VERS); do \
		env http_proxy='localhost' python$$py setup.py build_doc ;\
	done

override_dh_install:
	dh_numpy
	# Install everything excluding the *_d.so debug extensions to python-foo
	dh_install -X"*_d.so" "debian/tmp/*" -p python-fabio

	# Install the debug extensions to python-foo-dbg
	dh_install "debian/tmp/usr/lib/python*/*-packages/fabio/*_d.so" -p python-fabio-dbg

	# Continue with regular dh_install
	dh_install

override_dh_installdocs-indep:
	# install the documentation
	dh_installdocs "build/sphinx/html" -p python-fabio-doc
