#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#DH_VERBOSE = 1

# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

export OMPI_MCA_orte_rsh_agent=/bin/false

# Disable optimal compiler flags (like -march=native) unless
# DEB_BUILD_OPTIONS=custom is set
ifeq (,$(filter custom,$(DEB_BUILD_OPTIONS)))
CXXFLAGS_OPTS=--disable-optimal
else
CXXFLAGS_OPTS=--enable-optimal
endif

include /usr/share/mpi-default-dev/debian_defaults

%:
	dh $@ --parallel --with autotools-dev

override_dh_auto_clean:
	-dh_auto_clean
	rm -f config/missing config/config.sub config/depcomp config/config.guess config/test-driver config/compile config/install-sh
	rm -f aclocal.m4 configure doc/doxygen.cfg src/madness/config.h.in
	rm -f src/madness/mra/fplot.dat src/madness/mra/opf.dat src/madness/mra/opfplot.dat src/madness/mra/testline1  src/madness/mra/testline2 src/madness/mra/testline3 src/madness/mra/testplot src/madness/world/test.dat src/madness/world/testme.ar
	rm -f doc/Makefile src/apps/exciting/Makefile src/apps/hf/Makefile src/apps/interior_bc/Makefile src/apps/nick/Makefile src/apps/polar/Makefile
	find . -name "Makefile.in" | xargs rm -f

override_dh_auto_configure:
	./autogen.sh
	dh_auto_configure -- ${CXXFLAGS_OPTS}

override_dh_auto_install:
	dh_auto_install --destdir=$(CURDIR)/debian/tmp

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
	-dh_auto_test || cat src/madness/world/test-suite.log
endif
