#! /bin/sh
#
# For "inplace" usage of config.status, we need srcdir to be "."
# Hmmmm
CONFIG_FILES=""
destpair=""
for arg 
do
    if [ -s $arg.in ] ; then 
        CONFIG_FILES="$CONFIG_FILES $arg" 
    elif [ -s /usr/rels/mpich-1.2..4pre2/$arg.in ] ; then
        CONFIG_FILES="$CONFIG_FILES /usr/rels/mpich-1.2..4pre2/$arg" 
	destpair="$destpair /usr/rels/mpich-1.2..4pre2/$arg::$arg"
    else
        echo "Cannot find file $arg"
	exit 1
    fi
done
export CONFIG_FILES
PREFIX=""
#
# I once made a suggestion to do
#if [ -n "$PREFIX" ] ; then 
#    /bin/rm -f .t1 
#    cat $file | sed -e "s%@INSTALL_DIR@%$PREFIX%g" > .t1
#    mv .t1 $file
#fi
# 
# but I've lost the example that made me suggest this.
# 
# First, try the device/architecture specific config.status
# Our first try is for the mpireconfig.dat in the same directory as this script
# came from if it is specifically set.
mydir=`echo $0 | sed 's%/[^/][^/]*$%%'`
if [ -x $mydir/mpireconfig.dat ] ; then
    CONFIG_HEADERS=""
    export CONFIG_HEADERS
    $mydir/mpireconfig.dat 
elif [ -x /usr/rels/mpich-1.2..4pre2/bin/mpireconfig.dat ] ; then
    CONFIG_HEADERS=""
    export CONFIG_HEADERS
    /usr/rels/mpich-1.2..4pre2/bin/mpireconfig.dat 
elif [ -x /usr/rels/mpich-1.2..4pre2/bin/mpireconfig.dat ] ; then
    CONFIG_HEADERS=""
    export CONFIG_HEADERS
    /usr/rels/mpich-1.2..4pre2/bin/mpireconfig.dat 
elif [ -x /usr/rels/mpich-1.2..4pre2/build/LINUX/ch_gm/bin/config.status ] ; then 
    # Export the location of mpichconf.h.in
    #CONFIG_HEADERS="/usr/rels/mpich-1.2..4pre2/build/LINUX/ch_gm/include/mpichconf.h"
    # In fact, we DO NOT want to recreate mpichconf.h  We must
    # suppress it by defineing CONFIG_HEADERS as empty
    CONFIG_HEADERS=""
    export CONFIG_HEADERS
    /usr/rels/mpich-1.2..4pre2/build/LINUX/ch_gm/bin/config.status
elif [ -x /usr/rels/mpich-1.2..4pre2/config.status ] ; then
    # Export the location of mpichconf.h.in
    #CONFIG_HEADERS="/usr/rels/mpich-1.2..4pre2/mpichconf.h"
    CONFIG_HEADERS=""
    export CONFIG_HEADERS
    /usr/rels/mpich-1.2..4pre2/config.status
else
    echo "An mpireconfig.dat file is needed to perform a reconfig of a file"
    exit 1
fi
if [ -n "$destpair" ] ; then
    # Move created files to their final places
    for pair in $destpair ; do
	stmt=`echo "$pair" | sed 's/::/ /'`
        eval mv $stmt
    done
fi
