#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
pkg := $(shell dpkg-parsechangelog | sed -n 's/^Source: //p')
version=$(shell dpkg-parsechangelog -ldebian/changelog | grep Version: | cut -f2 -d' ' | cut -f1 -d- )
mandir=$(CURDIR)/debian/$(pkg)/usr/share/man/man1
bindir=$(CURDIR)/debian/$(pkg)/usr/bin

# according to dpkg-architecture(1) this should be set to support manual invocation
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

%:
	dh $@ --with autoreconf

override_dh_auto_configure:
	dh_auto_configure -- --with-boost-libdir=/usr/lib/$(DEB_HOST_MULTIARCH)

override_dh_installman:
	dh_installman

	# try to create man pages whereever possible
	mkdir -p $(mandir)
	help2man --no-info --no-discard-stderr  -h "" \
	    --name='tophat component converting bam directly into fastx' \
	    --version-string="$(version)" \
	         $(bindir)/bam2fastx > $(mandir)/bam2fastx.1
	help2man --no-info --no-discard-stderr -h "-h" \
	    --name='tophat component to convert junctions in BED format' \
	    --version-string="$(version)" \
	         $(bindir)/bed_to_juncs > $(mandir)/bed_to_juncs.1
	help2man --no-info --no-discard-stderr -h "-h" \
	    --name='tophat component taking NCBI seq_contig file and maps contig coords' \
	    --version-string="$(version)" \
	         $(bindir)/contig_to_chr_coords > $(mandir)/contig_to_chr_coords.1
	help2man --no-info --no-discard-stderr \
	    --name='TopHat maps short sequences from spliced transcripts to whole genomes' \
	    --version-string="$(version)" \
	         $(bindir)/tophat > $(mandir)/tophat.1

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