#!/usr/bin/make -f

#DH_VERBOSE = 1
include /usr/share/dpkg/default.mk

export NOPBBAM = 1
export HDF5_INC = /usr/include/hdf5/serial
export HDF5_LIB = /usr/lib/$(DEB_HOST_MULTIARCH)/hdf5/serial
export GTEST_INC = /usr/include
export GTEST_SRCDIR = /usr/src/gtest

export DEB_CFLAGS_MAINT_APPEND=-O3
export DEB_CXXFLAGS_MAINT_APPEND=-O3

%:
	dh $@ --parallel

override_dh_auto_configure:
	./configure.py PREFIX=/usr/

override_dh_auto_test:
# Ignore the return code because some tests
# require data that is not available in the source distribution.
	-$(MAKE) -k gtest

override_dh_auto_install:
	mkdir -p debian/libpbdata-dev/usr/include/pbseq
	cp -r pbdata debian/libpbdata-dev/usr/include/pbseq/
	mkdir -p debian/libpbihdf-dev/usr/include/pbseq/
	cp -r hdf debian/libpbihdf-dev/usr/include/pbseq/
	mkdir -p debian/libblasr-dev/usr/include/pbseq/
	cp -r alignment debian/libblasr-dev/usr/include/pbseq/
	find -L debian/*/usr/include/ -type f -regextype posix-egrep -not -regex '.*(hpp|h)$$' -delete
# defines.mk and build.mk files are symlinks and don't
# get removed by the previous command
	find debian/*/usr/include/ -name "*.mk" -delete
	dh_auto_install

override_dh_auto_clean:
	dh_auto_clean
	find -name defines.mk -delete
	$(RM) pbdata/libconfig.h
