#!/bin/sh

set -e

if [ "$1" = "configure" ]; then

update-alternatives \
	--install /usr/include/@DEB_HOST_MULTIARCH@/mpi mpi-@DEB_HOST_MULTIARCH@ /usr/lib/@DEB_HOST_MULTIARCH@/openmpi/include 50 \
	--slave /usr/lib/@DEB_HOST_MULTIARCH@/libmpi.so libmpi.so-@DEB_HOST_MULTIARCH@ /usr/lib/@DEB_HOST_MULTIARCH@/openmpi/lib/libmpi.so \
	--slave /usr/lib/@DEB_HOST_MULTIARCH@/pkgconfig/mpi.pc mpi.pc-@DEB_HOST_MULTIARCH@ /usr/lib/@DEB_HOST_MULTIARCH@/pkgconfig/ompi.pc \
	--slave /usr/lib/@DEB_HOST_MULTIARCH@/pkgconfig/mpi-fort.pc mpi-fort.pc-@DEB_HOST_MULTIARCH@ /usr/lib/@DEB_HOST_MULTIARCH@/pkgconfig/ompi-fort.pc \
	--slave /usr/lib/@DEB_HOST_MULTIARCH@/pkgconfig/mpi-c.pc mpi-c.pc-@DEB_HOST_MULTIARCH@ /usr/lib/@DEB_HOST_MULTIARCH@/pkgconfig/ompi-c.pc \

# Removed in OpenMPI >= 5.0.0
##update-alternatives \
#	--remove /usr/lib/@DEB_HOST_MULTIARCH@/libmpi++.so libmpi++.so-@DEB_HOST_MULTIARCH@ /usr/lib/@DEB_HOST_MULTIARCH@/openmpi/lib/libmpi_cxx.so  \
#	--remove /usr/lib/@DEB_HOST_MULTIARCH@/pkgconfig/mpi-cxx.pc mpi-cxx.pc-@DEB_HOST_MULTIARCH@ /usr/lib/@DEB_HOST_MULTIARCH@/pkgconfig/ompi-cxx.pc

fi

#DEBHELPER#
