#!/usr/bin/make -f

export http_proxy='localhost'

# for backport on stable without bpo
WITH_SPHINXDOC = $(shell if [ -x /usr/bin/dh_sphinxdoc ]; then echo "--with sphinxdoc"; fi)

override_dh_clean:
	rm -rf build/sphinx
	# remove useless file accidentaly forgotten by upstream.
	# THIS SHOULD BE FIXED FOR THE NEXT UPLOAD > 1.4.2
	rm -rf src/sardana/taurus/qt/qtgui/extra_macroexecutor/build/
	dh_clean

override_dh_auto_install:
	dh_auto_install -- --install-html=$(CURDIR)/debian/python-sardana-doc/usr/share/doc/python-sardana-doc/html
	# on squeeze python-sphinx is too old so create a fake documentation for now
	if [ ! -d build/sphinx ]; then mkdir -p build/sphinx/html; fi
	# Replace duplicate files with symlinks
	rdfind -outputname /dev/null -makesymlinks true debian/python-sardana-doc/
	# Fix those symlinks to make them relative
	symlinks -r -s -c debian/python-sardana-doc/

%:
	dh $@ --with python2 $(WITH_SPHINXDOC)
