#!/usr/bin/make -f

#export DH_VERBOSE = 1

export PYBUILD_NAME=todo_txt_gtd
export PYBUILD_INSTALL_ARGS=--install-lib=/usr/share/todo.txt-gtd\
 --install-scripts=/usr/share/todo.txt-gtd
export PYBUILD_TEST_PYTEST=0
export PYBUILD_SYSTEM=pyproject

manpages = $(shell (ls debian/*.md | sed 's/.md//'))

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

override_dh_auto_build:
	dh_auto_build
	for mn in ${manpages}; do\
	  pandoc $$mn.md -s -t man -o $$mn;\
	  sed -i 's/\\\[en\]/\\\-/' $$mn; \
	done

override_dh_auto_install:
	dh_auto_install
	rm -rf debian/todo.txt-gtd/usr/share/todo.txt-gtd/.pytest_cache
	for dir in prehooks posthooks; do \
	  mkdir -p debian/todo.txt-gtd/etc/todo.txt-base/$$dir; \
	  cp debian/50-gtdcleanup debian/todo.txt-gtd/etc/todo.txt-base/$$dir; \
	done
