#!/usr/bin/make -f

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

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

include /usr/share/dpkg/default.mk

DATE=$(shell date --date=@$(SOURCE_DATE_EPOCH) '+%d %B %Y')

%:
	dh $@

override_dh_auto_build:
	make BUILD_HOST='Debian' \
		BUILD_TIME="$(DATE)" \
		all doc
	help2man ./hisat2 --no-info --name \
		'graph-based alignment of short nucleotide reads to many genomes, wrapper script' \
		> debian/hisat2.1
	help2man ./hisat2-align-l --name 'HISAT2 graph-based alignment of short nucleotide reads to many genomes, large index binary' \
		--no-info > debian/hisat2-align-l.1
	help2man ./hisat2-align-s --name 'HISAT2 graph-based alignment of short nucleotide reads to many genomes, small index binary' \
		--no-info > debian/hisat2-align-s.1
	help2man ./hisat2-build --name 'HISAT2 indexer, wrapper script' \
		--no-info > debian/hisat2-build.1
	#rm hisat2-buildc
	help2man ./hisat2-build-l --name 'HISAT2 indexer, large index binary' \
		--no-info > debian/hisat2-build-l.1
	help2man ./hisat2-build-s --name 'HISAT2 indexer, small index binary' \
		--no-info > debian/hisat2-build-s.1
	help2man ./hisat2-inspect --name 'HISAT2 index inspector, wrapper script' \
		--no-info > debian/hisat2-inspect.1
	help2man ./hisat2-inspect-l --name 'HISAT2 index inspector, large index binary' \
		--no-info > debian/hisat2-inspect-l.1
	help2man ./hisat2-inspect-s --name 'HISAT2 index inspector, small index binary' \
		--no-info > debian/hisat2-inspect-s.1

override_dh_install:
	dh_install
	for pl in `grep -Rl '#!/usr/bin/env[[:space:]]\+perl' debian/*/usr/*` ; do \
	    sed -i '1s?^#!/usr/bin/env[[:space:]]\+perl?#!/usr/bin/perl?' $${pl} ; \
	done
