#!/usr/bin/make -f

DH_ARGS ?=
ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
	DH_ARGS += --with sphinxdoc
endif

%:
	dh $@ --buildsystem=pybuild --with python3 $(DH_ARGS)

override_dh_auto_clean:
	rm -rf doc/_build
	rm -f doc/dh_virtualenv.1
	rm -rf dh_virtualenv.egg-info
	dh_auto_clean

override_dh_auto_build:
	rst2man doc/dh_virtualenv.1.rst >doc/dh_virtualenv.1
	dh_auto_build

ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
override_dh_installdocs:
	python3 setup.py build_sphinx
	ln -sf /usr/share/javascript/jquery/jquery.js doc/_build/html/_static/jquery.js
	ln -sf /usr/share/javascript/underscore/underscore.js doc/_build/html/_static/underscore.js
	dh_installdocs doc/_build/html

# Make Sphinxdocs build on Jessie and Xenial
override_dh_sphinxdoc:
	dh_sphinxdoc -X.rst.html -X.rst.txt \
	             -Xunderscore.js -Xjquery.js -X searchtools.js -X doctools.js
endif
