#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1

export DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow

export PYBUILD_NAME = slixmpp

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

override_dh_auto_build:
	dh_auto_build
	# Build the documentation, with Sphinx for Python 3 as Slixmpp is
	# not usable with Python 2.
	PYTHONPATH=. http_proxy='127.0.0.1:9' make \
		   SPHINXBUILD=/usr/share/sphinx/scripts/python3/sphinx-build \
		   -C docs html

override_dh_auto_install:
	dh_auto_install
	# Move binary libraries to the binary package
	# (pybuild is supposed to be able to do that but it does not seem to
	# work)
	for library in debian/python3-slixmpp/usr/lib/python*/dist-packages/slixmpp/*.so ; \
	do \
	    short_path="$${library#debian/python3-slixmpp/}" ; \
	    short_dir="$${short_path%/*}" ; \
	    if [ ! -e "debian/python3-slixmpp-lib/$$short_dir" ] ; \
	    then \
	        mkdir -p "debian/python3-slixmpp-lib/$$short_dir" ; \
	    fi ; \
	    mv "$$library" "debian/python3-slixmpp-lib/$$short_dir" ; \
	done

override_dh_auto_clean:
	dh_auto_clean
	make -C docs clean
