#! /bin/sh
#
# Simple script to report information about the MPICH2 installation. This 
# script will likely be replaced with a program closer to 
# that found in MPICH1 once the library contains information on patches 
# applied, etc.
#

print_usage()
{
    echo ""
    echo "usage: mpich2version [-v|--version] [-d|--device] [-c|--configure] [-b|--compilers] [-h|--help]"
    echo ""
    echo "    --version - Show the version number for this installation of MPICH2"
    echo "    --device - Show the device used by this installation"
    echo "    --configure - Show the configure options used to build this installation"
    echo "    --compilers - Show the compilers used to build this installation"
    echo ""
}

if test $# -eq 0 ; then
    include_version=true
    include_device=true
    include_config_opts=true
    include_compilers=true
elif test $# -eq 1 ; then
    arg=$1
    case $arg in
	-v|--version)
	echo "1.0.5"
	;;

	-d|--device)
	echo "ch3:sock"
	;;

	-c|--configure)
	echo "'ppc-mandriva-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--x-includes=/usr/include' '--x-libraries=/usr/lib' '--datadir=/usr/share/mpich/' '--with-docdir=/usr/share/doc/mpich2-doc-1.0.5' '--with-htmldir=/usr/share/doc/mpich2-doc-1.0.5/www' '--enable-cache' '--with-mpe' '--enable-cxx' '--with-arch=LINUX' '--enable-sharedlibs=gcc' '--disable-weak-symbols' 'CFLAGS=-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fsigned-char -mcpu=750 -mtune=7450' 'CXXFLAGS=-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fsigned-char -mcpu=750 -mtune=7450' 'F90=/usr/bin/gfortran' 'FFLAGS=-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fsigned-char -mcpu=750 -mtune=7450' 'build_alias=ppc-mandriva-linux-gnu' 'host_alias=ppc-mandriva-linux-gnu' 'target_alias=ppc-mandriva-linux-gnu'"
	;;

	-b|--compiler)
	echo "ppc-mandriva-linux-gnu-gcc -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fsigned-char -mcpu=750 -mtune=7450"
	echo "ppc-mandriva-linux-gnu-g++ -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fsigned-char -mcpu=750 -mtune=7450"
	echo "f95 -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fsigned-char -mcpu=750 -mtune=7450"
	echo "/usr/bin/gfortran "
	;;

	-h|--help)
	print_usage
	exit 0
	;;

	*)
	echo ""
	echo "Invalid option: $arg"
	print usage
	exit 1
	;;
    esac
else
    include_version=false
    include_device=false
    include_config_opts=false

    for arg ; do
	case $arg in
	    -v|--version)
	    include_version=true
	    ;;

	    -d|--device)
	    include_device=true
	    ;;

	    -c|--configure)
	    include_config_opts=true
	    ;;

	    -b|--compiler)
	    include_compilers=true
	    ;;

	    -h|--help)
	    print_usage
	    exit 0
	    ;;

	    *)
	    echo ""
	    echo "Invalid option: $arg"
	    print usage
	    exit 1
	    ;;
	esac
    done
fi

if test "$include_version" = "true" ; then
    echo "Version:           1.0.5"
fi
if test "$include_device" = "true" ; then
    echo "Device:            ch3:sock"
fi
if test "$include_config_opts" = "true" ; then
    echo "Configure Options: 'ppc-mandriva-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--x-includes=/usr/include' '--x-libraries=/usr/lib' '--datadir=/usr/share/mpich/' '--with-docdir=/usr/share/doc/mpich2-doc-1.0.5' '--with-htmldir=/usr/share/doc/mpich2-doc-1.0.5/www' '--enable-cache' '--with-mpe' '--enable-cxx' '--with-arch=LINUX' '--enable-sharedlibs=gcc' '--disable-weak-symbols' 'CFLAGS=-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fsigned-char -mcpu=750 -mtune=7450' 'CXXFLAGS=-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fsigned-char -mcpu=750 -mtune=7450' 'F90=/usr/bin/gfortran' 'FFLAGS=-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fsigned-char -mcpu=750 -mtune=7450' 'build_alias=ppc-mandriva-linux-gnu' 'host_alias=ppc-mandriva-linux-gnu' 'target_alias=ppc-mandriva-linux-gnu'"
fi
if test "$include_compilers" = true ; then
    echo "CC:  ppc-mandriva-linux-gnu-gcc -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fsigned-char -mcpu=750 -mtune=7450"
    echo "CXX: ppc-mandriva-linux-gnu-g++ -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fsigned-char -mcpu=750 -mtune=7450"
    echo "F77: f95 -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fsigned-char -mcpu=750 -mtune=7450"
    echo "F90: /usr/bin/gfortran "
fi


exit 0
