#!/usr/bin/make -f

# DH_VERBOSE := 1
export LC_ALL=C.UTF-8

# some helpful variables - uncomment them if needed
# shamelessly stolen from http://jmtd.net/log/awk/
#DEBVERS        := $(shell dpkg-parsechangelog | awk '/^Version:/ {print $$2}')
#VERSION        := $(shell echo '$(DEBVERS)' | sed -e 's/^[0-9]*://' -e 's/-.*//')
#DEBFLAVOR      := $(shell dpkg-parsechangelog | awk '/^Distribution:/ {print $$2}')
#DEBPKGNAME     := $(shell dpkg-parsechangelog | awk '/^Source:/ {print $$2}')
#DEBIAN_BRANCH  := $(shell awk 'BEGIN{FS="[= ]+"} /debian-branch/ {print $$2}' debian/gbp.conf)
#GIT_TAG        := $(subst ~,_,$(VERSION))

# alternatively to manually set those variables, you can
#  include /usr/share/dpkg/default.mk
# and use what is set there.

# for hardening you might like to uncomment this:
export DEB_BUILD_MAINT_OPTIONS=hardening=+all

%:
	dh $@  --with autoreconf,sphinxdoc --parallel

override_dh_auto_clean:
	dh_auto_clean
	rm -rf $(CURDIR)/debian/sphinxdoc $(CURDIR)/debian/man

override_dh_auto_configure:
	dh_auto_configure --  --with-capnp=/usr --with-gsl=/usr --prefix=$(CURDIR)/debian/tmp/usr

override_dh_auto_build:
	dh_auto_build
	sphinx-build doc/sphinx $(CURDIR)/debian/sphinxdoc

override_dh_installman:
	mkdir -p $(CURDIR)/debian/man
	asciidoctor -a docdate='' -b manpage $(CURDIR)/debian/man_src/*.adoc
	cp $(CURDIR)/debian/man_src/*.? $(CURDIR)/debian/man
	dh_installman --
