#!/usr/bin/make -f

manpage = debian/sshoot.1
executable = debian/sshoot/usr/bin/sshoot

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

# generate manpage based on --help option of script itself
override_dh_auto_install: \
 _PYTHONPATH = debian/sshoot/usr/lib/$(shell py3versions -d)/dist-packages
override_dh_auto_install:
	dh_auto_install
	PYTHONPATH=$(_PYTHONPATH) help2man \
		--name="manage multiple sshuttle VPN sessions" \
		--no-info \
		--output=$(manpage) \
		$(executable) \
		|| { PYTHONPATH=$(_PYTHONPATH) $(executable) --help; false; }
	find debian/sshoot/usr/lib -name '*.pyc' -delete
	find debian/sshoot/usr/lib -type d -empty -delete

override_dh_clean:
	dh_clean
	rm -f $(manpage)
