#!/usr/bin/make -f
%:
	dh $@  --parallel --with autoreconf

# Which MPI implementation?
# Temporarily disabling MPI support for arm64 (not functionnal currently)
# set ARCH_DEFAULT_MPI_IMPL
ifneq (arm64,$(DEB_HOST_ARCH))
include /usr/share/mpi-default-dev/debian_defaults
else
ARCH_DEFAULT_MPI_IMPL := serial
endif

export OMPI_MCA_orte_rsh_agent=/bin/false                #workaround to start MPI-applications in chroot
export DEB_CPPFLAGS_MAINT_APPEND := -I/usr/include/$(ARCH_DEFAULT_MPI_IMPL) -DOMPI_SKIP_MPICXX=1 -DMPICH_SKIP_MPICXX=1
export DEB_LDFLAGS_MAINT_APPEND := -Wl,--as-needed

override_dh_auto_configure:
	HDF5_VERSION=11000 dh_auto_configure -- --with-hdf5=/usr/lib/$(DEB_HOST_MULTIARCH)/hdf5/$(ARCH_DEFAULT_MPI_IMPL) --with-hdf5-bin=/usr/bin

override_dh_auto_install:
	dh_auto_install
	rm -rf $(CURDIR)/debian/tmp/usr/bin/test* \
         $(CURDIR)/debian/tmp/usr/bin/usescases \
         $(CURDIR)/debian/tmp/usr/bin/unittests

override_dh_auto_test:
	MPIEXEC="mpiexec --allow-run-as-root --oversubscribe -np " dh_auto_test --max-parallel=1
