#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

include /usr/share/dpkg/default.mk
VERSION        := $(shell echo $(DEB_VERSION_UPSTREAM) | sed -e 's/+dfsg//')

export DEB_CXXFLAGS_MAINT_APPEND=-std=gnu++98 -O3 -fopenmp-simd -DSIMDE_ENABLE_OPENMP

%:
	dh $@

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	dh_auto_test
	./unit_tests
endif

override_dh_auto_build:
	dh_auto_build
	help2man --no-discard-stderr --no-info --version-string="${VERSION}" \
		--name "scalable nucleotide alignment program" \
		--help-option=" " ./snap-aligner > debian/snap-aligner.1
	for option in index single paired; do help2man \
		--no-discard-stderr --no-info --version-string="${VERSION}" \
		--include=debian/snap-aligner-$${option}-man-include \
		--help-option=" " "./snap-aligner $${option}" > \
		debian/snap-aligner-$${option}.1; done
	help2man --no-discard-stderr --no-info --version-string="${VERSION}" \
		--name "scalable nucleotide alignment program" \
		--help-option=" " ./SNAPCommand > debian/SNAPCommand.1

override_dh_auto_clean:
	dh_auto_clean
	rm -f debian/*.1
	rm -f */*.d */*/*.d
