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

#export DH_VERBOSE = 1

include /usr/share/dpkg/pkg-info.mk

BUILD_DATE  = $(shell LC_ALL=C date -u "+%d %B %Y" -d "@$(SOURCE_DATE_EPOCH)")
SPHINXOPTS := -E -N -D html_last_updated_fmt="$(BUILD_DATE)"

export PYBUILD_NAME=flask-openid

%:
	dh $@ --buildsystem=pybuild

override_dh_sphinxdoc:
ifeq (,$(findstring nodoc, $(DEB_BUILD_OPTIONS)))
	PYTHONPATH=`dirname $$(find .pybuild/ -type f -name "flask_openid.py" | head -n1)` \
	    python3 -m sphinx -b html $(SPHINXOPTS) docs/ $(CURDIR)/debian/python-flask-openid-doc/usr/share/doc/python-flask-openid-doc/html
	dh_sphinxdoc
endif

override_dh_installexamples:
	dh_installexamples
	# Ugly hack, moving "#!/bin/env python" -> "#!/usr/bin/python3"
	sed -i 's/bin\/env python/usr\/bin\/python3/g' $(CURDIR)/debian/python-flask-openid-doc/usr/share/doc/python-flask-openid-doc/examples/example.py
