#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# Lack of position independent executable is causing a number of errors
# in parsinsert results.  See #964082 for further details on the issue.
export DEB_CXXFLAGS_MAINT_APPEND = -fPIE

# Also, although -fPIE does help on several platforms, a bunch of
# architectures are still affected by precision issues.
UNOPTIMIZED_ARCHS := armel armhf mips64el ppc64el hppa ia64 powerpc ppc64 x32
ifneq (,$(filter $(DEB_BUILD_ARCH),$(UNOPTIMIZED_ARCHS)))
export DEB_CXXFLAGS_MAINT_APPEND = -O1
endif

%:
	dh $@

execute_after_dh_auto_build:
	mv ParsInsert parsinsert

execute_before_dh_auto_clean:
	mv parsinsert ParsInsert || true

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 set1000.tree
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
