#! /usr/bin/make -f

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

export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-pie

export PYBUILD_NAME=fava
%:
	dh $@ --with python3 --buildsystem=pybuild

override_dh_auto_build:
	dh_auto_build

# manpage generation: use help2man + manual overrides from d/manpages/fava.tpl
ifeq ($(filter nodoc,$(DEB_BUILD_PROFILES)),)
	help2man \
	  --name "Web interface for the double-entry accounting tool Beancount" \
	  --no-info \
	  --include $(CURDIR)/debian/manpages/fava.tpl \
	  "$$(pybuild --print interpreter --interpreter python3) -m fava.cli" \
	  > $(CURDIR)/debian/manpages/fava.1
	sed -i s/cli.py/fava/ $(CURDIR)/debian/manpages/fava.1
endif

override_dh_auto_clean:
	dh_auto_clean
	rm -f debian/manpages/fava.1

override_dh_installdocs:
	dh_installdocs -X __init__.py -X __pycache__
