#!/usr/bin/make -f
include /usr/share/dpkg/pkg-info.mk

# Automatically generate man pages with help2man
export PYBUILD_AFTER_INSTALL := \
	echo 'Automatically generating man pages with help2man' && \
	mkdir -p {destdir}/usr/share/man/man1 && \
	ls {destdir}/usr/bin | env PYTHONPATH={destdir}{install_dir} \
	xargs --verbose -I @ \
	help2man \
		--section 1 \
		--source $(DEB_SOURCE) \
		--version-string $(DEB_VERSION_UPSTREAM) \
		--no-info \
		--no-discard-stderr \
		--output {destdir}/usr/share/man/man1/@.1 \
		{destdir}/usr/bin/@ \
	;

# Run unit tests. Skip tests that require network access
export PYBUILD_AFTER_TEST := env \
	PYTHONPATH={build_dir} \
	PYTHONDONTWRITEBYTECODE=1 \
	make -C {dir}/test PYTHON={interpreter} \
		-o test_ldbd \
	;

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