#!/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 $@  --sourcedirectory=src

override_dh_link:
	dh_link
	for file in $(CURDIR)/debian/$(DEBPKGNAME)/usr/lib/$(DEBPKGNAME)/kraken* ; do \
	    if ! echo $${file} | grep -q '\.pm$$' ; then \
		ln -s ../lib/$(DEBPKGNAME)/`basename $${file}` $(CURDIR)/debian/$(DEBPKGNAME)/usr/bin/`basename $${file}` ; \
	    fi \
	done

override_dh_auto_install:
	dh_auto_install -- KRAKEN_DIR=$(CURDIR)/debian/$(DEBPKGNAME)/usr/lib/$(DEBPKGNAME)
	./install_kraken.sh /usr/lib/$(DEBPKGNAME) $(DEBPKGNAME)
