#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

VER = $(shell (echo ${DEB_VERSION}) | sed 's/-.\+//')
PRODUCT_VER = $(shell (grep -e "^\s*version" setup.py | tail -1 |  sed 's/[^0-9\.]//g'))


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

export PYBUILD_NAME=comitup
export PYBUILD_INSTALL_ARGS=--install-lib=/usr/share/comitup\
 --install-scripts=/usr/share/comitup

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

override_dh_auto_build:
	if [ "${VER}" != "${PRODUCT_VER}" ] ; then exit 1 ; fi
	dh_auto_build
	for mn in ${manpages}; do \
	  pandoc $$mn.md -s -t man -o $$mn; \
	  sed -i 's/\\\[en\]/\\\-/' $$mn; \
	  pandoc $$mn.md -s -t html -o $$mn.html; \
	done

override_dh_installsystemd:
	dh_installsystemd
	dh_installsystemd --name=comitup-web
