#!/usr/bin/make -f
# -*- coding: utf-8 -*-

#export DH_VERBOSE=1

VERSION := $(shell dpkg-parsechangelog | sed -ne 's/^Version: \(\([0-9]\+\):\)\?\(.*\)-.*/\3/p')

%:
	dh $@ --with python2,sphinxdoc

override_dh_auto_build:
	dh_auto_build
	mv docs/html docs/html.old && make -C docs html

override_dh_install:
	dh_install --fail-missing

override_dh_installchangelogs:
	dh_installchangelogs
	# install the upstream changelog at the right place in the doc package
	dh_installchangelogs -ppython-simpy-doc docs/source/Manuals/HISTORY.rst

override_dh_compress:
	dh_compress -X.py -X.txt

override_dh_auto_install:
	# Replace broken shebangs with /usr/bin/python
	find build/ -name '*.py' -exec sed -i -e '1s|^#!.*python.*|#!/usr/bin/python|' '{}' ';'

	dh_auto_install

override_dh_auto_clean:
	dh_auto_clean

	if [ -d docs/html.old ]; then make -C docs clean && mv docs/html.old docs/html; fi
