#!/usr/bin/make -f

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

override_dh_auto_build:
	V=`dpkg-parsechangelog -SVersion|cut -d- -f1`; \
	echo -n "__version__=\"" > codespell_lib/_version.py; \
	echo -n $$V >> codespell_lib/_version.py; \
	echo -n "\"" >> codespell_lib/_version.py
	dh_auto_build

override_dh_installman:

	PYTHONPATH=`ls -d ./debian/codespell/usr/lib/python3*/dist-packages/` \
	help2man ./debian/codespell/usr/bin/codespell --include codespell.1.include --no-info --output codespell.1 --no-discard-stderr
	if grep "ModuleNotFoundError: No module named" codespell.1; then exit 1; fi
	sed -i '/\.SS \"Usage/,+2d' codespell.1
	dh_installman

override_dh_auto_test:
	make check-dictionaries

override_dh_clean:
	rm -rf codespell.egg-info .cache .coverage dist venv
	dh_clean
