#!/usr/bin/make -f

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

export DEB_BUILD_MAINT_OPTIONS=hardening=+all
export CMAKE_PREFIX_PATH=/usr/lib/$(DEB_HOST_MULTIARCH)/cmake/
DTMP=$(CURDIR)/debian/sortmerna

%:
	dh $@ --buildsystem=cmake

execute_after_dh_install:
	find debian -name cmake -type d | xargs rm -rvf

execute_after_dh_installexamples:
	# Convert example files to Unicode.
	set -e \
	; cd $(CURDIR)/tests/sortmerna/ \
	; for cxxfile in *.cpp \
	; do iconv -f ISO-8859-15 -t UTF-8 \
	     < $${cxxfile} \
	     > $(DTMP)/usr/share/doc/sortmerna/examples/sortmerna/$${cxxfile} \
	; done

execute_after_dh_fixperms:
	find debian/sortmerna -name '*.sh' -exec chmod -v +x '{}' ';'
	find debian/sortmerna -name '*.py' -exec chmod -v -x '{}' ';'
