#!/usr/bin/make -f

PY2VERS := $(shell pyversions -s)
PY3VERS := $(shell py3versions -s)

%:
	dh $@ --with sphinxdoc,python2,python3

override_dh_auto_build:
	set -e ; \
	for python in $(PY2VERS) $(PY3VERS); do \
		$$python setup.py build; \
	done

	PYTHONPATH=../build/lib/ $(MAKE) -C doc html

override_dh_auto_install:
	set -e ; \
	for python in $(PY2VERS); do \
		$$python setup.py install --root=debian/python-sphinx-gallery --install-layout=deb; \
	done
	set -e ; \
	for python in $(PY3VERS); do \
		$$python setup.py install --root=debian/python3-sphinx-gallery --install-layout=deb; \
	done

	#dont install the scripts
	rm -rf $(CURDIR)/debian/*/usr/bin

override_dh_installchangelogs:
	dh_installchangelogs -A CHANGES.rst

override_dh_installdocs:
	dh_installdocs
	dh_installdocs -ppython-sphinx-gallery-doc examples/ mayavi_examples/ tutorials/ doc/_build/html/

override_dh_auto_clean:
	dh_auto_clean
	rm -rf $(CURDIR)/build/
	rm -rf $(CURDIR)/doc/_build/
	rm -rf $(CURDIR)/doc/auto_examples/
	rm -rf $(CURDIR)/doc/gen_modules/
	rm -rf $(CURDIR)/doc/tutorials/
	rm -rf $(CURDIR)/sphinx_gallery.egg-info/
