#!/usr/bin/make -f

# Hardening and lack of position independent executable are causing a number of
# errors in parsinsert results when a number of compiler optimizations are
# active.  See #964082 for further details on the issue.
export DEB_BUILD_MAINT_OPTIONS = hardening=-all optimize=-lto
export DEB_CXXFLAGS_MAINT_APPEND = -fPIE
# Also, although -fPIE does help on several platforms, a bunch of architectures
# are still affected by the precision issue.
export DEB_CXXFLAGS_MAINT_APPEND = -O1


%:
	dh $@

override_dh_auto_build:
	@ echo 'blhc: ignore-line-regexp: ^g\+\+ .* -fPIE.*$$'
	dh_auto_build
	mv ParsInsert parsinsert

override_dh_auto_clean:
	mv parsinsert ParsInsert || true
	dh_auto_clean

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	cd debian/tests/test_data && \
	$(CURDIR)/parsinsert -d0 -c80 -n1 set1000.fasta -m lanemask.txt -x rdp.taxonomy \
		-l set1000.log -o set1000.results -t core_rdp.ntree \
		-s core_rdp.fasta && \
	cmp -s right_results set1000.results || { \
	    echo "incorrect result" ; \
	    exit 1 ; } && \
	rm -f set1000.results
endif

# Note a manpage was generated using:
#  help2man -N ./parsinsert --version-string=1.04 > debian/parsinsert.1
#  But this was then manually edited, so it is not rebuilt automatically.

override_dh_install:
	dh_install -Xset1000.log
