#!/bin/sh
# This file is configure.
#
# Make all changes to configure.in, if at all possible.  After changing,
# run "autoconf".  If autoconf is not installed, then make changes to
# configure.
#
# Documentation on the autoconf program exists in GNU info file format.
# To read this, run emacs and type C-h i.  Then press the down arrow
# until you come to the line beginning "* Autoconf:".  Pressing enter on
# this line will bring up the documentaition.
#
# Type "configure" (i.e., no arguments) or read below for usage information.
#
print_error() {
    echo "$*" 2>&1 ;
}

print_usage()
{
cat <<.
Usage: configure -arch ARCH_TYPE -cc CC -f77 FC -debug -help
                 -cflags CFLAGS -fflags FFLAGS
                 -mpiinc MPI_INC_DIR -mpilib MPI_LIB
where
   ARCH_TYPE    = the type of machine that PGAPack is to be configured for
   CC           = the name of the ANSI C compiler
   FC           = the name of the FORTRAN 77 compiler
   CFLAGS       = C compiler flags
   FFLAGS       = FORTRAN compiler flags
   MPI_INC_DIR  = the MPI include directory
   MPI_LIB      = the full path to the MPI library


Known architectures are:

Workstations
	sun4		(SUN OS 4.x)
	hpux		(HP UX)
	irix    	(Silicon Graphics IRIX)
	alpha		(DEC Alpha)
	rs6000		(AIX for IBM RS6000)	
	next		(NeXT 680x0)
	freebsd		(PC clones running FreeBSD)
	linux		(PC clones running LINUX)
	generic		(Generic 32-bit UNIX-like machine)

MPP's
	powerchallenge	(Silicon Graphics PowerChallenge)
	challenge	(Silicon Graphics Challenge)
	t3d		(Cray-T3D)
	sp2		(IBM SP2)
	paragon		(Intel Paragon)
	exemplar	(Convex Exemplar)


In the absence of the -f77 or -cc options, configure assumes the name of 
a FORTRAN 77 or ANSI C compiler based on the architecture type.

If the -debug flag is set, then PGAPack will be built for debugging.  This
enables the extensive debugging options and datatype checks.

If both -mpiinc and -mpilib are missing, PGAPack is built using a non-parallel
"stub" library for all MPI calls.

The -help flag causes this usage guide to be printed.

Example 1:
----------
Configure and build for parallel operation on the sun4 architectue.  MPI is
in /usr/local/mpi; the MPI library is /usr/local/mpi/lib/sun4/ch_p4/libmpi.a.

  configure -arch sun4 -mpilib /usr/local/mpi/lib/sun4/ch_p4/libmpi.a \
            -mpiinc /usr/local/mpi/include
  make install

Example 2:
----------
Configure and build a debug sequential library on the rs6000 architecture.

  configure -arch rs6000 -debug
  make install
.
}

###############################################################################
# This section initializes the variables that will be used throughout
# the script.
###############################################################################
#!/bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated automatically using autoconf.
# Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

# Usage: configure [--srcdir=DIR] [--host=HOST] [--gas] [--nfp]
#        [--prefix=PREFIX] [--exec-prefix=PREFIX] [--with-PACKAGE[=VALUE]]
# Ignores all args except --srcdir, --prefix, --exec-prefix, and
# --with-PACKAGE[=VALUE] unless this script has special code to handle it.

