#!/usr/bin/make -f

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

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

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

override_dh_auto_build:
	dh_auto_build
	PYTHONPATH=.pybuild/pythonX.Y_2.7/build/ \
		http_proxy='127.0.0.1:9' \
		sphinx-build -b html -d doc/build/doctrees doc/source doc/build/html

override_dh_auto_test:
	#Loads of failures at this point.
	dh_auto_test || true

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
