#!/usr/bin/make -f

# DH_VERBOSE := 1

# 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.

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

override_dh_auto_build:
	dh_auto_build
	mv doc/source/license.rst doc/ # unused
	PYTHONPATH=. http_proxy='127.0.0.1:9' sphinx-build -N -bhtml doc/source doc/build/html
	mv doc/license.rst doc/source/
	cd obj*/src && \
	help2man --no-discard-stderr --no-info --name="highly-accurate, transcript-level quantification estimates from RNA-seq data"\
		./salmon > ../../debian/salmon.1 && \
	for option in index quant swim; do help2man --no-discard-stderr \
		--version-string="${VERSION}" --no-info "./salmon --no-version-check $${option}" \
		--include=../../debian/salmon-$${option}-man-include \
		> ../../debian/salmon-$${option}.1; done

override_dh_auto_clean:
	dh_auto_clean
	rm -f debian/*.1
	rm -Rf sample_data
	cd doc && $(MAKE) clean

get-orig-source:
	uscan --verbose --force-download --repack --compression xz
