#!/usr/bin/make -f

# DH_VERBOSE := 1

DEBVERS        := $(shell dpkg-parsechangelog | awk '/^Version:/ {print $$2}')
VERSION        := $(shell echo '$(DEBVERS)' | sed -e 's/^[0-9]*://' -e 's/-.*//')

# Fails to build when trying to enhance hardening
# export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	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