for arg
do
  # Handle --exec-prefix with a space before the argument.
  if test x$next_exec_prefix = xyes; then exec_prefix=$arg; next_exec_prefix=
  # Handle --host with a space before the argument.
  elif test x$next_host = xyes; then next_host=
  # Handle --prefix with a space before the argument.
  elif test x$next_prefix = xyes; then prefix=$arg; next_prefix=
  # Handle --srcdir with a space before the argument.
  elif test x$next_srcdir = xyes; then srcdir=$arg; next_srcdir=
  else
    case $arg in
     # For backward compatibility, recognize -exec-prefix and --exec_prefix.
     -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* | --exec=* | --exe=* | --ex=* | --e=*)
	exec_prefix=`echo $arg | sed 's/[-a-z_]*=//'` ;;
     -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- | --exec | --exe | --ex | --e)
	next_exec_prefix=yes ;;

     -gas | --gas | --ga | --g) ;;

     -host=* | --host=* | --hos=* | --ho=* | --h=*) ;;
     -host | --host | --hos | --ho | --h)
	next_host=yes ;;

     -nfp | --nfp | --nf) ;;

     -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
	prefix=`echo $arg | sed 's/[-a-z_]*=//'` ;;
     -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
	next_prefix=yes ;;

     -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=* | --s=*)
	srcdir=`echo $arg | sed 's/[-a-z_]*=//'` ;;
     -srcdir | --srcdir | --srcdi | --srcd | --src | --sr | --s)
	next_srcdir=yes ;;

     -with-* | --with-*)
       package=`echo $arg|sed -e 's/-*with-//' -e 's/=.*//'`
       # Reject names that aren't valid shell variable names.
       if test -n "`echo $package| sed 's/[-a-zA-Z0-9_]//g'`"; then
         echo "configure: $package: invalid package name" >&2; exit 1
       fi
       package=`echo $package| sed 's/-/_/g'`
       case "$arg" in
         *=*) val="`echo $arg|sed 's/[^=]*=//'`" ;;
         *) val=1 ;;
       esac
       eval "with_$package='$val'" ;;

     -v | -verbose | --verbose | --verbos | --verbo | --verb | --ver | --ve | --v)
       verbose=yes ;;

     *) ;;
    esac
  fi
done

trap 'rm -fr conftest* confdefs* core; exit 1' 1 3 15
trap 'rm -f confdefs*' 0

# NLS nuisances.
# These must not be set unconditionally because not all systems understand
# e.g. LANG=C (notably SCO).
if test "${LC_ALL+set}" = 'set' ; then LC_ALL=C; export LC_ALL; fi
if test "${LANG+set}"   = 'set' ; then LANG=C;   export LANG;   fi

rm -f conftest* confdefs.h
# AIX cpp loses on an empty file, so make sure it contains at least a newline.
echo > confdefs.h
compile='${CC-cc} $CFLAGS conftest.c -o conftest $LIBS >/dev/null 2>&1'

# A filename unique to this package, relative to the directory that
# configure is in, which we can look for to find out if srcdir is correct.
unique_file=source/pga.c

# Find the source files, if location was not specified.
if test -z "$srcdir"; then
  srcdirdefaulted=yes
  # Try the directory containing this script, then `..'.
  prog=$0
  confdir=`echo $prog|sed 's%/[^/][^/]*$%%'`
  test "X$confdir" = "X$prog" && confdir=.
  srcdir=$confdir
  if test ! -r $srcdir/$unique_file; then
    srcdir=..
  fi
fi
if test ! -r $srcdir/$unique_file; then
  if test x$srcdirdefaulted = xyes; then
    echo "configure: Can not find sources in \`${confdir}' or \`..'." 1>&2
  else
    echo "configure: Can not find sources in \`${srcdir}'." 1>&2
  fi
  exit 1
