#!/usr/bin/make -f

export DH_VERBOSE=1
export PYBUILD_NAME=fabio

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  --buildsystem=pybuild $(WITH_SPHINXDOC)

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

override_dh_auto_build-indep:
	dh_auto_build
	PYBUILD_SYSTEM=custom \
	PYBUILD_BUILD_ARGS="PYTHONPATH={build_dir} http_proxy='localhost' sphinx-build -N -bhtml doc/source build/html" dh_auto_build  # HTML generator

override_dh_auto_test:
	PYBUILD_SYSTEM=custom \
	PYBUILD_TEST_ARGS="PYTHONPATH={build_dir} {interpreter} test/test_all.py" dh_auto_test

override_dh_install:
	dh_numpy
	dh_install

	# remove the /bin part of the -dbg package which conflict with
	# non-dbg packages
	rm -rf debian/python-fabio-dbg/usr/bin

override_dh_installman:
	dh_installman -p python-fabio doc/man/fabio_viewer.1

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