#! /usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

PYTHON3_DEFAULT:=$(shell py3versions -vd)
export PYBUILD_NAME=parfive

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

override_dh_auto_build-indep:
	dh_auto_build -i
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	cd docs && \
	PYTHONPATH=$(CURDIR) http_proxy='http://127.0.0.1:9/' https_proxy='https://127.0.0.1:9/' \
	python3 -m sphinx -N -E -T -b html . $(CURDIR)/.pybuild/docs/html/
	rm -rf $(CURDIR)/.pybuild/docs/html/.doctrees
endif

override_dh_installman:
	PYTHONPATH=debian/python3-parfive/usr/lib/python$(PYTHON3_DEFAULT)/dist-packages/ debian/python3-parfive/usr/bin/parfive --help
	PYTHONPATH=debian/python3-parfive/usr/lib/python$(PYTHON3_DEFAULT)/dist-packages/ help2man -N -n "Python Asyncio Based Downloader" --version-string "$(DEB_VERSION_UPSTREAM)" debian/python3-parfive/usr/bin/parfive > parfive.1
	dh_installman

override_dh_auto_test:
	# pass
