#!/usr/bin/make -f

# Recommendations in https://wiki.debian.org/Hardening, motivated by lintian warnings.
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

# To run the first test program in `make check', mpirun is called.
# This may fail if run as root, e.g. during automated building in
# a chroot gaol. So for debian builds, running mpirun - on a single
# processor - is allowed.
export MPI_ALLOW_RUN_AS_ROOT = --allow-run-as-root

%:
	dh $@  --with autotools-dev

# https://lintian.debian.org/tags/binary-or-shlib-defines-rpath.html
# https://wiki.debian.org/RpathIssue
# TODO: Where is r(un)path inserted in upstream? [not obvious]
override_dh_install:
	chrpath -d $(CURDIR)/debian/mpgrafic/usr/bin/mpgrafic
	dh_install

# 2017-01-17: debian/0.3.7.5-1: Data on failures of the test script
# regression-0.3.7.sh on various architectures is needed in order to
# make both the source code and the test reproducible. This override
# is intended to be temporary only, while obtaining data on failures
# from the log files of builds.
override_dh_auto_test:
	dh_auto_test
	# temporary diagnostic as of v0.3.7.5
	printf "+++regression test diagnostic+++\n" && \
	 diff -u Output.stdout.np32 Output.stdout.np32.tmp && \
	 printf "+++/regression test diagnostic+++\n"
