#!/bin/sh

. ./hscalapack.version

#-----------------------------------------------------------------
#
# Set the variables
#
#-----------------------------------------------------------------
OUTFILE=$1
TARGETSTRING=$2

#-----------------------------------------------------------------
#
#Platform information on which HeteroScaLAPACK is being built
#
#-----------------------------------------------------------------
PLATFORM=`uname -s`
DATE=`date`
VERSION="`uname -r`"

if [ "$PLATFORM" = "AIX" ] ; then
        VERSION="`oslevel`"
fi

if [ "$PLATFORM" = "OSF1" ] ; then
        PLATFORM="Tru64 Unix"
        VERSION="`uname -r` (Rev. `uname -v`)"
fi

#-----------------------------------------------------------------
#
#Obtain HeteroScaLAPACK information
#
#-----------------------------------------------------------------
HeteroScaLAPACKINFO="HeteroScaLAPACK $_HSCALAPACK_VERSION"

#-----------------------------------------------------------------
#
#Obtain mpC information
#
#-----------------------------------------------------------------
MPCINFO="`hmpicc -v`"

#-----------------------------------------------------------------
#
#Obtain MPI information
#
#-----------------------------------------------------------------
if test -f $MPIDIR/bin/lamd; then
        if test -f $MPIDIR/bin/laminfo; then
                MPIINFO="`laminfo -version lam full`"
        else
                MPIINFO="LAM"
        fi
fi

if test -f $MPIDIR/bin/mpichversion; then
        MPIINFO="`mpichversion | grep "MPICH Version:" | awk '{print $3}'`"
fi

if test -f $MPIDIR/bin/ompi_info; then
        MPIINFO="`ompi_info | grep "Open MPI:"`"
fi

#-----------------------------------------------------------------
#
# Print the string
#
#-----------------------------------------------------------------
echo 'static char *__hscalapack_what_info = "@(#)' \($HeteroScaLAPACKINFO/$MPCINFO/$MPIINFO\) $PLATFORM $VERSION $TARGETSTRING $DATE '";' > $OUTFILE

exit 0
