#!/usr/bin/make -f

export PYBUILD_NAME=stdeb
export PYBUILD_AFTER_INSTALL_python3=rm -rf {destdir}/usr/bin

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

PYPI_DESC = downloads Python package from PyPI, creates Debian package and then installs it
DEB_UPSTREAM_VERSION=$(shell dpkg-parsechangelog | sed -rne 's,^Version: ([^-]+).*,\1,p')
help2man = PYTHONPATH=${CURDIR} help2man -N --version-string=${DEB_UPSTREAM_VERSION} \
		-o $1 -n '$2' $(CURDIR)/debian/python-stdeb/usr/bin/$(subst .1,,$1)

py2dsc.1:
	$(call help2man,$@,creates Debian source package from Python package)

py2dsc-deb.1:
	$(call help2man,$@,dpkg-buildpackage wrapper that integrates with py2dsc and build binary package)

pypi-install.1:
	$(call help2man,$@,${PYPI_DESC})

pypi-download.1:
	$(call help2man,$@,downloads tarballs from PyPI)

override_dh_installman: py2dsc.1 py2dsc-deb.1 pypi-install.1 pypi-download.1
	dh_installman -p python-stdeb py2dsc.1 py2dsc-deb.1 pypi-install.1 pypi-download.1

clean:
	rm -f py2dsc.1 pypi-install.1 py2dsc-deb.1 pypi-download.1
	dh $@ --buildsystem=pybuild

