#! /usr/bin/make -f

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

export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-pie
export SETUPTOOLS_SCM_PRETEND_VERSION=$(DEB_VERSION_UPSTREAM)
export PYBUILD_NAME=fava

%:
	dh $@ --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 \
	  "PYTHONPATH=\"$(CURDIR)/src\" $$(pybuild --print interpreter --interpreter python3) -m fava.cli" \
	  > $(CURDIR)/debian/manpages/fava.1
	sed -i s/cli.py/fava/ $(CURDIR)/debian/manpages/fava.1
	sed -i s/FAVA,/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__
