#!/usr/bin/make -f
#export DH_VERBOSE=1

export PYBUILD_NAME=openslide
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@ --buildsystem=pybuild

execute_before_dh_auto_build:
	if [ -d openslide_python.egg-info ] \
	; then cp -a openslide_python.egg-info openslide_python.egg-info.orig \
	; fi

execute_before_dh_clean:
	if [ -d openslide_python.egg-info.orig ] \
	; then rm -r openslide_python.egg-info \
	       && mv openslide_python.egg-info.orig openslide_python.egg-info \
	; fi

override_dh_installexamples:
	dh_installexamples -ppython-openslide-examples -Xjquery.js examples/*
	dh_link -ppython-openslide-examples \
		usr/share/javascript/jquery/jquery.js \
		usr/share/doc/python-openslide-examples/examples/deepzoom/static/jquery.js
	# Fix interpreter shebang.
	sed -i '1s@#!.*python.*@#!/usr/bin/python3@' \
		debian/*/usr/share/doc/python-openslide-examples/examples/deepzoom/deepzoom_multiserver.py \
		debian/*/usr/share/doc/python-openslide-examples/examples/deepzoom/deepzoom_server.py \
		debian/*/usr/share/doc/python-openslide-examples/examples/deepzoom/deepzoom_tile.py

override_dh_compress:
	dh_compress -X.py

execute_after_dh_install:
	# Remove unused file tripping lintian.
	rm -vf debian/*/usr/lib/python*/dist-packages/openslide_python-*.dist-info/top_level.txt
