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

include /usr/share/dpkg/default.mk
export DPKG_EXPORT_BUILDFLAGS=1

export PYBUILD_NAME=pysquashfsimage
export PYBUILD_INSTALL_ARGS=--install-scripts=../pysquashfsimage/usr/bin

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

execute_after_dh_auto_install:
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	PYTHONPATH=$(shell pybuild --print {build_dir} --interpreter python3) \
	http_proxy='http://127.0.0.1:9/' https_proxy='https://127.0.0.1:9/' \
	python3 -m sphinx -b html docs $(CURDIR)/debian/python-$(PYBUILD_NAME)-doc/usr/share/doc/python-$(PYBUILD_NAME)-doc/html
	rm -rf $(CURDIR)/debian/python-$(PYBUILD_NAME)-doc/usr/share/doc/python-$(PYBUILD_NAME)-doc/html/.doctrees
endif
