#!/usr/bin/make -f

export PYBUILD_NAME = letsencrypt-apache

UPSTREAM_VERSION := $(shell head -n 1 debian/changelog | \
		perl -ne '$$_ =~ m/\((?:[0-9]+:)?([0-9][A-Za-z0-9\.\-\+~:]*)-([0-9A-Za-z\+\.~]+)\)/; print $$1;')

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

clean: debian/control
	dh_clean

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

override_dh_auto_build:
	dh_auto_build
	PYTHONPATH=. http_proxy='127.0.0.1:9' sphinx-build -N -bhtml docs/ build/html

override_dh_auto_install:
	dh_auto_install
	rm -rf $(CURDIR)/debian/python-letsencrypt-apache/usr/lib/python2.7/dist-packages/letsencrypt_apache/tests/testdata
