#!/usr/bin/make -f
# -*- makefile -*-

DEBPKGNAME     := $(shell dpkg-parsechangelog | awk '/^Source:/ {print $$2}')

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

%:
	dh $@ --parallel

override_dh_install:
	d-shlibmove --commit \
		    --multiarch \
		    --devunversioned \
		    --exclude-la \
		    --movedev debian/tmp/usr/include/* usr/include \
		    debian/tmp/usr/lib/lib*.so
	dh_install
	# no need to install different versions of bamtools
	rm -rf debian/$(DEBPKGNAME)/usr/bin/$(DEBPKGNAME)
	mv debian/$(DEBPKGNAME)/usr/bin/$(DEBPKGNAME)-[0-9]* debian/$(DEBPKGNAME)/usr/bin/$(DEBPKGNAME)

#override_dh_installman:
#	LD_LIBRARY_PATH=debian/tmp/usr/lib:${LD_LIBRARY_PATH} help2man --name "a command-line toolkit for reading, writing, and manipulating BAM (genome alignment) files" --no-info --no-discard-stderr debian/tmp/usr/bin/bamtools > debian/bamtools.1

SOURCEPKG=$(shell dpkg-parsechangelog | sed  -n 's/^Source: \(.*\)/\1/p')
UPSTREAM=$(shell dpkg-parsechangelog |  sed -n 's/^Version: \(.*\)-[^-]*/\1/p')
SHA1=$(lastword $(subst ~g, ,$(UPSTREAM)))
ORIG=${SOURCEPKG}_${UPSTREAM}.orig.tar

describe-current-version:
	git describe --tags upstream | sed 's,^release-,,;s,-,+,;s,-,~,;'

get-orig-source:
	uscan --download-current-version --force-download --rename --repack-compression xz
