#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
export PYBUILD_NAME=argcomplete

# Avoid failures in unit tests
# See https://github.com/kislyuk/argcomplete/issues/199
unexport LC_ALL

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

# Workaround
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1010941
# https://github.com/kislyuk/argcomplete/issues/337#issuecomment-771835184
override_dh_auto_test:
	echo "set enable-bracketed-paste off" > .inputrc
	INPUTRC=$(CURDIR)/.inputrc dh_auto_test

override_dh_auto_clean:
	rm -f .inputrc
	dh_auto_clean

generate_manpages:
	VERSION=$$(./setup.py -V) ; \
	for file in \
		activate-global-python-argcomplete \
		python-argcomplete-check-easy-install-script \
		register-python-argcomplete; \
	do \
		cp -f scripts/$$file debian/$$file ; \
		chmod a+x debian/$$file ; \
		PYTHONPATH=. help2man --version-string="$$VERSION" \
			--no-info --include=debian/help2man.include \
			--name "$$file - argcomplete utility script" \
			-o debian/$$file.1 --no-discard-stderr \
			debian/$$file ; \
		rm -f debian/$$file; \
	done ; \
	rm -f argcomplete/*.py[co]
