#!/usr/bin/make -f
# -*- makefile -*-

#export DH_VERBOSE=1
export PYBUILD_NAME=dugong
export PYBUILD_TEST_PYTEST=1
export PYBUILD_TEST_ARGS="{dir}/test/"

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

.PHONY: override_dh_auto_build
override_dh_auto_build:
	dh_auto_build

	# We need at least Python 3.4 to build the documentation. 
	# While dugong supports Python 3.3 as well, there are some
	# optional components that require the asyncio module. To
	# include these components in the documentation, we need to
	# build the docs with Python 3.4. If Python 3.4 is not available,
	# fall back to the default Python (which is hopefully 3.5 or
	# newer :-).
	if which python3.4 > /dev/null; then \
	    python3.4 setup.py build_sphinx; \
	else \
	    python3 setup.py build_sphinx; \
	fi

.PHONY: override_dh_auto_clean
override_dh_auto_clean:
	dh_auto_clean
	rm -rf doc/html doc/doctrees

.PHONY: update_intersphinx
update_intersphinx:
	wget http://docs.python.org/3.4/objects.inv -O debian/python.inv

.PHONY: get-orig-source
get-orig-source:
	uscan --rename --destdir=$(CURDIR) --repack --force-download \
	      --download-current-version
