#!/usr/bin/make -f

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

destdir = debian/silkaj
cmd = silkaj
python3path = $(destdir)/usr/lib/$(shell py3versions -d)/dist-packages

# generate manpage with help2man from --help option of python script
_mkman = PYTHONPATH=$(python3path) \
 help2man $(patsubst %,--name %,$3) --no-info --output $2 $1 \
 || { PYTHONPATH=$(python3path) $1 --help; false; }

# generate manpage based on --help option of script itself
# * Fix encode special Duniter signature "Ğ"
override_dh_auto_install:
	dh_auto_install
	$(call _mkman, $(destdir)/usr/bin/$(cmd), debian/$(cmd).1, \
		command-line client for Duniter)
	perl -i -pe 's/\?\?(?=1|Test)/ \\\[u011E\]/g' \
		debian/$(cmd).1
	find $(destdir)/usr/lib -name '*.pyc' -delete
	find $(destdir)/usr/lib -type d -empty -delete
