#!/usr/bin/make -f

PY3DEF=$(shell py3versions -vd)
PYDEF=$(shell pyversions -vd)
SPHINXBUILD="/usr/share/sphinx/scripts/python{version.major}/sphinx-build"

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

override_dh_auto_clean:
	dh_auto_clean
	$(MAKE) distclean
	rm -rf html

override_dh_auto_build:
	dh_auto_build
	pybuild --system=custom -p $(PY3DEF) --build \
		--build-args="env PYTHONPATH={build_dir} $(MAKE) SPHINXBUILD=$(SPHINXBUILD)"
	mv testsuite/build/html html

override_dh_auto_test:
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
	# We test breathe by building the documention. The documentation has already
	# been built for the default Python 3 version, so we do not need to do this
	# again. We just test with the default Python 2 version here.
	pybuild --system=custom -p $(PY3DEF) --build \
		--build-args="env PYTHONPATH={build_dir} $(MAKE) SPHINXBUILD=$(SPHINXBUILD)"
endif

override_dh_sphinxdoc:
	dh_sphinxdoc -X/usr/share/javascript/mathjax/MathJax.js
