#!/usr/bin/make -f
# DH_VERBOSE := 1
export LC_ALL=C.UTF-8

include /usr/share/dpkg/default.mk
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CPPFLAGS_MAINT_APPEND += -DSIMDE_ENABLE_OPENMP
export DEB_CPPFLAGS_MAINT_APPEND += -DSIMDE_ENABLE_NATIVE_ALIASES
export DEB_CFLAGS_MAINT_APPEND += -fopenmp-simd -O3
export DEB_CXXFLAGS_MAINT_APPEND += -fopenmp-simd -O3
export PYBUILD_NAME=pyabpoa

%:
	dh $@ --with=python3 --buildsystem=pybuild

execute_before_dh_testdir:
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	# Guard against outdated maintainer manual page.
	# Hint: help2man does mostly the right thing except for stderr
	# capture, multiple commands support, and commands description.
	grep -q $(DEB_VERSION_UPSTREAM) debian/manuals/abpoa.1
endif

execute_after_dh_auto_build:
	dh_auto_build --buildsystem=makefile -- all

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	# Tests from the README.md document
	./bin/abpoa ./test_data/seq.fa > cons.fa
	./bin/abpoa ./test_data/heter.fa > 2cons.fa
	./bin/abpoa -r1 ./test_data/seq.fa > out.msa
	./bin/abpoa -r2 ./test_data/seq.fa > out_cons.msa
	./bin/abpoa -r3 ./test_data/seq.fa > out.gfa
	./bin/abpoa -r4 ./test_data/seq.fa > out4.gfa
	cp out.gfa in.gfa
	cp out.msa in.msa
	./bin/abpoa -i in.gfa ./test_data/seq.fa -r3 > out.gfa
	./bin/abpoa -i in.msa ./test_data/seq.fa -r1 > out.msa
	./bin/abpoa ./test_data/seq.fa -g poa.png > cons.fa
	./bin/abpoa ./test_data/heter.fa -d2
endif

override_dh_gencontrol:
	dh_gencontrol -- \
		-Vsimde:Built-Using="$(shell dpkg-query -f '$${source:Package} (= $${source:Version}), ' -W "libsimde-dev")"
