#!/usr/bin/make -ef

export PYBUILD_NAME = letsencrypt

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

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

clean: debian/control
	dh_clean

debian/control: debian/control.in debian/changelog
	sed -e 's/###UPSTREAM_VERSION###/$(DEB_VERSION_UPSTREAM)/g' < debian/control.in > debian/control

override_dh_install:
	mkdir -p debian/letsencrypt/usr/bin
	mv debian/python-letsencrypt/usr/bin/* debian/letsencrypt/usr/bin
	rm -rf debian/python-letsencrypt/usr/bin
	PYTHONPATH=. PATH=../debian/letsencrypt/usr/bin:${PATH} \
		http_proxy='127.0.0.1:9' \
		sphinx-build -N -bhtml docs/ build/html
	PYTHONPATH=. PATH=../debian/letsencrypt/usr/bin:${PATH} \
		http_proxy='127.0.0.1:9' \
		sphinx-build -N -bman docs/ build/man
	chmod -x debian/python-letsencrypt/usr/lib/python2.7/dist-packages/letsencrypt/tests/testdata/sample-renewal*.conf
