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

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# For svn-orig-source.sh
PKGDIR = $(dir $(firstword $(MAKEFILE_LIST)))
UPNAME = $(shell dpkg-parsechangelog -l$(PKGDIR)/changelog | \
                sed -nre 's,^Source:\s+(.*),\1,p')
UPVER = $(shell dpkg-parsechangelog -l$(PKGDIR)/changelog | \
                sed -nre 's,^Version:\s+(.*)\+svn([0-9]+)\+dfsg-.*,\1,p')
SVNREV = $(shell dpkg-parsechangelog -l$(PKGDIR)/changelog | \
                sed -nre 's,^Version:\s+(.*)\+svn([0-9]+)\+dfsg-.*,\2,p')
SVNURL = https://pyevolve.svn.sourceforge.net/svnroot/pyevolve/trunk/
export UPNAME UPVER SVNURL SVNREV


%:
	dh  $@

# Override needed for docs and egg-info
override_dh_auto_clean:
	dh_auto_clean
	rm -rf Pyevolve.egg-info
	rm -rf docs/html

# Override needed for building documentation; jquery link
override_dh_auto_build:
	dh_auto_build
	cd docs && sphinx-build -E -a -b html ./source ./html
	rm -rf docs/html/.buildinfo
	rm -rf docs/html/.doctrees
	rm -rf docs/html/_sources
	rm -f docs/html/objects.inv
	rm -f docs/html/_static/jquery.js

# Override needed for multiple binary package;
# script must be renamed, line endings converted to Unix
override_dh_auto_install:
	dh_auto_install --destdir=debian/python-pyevolve
	tr -d '\r' < debian/python-pyevolve/usr/bin/pyevolve_graph.py \
	           > debian/python-pyevolve/usr/bin/pyevolve-graph
	rm -f debian/python-pyevolve/usr/bin/pyevolve_graph.py

# Don't compress sphinx's javascript and Python example files
override_dh_compress:
	dh_compress -X.js -X.py

get-orig-source:
	sh $(PKGDIR)/svn-orig-source.sh
