#!/usr/bin/make -f
# -*- makefile -*-

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

export OMPI_MCA_orte_rsh_agent=/bin/false
export LIBS=-lblacs-$(ARCH_DEFAULT_MPI_IMPL) -lblacsCinit-$(ARCH_DEFAULT_MPI_IMPL) -lscalapack-$(ARCH_DEFAULT_MPI_IMPL)
export DEB_LDFLAGS_MAINT_APPEND=-Wl,--as-needed

ifneq (,$(filter $(DEB_HOST_ARCH), i386 armel mipsel))
	export ELPA_TEST_SCALE=2000
endif

ifneq (,$(filter $(DEB_HOST_ARCH), mips))
	export ELPA_TEST_SCALE=500
endif

%:
	dh $@ --with autoreconf

override_dh_autoreconf:
	dh_autoreconf --as-needed

override_dh_auto_configure:
	dh_auto_configure -- --with-generic-simple

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
	$(MAKE) check || cat test-suite.log
	grep Total.time *.log
        # error out in case of test suite failures
	if grep ^FAIL test-suite.log; then exit 1; fi
endif
