# Description: High performance message passing library (MPI)
# URL: https://www.open-mpi.org
# Maintainer: Tim Biermann, tbier at posteo dot de
# Depends on: eudev gcc-fortran libevent libnl zlib
# Optional: cuda hwloc

name=openmpi
version=4.1.5
release=1
source=(https://www.open-mpi.org/software/ompi/v${version%.*}/downloads/$name-$version.tar.bz2)

build() {
  cd $name-$version

  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc/$name \
    --enable-mpi-fortran=all \
    --libdir=/usr/lib/$name \
    --enable-builtin-atomics \
    --enable-mpi-cxx \
    --enable-pretty-print-stacktrace \
    --without-slurm \
    FC=/usr/bin/gfortran \
    LDFLAGS="${LDFLAGS} -Wl,-z,noexecstack"

  make
  make DESTDIR=$PKG install

  install -dm 755 $PKG/usr/lib/pkgconfig
  for i in ompi-c.pc ompi-cxx.pc ompi-f77.pc ompi-f90.pc ompi.pc; do
    ln -sf /usr/lib/openmpi/pkgconfig/$i $PKG/usr/lib/pkgconfig/
  done

  install -dm 755 $PKG/etc/ld.so.conf.d
  echo /usr/lib/$name > $PKG/etc/ld.so.conf.d/$name.conf
}
