#!/usr/bin/make -f
#export DH_VERBOSE=1
export PYBUILD_NAME=wand

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

.PHONY: build_doc clean_doc

override_dh_auto_build: build_doc
	dh_auto_build

override_dh_install:
	dh_install
	rm -f $(CURDIR)/debian/*/usr/README.rst
	rm -f $(CURDIR)/debian/*/usr/lib/*/README.rst

override_dh_installchangelogs:
	dh_installchangelogs $(CURDIR)/docs/changes.rst

override_dh_auto_clean: clean_doc
	dh_auto_clean

# The testsuite is disabled for now; it fails on the ImageMagick 6.8.* or
# later
override_dh_auto_test:
	#dh_auto_test

build_doc:
	$(MAKE) -C $(CURDIR)/docs html
	find $(CURDIR)/docs/_build/html -mindepth 2 -maxdepth 2 -type f | xargs sed -i 's;https://cdnjs.*HTMLorMML;../_static/mathjax.js;g'
	find $(CURDIR)/docs/_build/html -maxdepth 1 -type f | xargs sed -i 's;https://cdnjs.*HTMLorMML;_static/mathjax.js;g'

clean_doc:
	$(MAKE) -C $(CURDIR)/docs clean
