#!/usr/bin/make -f

# DH_VERBOSE := 1

export DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow

include /usr/share/dpkg/default.mk

export PYBUILD_NAME=$(DEB_SOURCE)
PYVERS = $(shell pyversions -r)
PY3VERS = $(shell py3versions -r)

%:
	dh $@ --buildsystem=cmake

override_dh_auto_clean:
	dh_auto_clean

override_dh_auto_configure:
	dh_auto_configure -- -DINSTALL_PREFIX=/usr

override_dh_auto_build:
	# no idea about the purpose of the dynamic library - executables are not simply linked against it
	dh_auto_build -- MP MPI GTEST # LIB

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	find obj-* -name HYPHYGTEST -exec \{\} \;
endif

override_dh_install:
	# smallcaps for executables
	for bindir in `find . -type d -name bin` ; do \
	    for bin in $${bindir}/* ; do \
	        # ln -s `basename $${bin}` $${bindir}/`basename $${bin} | tr [A-Z] [a-z]` ; \
	        mv $${bindir}/`basename $${bin}` $${bindir}/`basename $${bin} | tr [A-Z] [a-z]` ; \
	    done ; \
	done
	dh_install