fi
# Preserve a srcdir of `.' to avoid automounter screwups with pwd.
# But we can't avoid them for `..', to make subdirectories work.
case $srcdir in
  .|/*|~*) ;;
  *) srcdir=`cd $srcdir; pwd` ;; # Make relative path absolute.
esac


# Save the original args to write them into config.status later.
configure_args="$*"

ARCH=""                         # architecture type
PARALLEL=0                      # parallel libray, or use stub routines?
OPTIMIZE=1                      # optimized?
CPPFLAGS=""                     # flags to send to the C preprocessor
LDFLAGS=""                      # link flags
CFLAGS=""                       # flags to send to the C compiler
FFLAGS=""                       # flags to send to the FORTRAN compiler
PGA_DIR="`pwd`"                 # the root of the pgapack tree
PGA_DIR=`echo $PGA_DIR | sed "s=tmp_mnt/=="`    # get rid of 'tmp_mnt/'
HEADERS="$PGA_DIR/include/pgapack.h" # headers upon which pgapack depends
INCLUDES="-I$PGA_DIR/include"   # directories where to search for include files
LIB_DIRS=""                     # directories where to search for libraries
LIBS=""                         # libraries with which to link
MPI_INC_DIR=""
MPI_LIB=""
SHELL="/usr/bin/sh"
RM="/bin/rm -f"                 # command to force removal of files

OBJS='$(PGA_LIB_DIR)/binary.o        \\\
      $(PGA_LIB_DIR)/char.o          \\\
      $(PGA_LIB_DIR)/cmdline.o       \\\
      $(PGA_LIB_DIR)/create.o        \\\
      $(PGA_LIB_DIR)/cross.o         \\\
      $(PGA_LIB_DIR)/debug.o         \\\
      $(PGA_LIB_DIR)/duplcate.o      \\\
      $(PGA_LIB_DIR)/evaluate.o      \\\
      $(PGA_LIB_DIR)/fitness.o       \\\
      $(PGA_LIB_DIR)/hamming.o       \\\
      $(PGA_LIB_DIR)/heap.o          \\\
      $(PGA_LIB_DIR)/integer.o       \\\
      $(PGA_LIB_DIR)/mutation.o      \\\
      $(PGA_LIB_DIR)/parallel.o      \\\
      $(PGA_LIB_DIR)/pga.o           \\\
      $(PGA_LIB_DIR)/pop.o           \\\
      $(PGA_LIB_DIR)/random.o        \\\
      $(PGA_LIB_DIR)/real.o          \\\
      $(PGA_LIB_DIR)/report.o        \\\
      $(PGA_LIB_DIR)/restart.o       \\\
      $(PGA_LIB_DIR)/select.o        \\\
      $(PGA_LIB_DIR)/stop.o          \\\
      $(PGA_LIB_DIR)/system.o        \\\
      $(PGA_LIB_DIR)/user.o          \\\
      $(PGA_LIB_DIR)/utility.o'      # these are pgapack's object files

###############################################################################
# This section parse the command line options. There a two types of options:
# those that take arguments and those that don't.  Parsing the case where an
# option takes an argument is a little tricky.  This is how it works.  Suppose
# that the program comes upon "-cc".  Then we know that the next argument
# will be the name of the C compiler.  Hence, we set the flag next_cc to be
# equal to "yes".  The next time through the loop, it will be the case that
# x$next_cc equal "xyes" because $next_cc expands to "yes".  Thus, we know that
# this argument is the name of the compiler and we assign it to USR_CC.  Then
# we set next_cc back to a null string.  This way on the next time through
# the loop x$next_cc will equal just "x".  Since the shell initializes
# variables to null strings, we do not have to initialize the "next_" family
# of variables by hand.
###############################################################################
for arg
do
    if test x$next_arch = xyes
        then
            ARCH=$arg
            next_arch=
        elif test x$next_mpiinc = xyes
            then
                MPI_INC_DIR=$arg
                next_mpiinc=
        elif test x$next_mpilib = xyes
            then
                MPI_LIB=$arg
                next_mpilib=
        elif test x$next_f77 = xyes
            then
                USR_FC=$arg
                next_f77=
        elif test x$next_cc = xyes
            then
                USR_CC=$arg
                next_cc=
        elif test x$next_cflags = xyes
            then
                CFLAGS="$arg $CFLAGS"
                next_cflags=
        elif test x$next_fflags = xyes
            then
                FFLAGS="$arg $FFLAGS"
                next_fflags=
        else
            case $arg in
                -arch)
                    next_arch=yes
                    ;;
                -f77)
                    next_f77=yes
                    ;;
                -cc)
                    next_cc=yes
                    ;;
                -mpiinc)
                    next_mpiinc=yes
                    PARALLEL=1
                    ;;
                -mpilib)
                    next_mpilib=yes
                    PARALLEL=1
                    ;;
                -debug)
                    OPTIMIZE=0
                    ;;
                -cflags)
                    next_cflags=yes
                    ;;
                -fflags)
                    next_fflags=yes
                    ;;
                -help)
                    print_usage >& 2
                    exit 1
                    ;;
                *) 
                    ;;
            esac
    fi
done

if test "$MPI_LIB" -a "$MPI_INC_DIR" ; then
    if test ! -d "$MPI_INC_DIR" ; then
        print_error "MPI_INC_DIR == $MPI_INC_DIR is not a valid directory!"
        exit 1
    fi
    if test ! -f "$MPI_INC_DIR/mpi.h" ; then
        print_error "Couldn't find $MPI_INC_DIR/mpi.h!"
        exit 1
    fi

    if test ! -f "$MPI_LIB" ; then
        print_error "MPI_LIB == $MPI_LIB is not a file!"
        exit 1
    fi

    PARALLEL=1
else
    PARALLEL=0
    CPPFLAGS="-DFAKE_MPI $CPPFLAGS"
fi

if test $OPTIMIZE -eq 1 ; then
	CPPFLAGS="-DOPTIMIZE $CPPFLAGS"
	CFLAGS="-O $CFLAGS"
	FFLAGS="-O $FFLAGS"
	PGA_LIB="pgaO"
else
	CFLAGS="-g $CFLAGS"
	FFLAGS="-g $FFLAGS"
	PGA_LIB="pgag"
fi


###############################################################################
# This section sets the default values of certain variables based upon the
# architecture type specified.  If no architecture was specified, the script
# issues an error and aborts.
###############################################################################
if test -z "$ARCH"
    then
        print_error "You must specify the architecture with -arch <value>"
        print_error "Valid architectures are the following:"	
	print_error " Workstations      MPP's"
	print_error "    sun4        powerchallenge"
	print_error "    next        challenge"
	print_error "    rs6000      t3d"
	print_error "    freebsd     sp2"
	print_error "    irix        paragon"
	print_error "    linux       exemplar"
	print_error "    hpux"
	print_error "    alpha"
	print_error "    generic"
	print_error ""
	print_error "For more information type configure -help."
        exit 1
fi

case $ARCH in
    sun4)
        CC=cc
        FC=f77
        CPPFLAGS="-DWL=32 -DFORTRANUNDERSCORE $CPPFLAGS"
        ;;
    next)
        CC=cc
        FC=
        CPPFLAGS="-DWL=32 -DFORTRANUNDERSCORE $CPPFLAGS"
        ;;
    rs6000)
        CC=cc
        FC=f77
        CPPFLAGS="-DWL=32 $CPPFLAGS"
        ;;
    freebsd)
        CC=cc
        FC=f77
	FFLAGS="-w"
        CPPFLAGS="-DWL=32 -DFORTRANUNDERSCORE $CPPFLAGS"
        ;;
    irix)
        CC=cc
        FC=f77
        CPPFLAGS="-DWL=32 -DFORTRANUNDERSCORE $CPPFLAGS"
        ;;
    alpha)
        CC=cc
        FC=f77
        CPPFLAGS="-DWL=64 -DFORTRANUNDERSCORE $CPPFLAGS"
        ;;
    hpux)
        CC=cc
        FC=f77
        CPPFLAGS="-DWL=32 $CPPFLAGS"
	SHELL=/bin/sh
        ;;
    linux)
	SHELL="/bin/sh"
        CC=cc
        FC=f77
	FFLAGS="-w"
	LDFLAGS="-s $LDFLAGS"
        CPPFLAGS="-DWL=32 -DFORTRANUNDERSCORE $CPPFLAGS"
        ;;
    t3d)
        CC=/mpp/bin/cc
        FC=/mpp/bin/cf77
        CFLAGS="-T cray-t3d"
        FFLAGS="-C cray-t3d -dp"
        CPPFLAGS="-DWL=64 -DFORTRANCAP $CPPFLAGS"
	SHELL=/bin/sh
        ;;
    powerchallenge)
        CC=cc
        FC=f77
	CFLAGS="-mips4 -fullwarn -64"
        CPPFLAGS="-DWL=64 -DFORTRANUNDERSCORE $CPPFLAGS"
        ;;
    challenge)
        CC=cc
        FC=f77
	CFLAGS="-mips2 -fullwarn -32"
        CPPFLAGS="-DWL=32 -DFORTRANUNDERSCORE $CPPFLAGS"
        ;;
    paragon)
        CC=cc
        FC=f77
        CFLAGS="-nx $CFLAGS"
        FFLAGS="-nx $FFLAGS"
        CPPFLAGS="-DWL=32 -DFORTRANUNDERSCORE $CPPFLAGS"
        ;;
    sp2)
        CC=cc
        FC=f77
        CPPFLAGS="-DWL=32 $CPPFLAGS"
        ;;
    exemplar)
        CC=cc
        FC=fort77
	FFLAGS="-L/usr/lib -lU77 $FFLAGS"
        CPPFLAGS="-DWL=32 $CPPFLAGS"
	SHELL=/bin/sh
        ;;
    *)
	CC=cc
	FC=f77
	CPPFLAGS="-DWL=32 $CPPFLAGS"
	print_error "WARNING:  Configuring for untested architecture.  Using"
        print_error "          word size of 32 bits, cc and f77 as compilers."
	print_error "          You might have trouble with Fortran programs"
        print_error "          not linking correctly.  Check the manual on"
        print_error "          the FORTRANUNDERSCORE #define."
	;;
esac

###############################################################################
# This section sets the variables that do not relate to parallel code.
###############################################################################
CPPFLAGS="-D$ARCH $CPPFLAGS"
PGA_LIB_DIR="../lib/$ARCH"
LIB_DIRS="-L$PGA_DIR/lib/$ARCH $LIB_DIRS"
LIBS="-l$PGA_LIB $LIBS"

#     Set output variable `RANLIB' to `ranlib' if `ranlib' is found,
#     otherwise to `:' (do nothing).
if test -z "$RANLIB"; then
  # Extract the first word of `ranlib', so it can be a program name with args.
  set dummy ranlib; word=$2
  echo checking for $word
  IFS="${IFS= 	}"; saveifs="$IFS"; IFS="${IFS}:"
  for dir in $PATH; do
    test -z "$dir" && dir=.
    if test -f $dir/$word; then
      RANLIB="ranlib"
      break
    fi
  done
  IFS="$saveifs"
fi
test -z "$RANLIB" && RANLIB=":"
test -n "$RANLIB" && test -n "$verbose" && echo "	setting RANLIB to $RANLIB"


#    "Determine a C compiler to use.  If `CC' is not already set in the
#     environment, check for `gcc', and use `cc' if it's not found.  Set
#     output variable `CC' to the name of the compiler found.
#
#    "If using the GNU C compiler, set shell variable `GCC' to `yes',
#     empty otherwise.  If output variable `CFLAGS' was not already set,
#     set it to `-g -O' for the GNU C compiler (`-O' on systems where
#     GCC does not accept `-g'), or `-g' for other compilers."
if test -n "$USR_CC"
     then
          CC=$USR_CC
     else
          if test -z "$CC"; then
  # Extract the first word of `gcc', so it can be a program name with args.
  set dummy gcc; word=$2
  echo checking for $word
  IFS="${IFS= 	}"; saveifs="$IFS"; IFS="${IFS}:"
  for dir in $PATH; do
    test -z "$dir" && dir=.
    if test -f $dir/$word; then
      CC="gcc"
      break
    fi
  done
  IFS="$saveifs"
fi
test -z "$CC" && CC="cc"
test -n "$CC" && test -n "$verbose" && echo "	setting CC to $CC"

# Find out if we are using GNU C, under whatever name.
cat > conftest.c <<EOF
#ifdef __GNUC__
  yes
#endif
EOF
${CC-cc} -E conftest.c > conftest.out 2>&1
if egrep yes conftest.out >/dev/null 2>&1; then
  GCC=1 # For later tests.
fi
rm -f conftest*

fi

#     Check for each program in the whitespace-separated list
#     PROGS-TO-CHECK-FOR exists in `PATH'.  If it is found, set VARIABLE
#     to the name of that program.  Otherwise, continue checking the
#     next program in the list.  If none of the programs in the list are
#     found, set VARIABLE to VALUE-IF-NOT-FOUND; if VALUE-IF-NOT-FOUND
#     is not specified, the value of VARIABLE is not changed.
if test -n "$USR_FC"
     then
          FC=$USR_FC
     else
          for p in f77 fortran xlf gf77 mpxlf if77
do
if test -z "$FC"; then
  # Extract the first word of `$p', so it can be a program name with args.
  set dummy $p; word=$2
  echo checking for $word
  IFS="${IFS= 	}"; saveifs="$IFS"; IFS="${IFS}:"
  for dir in $PATH; do
    test -z "$dir" && dir=.
    if test -f $dir/$word; then
      FC="$p"
      break
    fi
  done
  IFS="$saveifs"
fi

test -n "$FC" && test -n "$verbose" && echo "	setting FC to $FC"

test -n "$FC" && break
done

fi

# Originally had
#                     OBJS="$OBJS $(PGA_LIB_DIR)/f2c.o"
# However, freebsd bourne shell equates $(var) and `var`.  Hence, I had
# to break the assignment up into two parts.  $FORTWRAP is a Makefile
# dependency line defining how to compile f2c.c
if test -n "$FC"
    then
	TEMP='$(PGA_LIB_DIR)/f2c.o'
        OBJS="$OBJS $TEMP"
        FORTWRAP='$(PGA_LIB_DIR)/f2c.o: f2c.c $(HEADERS)\
	$(COMPILE.c) f2c.c'
fi

if test ! -d lib
    then
        mkdir lib
fi

if test ! -d lib/$ARCH
    then
        mkdir lib/$ARCH
fi

#  Set up symlinks for pgapackf.h to any directories with Fortran source
rm -f ./examples/fortran/pgapackf.h ./examples/mgh/pgapackf.h ./test/pgapackf.h
ln -s ../../include/pgapackf.h ./examples/fortran/pgapackf.h
ln -s ../../include/pgapackf.h ./examples/mgh/pgapackf.h
ln -s ../include/pgapackf.h    ./test/pgapackf.h

#  Use the stub library.
if test $PARALLEL -eq 0
  then
    rm -f ./include/mpi.h ./include/mpif.h ./examples/fortran/mpif.h ./examples/mgh/mpif.h ./test/mpif.h
    ln -s fakempi_h include/mpi.h
    ln -s fakempif_h include/mpif.h
    ln -s ../../include/mpif.h ./examples/fortran/mpif.h
    ln -s ../../include/mpif.h ./examples/mgh/mpif.h
    ln -s ../include/mpif.h ./test/mpif.h
    TEMP='$(PGA_LIB_DIR)/mpi_stub.o'
    OBJS="$OBJS $TEMP"
    MPICOMP='$(PGA_LIB_DIR)/mpi_stub.o: mpi_stub.c $(HEADERS)\
	$(COMPILE.c) mpi_stub.c'
#  The tab above is IMPORTANT!  Needed for make!
else
    rm -f ./include/mpi.h ./include/mpif.h ./examples/fortran/mpif.h ./examples/mgh/mpif.h ./test/mpif.h
    ln -s $MPI_INC_DIR/mpif.h ./examples/fortran/mpif.h
    ln -s $MPI_INC_DIR/mpif.h ./examples/mgh/mpif.h
    ln -s $MPI_INC_DIR/mpif.h ./test/mpif.h
    LIBS="$LIBS $MPI_LIB"
    INCLUDES="$INCLUDES -I$MPI_INC_DIR"
fi

LIBS="$LIBS -lm"
CPPFLAGS="$INCLUDES $CPPFLAGS"
LDFLAGS="$LDFLAGS $LIB_DIRS $LIBS"
###############################################################################
# This section exports the variables that have previously been set.
# Configure creates the Makefiles listed on the last line from the
# Makefile.in in each directory.  It does this by substituting the value
# of $VAR for every occurent of @VAR@ in the Makefile.in.  For
# example, if the characters @CC@ occur any place in a Makefile.in, they
# will be replaced with the value that $CC has when ac_subst(CC) is
# called.
###############################################################################
















# Set default prefixes.
if test -n "$prefix"; then
  test -z "$exec_prefix" && exec_prefix='${prefix}'
  prsub="s%^prefix\\([ 	]*\\)=\\([ 	]*\\).*$%prefix\\1=\\2$prefix%"
fi
if test -n "$exec_prefix"; then
  prsub="$prsub
s%^exec_prefix\\([ 	]*\\)=\\([ 	]*\\).*$%exec_prefix\\1=\\2$exec_prefix%"
fi
# Quote sed substitution magic chars in DEFS.
cat >conftest.def <<EOF
$DEFS
EOF
escape_ampersand_and_backslash='s%[&\\]%\\&%g'
DEFS=`sed "$escape_ampersand_and_backslash" <conftest.def`
rm -f conftest.def
# Substitute for predefined variables.

trap 'rm -f config.status; exit 1' 1 3 15
echo creating config.status
rm -f config.status
cat > config.status <<EOF
#!/bin/sh
# Generated automatically by configure.
# Run this file to recreate the current configuration.
# This directory was configured as follows,
# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
#
# $0 $configure_args

for arg
do
  case "\$arg" in
    -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
    echo running \${CONFIG_SHELL-/bin/sh} $0 $configure_args
    exec \${CONFIG_SHELL-/bin/sh} $0 $configure_args ;;
    *) echo "Usage: config.status --recheck" 2>&1; exit 1 ;;
  esac
done

trap 'rm -f Makefile source/Makefile test/Makefile test/Makefile \
	  examples/Makefile examples/c/Makefile examples/fortran/Makefile \
	  examples/mgh/Makefile; exit 1' 1 3 15
RANLIB='$RANLIB'
CC='$CC'
FC='$FC'
CFLAGS='$CFLAGS'
FFLAGS='$FFLAGS'
CPPFLAGS='$CPPFLAGS'
FORTWRAP='$FORTWRAP'
HEADERS='$HEADERS'
LDFLAGS='$LDFLAGS'
PARALLEL='$PARALLEL'
PGA_LIB_DIR='$PGA_LIB_DIR'
PGA_LIB='$PGA_LIB'
OBJS='$OBJS'
MPICOMP='$MPICOMP'
RM='$RM'
SHELL='$SHELL'
LIBS='$LIBS'
srcdir='$srcdir'
DEFS='$DEFS'
prefix='$prefix'
exec_prefix='$exec_prefix'
prsub='$prsub'
extrasub='$extrasub'
EOF
cat >> config.status <<\EOF

top_srcdir=$srcdir

CONFIG_FILES=${CONFIG_FILES-"Makefile source/Makefile test/Makefile test/Makefile \
	  examples/Makefile examples/c/Makefile examples/fortran/Makefile \
	  examples/mgh/Makefile"}
for file in .. ${CONFIG_FILES}; do if test "x$file" != x..; then
  srcdir=$top_srcdir
  # Remove last slash and all that follows it.  Not all systems have dirname.
  dir=`echo $file|sed 's%/[^/][^/]*$%%'`
  if test "$dir" != "$file"; then
    test "$top_srcdir" != . && srcdir=$top_srcdir/$dir
    test ! -d $dir && mkdir $dir
  fi
  echo creating $file
  rm -f $file
  echo "# Generated automatically from `echo $file|sed 's|.*/||'`.in by configure." > $file
  sed -e "
