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

#export DH_VERBOSE=1
export PYBUILD_NAME=pymodbus
export http_proxy = http://127.0.0.1:9
export https_proxy = https://127.0.0.1:9

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

override_dh_auto_build:
	dh_auto_build
	( cd doc; \
	  PYTHONPATH=.. http_proxy='127.0.0.1:9' python3 -m sphinx -M html . _build )

# pybuild hangs after successful tests since Python 3.7, therefore disabled
# hopefully solved, when upstream supports Python 3.7 officially
override_dh_auto_test:

override_dh_install:
	dh_install
	rm -f $(CURDIR)/debian/python*-pymodbus/usr/lib/python*/dist-packages/.coverage
	# remove the new script, currently broken on Debian anyway
	rm -f $(CURDIR)/debian/python*-pymodbus/usr/bin/pymodbus.console
	# remove asyncio code for Python 2
	rm -rf $(CURDIR)/debian/python-pymodbus/usr/lib/python2*/dist-packages/pymodbus/client/asynchronous/asyncio/

override_dh_installdocs:
	dh_installdocs -ppython-pymodbus-doc --doc-main-package=python-pymodbus-doc
	dh_installdocs --remaining-packages

override_dh_installexamples:
	dh_installexamples -ppython-pymodbus-doc --doc-main-package=python-pymodbus-doc
	dh_installexamples --remaining-packages