#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow

export PYBUILD_NAME=skbio
export MPLBACKEND=agg
DOCPKG=python-$(PYBUILD_NAME)-doc

%:
	dh $@ --with python3,sphinxdoc --buildsystem=pybuild

override_dh_auto_build:
	dh_auto_build
	PYTHONPATH=$(shell echo .pybuild/pythonX.Y_3.5*/build/) \
		http_proxy='127.0.0.1:9' \
		python3 `which sphinx-build` -b html -d doc/build/doctrees doc/source doc/build/html

override_dh_auto_test:
	dh_auto_test

override_dh_auto_clean:
	if [ "`find . -name "*.pyo"`" = "" ] ; then echo no need to clean up ; else dh_auto_clean; fi

override_dh_clean:
	dh_clean
	find ./skbio -name '*.so' -delete
	rm -rf .eggs

override_dh_sphinxdoc:
ifeq (,$(findstring nodoc,$(DEB_BUILD_OPTIONS)))
	dh_link --package=$(DOCPKG) \
		/usr/share/javascript/mathjax/MathJax.js \
		/usr/share/doc/$(DOCPKG)/html/_static/MathJax.js
	dh_sphinxdoc --package=$(DOCPKG)
endif
