#!/bin/bash

echo "# Intel MPI" >> ${SRC_DIR}/mpi.cfg
echo "[impi]" >> ${SRC_DIR}/mpi.cfg
echo "include_dirs         = ${PREFIX}/include" >> ${SRC_DIR}/mpi.cfg
echo "libraries            = mpi" >> ${SRC_DIR}/mpi.cfg
echo "library_dirs         = ${PREFIX}/lib" >> ${SRC_DIR}/mpi.cfg

export LD_LIBRARY_PATH=${PREFIX}/lib/libfabric:$LD_LIBRARY_PATH
export LDFLAGS="-Wl,-rpath=$PREFIX/lib/libfabric/ $LDFLAGS"
$PYTHON setup.py build --mpi=impi
$PYTHON setup.py install

if [ `uname` == Linux ]; then
    if [ $PY3K == 1 ]; then
        for so in `find ${SP_DIR}/mpi4py -type f -name "*.so"`; do
            ${PREFIX}/bin/chrpath -d ${so}
        done
    fi
fi