$prsub
$extrasub
s%@RANLIB@%$RANLIB%g
s%@CC@%$CC%g
s%@FC@%$FC%g
s%@CFLAGS@%$CFLAGS%g
s%@FFLAGS@%$FFLAGS%g
s%@CPPFLAGS@%$CPPFLAGS%g
s%@FORTWRAP@%$FORTWRAP%g
s%@HEADERS@%$HEADERS%g
s%@LDFLAGS@%$LDFLAGS%g
s%@PARALLEL@%$PARALLEL%g
s%@PGA_LIB_DIR@%$PGA_LIB_DIR%g
s%@PGA_LIB@%$PGA_LIB%g
s%@OBJS@%$OBJS%g
s%@MPICOMP@%$MPICOMP%g
s%@RM@%$RM%g
s%@SHELL@%$SHELL%g
s%@LIBS@%$LIBS%g
s%@srcdir@%$srcdir%g
s%@DEFS@%$DEFS%
" $top_srcdir/${file}.in >> $file
fi; done


exit 0
EOF
chmod +x config.status
${CONFIG_SHELL-/bin/sh} config.status


if test ! -f ".pgapack" ; then
  if test $PARALLEL -eq 1 ; then
      OPERATION="parallel"
      ECHO_LIBS="$MPI_LIB"
  else
      OPERATION="sequential"
      ECHO_LIBS="stub routines in mpi_stub.c"
  fi
  if test $OPTIMIZE -eq 1 ; then
      OPERATION="optimized $OPERATION"
  else
      OPERATION="debug $OPERATION"
  fi
  echo " "
  echo "PGAPack has been configured for $OPERATION operation on"
  echo "the $ARCH architecture, using $ECHO_LIBS."
  echo " "
  echo "Type \"make install\" to install PGAPack."
  echo " "
fi


