dnl This is an autoconf script.
dnl To rebuild the `configure' script from this, execute the command
dnl 	autoconf
dnl in the directory containing this script.  You must have autoconf
dnl version 1.4 or later (but NOT version 2.0 or later)
dnl
dnl The following text appears in the resulting `configure' script,
dnl explaining how to rebuild it.
[#!/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.

progname="`echo $0 | sed 's:^\./\./:\./:'`"
print_error() {
    echo "*# $*" 2>&1 ;
    }
print_usage() {
cat <<EOF
Usage: ${progname} [--with-arch=ARCH_TYPE] [-comm=COMM_TYPE]
            [--with-device=DEVICE]
            [--with-mpe] [--without-mpe] 
	    [--disable-f77] [--disable-f90] [--with-f90nag] [--with-f95nag] 
	    [--disable-f90modules]
            [--enable-c++ ] [--disable-c++]
            [--enable-mpedbg] [--disable-mpedbg] 
            [--enable-devdebug] [--disable-devdebug] 
            [--enable-debug] [--disable-debug] 
            [--enable-short-longs] [--disable-short-longs]
	    [--with-jumpshot[=JUMPSHOT_OPTS]]
            [-prefix=INSTALL_DIR] 

            [-c++[=C++_COMPILER] ] [noc++] 
            [-opt=OPTFLAGS] 
            [-cc=C_COMPILER] [-fc=FORTRAN_COMPILER]
            [-clinker=C_LINKER] [-flinker=FORTRAN_LINKER]
            [-c++linker=CC_LINKER] 
            [-cflags=CFLAGS] [-fflags=FFLAGS] [-c++flags=CCFLAGS]
            [-optcc=C_OPTFLAGS] [-optf77=F77_OPTFLAGS]
            [-f90=F90_COMPILER] [-f90flags=F90_FLAGS]
            [-f90inc=INCLUDE_DIRECTORY_SPEC_FORMAT_FOR_F90]
            [-f90linker=F90_LINKER] 
            [-f90libpath=LIBRARY_PATH_SPEC_FORMAT_FOR_F90]
            [-lib=LIBRARY] [-mpilibname=MPINAME]
            [-mpe_opts=MPE_OPTS] [-jumpshot_opts=JUMPSHOT_OPTS]
	    [-make=MAKEPGM ]
            [-memdebug] [-ptrdebug] [-tracing] [-dlast]
	    [-listener_sig=SIGNAL_NAME]
            [-usesysv] [-cross]
	    [-pkt_size=LENGTH] 
            [-adi_collective]
            [-fortnames=FORTRANNAMES]
            [-automountfix=AUTOMOUNTFIX]
            [-noranlib] [-ar_nolocal] 
            [-rsh=RSHCOMMAND] [-rshnol]
	    [-globusdir=GLOBUSDIR] [-noromio] [-file_system=FILE_SYSTEM]
            [-p4_opts=P4_OPTS]
where
   ARCH_TYPE       = the type of machine that MPI is to be configured for
   COMM_TYPE       = communications layer or option to be used
   DEVICE          = communications device to be used
   INSTALL_DIR     = directory where MPI will be installed (optional)
   MPE_OPTS        = options to pass to the mpe configure
   JUMPSHOT_OPTS   = options to pass to the jumpshot configure
   P4_OPTS         = options to pass to the P4 configure (device=ch_p4)
   C++_COMPILER    = default is to use xlC, g++, or CC (optional)
   OPTFLAGS        = optimization flags to give the compilers (e.g. -g)
   CFLAGS          = flags to give C compiler
   FFLAGS          = flags to give Fortran compiler
   MAKEPGM         = version of make to use
   LENGTH          = Length of message at which ADI switches from short
                     to long message protocol
   FORTRANNAMES    = Form of the Fortran names.  See below.
   AUTOMOUNTFIX    = Command to fix automounters
   RSHCOMMAND      = Command to use for remote shell
   MPILIBNAME      = Name to use instead of mpich in the name of the MPI
                     library.  If set, libMPILIBNAME will be used instead
                     or libmpich.  This can be used on systems with
                     several different MPI implementations.
   GLOBUSDIR       = the location of the Globus distribution
   FILE_SYSTEM     = name of the file system ROMIO is to use.  Currently 
                     supported values are nfs, ufs, pfs (Intel), 
                     piofs (IBM), hfs (HP), sfs (NEC), and xfs (SGI).
   SIGNAL_NAME     = name of the signal for the P4 (device=ch_p4) device to
                     use to indicate that a new connection is needed.  By
                     default, it is SIGUSR1.

All arguments are optional, but if 'arch', 'comm', or 'prefix' arguments
are provided, there must be only one.  'arch' must be specified before
'comm' if they both appear.

Packages that may be included with MPICH

--with-device=name     - Use the named device for communication.  Known
                         names include ch_p4, ch_mpl, ch_shmem, and globus.
                         If not specified, a default is chosen.  Special 
                         options for the device are specified after the 
                         device name, separated by a colon.  E.g., 
                         --with-device=name:-globusdir=/usr/local/globus
--with-romio[=OPTIONS] - Use ROMIO to provide MPI-I/O from MPI-2 (default).
                         The options include -file_system=FSTYPE, where
                         fstype can be any combination of nfs, ufs, 
                         pfs (intel), piofs (IBM), hfs (HP), sfs (NEC), and 
                         xfs (SGI), combined with '+'.  If romio is not
                         included, the Fortran 90 modules cannot be built.
--with-mpe             - Build the MPE environment (default)
--with-f90nag          - Choose the NAG f90 compiler for Fortran 
                         (preliminary version intended for use *instead* 
                         of a Fortran 77 compiler)
--with-f95nag          - Choose the NAG f95 compiler for Fortran

You can use --without-<featurename> to turn off a feature (except for 
device).
EOF
#
# For each device with a setup file, give the usage output
if test -z "$srcdir" ; then srcdir="." ; fi
for mpid in $srcdir/mpid/* ; do
    if test -d $mpid ; then
	DEVICE=`echo $mpid | sed 's%.*/%%g'`
 	device_setup=$mpid/setup_$DEVICE
        if test -f $device_setup ; then
	    echo "Options for device $DEVICE:" 
	    export DEVICE
	    eval $device_setup --usage 2>&1
	    echo " "
	fi
    fi
done
#
cat <<EOF
Features that may be included with MPICH

--enable-c++          - Build C++ interfaces to the MPI-1 routines 
                        (default)
--enable-f77          - Build Fortran 77 interfaces to the MPI 
                        routines (default)
--enable-weak-symbols - Use weak symbols for MPI/PMPI routines.  This uses
                        weak symbols, if available, for the profiling 
                        interface (default)
--enable-debug        - Enable support for debuggers to access message 
                        queues
--enable-mpedbg       - Enable the -mpedbg command-line argument (e.g., 
                        errors can start an xterm running a debugger).  
                        Only works with some workstation systems.
--enable-sharedlib    - Attempt to build shared libraries.  Static 
--enable-sharedlib=dir  libraries are always built.  If a directory is
                        specified, the shared libraries will be placed in 
                        that directory.  This can be used to place the 
                        shared libraries in a uniform location in local 
                        disks on a cluster.
--enable-f90modules   - Build Fortran 90 module support (default if a
                        Fortran 90 or 95 compiler is found).  If ROMIO
                        is not built, no Fortran 90 modules will be built.

The following are intended for MPI implementors and debugging of configure
--enable-strict       - Try and build MPICH using strict options in Gnu gcc
--enable-echo         - Cause configure to echo what it does
--enable-devdebug     - Enable debugging code in the ADI.  

You can use --disable-<featurename> to turn off a feature.

Notes on configure usage:

The suggestions for GNU configure usage suggest that configure not be used
to build different tools, only controlling some basics of the features 
enabled or the packages included.  Our use of configure does not follow 
these rules because configure is too useful but we need the flexibility 
that allows the user to produce variations of MPICH.

More notes on command-line parameters:

You can select a different C and Fortran compiler by using the '-cc' and
'fc' switches.  The environment variables 'CC' and 'FC' can also provide
values for these but their settings may be overridden by the configure
script.  Using '-cc=\$CC -fc=\$FC' will force configure to use those
compilers.

If '-cross' is given, configure assumes that you are cross-compiling.  If
it is not given, configure expects to be able to run programs.  Even if
'-cross' is not selected, configure will try to determine if you are
cross-compiling; this switch is needed only on systems where attempting
to run a cross-compiled program causes the configure script to hang.

The option '-opt' allows you to specify optimization options for the
compilers (both C and Fortran).  For example, '-opt=-O' chooses optimized
code generation on many systems.  '-optcc' and '-optf77' allow you to
specify options for just the C or Fortran compilers.  Use -cflags and
-fflags for options not related to optimization.  

Note that the '-opt' options are not passed to the 'mpicc', 'mpif77', 
'mpiCC', and 'mpif90' scripts.  The '-opt' options are used only in 
building MPICH.

The option '-lib' allows you to specify the location of a library that
may be needed by a particular device.  Most devices do NOT need this
option; check the installation instructions for those that might.

The option '-make' may be used to select an alternate make program.  For
example, on FreeBSD systems, -make=gnumake may be required because makes
derived from BSD 4.4 do not support the include operation (instead using
the form .include, unlike all other makes); this is used in the wrappergen
utility.

The option '--disable-short-longs' may be used to suppress support for 
the C types 'long long' (a common extension) and 'long double' (ANSI/ISO C)
when they are the same size as 'long' and 'double' respectively.  Some 
systems allow these long C types, but generate a warning message when 
they are used; this option may be used to suppress these messages (and 
support for these types).

The option '-fortnames=FORTRANNAMES' allows you to specify the form of
the Fortran names.  This is used primarily to generate names with and
without trailing underscores for those systems that support both.
Possible values are
    FORTRANNAMES value     if Fortran MPI_SEND looks like
    DOUBLEUNDERSCORE       mpi_send__
    UNDERSCORE             mpi_send_
    CAPS                   MPI_SEND
    NOUNDERSCORE           mpi_send 

This option should normally NOT be used; configure determines what the
Fortran compiler generates.  This can be used to override that choice.
Note that if you use this choice, it is your responsibility to ensure that 
Fortran compiler follows the rule that you have chosen.  In otherwords, if
your Fortran compiler generates names of the form 'mpi_send__', and you
use the option -fortnames=UNDERSCORE, then the MPI build will be incorrect.
If you plan to force your Fortran compiler to use a different naming rule, 
you should pass the appropriate argument with the -fflags option.  For 
example, with g77, you can use -fflags=-fno-second-underscore .  The 
MPICH configure will then figure out that names have the format 
of UNDERSCORE.

The option -finttype=<type> allows you to specify the C integer type
that corresponds to a Fortran INTEGER.  This is int by default.

The option '-ar_nolocal' prevents the library archive command from
attempting to use the local directory for temporary space.  This option
should be used when (a) there isn't much space (less than 20 MB)
available in the partition where MPICH resides and (b) there is enough
space in /tmp (or wherever ar places temporary files by default).

The option '-noranlib' causes the 'ranlib' step (needed on some systems
to build an object library) to be skipped.  This is particularly useful
on systems where 'ranlib' is optional (allowed but not needed; because it
is allowed, configure chooses to use it just in case) but can fail (some
'ranlib's are implemented as scripts using 'ar'; if they don't use the
local directory, they can fail (destroying the library in the process) if
the temporary directory (usually '/tmp') does not have enough space.
This has occured on some OSF systems.

The option '-memdebug' enables extensive internal memory debugging code.
This should be used only if you are trying to find a memory problem (it
can be used to help find memory problems in user code as well).  Running
programs with the option '-mpidb memdump' will produce a summary, when 
'MPI_Finalize' is called, of all unfreed memory allocated my MPI.   For
example, a user-created datatype that was not later freed would be 
reported.

The option '-tracing' enables tracing of internal calls.  This should be
used only for debugging the MPICH implementation itself.

The option '-dlast' enables tracing of the most recent operations performed
by the device.  These can be output when a signal (like SIGINT), error, 
or call to a special routine occurs.  There is a performance penalty for
this option, but it can be very useful for implementors attempting to debug
problems.  

The option '-rsh' allows you to select an alternative remote shell
command (by default, configure will use 'rsh' or 'remsh' from your
'PATH').  If your remote shell command does not support the '-l' option
(some AFS versions of 'rsh' have this bug), also give the option
'-rshnol'.  These options are useful only when building a network version
of MPICH (e.g., '--with-device=ch_p4').

Special Tuning Options:

There are a number of options for tuning the behavoir of the ADI
(Abstract Device Interface) which is the low-level message-passing
interface.  These should NOT be used unless you are sure you know what
you are doing.

The option '-pkt_size=LENGTH' allows you to choose the message length at
which the ADI (Abstract Device Interface) switches from its short to long
message format.  LENGTH must be positive.

The option '-adi_collective' allows the ADI to provide some collective
operations in addition to the basic point-to-point operations.
Currently, most systems do not support this option (it is ignored) and on
the others it has not been extensively tested.  

Sample Configure Usage:

To make for running on sun4's running SunOS with ch_p4 as the device,
 and with the installation directory equal to the current directory:

  ./configure --with-device=ch_p4 --with-arch=sun4
  make

Known devices are 
        ch_nx     (native Intel NX calls), 
        ch_mpl    (native IBM EUI or MPL calls),
        ch_p4     (p4)
	globus    (Globus)
        ch_meiko  (for Meiko CS2, using NX compatibility library),
        ch_shmem  (for shared memory systems, such as SMPs), 
        ch_lfshmem(for shared memory systems, such as SMPs; uses
                   lock-free message buffers), 
        ch_cenju3 (native NEC Cenju-3 calls)

The following devices were supported with ADI-1, but are currently
unsupported.  Please contact us if you are interested in helping us
support these devices:
        meiko     (for Meiko CS2, using elan tport library), and
	nx        (for Intel Paragon),
	t3d	  (for the Cray T3D, using Cray shmem library).
        ch_nc     (native nCUBE calls, requires -arch=ncube),
        ch_cmmd   (native TMC CM-5 CMMD calls)
These are no longer distributed with the MPICH distribution.      

Known architectures include (case is important)
        sun4      (SUN OS 4.x)
        solaris   (Solaris)
	solaris86 (Solaris on Intel platforms)
        hpux      (HP UX)
        sppux     (SPP UX)
        rs6000    (AIX for IBM RS6000)
        sgi       (Silicon Graphics IRIX 4.x, 5.x or 6.x)
        sgi5      (Silicon Graphics IRIX 5.x on R4400's, for the MESHINE)
        IRIX      (synonym for sgi)
        IRIX32    (IRIX with 32bit objects -32)
        IRIXN32   (IRIX with -n32)
        IRIX64    (IRIX with 64bit objects)
        alpha     (DEC alpha)
        intelnx   (Intel i860 or Intel Delta)
        paragon   (Intel Paragon)
        meiko     (Meiko CS2)
        CRAY      (CRAY XMP, YMP, C90, J90, T90)
        cray_t3d  (CRAY T3D)
        freebsd   (PC clones running FreeBSD)
        netbsd    (PC clones running NetBSD)
	LINUX     (PC clones running LINUX)
        ksr       (Kendall Square KSR1 and KSR2)
        EWS_UX_V  (NEC EWS4800/360AD Series workstation.  Untested.)
        UXPM      (UXP/M. Untested.)
        uxpv      (uxp/v. Untested.)
        SX_4_float0
                  (NEC SX-4; Floating point format float0
                             Conforms IEEE 754 standard.
                   C:       sizeof (int)     = 4; sizeof (float) = 4
                   FORTRAN: sizeof (INTEGER) = 4; sizeof (REAL)  = 4)
        SX_4_float1
                  (NEC SX-4; Floating point format float1
                             IBM floating point format.
                   C:       sizeof (int)     = 4; sizeof (float) = 4
                   FORTRAN: sizeof (INTEGER) = 4; sizeof (REAL)  = 4)
        SX_4_float2
                  (NEC SX-4; Floating point format float2
                             CRAY floating point format.
                   C:       sizeof (int)     = 4; sizeof (float) = 8
                   FORTRAN: sizeof (INTEGER) = 8; sizeof (REAL)  = 8)
                   !!! WARNING !!! This version will not run
                                   together with FORTRAN routines.
                                   sizeof (INTEGER) != sizeof (int)
        SX_4_float2_int64
                   (NEC SX-4; Floating point format float2 and
                              64-bit int's)
                    C:       sizeof (int)     = 8; sizeof (float) = 8
                    FORTRAN: sizeof (INTEGER) = 8; sizeof (REAL)  = 8)

Special notes:

For SGI (--with-arch=IRIX) multiprocessors running the ch_p4 device, use
-comm=ch_p4 to disable the use of the shared-memory p4 communication
device, and -comm=shared to enable the shared-memory p4 communication
device.  The default is to enable the shared-memory communication device.

Others may be recognized.
EOF
}
#
# Special environment variables
# MPICH_WARNING_SEP - if set, is echoed around warning messages.  This is
# used to simplify automated testing where we want to ignore warning messages
# Specifically, echo '>'$MPICH_WARNING_SEP preceeds the warning and
#               echo '<'$MPICH_WARNING_SEP follows it
# finderrors and findnosuccess use the same environment variable to 
# skip output
#
UseSharedLibs=0
NEEDS_CC_SHARED_OPT=1
ARCH=""
CPP_DIR=""
MPE_DIR=""
LIB_PATH=""
FLIB_PATH=""
OPTFLAGS=""
OPTFLAGSF=""
F90=${F90:-""}
f90nag=0
NOF77=0
F77_COMPILE_FLAG=0
F77_EXTRA_FLAG=""
NOMPE=0
ENABLE_MPEDBG=""
NOCXX=""
AR_LOCAL=l
NOSHORTLONGS=0
HAS_FORTRAN=1
MPILIBNAME=${MPILIBNAME:-"mpich"}
USER_SET_GETARG=0
# Nag F90 names are call f90_unix_MP_getarg(i,s) and 
# f90_unix_MP_iargc().
#F77GETARGDECL=${F77GETARGDECL:-"external getarg"}
#F77GETARG=${F77GETARG:-"call getarg(i,s)"}
#F77IARGC=${F77IARGC:-"iargc()"}
# Use the same defaults for F90
F90GETARGDECL=${F90GETARGDECL:-"external getarg"}
F90GETARG=${F90GETARG:-"call getarg(i,s)"}
F90IARGC=${F90IARGC:-"iargc()"}
F90UNIX=${F90UNIX:-"C"}
do_f90modules="yes"
#
MPI_FOBJECTS="\$(MPI_FOBJECTS)"
MPI_FINT=int
MPI_AINT=long
CFLAGS=""
# Attempt to use weak symbol support
TRY_WEAK_SYMBOLS=1
# We use @ because configure uses %
AUTOMOUNTFIX=${AUTOMOUNTFIX:-'sed -e s@/tmp_mnt/@/@g'}
#
# By not setting FFLAGS, we get the values from the environment
# Most of these should come from the environment if set
MAKE=${MAKE:-"make"}
P4_MDEPCFLAGS=""
ASMFILES_O=""
PREFIX=""
MPE_OPTS=""
P4_OPTS=""
JUMPSHOT_OPTS=""
DEVCFLAGS=""
CONFIGURE_ARGS="$*"
DEFAULT_MACHINE=''
DEVICE_KIND=MPP
#
cross_compiling=0
debug_version=0
#
FILE_SYSTEM=""
ROMIO=1
ROMIO_CFLAGS=""
ROMIO_FFLAGS=""
ROMIO_LFLAGS=""
ROMIO_TCFLAGS=""
ROMIO_TCPPFLAGS=""
ROMIO_TFFLAGS=""
usesysv=0
#
# -mpedbg
#MPE_MPI_EXT_C="$MPE_MPI_EXT_C dbxerr.c mpehname.c"
#MPE_MPI_EXT_O="$MPE_MPI_EXT_O dbxerr.o mpehname.o"
# dbxerr.c support has become too difficult to make part of the basic
# system (both because it is in MPE, which is now separately built and 
# configured after MPICH, and because of diverging (even for a single vendor)
# command syntax for the debuggers.  Add dbxdee.c/.o when we have a better
# solution.
MPE_MPI_EXT_C="$MPE_MPI_EXT_C mpehname.c"
MPE_MPI_EXT_O="$MPE_MPI_EXT_O mpehname.o"
#
# -devdebug
DEVDEBUGCFLAGS="-DMPID_DEBUG_NONE -DMPID_STAT_NONE"
# -dlast
DLAST=""
#
# This next variable is a version without quotes.
# We could also consider `echo $a | sed -e 's/"/\\"/g'`
CONFIGURE_ARGS_CLEAN=`echo $* | tr '"' ' '`
if test -n "$CONFIGURE_ARGS" ; then 
    echo "Configuring with args $CONFIGURE_ARGS"
fi
#
# Test for C++ support
# We can only set this if there is a C++ compiler....
buildcpp=0
# 
if test -s include/patchlevel.h ; then
    tmpsrcdir=.
else
    # try to determine the source dir
    tmpsrcdir=`echo $0 | sed -e 's%/configure%%' -e "s%^~/%$HOME/%"`
    if test ! -s $tmpsrcdir/include/patchlevel.h ; then
        tmpsrcdir=""
    fi
fi
if test -n "$tmpsrcdir" ; then
    MPIVERSION=`grep 'PATCHLEVEL ' $tmpsrcdir/include/patchlevel.h | awk '{print $3}'`
    # Make sure to remove quotes...
    mvk=`grep 'PATCHLEVEL_RELEASE_KIND' $tmpsrcdir/include/patchlevel.h | awk '{print $3}' | \
     sed -e 's/"//g'`
    mv1=`grep 'PATCHLEVEL_SUBMINOR' $tmpsrcdir/include/patchlevel.h | awk '{print $3}'`
    mvtime=`grep 'Date:' $tmpsrcdir/include/patchlevel.h | sed -e 's/^.*$Date\(.*\)\$".*$/\1/g'`
    if test -n "$mvk" ; then
        MPIVERSION="$MPIVERSION.$mv1 ($mvk) of $mvtime"
    else
        MPIVERSION="$MPIVERSION.$mv1 of $mvtime"
    fi
    echo "Configuring MPICH Version $MPIVERSION"
fi
#
# IS_HETERO is set if the device supports heterogeneous machines.
# This requires additional coding, including checking for XDR
IS_HETERO=0
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, also recognize exact --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 ;;

     -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
	PREFIX=`echo $arg | sed 's/[-a-z_]*=//'` 
	prefix=$PREFIX ;;
     -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 ;;

     -datadir=* | --datadir=* )
	datadir=`echo $arg | sed 's/[-a-z_]*=//'` ;;

     -libdir=* | --libdir=* )
	libdir=`echo $arg | sed 's/[-a-z_]*=//'` ;;

     -bindir=* | --bindir=* )
	bindir=`echo $arg | sed 's/[-a-z_]*=//'` ;;

     -sbindir=* | --sbindir=* )
	sbindir=`echo $arg | sed 's/[-a-z_]*=//'` ;;

     -includedir=* | --includedir=* )
	includedir=`echo $arg | sed 's/[-a-z_]*=//'` ;;
#
# Here begin the MPICH options
     -arch=* | --arch=* | -with-arch=* | --with-arch=*)
       package=`echo $arg|sed 's/-*[^=]*arch=//'`
       # Delete all the valid chars; see if any are left.
       if test -n "`echo $package|sed 's/[-a-zA-Z0-9_]*//g'`"; then
         print_error "configure: $package: invalid architecture name"; exit 1
       fi
       # Extract arch-specific args
       ARCH=`echo $package | sed 's/:.*//g'`
       arch_args=`echo $package | sed 's/[^:]*://g'`
       if test "$arch_args" = "$package" ; then arch_args='' ; fi
       eval "arch_`echo $ARCH|sed s/-/_/g`=1"
       ;;

     -comm=* | --comm=* | --with-comm=* | -with-comm=*)
       package=`echo $arg|sed 's/-*[^=]*comm=//'`
       # Delete all the valid chars; see if any are left.
       if test -n "`echo $package|sed 's/[-a-zA-Z0-9_]*//g'`"; then
         print_error "configure: $package: invalid communications layer name";
	  exit 1
       fi
       COMM=`echo $package|sed s/-/_/g`	
       eval "comm_`echo $package|sed s/-/_/g`=1" 
	;;

     -device=* | --device=* | --with-device=* | -with-device=*)
       package=`echo $arg|sed 's/^-*[^=]*device[=]*//'`
       # Delete all the valid chars; see if any are left.
       if test -n "`echo $package|sed 's/[-a-zA-Z0-9_]*//g'`"; then
         print_error "configure: $package: invalid device name" ; exit 1
       fi
       # Extract device-specific args
       DEVICE=`echo $package | sed 's/:.*//g'`
       device_args=`echo $package | sed 's/[^:]*://g'`
       if test "$device_args" = "$package" ; then device_args='' ; fi
       #DEVICE=$package    #|sed s/-/_/g`
       # Can't have - in variable names
       package=`echo $DEVICE | sed s/-/_/g`
       eval "device_$package=1" 
       # Handle possible synonyms
       if test -n "$device_ch_eui"; then
           device_ch_mpl=1
           DEVICE=ch_mpl
       fi
       ;;

     -mpedbg | --mpedbg | --enable-mpedbg | -enable-mpedbg)
	# Definitions of DEFS must follow the PREPARE
	MPE_MPI_EXT_C="$MPE_MPI_EXT_C dbxerr.c mpehname.c"
	MPE_MPI_EXT_O="$MPE_MPI_EXT_O dbxerr.o mpehname.o"
	ENABLE_MPEDBG="--enable-mpedbg"
	;;

     -nompedbg | --nompedbg | --disable-mpedbg | -disable-mpedbg)
	# Definitions of DEFS must follow the PREPARE
	MPE_MPI_EXT_C=""
	MPE_MPI_EXT_O=""
	;;

     -sharedlib* | --sharedlib* | --enable-sharedlib* | -enable-sharedlib*)
	# Try to build shared libraries
	sharedlib_dir=`echo A$arg|sed -e 's/A-.*sharedlib=//g'`
	if test "$sharedlib_dir" = "A$arg" ; then sharedlib_dir="" ; fi
	UseSharedLibs=1
	;;

     -nosharedlib | --nosharedlib | --disable-sharedlib | -disable-sharedlib)
	# Done't use shared libraries
	UseSharedLibs=0
	;;

     --enable-strict|-enable-strict|-strict)
	# Setup for gcc strict checking
	# To get -Wuninitialized, we need -O
	CFLAGS="$CFLAGS -O -Wall -Wstrict-prototypes -Wmissing-prototypes"
	USER_CFLAGS="$USER_CFLAGS -O -Wall -Wstrict-prototypes -Wmissing-prototypes"
	ROMIO_CFLAGS="$ROMIO_CFLAGS -O -Wall -Wstrict-prototypes -Wmissing-prototypes"
	if test -z "$CC" ; then
	    CC=gcc
	    USERCC=1
        fi
	;;

     --enable-weak-symbols|-enable-weak-symbols)
	TRY_WEAK_SYMBOLS=1
	;;
     --disable-weak-symbols|-disable-weak-symbols)
	TRY_WEAK_SYMBOLS=0
	ROMIO_ARGS="$ROMIO_ARGS --disable-weak-symbols"
	;;

     -ar_nolocal | --ar_nolocal)
	AR_LOCAL=''
	;;

     -noranlib | -no_ranlib)
        RANLIB=':'
	;;

# which device(s) - ch_shmem etc (device_args)
     -usesysv)
	usesysv=1
	;;

# end of ch_shmem /ch_lfshmem device

# This is a p4 option.  It should be an env variable or a 
#--with-device=ch_p4:-listenersig=SIGUSR2

      -listenersig=*)
         listener_sig=`echo A$arg|sed -e 's/A-listenersig=//g'`
         ;;

      -listener_sig=*)
         listener_sig=`echo A$arg|sed -e 's/A-listener_sig=//g'`
         ;;

     -dlast | --dlast)
	# Note that this is supported only for p4 now
	DLAST="-dlast"
	;;

     -p4_opts=* | --p4_opts=*)
	package="`echo $arg | sed 's/-*p4_opts=//'`"
	if test -z "$P4_OPTS" ; then
  	    P4_OPTS="$package" 
	else
	    P4_OPTS="$P4_OPTS $package"
	fi
	;;
    
## end of ch_p4 device

## globus device
     -globusdir=* | --globusdir=*)
	GLOBUSDIR="`echo $arg|sed 's/-*globusdir=//'`"
       ;;
## end of globus device

     -nodevdebug | --nodevdebug | -disable-devdebug | --disable-devdebug)
        NODEVDEBUG=1
	DEVDEBUGCFLAGS="-DMPID_DEBUG_NONE -DMPID_STAT_NONE"
	;;

     -devdebug | --devdebug | -enable-devdebug | --enable-devdebug)
        NODEVDEBUG=0
	DEVDEBUGCFLAGS=""
	;;

     -debug | --debug | --enable-debug | -enable-debug )
	debug_version=1
	;;
	
     -nodebug | --nodebug | --disable-debug | -disable-debug )
	debug_version=0
	;;

# This is should be an env variable
     -mpilibname=*)
	MPILIBNAME=`echo A$arg|sed 's/A-*mpilibname=//'`
	;;

     -no_short_longs | --no_short_longs | --disable-short-longs | -disable-short-longs)
	NOSHORTLONGS=1
	;;

     --enable-short-longs | -enable-short-longs)
	NOSHORTLONGS=0
	;;

     -memdebug | --memdebug)
	MEMDEBUG=1
	;;

     -ptrdebug | --ptrdebug)
	PTRDEBUG=1
	;;

     -tracing | --tracing)
	TRDEBUG=1
	;;

     -cross)
	cross_compiling=1
	;;

     -pkt_size=* | --pkt_size=*)
	pktsize=`echo $arg|sed 's/-*pkt_size=//'`
	PKTSIZE=$pktsize
       	DEVCFLAGS="$DEVCFLAGS -DMPID_PKT_MAX_DATA_SIZE=$pktsize"
	;;

     -limited_buffers | --limited_buffers)
	LIMITEDBUFFERS=1
	DEVCFLAGS="$DEVCFLAGS -DMPID_LIMITED_BUFFERS"
	;;

     -tiny_buffers | --tiny_buffers)
	TINYBUFFERS=1
	DEVCFLAGS="$DEVCFLAGS -DMPID_TINY_BUFFERS"
	;;

     -nolimited_buffers | --nolimited_buffers)
	LIMITEDBUFFERS=0
	DEVCFLAGS="$DEVCFLAGS -DMPID_NO_LIMITED_BUFFERS"
	;;

     -notiny_buffers | --notiny_buffers)
	TINYBUFFERS=0
	DEVCFLAGS="$DEVCFLAGS -DMPID_NO_TINY_BUFFERS"
	;;

	# This is for p4 (and p3?)
      -socksize=*|--socksize=*)
   	SOCKSIZE="`echo $arg|sed 's/-*socksize=//'`"
     	;;

     -adi_collective | --adi_collective)
	ADI_COLLECTIVE=1
	;;

     -f77idx)
	# Force POINTER_64_BITS definition
	F77IDX=1
	;;

     -f90nag | --with-f90nag | -with-f90nag)
        # Insert module 
	F90UNIX="      use f90_unix"
	FC=f90
	f90nag=1
	# -mismatch allows type mismatches in arguments.  This 
	# is necessary until we have a Fortran 90 module with
	# generic paramters
	FFLAGS="$FFLAGS -mismatch"
	# Still to do - make sure that the Fortran interface is correctly
	# selected.
        ;;

     -f95nag | --with-f95nag | -with-f95nag)
        # Insert module 
	USER_SET_GETARG=1
	F90UNIX="      use f90_unix_env"
	FC=f95
        F77GETARGDECL=""
	F90GETARGDECL=""
	#f90nag=1
	# -mismatch allows type mismatches in arguments.  This 
	# is necessary until we have a Fortran 90 module with
	# generic paramters
	#FFLAGS="$FFLAGS -mismatch"
	# Still to do - make sure that the Fortran interface is correctly
	# selected.
        ;;

      -f90=*)
	F90=`echo $arg|sed 's/-*f90=//'`
	USERF90=1
	;;
      -f90flags=*)
	USER_SET_F90FLAGS=1
	F90FLAGS=`echo $arg|sed 's/-*f90flags=//'`
	;;
      -f90inc=*)
	USER_SET_F90INC=1
	F90INC=`echo $arg|sed 's/-*f90inc=//'`	
	;;
      -f90linker=*)
	USER_SET_F90LINKER=1
	F90LINKER=`echo $arg|sed 's/-*f90linker=//'`
	;;
      -f90libpath=*)
	USER_SET_F90LIB_PATH=1
	F90LIB_PATH=`echo $arg|sed 's/-*f90libpath=//'`
	;;

      -enable-f90modules | --enable-f90modules)
	do_f90modules="yes"
	;;

      -disable-f90modules | --disable-f90modules)
	do_f90modules="no"
	;;

     -noc++ | --noc++ | --disable-c++ | -disable-c++ )
        NOCXX="nocxx"
        ;;

     --enable-c++ | -enable-c++) 
	;;

     -c++=* | --c++=*)
       # We use .. instead of \+\+ because \+ is interpreted differently
       # by various sed's
       package=`echo $arg|sed 's/-*c..=//'`
       # Delete all the valid chars; see if any are left.
       #if test -n "`echo $package|sed 's/[-a-zA-Z0-9_+]*//g'`"; then
       #  print_error "configure: $package: invalid c++ compiler name"; exit 1
       #fi
       CPP_DIR="MPI-2-C++"
       CPP_COMPILER=`echo $package`
       USERCPP=1
       # We need to use mpCC for ch_mpl device!
       if test "$CPP_COMPILER" = "xlC" -a "$DEVICE" = "ch_mpl" ; then
	    CPP_COMPILER=mpCC
       fi
       echo Compiling C++ interface with $CPP_COMPILER ;;

     -cc=* | --cc=*)
	CC=`echo $arg|sed 's/-*cc=//'`
	USERCC=1
	;;

     -fc=* | --fc=*)
	FC=`echo $arg|sed 's/-*fc=//'`
	USERF77=1
	;;

     -fortnames=*)
	# Valid values are
	# FORTRANDOUBLEUNDERSCORE
	# FORTRANUNDERSCORE
	# FORTRANCAPS
	# FORTRANNOUNDERSCORE
	FORTRANNAMES="FORTRAN`echo $arg|sed 's/-*fortnames=//'`"
	;;

     -finttype=*)
	MPI_FINT=`echo a$arg | sed -e '/a-finttype=//g'`
	;;

     -clinker=* | --clinker=*)
	CLINKER=`echo $arg|sed 's/-*clinker=//'`
	USERCLINKER=1
	;;

     -c++linker=* | --c++linker=*)
       # We use .. instead of \+\+ because \+ is interpreted differently
       # by various sed's
	CCLINKER=`echo $arg|sed 's/-*c..linker=//'`
        # We need to use mpCC for ch_mpl device!
        if test "$CCLINKER" = "xlC" -a "$DEVICE" = "ch_mpl" ; then
	    CCLINKER=mpCC
        fi
	USERCCLINKER=1
	;;

     -flinker=* | --flinker=*)
	FLINKER=`echo $arg|sed 's/-*flinker=//'`
	USERFLINKER=1
	;;

      -rsh=*)
	rshcommand=`echo A$arg|sed 's/A-rsh=//'`
	;;

      -rshnol)
	rshnol=1
	;;

     -lib=* | --lib=*)
       package="`echo $arg|sed 's/-*lib=//'`"
       USERLIB="$package" ;;

     -opt=* | --opt=*)
       package="`echo $arg|sed 's/-*opt=//'`"
       OPTFLAGS="$package" ;;

     -optcc=* | --optcc=*)
       package="`echo $arg|sed 's/-*optcc=//'`"
       OPTFLAGSC="$package" ;;

     -optf77=* | --optf77=*)
       package="`echo $arg|sed 's/-*optf77=//'`"
       OPTFLAGSF="$package" ;;

     -mpe_opts=* | --mpe_opts=*)
	package="`echo $arg | sed 's/-*mpe_opts=//'`"
	if test -z "$MPE_OPTS" ; then
  	    MPE_OPTS="$package" 
	else
	    MPE_OPTS="$MPE_OPTS $package"
	fi
	;;
    
     --with-jumpshot*)
	withval=`echo $arg | sed 's/-*with-jumpshot[=]*//g'`
	if test -z "$JUMPSHOT" ; then JUMPSHOT_OPTS="$withval" ; fi
	;;

     --without-jumpshot)
	;;

     -jumpshot_opts=* | --jumpshot_opts=*)
	package="`echo $arg | sed 's/-*jumpshot_opts=//'`"
	if test -z "$JUMPSHOT_OPTS" ; then
	    JUMPSHOT_OPTS="$package" 
	else
	    JUMPSHOT_OPTS="$JUMPSHOT_OPTS $package" 
	fi
	;;

     -cflags=* | --cflags=*)
       package="`echo $arg|sed 's/-*cflags=//'`"
       USER_CFLAGS="$package"
       ROMIO_CFLAGS="$package"
       CFLAGS="$CFLAGS $package" ;;

     -c++flags=* | --c++flags=*)
       # We use .. instead of \+\+ because \+ is interpreted differently
       # by various sed's
       package="`echo $arg|sed 's/-*c..flags=//'`"
       USER_CCFLAGS="$package"
       CCFLAGS="$CCFLAGS $package" ;;

     -fflags=* | --fflags=*)
       package="`echo $arg|sed 's/-*fflags=//'`"
       ROMIO_FFLAGS="$package"
       FFLAGS="$package" ;;

     -nompe | --nompe | -without-mpe | --without-mpe)
       MPE_DIR=""
       NOMPE=1
       echo "Make will not build MPE routines" ;;
 
     -mpe | --mpe | -with-mpe | --with-mpe )
       MPE_DIR="mpe"
       NOMPE=0
	;;
 
# Another environment variable
     -make=* | --make=*)
       package=`echo $arg|sed 's/-*make=//'`
       MAKE="$package"
	;;

     -nof77 | --nof77 | -disable-f77 | --disable-f77 )
       echo "Don't build the Fortran interfaces"
       NOF77=1
       HAS_FORTRAN=0
       CFLAGS="-DMPID_NO_FORTRAN $CFLAGS"
       romio_config_args="$romio_config_args -nof77"
       MPI_FOBJECTS="" ;;

     -nof90 | --nof90 | -disable-f90 | --disable-f90 )
	NO_F90=1 ;;
	
     -automountfix=* | --automountfix=*)
	AUTOMOUNTFIX="`echo $arg | sed 's/-*automountfix=//'`"
	;;

     -nobanner)
	nobanner=1
	;;

     -echo | --enable-echo | -enable-echo )
	set -x 
        configure_echo=1
	;;

     -noromio | --noromio | --without-romio | --with-romio=no )
        ROMIO=0
       ;;

     -with-romio* | --with-romio*)
	withval=`echo $arg | sed 's/-*with-romio[=]*//g'`
	ROMIO_ARGS="$ROMIO_ARGS $withval"
	;;

     -file_system=* | --file_system=* )
        FILE_SYSTEM="`echo $arg|sed 's/-*file_system=//'`"
       ;;

      -u | -usage | --usage | --usag | --usa | --us | --u | -help | --help )
	print_usage >& 2
       exit 1 ;;

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

     *) 
	print_error "Unrecognized configure option $arg" 
	exit 1
	;;
    esac
  fi
done]

dnl Finish the initalization
rm -f config.log
AC_PREPARE()
dnl
dnl Place the definitions into a configuration file, rather than sedding
dnl them into Makefiles.  
dnl Comment out this line (with dnl!) to force the definitions into
dnl the Makefiles.  Also, make sure that this file gets moved into the
dnl library directory before the builds take place.
AC_CONFIG_HEADER(mpichconf.h)
# We may need to delete this
PAC_FIXUP_SRCDIR
#
# There are definitions in aclocal.m4 that must be in the same directory
# as this configure file for autoconf to properly build configure.
#
# Set basic defintions based on flags set from commandline
#
if test "$ADI_COLLECTIVE" = 1 ; then
    AC_DEFINE(MPID_USE_ADI_COLLECTIVE)
fi
#
if test -n "$DEVDEBUGCFLAGS" ; then 
    DEVCFLAGS="$DEVCFLAGS $DEVDEBUGCFLAGS"
fi
#
# Definitions for special debugging features.  
if test $debug_version = 1 ; then
    # Make the code keep separate send queues.
    AC_DEFINE(MPI_KEEP_SEND_QUEUE)
fi
#
# Find the home directory if not specified
if test "X$srcdir" != "X." -a -s $srcdir/src/pt2pt/Makefile.in ; then 
    MPIR_TRIAL=$srcdir
else
    PAC_GETWD(MPIR_TRIAL,src/pt2pt/Makefile.in)
fi
MPIR_HOME=$MPIR_TRIAL
if test "$NOMPE" = 0 ; then
    MPE_DIR=$MPIR_HOME/mpe
fi
#
#
# Check that an ARCH was set
# If it wasn't set, try to guess using "bin/tarch"
#
if test -z "$ARCH" ; then 
    # First check for some special cases
    if test -n "$device_t3d" ; then 
	ARCH=cray_t3d
        arch_cray_t3d=1
    fi
fi
if test -z "$ARCH" -a -x $srcdir/bin/tarch ; then
    AC_MSG_CHECKING(for architecture)
    ARCH=`$srcdir/bin/tarch | sed s/-/_/g`
    if test -z "$ARCH" ; then
       AC_MSG_RESULT(Unknown!)
       print_error "Error: Couldn't guess target architecture, you must"
       print_error "       set an architecture type with -arch=<value>"
       exit 1
    fi
    eval "arch_$ARCH=1"
    AC_MSG_RESULT($ARCH)
fi
if test -n "$arch_sgi" ; then
    arch_IRIX=1
    ARCH=IRIX
fi
#
# When specifying a specific IRIX architecture, select the appropriate 
# compiler (and we mean compiler; these aren't flags)
if test -n "$arch_IRIX64" ; then
    arch_IRIX=1
    if test -z "$USERCC" ; then CC="cc -64" ; USERCC=1 ; fi
    if test -z "$USERCPP" ; then CPP_COMPILER="CC -64" ; USERCPP=1 ; fi
    if test -z "$USERF77" ; then FC="f77 -64" ; USERF77=1 ; fi
    if test -z "$USERF90" ; then F90="f90 -64" ; USERF90=1 ; fi
fi
if test -n "$arch_IRIX32" ; then
    arch_IRIX=1
    if test -z "$USERCC" ; then CC="cc -32" ; USERCC=1 ; fi
    if test -z "$USERCPP" ; then CPP_COMPILER="CC -32" ; USERCPP=1 ; fi
    if test -z "$USERF77" ; then FC="f77 -32" ; USERF77=1 ; fi
    if test -z "$USERF90" ; then F90="f90 -32" ; USERF90=1 ; fi
fi
if test -n "$arch_IRIXN32" ; then
    arch_IRIX=1
    if test -z "$USERCC" ; then CC="cc -n32" ; USERCC=1 ; fi
    if test -z "$USERCPP" ; then CPP_COMPILER="CC -n32" ; USERCPP=1 ; fi
    if test -z "$USERF77" ; then FC="f77 -n32" ; USERF77=1 ; fi
    if test -z "$USERF90" ; then F90="f90 -n32" ; USERF90=1 ; fi
fi
#  Handle solaris on Intel platforms, needed to get heterogeneity right in p4
if test -n "$arch_solaris86" ; then
    arch_solaris=1
    ARCH=solaris86
fi
if test -n "$arch_sgi5" ; then
    arch_IRIX5=1
    ARCH=IRIX
fi
if test -n "$arch_cray" ; then
    arch_CRAY=1
    ARCH=CRAY
fi
# check whether --comm=pvm3 was given
if test -n "$comm_pvm3"; then
  echo "PVM 3 no longer supported."
  echo "Note that MPICH was NEVER implemented on top of PVM; PVM was merely"
  echo "one of the many devices supported from the very beginning."
  exit 1
fi
#
# Check that a DEVICE was set
# If it wasn't set, try to guess using "bin/tdevice"
#
if test -z "$DEVICE" -a -x $srcdir/bin/tdevice ; then
    AC_MSG_CHECKING(device)
    DEVICE=`$srcdir/bin/tdevice $ARCH`
    if test ! -n "$DEVICE" ; then
	AC_MSG_RESULT(Unknown!)
        print_error "Error: Couldn't guess device, you must" 
        print_error "       set a device with -device=<value>" 
        exit 1
    fi
    eval "device_$DEVICE=1" 
    AC_MSG_RESULT($DEVICE)
fi
#
# Check for a VALID device
if test ! -d $srcdir/mpid/$DEVICE ; then
    print_error "$DEVICE is not a valid device!" 
    exit 1
fi
#
#
F77=${FC:-f77}
if test -n "$FC" ; then
    USERF77=1
fi
# CLINKER and FLINKER are set by PAC _GET_CC and F77
#
# Eventually we'll use install (need install-sh)
AC_PROG_INSTALL
#
# Using this autoconf macro for ranlib doesn't handle the problem 
# of 'helpful' ranlib's that issue error messages (!).  Once
# we've identified the proper compiler etc, we'll try this 
# ranlib below; if it fails, we'll replace it with ':'
#
if test -z "$RANLIB" ; then
    AC_PROG_RANLIB
fi
#
# Problem: Using the ar_local option can cause low performance; not using it
# can cause failures.  Should we try to get disk space, and pick default 
# based on a guess about the available space?
AR="ar cr$AR_LOCAL"
# CPRP is the version of cp that accepts -r and -p arguments.
# See CRAY below
CPRP="cp"
INCLUDE_PATH=""
LIB_LIST=""
# Fixup for make
PAC_MAKE_IS_GNUMAKE
PAC_MAKE_IS_BSD44
PAC_MAKE_IS_OSF
#
# WARNING: The AIX VPATH can't handle a trailing blank on the VPATH line (!)
# Use
#  find . -name 'Makefile.in' -exec grep '@VPATH@ ' /dev/null \{\} \;
# to discover these problems
PAC_MAKE_VPATH
#
# If we are relying on vpath and no vpath is set, then we must exit
if test ! -s src/pt2pt/isend.c -a -z "$VPATH" ; then
    print_error "No virtual MAKE path command found."
    print_error "You may need to set your make command"
    print_error "The GNU make (sometimes available as gnumake) can be used."
    exit 1
fi
#
# Check that a DEVICE was set or found
if test -z "$DEVICE" ; then
    print_error "You must set a device type with -device=<value>" 
    exit 1
fi
#
# Check that an ARCH was set or found
if test -z "$ARCH" ; then
    print_error "You must set an architecture type with -arch=<value>"
    exit 1
fi
#
# If some extensions are set, mark the defs
if test -n "$MPE_MPI_EXT_C" ; then
   AC_DEFINE(MPE_USE_EXTENSIONS)
fi

############################################################################
# In order to determine the correct compilers and options to use, 
# we sometimes need to get more detailed information on the system
# This is osversion, osvminor, and cputype.
# Currently, only IRIX uses this
############################################################################
PAC_GET_SPECIAL_SYSTEM_INFO

# special case 'sgi5' for use on MESHINE which is much like an SGI running
# irix 5 with r4400 chips, but does not have 'hinv', so above code doesn't
# work
if test -n "$arch_sgi5"; then
   osversion=5
   cputype=4400
   IRIXARCH="$ARCH_$osversion"
   IRIXARCH="$IRIXARCH_$cputype"
   echo "IRIX-specific architecture is $IRIXARCH"
fi

if test -n "$arch_EWS_UX_V" ; then
    # This is a Unix System V system running on MIP/SGI processors
    LIB_LIST="$LIB_LIST -lsocket -lnsl -lc"	
fi
#
# End of architecture-specific tests
#
# Create the "autoconf" style directory names...
#
# When we build with the virtual path feature, we want these directories
# to be relative to the build directory, not the source directory.
# One possibility is to redefine the Makefiles to use a local directory, 
# with the "installation" directory given by the usual autoconf symbols (e.g.,
# libdir, includedir
#
# Default includedir should use prefix.  For installation in place, we should
# just use prefix=localdir
# Alternate is to use build/<arch>/<device>/include
# Include dir for USER PROGRAMS
if test -z "$prefix" ; then
    # Should this be $MPIR_HOME/build/$ARCH/$DEVICE?
    prefix=$MPIR_HOME
fi
includedir="${prefix}/include"
AC_SUBST(includedir)
#
# We can't use a relative srcdir path because autoconf1 has a bug that
# resets top_srcdir to srcdir!
# srcdir is the directory that contains SOURCE files.
if test -z "$srcdir" -o "$srcdir" = "." ; then srcdir="$MPIR_HOME" ; fi
AC_SUBST(srcdir)
if test -z "$exec_prefix" ; then 
    exec_prefix='${prefix}'
fi
# exec_prefix is the prefix for directories containing machine-specific
# files such as libraries and executables.  For the USER
AC_SUBST(exec_prefix)
# bindir is for executable programs for the USER
if test -z "$bindir" ; then bindir=$exec_prefix/bin ; fi
AC_SUBST(bindir)
# sbindir is for executable programs for the ADMINISTRATOR
if test -z "$sbindir" ; then sbindir=$exec_prefix/sbin ; fi
AC_SUBST(sbindir)
# libdir is for libraries for the USER
if test -z "$libdir" ; then libdir="$exec_prefix/lib" ; fi
AC_SUBST(libdir)
# 
# There are two sharedlib dirs for the future, when we will distinguish
# between the common, visable everywhere (e.g., NFS mounted) location, and
# the local, visable only on the referenceing machine (e.g., UFS mounted, 
# such as /tmp) locations.  SHAREDLIB_LOCALDIR is the local location.
if test -z "$sharedlib_dir" ; then 
    sharedlib_dir=$libdir/shared
else 
    SHAREDLIB_LOCALDIR=$sharedlib_dir
fi
AC_SUBST(sharedlib_dir)
AC_SUBST(SHAREDLIB_LOCALDIR)
# prefix is used to construct the rest of the variables.
if test -z "$prefix" ; then prefix=$PREFIX ; fi
AC_SUBST(prefix)
# mandir is the root for the man pages
if test -z "$mandir" ; then mandir='${prefix}/man' ; fi
AC_SUBST(mandir)

# top_srcdir is the top level source code directory (mpich home)
if test -z "$top_srcdir" -o "$top_srcdir" = "." ; then 
    top_srcdir=$MPIR_HOME
fi
AC_SUBST(top_srcdir)
if test -z "$datadir" ; then
    datadir='${prefix}/share'
fi
AC_SUBST(datadir)
#
# libbuild_dir is used to build the libraries in before they are installed.
# binbuild_dir is for the scripts/programs
# includebuild_dir is for all user header files
rootbuild_dir=`pwd`
# 
# pwd may provide an effectively invalid directory because of the design
# of automounters
if test -n "$AUTOMOUNTFIX" ; then
    rtest=`echo $rootbuild_dir | $AUTOMOUNTFIX`
    if test -d $rtest ; then
        rootbuild_dir=$rtest
    fi
fi
for dir in lib bin include ; do
    dirname=${dir}build_dir
    eval dirvalue=\$"$dirname"
    if test -z "$dirvalue" ; then 
        eval $dirname=$rootbuild_dir/$dir
    fi
    eval dirvalue=\$"$dirname"
    if test ! -d $dirvalue ; then
        if mkdir $dirvalue ; then
	    :
        else
            print_error "Could not create directory $dirvalue"
            exit 1
        fi
    fi
done
# sharedlibbuild_dir is special;  It is set only if shared libs are
# built (see below)

AC_SUBST(libbuild_dir)
AC_SUBST(sharedlibbuild_dir)
AC_SUBST(binbuild_dir)
AC_SUBST(includebuild_dir)

# arch-specific readonly data goes? (message catalogs).  Into sysconfdir
if test -x "$sysconfdir" ; then sysconfdir="$exec_prefix/data" ; fi
AC_SUBST(sysconfdir)
if test -z "$NOCXX" ; then
    CPP_DIR="MPI-2-C++"
    if test -z "$CPP_COMPILER" ; then
	# aCC is the HPUX ANSI C++ compiler (CC is their older one)
	# We need to use xlC in preference to g++ on AIX 
	# And we need to use mpCC for ch_mpl device!
        # We need to check that the compiler actually works!
	# (note that g++ doesn't work on Solaris 2.7 (64bit) platforms)
	for program in $GXX xlC g++ c++ aCC CC cxx ; do
	    # Does program exist?
            AC_PROGRAM_CHECK(GXXTRIAL,$program,$program,)
  	    if test "$GXXTRIAL" = "xlC" -a "$DEVICE" = "ch_mpl" ; then
	        GXXTRIAL=mpCC
            fi
            # Test that this really works: compile iostream.h
            # Don't assume that g++ works (it can be installed improperly; 
            # it also doesn't work with 64-bit Solaris 2.7)
            # (the autoconf tests are too GNU-centric)
	    if test -n "$GXXTRIAL" ; then 
                cat > conftest.cc <<EOF
#include <iostream.h>
EOF
	        rm -f conftest.out
  	        if $GXXTRIAL -c conftest.cc >conftest.out 2>&1 ; then
                    CPP_COMPILER="$GXXTRIAL"
		    GXX="$GXXTRIAL"
	            echo Compiling C++ interface with $GXXTRIAL
	        else
		    print_error "C++ compiler $GXXTRIAL failed to compile a simple program"
		    print_error "C++ interface will not be built with this compiler"
	            if test -s conftest.out ; then 
		        cat conftest.out >>config.log
		    fi
	            GXX=""
		    GXXTRIAL=""
	        fi
	        /bin/rm -f conftest*
	    fi
	    # If we found a working C++ compiler, then stop looking.
	    if test -n "$GXX" ; then break ; fi
	done
    fi
    # Note that C++ doesn't support VPATH build yet.
    # It does (sort of!)
    if test -d ${top_srcdir}/MPI-2-C++ -a -n "$CPP_COMPILER" ; then
#	-a -s MPI-2-C++/configure ; then
	echo ' '
	echo 'Include C++ bindings for MPI from http://www.mpi.nd.edu/research/mpi2c++'
	echo ' '
	if test ! -d MPI-2-C++ ; then mkdir MPI-2-C++ ; fi
	buildcpp=1
    else
	# No compiler found; set the C++ directory to null
	CPP_DIR=""
    fi
fi
#
# Set Default values of variables
if test -z "$NOCXX" ; then
    if test -n "$CPP_COMPILER" -a -z "$CCLINKER" ; then
        CCLINKER="$CPP_COMPILER"
    fi
    # -O conflicted with -O3, which the C++ configure uses with IRIX64
    # Note that the C++ configure takes -O by default!

    # The following are suitable ONLY while building C++
    CPPFLAGS="-I$MPIR_HOME/$CPP_DIR/src -I`pwd`/$CPP_DIR"
    CPPLDFLAGS="-L`pwd`/$CPP_DIR/src"
    if test "$CPP_COMPILER" = "g++" ; then 
	# Particularly for LDFLAGS, -fhandle-exceptions must ONLY be used
	# for GNU g++
	AC_MSG_CHECKING([for g++ compiler exception flags])
	cat > conftest.cc <<EOF
int main () {}
EOF
	$CPP_COMPILER -c conftest.cc -fhandle-exceptions 2>conftest.out
	if test ! -s conftest.out ; then
	    CPPFLAGS="$CPPFLAGS -fhandle-exceptions"
	    AC_MSG_RESULT(-fhandle-exceptions)
	else
	    /bin/rm -f conftest.o conftest.out
	    $CPP_COMPILER -c conftest.cc -fexceptions 2>conftest.out
	    if test ! -s conftest.out ; then
	        CPPFLAGS="$CPPFLAGS -fexceptions"
		AC_MSG_RESULT(-fexceptions)
	    else
		AC_MSG_RESULT(not determined)	
	    fi
	    /bin/rm -f conftest.o conftest.out conftest.cc
	fi	
	# These LDFLAGS break configure tests that try to link when the
	# compiler is not the C++ compiler.
	# These should be CPPLDFLAGS, if those are required
        #CPPLDFLAGS="$LDFLAGS -fhandle-exceptions"
    fi
fi
if test -n "$CCC" ; then 
    CPP_COMPILER=${CCC}
fi
#
# For autoconf 2, we may need evaluated values for these routines (since
# the values for these can be Makefile expressions, rather than sh expressions)

# Check all of the devices first; they need to be known 
# before doing the transport layer
# 
# Get the C compiler, Fortran compiler, and archiver
CARCH=$ARCH
case $DEVICE in
    ch_cenju3)       CARCH=cenju3 ;;
    ch_mpl|ch_eui)   CARCH=ibmpoe ;;
    ch_meiko|meiko)  CARCH=meiko ;;
    ch_nx|nx)        CARCH=intelnx ;;
esac

# First, check for the basic CC
# Note that get_ansi_cc does a programs_check
if test -z "$USERCC" ; then
    # We do NOT want to use PROG_CC because it prefers gcc over the 
    # vendor's compiler.  This is ok for the GNU tools, but is not
    # what we want for MPICH.
    # PROG_CC simply looks for gcc and then cc.  We just flip this around.
    dnl _PROG_CC
    PAC_PROGRAMS_CHECK(CC,cc gcc)
    dnl This also eliminates the gcc short-circuit in the tests.  A good
    dnl thing too, since gcc might change!
fi
dnl GET_ANSI_CC looks for a compiler that accepts prototypes.  It tries 
dnl gcc if the selected CC doesn't accept prototypes
PAC_GET_ANSI_CC($CARCH)
if test $NOF77 = 0 ; then
    PAC_GET_F77($CARCH)
else
    HAS_F77=0
fi
# if HAS_F77 = 0, then define the same variables as if the -nof77 switch
# was given at configure time
if test "$HAS_F77" = "0" ; then
    echo "Will not  build the Fortran interfaces"
    NOF77=1
    HAS_FORTRAN=0
    CFLAGS="-DMPID_NO_FORTRAN $CFLAGS"
    romio_config_args="$romio_config_args -nof77"
    MPI_FOBJECTS="" 
fi
#
PAC_GET_AR($CARCH)
#
# Check to see if the compilers work at all (you'd be surprised!)
AC_COMPILE_CHECK([whether compiler works],,,compile_check=yes,compile_check=no)
if test "$compile_check" = "no" ; then
    print_error "Compiler $CC failed to compile a simple program!"
    exit 1 
fi
#
# Check to see if the compiler accepts prototypes
PAC_CHECK_CC_PROTOTYPES(AC_DEFINE(HAVE_PROTOTYPES))
#
# Check to see if compiler has old_style CPP concat
PAC_CHECK_CPP_CONCAT(,AC_DEFINE(OLD_STYLE_CPP_CONCAT))
#
# Check to see if it accepts const
HAVE_NO_C_CONST=0
AC_SUBST(HAVE_NO_C_CONST)
PAC_CHECK_CC_CONST(,AC_DEFINE(HAVE_NO_C_CONST)
HAVE_NO_C_CONST=1
ROMIO_CFLAGS="$ROMIO_CFLAGS -DHAVE_NO_C_CONST")

# Panic check to see if we have any compiler at all
if test -z "$CC" ; then
    print_error "Could not find a C compiler!"
    exit 1
fi
# We must NOT check for Unix variants until after we have determined the
# compiler that we will use.  This is due to a bug in autoconf: it tries to 
# use the C preprocessor directly, without invoking the compiler.
# Unfortunately, the preprocessor that it uses may bear no relationship to the
# compiler.
AC_PROG_CPP

# Check for Unix Variants
AC_AIX
AC_MINIX
#
# Before we go any farther, check for cross-compiling
# We can't do this yet, but we need to 
#
# Check to see if it accepts volatile (needed in src/nerrmsgs.c as well as
# some devices)
PAC_HAVE_VOLATILE

# Check for shared library options
if test -z "$SHAREDKIND" ; then 
    SHAREDKIND="ignore"
fi
if test -z "$SHAREDKIND_FOR_TV" ; then
    SHAREDKIND_FOR_TV="ignore"
fi
#
# This needs a script that makes the tests and returns the answer; 
# we can later let autoconf figure out how to include the needed info
# One option is to use libtool if it is available.
if test "$UseSharedLibs" = 1 -o "$debug_version" = 1 ; then
    # Options are -fPIC for C (gcc)
    # -KPIC (Solaris SunPro)
    # (none) (AIX, but making the library itself is a mess, and allows -KPIC
    #         as an option!)
    # (none) (Alpha, but allows -fPIC as an option!)
    #
    # There are also needed linker options.  For example, under solaris, 
    # -R<mpich-lib-dir>:$LD_RUN_PATH is needed; this should be determined
    # at mpicc LINK time.  These are provided by the makesharedlib script
    if test "$CC" != "gcc" -a "$ARCH" = "rs6000" ; then
        NEEDS_CC_SHARED_OPT=0
    fi
    if test "$CC" != "gcc" -a "$ARCH" = "alpha" ; then
        NEEDS_CC_SHARED_OPT=0
    fi

    if test "$NEEDS_CC_SHARED_OPT" = 1 ; then 
        # CHECK_COMPILER_OPTION adds option if successful
        CFLAGSSAV="$CFLAGS"
        if test -z "$CC_SHARED_OPT" ; then
            PAC_CHECK_COMPILER_OPTION(-fPIC,CC_SHARED_OPT=-fPIC;SHAREDKIND="gcc")
            # Check that we can link with that option
  	    # Note that this does NOT work with SunOS
        fi
        if test -z "$CC_SHARED_OPT" ; then
            PAC_CHECK_COMPILER_OPTION(-KPIC,CC_SHARED_OPT=-KPIC)
            if test $ARCH = "solaris" ; then
	        SHAREDKIND=solaris
	        # This only works with some compilers.
	        # Also note that this overrides LD_RUN_PATH
		# -R is used for RUNTIME linking (dlopen)
	        #LDFLAGS="$LDFLAGS -R$libdir/shared"
	    elif test $ARCH = "IRIX" -o $ARCH = "IRIX64" ; then
		# for testing only
		SHAREDKIND=irix
            fi
        fi
	CFLAGS="$CFLAGSSAV"
        # This isn't quite right, but it will work for some systems 
        # Export the shared option to the MPI-2-C++ configure
        CXXFLAGS_FOR_SHARED=$CC_SHARED_OPT
    fi
    if test "$SHAREDKIND" != "ignore" ; then
        # Fortran choices
	# (none)
        # -PIC (SunOS)
        # -KPIC (Solaris, IRIX)
	# -fPIC (g77)
	# This is made more compilicated by the fact that some systems
	# accept -PIC, but for very different options (e.g., absoft).
	#
        # CHECK_COMPILER_OPTION adds option if successful
        FFLAGSSAV="$FFLAGS"
        if test -z "$FC_SHARED_OPT" ; then
            PAC_CHECK_FC_COMPILER_OPTION(-PIC,FC_SHARED_OPT=-PIC)
        fi
        if test -z "$FC_SHARED_OPT" ; then
            PAC_CHECK_FC_COMPILER_OPTION(-fPIC,FC_SHARED_OPT=-fPIC)
        fi
        if test -z "$FC_SHARED_OPT" ; then
            PAC_CHECK_FC_COMPILER_OPTION(-KPIC,FC_SHARED_OPT=-KPIC)
        fi
	# Handle the special case of a predefined value of <none needed>
	if test "$FC_SHARED_OPT" = "none" ; then
	    FC_SHARED_OPT=""
	fi
        FFLAGS="$FFLAGSSAV"
    fi
    # Check that the shared libraries work
    export CC
    export CLINKER
    SHARED_LIB_PATH="-L."
    export SHARED_LIB_PATH
    SHARED_LIB_UTIL="${top_srcdir}/util/makesharedlib -noecho -kind=$SHAREDKIND -local -link -noverbose"
    SHARED_LIB_SEARCH_PATH_LEADER=`${top_srcdir}/util/makesharedlib -kind=$SHAREDKIND -getpathspec`
    AC_SUBST(SHARED_LIB_SEARCH_PATH_LEADER)
    SHARED_LIB_SEARCH_PATH="${SHARED_LIB_SEARCH_PATH_LEADER}`pwd`"
    PAC_SHARED_LIBS_OK(,SHAREDKIND=ignore)
    # Note that configure uses CFLAGS for compiling and linking !
    # Add the shared option only if we're building shared libraries
    # (the shared option is also needed when building the totalview
    # dynamically loadable queue library).
    SHAREDKIND_FOR_TV="$SHAREDKIND"
    if test "$SHAREDKIND" = "ignore" ; then 
	UseSharedLibs=0
	SHARED_LIB_SEARCH_PATH_LEADER=""
	SHARED_LIB_PATH=""
    fi
    if test "$UseSharedLibs" = 1 ; then 
	# If CFLAGS will have the SHARED_OPT, the TV build won't need its
        # own copy.  If we aren't building the shared libs, then 
        # we set the OPT_FOR_TV in the other branch of the if.
        CFLAGS="$CC_SHARED_OPT $CFLAGS"
        FFLAGS="$FC_SHARED_OPT $FFLAGS"
    else
        CC_SHARED_OPT_FOR_TV="$CC_SHARED_OPT"
	CC_SHARED_OPT=""
	FC_SHARED_OPT=""
	CXXFLAGS_FOR_SHARED=""
        SHAREDKIND="ignore"
    fi
    # If we can't find the appropriate options, we should switch to 
    # UseSharedLibs=0
fi
if test $UseSharedLibs = 1 ; then
    if test -z "$sharedlibbuild_dir" ; then 
        sharedlibbuild_dir="$libbuild_dir/shared"
    fi
    if test ! -d $sharedlibbuild_dir ; then
        if mkdir $sharedlibbuild_dir ; then
            :
        else
            print_error "Could not create directory $sharedlibbuild_dir"
            exit 1
	fi
    fi
fi

AC_SUBST(CC_SHARED_OPT)
AC_SUBST(CC_SHARED_OPT_FOR_TV)
AC_SUBST(CXXFLAGS_FOR_SHARED)
AC_SUBST(SHAREDKIND)
AC_SUBST(SHAREDKIND_FOR_TV)
#
#
# Various systems have known special needs (particularly libraries);
# get thos here
#    
DEFAULT_MACHINE=$DEVICE
#
#
# we could have some "blessed" devices using an dnl include
# statement, which would simplify some of the setup.  However, it increases
# the inter-relationships between the main configure and the individual 
# devices.
#
device_setupfile="setup_$DEVICE"
if test -f $srcdir/mpid/$DEVICE/$device_setupfile ; then
    # Source the file.  This way it inherits all variables and can
    # change any that it wants.  The alternative is to have an explicit
    # import/export list.
    # If this device has any special needs, such as #defines, it should
    # use a configure with a header file specific for that device, rather
    # than including them in the master mpichconf.h file.
    # Should set DEFAULT_MACHINE type
    # Create any device-specific configuration header files
    # This is run in the TOP directory; if the setup script needs to run in 
    # the device directory, it should change to that directory
    #
    # The setup program should also be careful to remove any 
    # configuration-specific files (such as config.h files) from both the 
    # local directory and the source directory in case a VPATH build is 
    # being done.
    echo "Running device-specific setup program"
    # Note that configure uses "set dummy $p" this resets the positional 
    # parameters.  We clear this with
    set dummy
    shift
    if test ! -d mpid/$DEVICE ; then
	if test ! -d mpid ; then mkdir mpid ; fi
        mkdir mpid/$DEVICE
    fi
    # We must run this from the relative directory, since we may be building
    # a build tree in another location (. != $srcdir)
    . $srcdir/mpid/$DEVICE/$device_setupfile
    if test $? != 0 ; then
	print_error "Setup of $DEVICE failed!  Aborting configure"
	exit 1
    fi
fi

#
# ch_shmem/ch_lfshmem have a setup_ch_shmem file 
#
# meiko and ch_meiko have a setup file
#
# ch_mpl has a setup file
#
# Globus has a setup file (previously BEFORE the CC/FC find steps)

dnl if test -n "$device_ch_spp" ; then
dnl    DEFAULT_MACHINE="convex_spp"
dnl   if test -z "$OPTFLAGS" ; then
dnl	# If optimization is turned on, the wrong code is generated for
dnl	# some operations with unsigned chars.
dnl	OPTFLAGS=-O0
dnl   fi
dnl   AC_RETSIGTYPE
dnl   PAC_HAVE_VOLATILE
dnl   PAC_SIGNALS_WORK
dnl   #  
dnl   LIB_LIST="$LIB_LIST -lcnx_syscall /lib/libail.sl"
dnl fi
#
# The following is shared with some devices.  How should we do this?
# It should be a common macro PAC _WORKING_ANON_MMAP
# Later devices use /dev/zero trick
if test \( -n "$device_ch_p4" -a "$COMM" = "shared" \) ; then 
    MMAP=0
    PAC_HAVE_ANON_MMAP(MMAP=1,AC_DEFINE(HAVE_NO_ANON_MMAP))

    # We need to check that semctl is ok.
    PAC_SEMGET_WORKS(SEMGET=1,SEMGET=0,print_error)

    if test $MMAP = 0 -a "$SEMGET" = 0; then
        print_error "Configure detected that both anonymous mmap and semget fail."
        print_error "Configuring MPICH for shared memory may cause problems!"
    fi
fi
dnl

if test -n "$device_ch_p4"; then
  P4EXT=""
fi
if test -n "$device_ch_p4mpd"; then
  P4EXT="mpd"
  if test "$COMM" = "ch_p4mpd"; then
    COMM="ch_p4"
    echo "Setting COMM to ch_p4 for ch_p4mpd device"
  fi
fi

#
# Architecture-specific tests.  These should go into aclocal files (e.g., 
# acarch_$archname, which aclocal.m4 loads with include
# PAC _OS_VERSION (already in special system macro)
# PAC _ARCH_CC_FLAGS
# PAC _ARCH_FC_FLAGS
# PAC _ARCH_SPECIFIC
# 
# Note that some of these tests need to be made more generic
# (e.g., FORTRAN_SPECIAL_POINTER)
if test -n "$arch_IRIX"; then
   # We now have to look at  all sorts of things to determine the
   # various flags.  We need to set both the CFLAGS and various options
   # for the linkers (by setting CLINKER and FLINKER).
   # The OS version and chipset were determined above so that they could
   # be used to set the P4_ARCH if necessary.
   #
   # Latest information we have is that (thanks to Winfrid Tschiedel 
   # <Winfrid.Tschiedel@mch.sni.de>):
   #  cputype          Instruction sets
   #  R4X00            -mips2 -mips3 (mips2 requires -32)
   #  R5000, R8000 and R10000 : -mips2 (-32) and -mips3 (-n32 or -64)
   #                            -mips4 (-n32 or -64)
   # Also, IRIX 6.2 supports R4X00 only in 32 bit mode (requires -n32)
   # EXCEPT for R4400, which also supports -64.
   # In 6.2, the defaults SEEM to be -32 -mips 2
   # but you may need -64 -mips3 OR -mips 4 OR -n32 -mips3 or -mips4
   # Also, some systems REQUIRE -non_shared and others REQUIRE NOT 
   # -non_shared.  
   # 
   # Finally, compilation with optimization may stress the linker;
   # include -TENV:large_GOT=ON in this case
   #
   if test $osversion = 4 ; then
	# Nathan's tests showed that we needed this.
	RANLIB="ar ts"
   elif test $osversion = 5 ; then
        # Turn off warnings about long doubles not being supported.
	if test "$CC" != "gcc" ; then
            CFLAGS="$CFLAGS -woff 728"
	    # Other useful woff values are: 852,635,813,831,835
        fi
   elif test $osversion = 6 ; then
#       these flags settings are handled by including MDEPCFLAGS from p4
	SYMTYPE=""
        # We should not use/need these tests (I just had to add cputype =
        # 12000) 
	if test $cputype = 8000 -o $cputype = 10000 -o $cputype = 12000 ; then
	    if test -n "$arch_IRIX64" ; then
	        SYMTYPE="-64 -mips4"
            elif test -n "$arch_IRIXN32" ; then
		SYMTYPE="-n32"
            else 
		SYMTYPE="-32"
            fi
	elif test $cputype -gt 4000 ; then
	    if test -n "$arch_IRIX64" ; then
		SYMTYPE="-64 -mips3"
            elif test -n "$arch_IRIXN32" ; then
		SYMTYPE="-n32"
            else 
		SYMTYPE="-32"
            fi
        else
	    # According to winfrid.tschiedel@mch.sni.de, need -n32 for R4000
	    SYMTYPE="-n32"
            # Not "-n32 -mips3"?
        fi
	if test -n "$P4_MDEPFFLAGS" ; then
	    # This no longer works.  At least at MCS, the Fortran compiler
	    # won't accept these.
	    addflags=0
	    PAC_CHECK_FC_COMPILER_OPTION($P4_MDEPFFLAGS,addflags=1)
	    if test $addflags = 1 ; then 
                FFLAGS="$FFLAGS $P4_MDEPFFLAGS"
	    fi
        fi
        # Warning flags are > 1000
#       CFLAGS="$CFLAGS -woff 1152,1174,1184"
#       1184 not in the p4 list
        if test "$CC" != "gcc" ; then
            CFLAGS="$CFLAGS -woff 1184,1174"
        fi
	# Check whether we need to add SYMTYPE to CFLAGS and FFLAGS
	hasarg=`echo A$CFLAGS | sed -n -e '/-n32/p' -e '/-32/p' -e '/-64/p'`
#       override SYMTYPE computed above (2/21)
#       !!!! overriding the SYMTYPE eliminates the ability to select compiler
#       option for the symbol type.  Instead, we MANDATE that IRIX64 implies
#       -64 and IRIXN32 implies -n32.
        SYMTYPE=""
	if test -z "$hasarg" ; then
            CC="$CC $SYMTYPE"
	    F77="$F77 $SYMTYPE"
	    CLINKER="$CC $SYMTYPE"
	    FLINKER="$F77 $SYMTYPE"
#	else 
#	    hasarg=`echo A$CLINKER | sed -n -e '/-n32/p' -e '/-32/p' -e '/-64/p'`
#	    if test -z "$hasarg" ; then
#		# We need to make the linker compatible with the compiler.
#	    fi
	fi
   fi
   echo "Messages about long doubles not being supported are being suppressed"
   dnl AC_HAVE_ LIBRARY ( sun )
fi

# for symm_ptx, add the ptx_ifile to  LIB_LIST
if test -n "$arch_symm_ptx"; then
  LIB_LIST="$LIB_LIST $MPIR_HOME/util/ptx_ifile"
fi

# check whether --arch=intelnx was given
# Use this for both i860 and Delta
if test -n "$arch_intelnx"; then
  DEFAULT_MACHINE="i860"
  # Note that RANLIB may be set incorrectly if we are cross-compiling...
  RANLIB=true
  # inteldelta is used to select the appropriate args to killproc...
  DEVCFLAGS="$DEVCFLAGS -Dinteldelta"
  #
  # X11 includes are in /usr/ipsc/XDEV/i860/include-ipsc/X11
  # X11 libs are in /usr/ipsc/XDEV/i860/lib-coff
  # at least on one system
fi

# check whether --arch=paragon was given
if test -n "$arch_paragon"; then
  DEFAULT_MACHINE="paragon"
  #OPTFLAGS="-O"
  # Note that RANLIB may be set incorrectly if we are cross-compiling...
  RANLIB=true
  #echo "If you get errors about killproc, uncomment this line"
  #DEVCFLAGS="$DEVCFLAGS -DPARAGON_HAS_NO_KILLPROC"
fi


if test -n "$arch_CRAY"; then
   # The CRAY cp doesn't even support -r (!!) but at least there 
   # is a version that does work.
   if test -x /usr/ucb/cp ; then
       CPRP="/usr/ucb/cp"
   else
       print_error "Using default cp for copy; install may fail if -r and -p"
       print_error "switches are not supported."
   fi
   # It might be better to use AR="bld qvz" than the regular ar clr
   DEVCFLAGS="$DEVCFLAGS -DMPID_FLOAT_CRAY"
   # We might want to add
   # -DMPIR_FORT_INT_T=long
   # to the defines.
   # According to Laurie Costello <lmc@cray.com>, the Triton needs this
   # definition
dnl
   # If tested code does NOT compile, then define _TWO_WORD_FCD
   AC_COMPILE_CHECK([whether TWO_WORD_FCDs are used],
[#include <fortran.h>],[void  *buf;_fcd temp;temp = _fcdtocp(buf);],
compile_check=yes,compile_check=no)
if test "$compile_check" = "no" ; then
    TEMP_CFLAGS=$CFLAGS
    CFLAGS="-D_TWO_WORD_FCD $CFLAGS"
    AC_COMPILE_CHECK([whether program compiles if _TWO_WORD_FCD is defined ],
[#include <fortran.h>],[void  *buf;_fcd temp;temp = _fcdtocp(buf);],
compile_check=yes,compile_check=no)
    if test "$compile_check" = "no" ; then
	print_error "You may have problems compiling the Fortran interface",
	print_error "specifically calls to  _fcdtocp"
    elif test "$compile_check" = "yes" ; then
        AC_DEFINE(_TWO_WORD_FCD)
    fi
    CFLAGS=$TEMP_CFLAGS
fi
   # 
dnl   if test -n "$arch_CRAYTS" ; then 
dnl       AC_DEFINE(_TWO_WORD_FCD)
dnl   fi
fi
#
# The compilers are in /mpp/bin (at least on some systems)
# You may also need 
# setenv TARGET cray-t3d
# Also need -lsma library
if test -n "$arch_cray_t3d"; then
   DEFAULT_MACHINE="cray_t3d"
   LIB_LIST="$LIB_LIST -lsma"
   RANLIB=true
   # dbxerr not supported by T3D (-mpedbg)
   MPE_MPI_EXT_C="mpehname.c"
   MPE_MPI_EXT_O="mpehname.o"
   AC_DEFINE(MPI_NO_MPEDBG)
   # The CRAY cp doesn't even support -r (!!) but at least there 
   # is a version that does work.
   if test -x /usr/ucb/cp ; then
       CPRP="/usr/ucb/cp"
   else
       print_error "Using default cp for copy; install may fail if -r and -p"
       print_error "switches are not supported."
   fi
   #  ASMFILES_O="shmem_stack.o get_stack.o"
   # Some users needed /mpp/bin/asm, others /opt/ctl/bin/cam
   for asm in /mpp/bin/cam /opt/ctl/bin/cam /mpp/bin/asm ; do
       if test -s $asm ; then
           ASM=$asm
           break
       fi
   done
   if test -z "$ASM" ; then 
        print_error "Cannot find assembler needed to build MPICH"
        print_error "Neither /mpp/bin/cam, /opt/ctl/bin/cam,  nor "
        print_error "/mpp/bin/asm is available."
        exit 1
   fi
   # 
   # This is needed for the Fortran interfaces (also for the triton CRAY TS)
   AC_DEFINE(_TWO_WORD_FCD)
fi

# In default (pre-ANSI) mode, nested #if's cause most of the file to
# be SILENTLY skipped.  
if test -n "$arch_hpux" -o -n "$arch_sppux" ; then
    if test -n "$device_ch_shmem" -o -n "$device_ch_lfshmem" ; then
       ASMFILES_O="amem.o"
       DEVCFILES="mem.c"
       DEVOFILES="mem.o"
    fi
    if test -n "$device_ch_shmem" -a -n "$comm_convex_spp" ; then
       DEVCFILES="shmem1stbar.c cnxCxdb.c cnxQuerySC.c cnxGlobalop.c cnxCopy.c"
       DEVOFILES="shmem1stbar.o cnxCxdb.o cnxQuerySC.o cnxGlobalop.o cnxCopy.o"
    fi
    # We can also remove +U77 and -lU77 from the p4 lib/defs.all file.
fi

#
# We need to check for this - it is probably the Fujitsu problem with
# attributes.
if test -n "$arch_UXPM" ; then
    # This asserts that Fortran passes functions by passing the address of the
    # pointer to the function.
    # We really need a TEST for this
    AC_DEFINE(FORTRAN_SPECIAL_FUNCTION_PTR)
    # Suggested values for these are
    #CFLAGS=-O
    dnl    #FFLAGS=-Oe,-U -Aabe ( Parameter e is not supported on  uxp/m )
    FLINKER=frt
    FLIBS="$(FLIB_PATH) $(LIB_LIST)"
fi
if test -n "$arch_uxpv" ; then
    # This asserts that Fortran passes functions by passing the address of the
    # pointer to the function.
    # We really need a TEST for this
    AC_DEFINE(FORTRAN_SPECIAL_FUNCTION_PTR)
    # Suggested values for these are
    #CFLAGS=-O
    # Thanks to Winfrid Tschiedel <Winfrid.Tschiedel@mch.sni.de> for
    # this information
    dnl FLINKER="ld -dy -J /usr/ccs/lib/crt0.o /usr/lang/lib/fj90rt0.o /usr/ccs/lib/values-Xt.o"
    FLINKER="frt  -sc -Wl,-dy" # it works already and it is close the final solution
    # This isn't quite correct, but at least this is a place to put this 
    # information.
dnl    FLIBS="$(FLIB_PATH) $(LIB_LIST)  -lfj90 -lfj90fv -lfj90f -lfjsamp -lm -lelf        -lsocket -lnsl -lgen -lpx -ljsp -lvfl -lc"
    FLIBS="$(FLIB_PATH) $(LIB_LIST)"
fi
#
# Not all versions of gcc support -munalign-doubles!
#if test -n "$arch_sun4" -o -n "$arch_solaris" ; then
#    if test "$CC" = "gcc" -a "$NOF77" = 0 ; then
#        CC="$CC -munaliged-doubles"
#    fi
#fi

dnl if test -n "$arch_SX4" ; then 
dnl     CFLAGS="$CFLAGS -pvctl,nomsg -DCHAR_PTR_IS_ADDRESS"
dnl fi
# This really needs to look at arches of the form SX_4_float[012] and
# SX_4_float2_int64
issx4=`expr "$ARCH" : "\(SX_4_float\)[012]"`
if test "$issx4" = "SX_4_float" ; then
    arch_SX4=1
fi
if test -n "$arch_SX4" ; then 
    # The -pvctl,nomsg option suppresses "vec inf: Unvectorized loop"
    # messages from the compiler.  Need to test that this is a valid
    # option....
    # Also note that it causes -hobjlst (assembly listing) to silently fail.
    dnl CFLAGS="$CFLAGS -pvctl,nomsg -DCHAR_PTR_IS_ADDRESS"
    if test -n "$device_ch_lfshmem" ; then
       ASMFILES_O="vtest1.o syncvset0.o syncvset1.o vmemcpy.o tslock.o tsunlock.o tslock_init.o"
       DEVCFLAGS="$DEVCFLAGS -DLOCKS_PICKED -DUSE_TSLOCKS -DMPID_USE_SX4_VOPS"
#
	if test -z "$sx4int" ; then
	    if test "$ARCH" = SX_4_float2_int64 ; then
		sx4int=int64
	    else
	        sx4int=int32
	    fi
	fi
       for file in $ASMFILES_O
       do
          files=`echo $file | sed -e "s/.o$/.s/"`
          rm -f mpid/$DEVICE/$files
          cp mpid/$DEVICE/sx4_$sx4int/$files mpid/$DEVICE/$files
       done
    else
       DEVCFLAGS="$DEVCFLAGS -DLOCKS_PICKED -DUSE_SEMOP"
    fi
    DEVCFLAGS="$DEVCFLAGS -DHAVE_SHMAT=1 -DHAVE_SEMOP=1 -DRETSIGTYPE=void -DHAVE_SIGACTION -DMPI_SX_4 -DMPID_SETUP_SIGNALS"
dnl    # We've learned that if Fortran is selected, you should use Fortran to
dnl    # link with.
dnl    if test "$USERCLINKER" != 1 -a "$NOF77" != 1 -a -n "$FLINKER" ; then 
dnl	CLINKER="$FLINKER"
dnl    fi
fi

#
# Finally, we are ready to check to see if we are cross-compiling.
#
if test $cross_compiling = 0 ; then
    AC_CROSS_CHECK()
fi
#
if test $cross_compiling = 1 ; then
    if test $DEVICE = ch_shmem -o $DEVICE = ch_p4 -o $DEVICE = ch_p4mpd \
                               -o $DEVICE = ch_lfshmem ; then
        print_error "Configure was unable to compile and run a simple program."
    fi
fi
#
# Some devices use gettimeofday.  If this is one of them, check to see 
# what form it is
PAC_IS_GETTIMEOFDAY_OK(,DEVCFLAGS="$DEVCFLAGS -DUSE_WIERDGETTIMEOFDAY")

# Look for sigaction routine (instead of signal)
# This is used in one of the TEST programs (sigchk.c)
# FIXME!!! (move to test configure?)
PAC_CHECK_HEADERS(signal.h)
AC_HAVE_FUNCS(sigaction)
AC_COMPILE_CHECK(for struct sigaction,[#include <signal.h>],[
struct sigaction act; sigaddset( &act.sa_mask, SIGINT );],sigaction_ok="yes",sigaction_ok="no")
#
# Test for weak symbol support...
# We can't put # in the message because it causes autoconf to generate
# incorrect code
HAS_WEAK_SYMBOLS=0
AC_SUBST(HAS_WEAK_SYMBOLS)
if test $TRY_WEAK_SYMBOLS = 1 ; then
  AC_MSG_CHECKING(for weak symbol support)
  AC_TRY_LINK([
#pragma weak PFoo = Foo
int Foo(a) { return a; }
],[return PFoo(1);],has_pragma_weak=1)
  if test "$has_pragma_weak" = 1 ; then
    AC_MSG_RESULT([pragma weak])
    HAS_WEAK_SYMBOLS=1
    AC_DEFINE(HAVE_WEAK_SYMBOLS)
    AC_DEFINE(HAVE_PRAGMA_WEAK)
  else
    AC_TRY_LINK([
#pragma _HP_SECONDARY_DEF Foo  PFoo
int Foo(a) { return a; }
],[return PFoo(1);],has_pragma_hp_secondary=1)
    if test "$has_pragma_hp_secondary" = 1 ; then 
        AC_MSG_RESULT([pragma _HP_SECONDARY_DEF])
        HAS_WEAK_SYMBOLS=1
        AC_DEFINE(HAVE_WEAK_SYMBOLS)
        AC_DEFINE(HAVE_PRAGMA_HP_SEC_DEF)
    else
        AC_TRY_LINK([
#pragma _CRI duplicate PFoo as Foo
int Foo(a) { return a; }
],[return PFoo(1);],has_pragma_cri_duplicate=1)
        if test "$has_pragma_cri_duplicate" = 1 ; then
	    AC_MSG_RESULT([pragma _CRI duplicate x as y])
	    HAS_WEAK_SYMBOLS=1
	    AC_DEFINE(HAVE_WEAK_SYMBOLS)
	    AC_DEFINE(HAVE_PRAGMA_CRI_DUP)
        else    
            AC_MSG_RESULT(no)
        fi
    fi
  fi
fi
#
#
# Under IRIX (some version) __Argc and __Argv gave the argc,argv values
AC_MSG_CHECKING([for alternative argc,argv names])
AC_TRY_LINK([
extern int __Argc; extern char **__Argv;],[return __Argc;],
AC_MSG_RESULT(__Argc),
AC_MSG_RESULT(none found))

#
# Check for remote shell program (not needed for all devices)
# FIXME: Who needs this?
if test -z "$rshcommand" ; then
    PAC_PROGRAMS_CHECK(RSHCOMMAND,remsh rsh ssh)
    # should check that it works; allow ssh as another fallback
    rshcommand="$RSHCOMMAND"
fi
#
# Check for perl and perl version
PAC_PROGRAMS_CHECK(PERL,perl5 perl,,,PERLFULLPATH)
if test -n "$PERL" ; then
    PERL="$PERLFULLPATH"
    changequote(,)
    perlversion=`$PERL -v | grep 'This is perl' | \
	sed -e 's/^.*version *\([0-9]\).*$/\1/'`
    changequote([,])
    # Should do a test first for ch_p4 etc.
    if test "$perlversion" != 5 ; then
        echo "Some scripts require perl version 5, which configure did not find."
        echo "You can set the environment variable PERL to contain the "
        echo "location of perl version 5."
	echo "Configure believes that $PERL is version $perlversion ."
	PERL=""
    fi
    AC_SUBST(PERL)
fi
#
# Check for Fortran
if test $HAS_F77 = 0 -a "$NOF77" = 0 ; then   
    NOF77=1
    HAS_FORTRAN=0
    AC_DEFINE(MPID_NO_FORTRAN)
    dnl CFLAGS="$CFLAGS -DMPID_NO_FORTRAN"
    MPI_FOBJECTS="" 
elif test $HAS_F77 != 0 ; then  
    #
    dnl hpux's Fortran compiler f77 (but not the POSIX version fort77) does
    dnl not accept -L <dir> for library search path.
    if test -z "$FLIB_PATH" -a -z "$LIB_PATH" ; then
        FLIB_TEST_PATH="$libbuild_dir"
    elif test -z "$LIB_PATH" ; then
        FLIB_TEST_PATH=`echo $FLIB_PATH | sed -e 's/-L//g'`
    elif test -z "FLIB_PATH"  ; then
       FLIB_TEST_PATH=`echo $LIB_PATH | sed -e 's/-L//g'`
    else
        FLIB_PATH="$FLIB_PATH $LIB_PATH"
        FLIB_TEST_PATH=`echo $FLIB_PATH | sed -e 's/-L//g'`
    fi
    dnl   FLIB_PATH=`echo $FLIB_PATH | sed -e 's/-L/-Wl,-L,/g'`	
    dnl   FLIB_PATH_LEADER="-Wl,-L,"
    dnl   FLIB_LIST=`echo $FLIB_LIST | sed -e 's/-L/-Wl,-L,/g'`
    msg_yes=no
    rm -f conftest.*
    cat > conftest.f <<EOF
        program main
        end
EOF
    # First, create the .o file with F77.  Then try to link it with
    # FLINKER.
    if $F77 $FFLAGS -c -o conftest.o conftest.f >conftest.out 2>&1 ; then
        AC_MSG_CHECKING(if -L should be used to link library paths )
	echo "$FLINKER $FFLAGS -o conftest conftest.o -L$FLIB_TEST_PATH" >> config.log
        if $FLINKER $FFLAGS -o conftest conftest.o -L$FLIB_TEST_PATH >> config.log 2>&1 ; then 
            if test -x conftest ; then 
	        AC_MSG_RESULT(yes)
  	        msg_yes=yes
                FLIB_PATH_LEADER="-L"	
	        FLIB_PATH=$FLIB_TEST_PATH
            fi  
        fi  
        if test "$msg_yes" = "no" ; then  
  	    AC_MSG_RESULT(no)
            AC_MSG_CHECKING([if -Wl,-L, should be used to link library paths] )
	    echo "$FLINKER $FFLAGS -o conftest conftest.o -Wl,-L$FLIB_TEST_PATH" >> config.log
            if $FLINKER $FFLAGS -o conftest conftest.o -Wl,-L$FLIB_TEST_PATH >> config.log 2>&1 ; then 
                if test -x conftest ; then  
  	            AC_MSG_RESULT(yes)
	            msg_yes=yes
                    FLIB_PATH_LEADER="-Wl,-L,"
		    FLIB_PATH=$FLIB_TEST_PATH	
                fi  
            fi  
        fi 
        if test "$msg_yes" = "no" ; then   
             AC_MSG_RESULT(no)
	     print_error "Could not determine how to link library paths"
        fi	    
    else 
	AC_MSG_RESULT([Could not compile a simple Fortran program!])
	if test -s conftest.out ; then cat conftest.out >>config.log ; fi
	NOF77=1
        AC_DEFINE(MPID_NO_FORTRAN)
        MPI_FOBJECTS="" 
	HAS_F77=0
    fi
fi
#
# Test again in case we failed to build a simple program
if test "$NOF77" != 1 ; then
    #
    # Grumph.  Here are a punch of different approaches
    # We have several axes the check:
    # Name of routine
    # Library to link with (none, -lU77 (HPUX), -lg2c (LINUX f77))
    trials="0 1 2 3 4 5 6"
    # "0" means (none)
    triallibs="0 -lU77 -lg2c"
    # Trialopts is for systems where you
    # need to add *compile-time* options to get command line arguments to
    # work.  
    # +U77 is needed by HP Fortran to access getarg etc.
    # The -N109 was used for getarg before we realized that GETARG
    # was necessary with the (non standard conforming) Absoft compiler
    # (Fortran is monocase; Absoft uses mixedcase by default)
    trialopts="0 +U77 -N109"
    #
    AC_MSG_RESULT([Checking for how to get command-line arguments in Fortran])
    msg_yes="no"
    for trial in $trials ; do 
	if test "$msg_yes" = "yes" ; then break ; fi 
        case $trial in 
	0) # User-specified values, if any
	   if test -z "$F77GETARG" -o -z "$F77IARGC" ; then continue ; fi
	   AC_MSG([Trying environment variables F77GETARG etc.])
	   ;;
	1) # Standard practice, uppercase (some compilers are case-sensitive)
	   F90UNIX=""
	   F77GETARGDECL="external GETARG"
	   F77GETARG="call GETARG(i,s)"
	   F77IARGC="IARGC()"
	   AC_MSG([Trying GETARG and IARGC])
	   ;;
	2) # Standard practice, lowercase
	   F90UNIX=""
           F77GETARGDECL="external getarg"
	   F77GETARG="call getarg(i,s)"
	   F77IARGC="iargc()"
	   AC_MSG([Trying getarg and iargc])
	   ;;
	3) # Posix alternative
	   F90UNIX=""
	   F77GETARGDECL="external pxfgetarg"
	   F77GETARG="call pxfgetarg(i,s,l,ier)"
	   F77IARGC="ipxfiargc()"
	   AC_MSG([Trying pxfgetarg and ipxfiargc])
	   ;;
	4) # Nag f90_unix_env module
	   F90UNIX="        use f90_unix_env"
	   F77GETARGDECL=""
	   F77GETARG="call getarg(i,s)"
	   F77IARGC="iargc()"
	   AC_MSG([Trying f90_unix_env module])
	   ;;
        5) # Nag f90_unix module
	   F90UNIX="        use f90_unix"
	   F77GETARGDECL=""
	   F77GETARG="call getarg(i,s)"
	   F77IARGC="iargc()"
	   AC_MSG([Trying f90_unix module])
	   ;;
	6) # user spec in a file
	   if test -s f77argdef ; then
		. ./f77argdef
	       AC_MSG([Using definitions in the file f77argdef])
	   else
		continue
	   fi
	   ;;
	esac
	# Create the program
        cat > conftest.f <<EOF
        program main
$F90UNIX
        integer i
        character*20 s

        $F77GETARGDECL
        $F77GETARG
        i=$F77IARGC
        end
EOF
	for fopt in $trialopts ; do 
            if test "$msg_yes" = "yes" ; then break ; fi 
	    FFLAGS_SAV="$FFLAGS"
	    case $fopt in 
		0) ;;
		*) FFLAGS="$FFLAGS $fopt" ;;
	    esac
 	    # Try to compile
            echo "$F77 $FFLAGS -c -o conftest.o conftest.f" >> config.log
            if $F77 $FFLAGS -c -o conftest.o conftest.f >> config.log 2>&1 ; then
	        if `cat conftest.out | grep -i absoft > absoft.out 2>&1` ; then
	            if test -n absoft.out ; then
	                F77_COMPILE_FLAG=1
                    fi
	        fi
	        rm -f absoft.out
	    else
	        # Could not compile sample program
	        AC_MSG_RESULT([could not compile test program])
	        continue
	    fi
	    # We could *compile* the program.  Can we link it?	
	    # Now for the possible libraries
            FLIBSAVE="$FLIBS"
	    for triallib in $triallibs ; do
  	        if test "$msg_yes" = "yes" ; then break ; fi 
                rm -f conftest
                # msg_yes set to yes if the command line routine is found
                msg_yes=no
	        if test $triallib != "0" ; then 
		    FLIBS="$triallib $FLIBS" 
		    AC_MSG([linking with library $triallib])
	        fi
		
                echo "$FLINKER $FFLAGS -o conftest conftest.o $FLIBS" >> config.log
                if $FLINKER $FFLAGS -o conftest conftest.o $FLIBS >> config.log 2>&1 ; then
                    if test -x conftest ; then
	                AC_MSG_RESULT(yes)
                        msg_yes=yes
                    fi
  	        else
	            if test -s conftest.out ; then cat conftest.out >> config.log ; fi
                fi
	        rm -f conftest.out conftest
                # This format and library choice didn't work
                if test "$msg_yes" = "no" ; then   
	             AC_MSG_RESULT(no)
	             FLIBS="$FLIBSAVE"
	         fi
             done
	     # This set of flags did not work with any library
	     if test "$msg_yes" = "no" ; then
	         # Just in case
                 FLIBS="$FLIBSAVE"
                 FFLAGS="$FFLAGS_SAVE"
             fi
         done
     # End of loop over tests
     done
     if test "$msg_yes" = "no" ; then
	F90UNIX=""
	F77GETARGDECL=""
	# We wanted to generate an error message, but we can't
	# put single quotes into a variable
	F77GETARG='print *, "'"'"'"ERROR - CANNOT FIND COMMAND LINE ARGS"'"'"'"'
	F77IARGC=1
	print_error "Command line options will not work with Fortran"
	print_error "You will not be able to run MPI programs "
	print_error "if MPI_INIT is called from Fortran."
     fi
     rm -f conftest*
     # Check to see if need absoft compiler flag -f.  This option makes the
     # absoft compiler not distinguish between upper and lower case.  Unless
     # of course if they change this (which they will undoubtedly do)
     if test "$F77_COMPILE_FLAG" = "1"; then
	AC_MSG_CHECKING([if compiler flag -f is needed])
cat > conftest.f<<EOF
      program main
      call MPI_TEST()
      end

      subroutine mpi_test()
      return
      end
EOF
         # Try to compile
         if $F77 $FFLAGS -f -c -o conftest.o conftest.f > conftest.out 2>&1 ; then
	     # Try to link 
	     if $FLINKER $FFLAGS -o conftest conftest.o $FLIBS > conftest.out 2>&1 ; then
	         AC_MSG_RESULT(yes)
	         F77_EXTRA_FLAG=-f
	     else
                 AC_MSG_RESULT(no)
	     fi
	 else
             AC_MSG_RESULT(no)
         fi
     fi
#
     PAC_GET_FORTNAMES
     if test $HAS_FORTRAN = 0 ; then
         dnl CFLAGS="$CFLAGS -DMPID_NO_FORTRAN"
	 AC_DEFINE(MPID_NO_FORTRAN)
         MPI_FOBJECTS=""
     elif test -n "$WDEF" ; then
         CFLAGS="$CFLAGS $WDEF"
dnl      elif test -n "$FORTRANNAMES" ; then
dnl	 AC_DEFINE($FORTRANNAMES)
     fi
fi  #elif

if test $HAS_FORTRAN != 0 ; then
    # FINCARG is the argument used to specify an include directory.
    # It is set in the following test
    PAC_FORTRAN_HAS_INCDIR($MPIR_HOME/include,FINC="-I$includebuild_dir",)
    # some systems support FINC="-Wf,-I@MPIR_HOME@/include" (SGI for one)
    # If I can find others, I'll try them.  For this, I'll need
    # to test for it (the test above tries -I$1 for a file created for the test)

    PAC_FORTRAN_HAS_EXCLAM_COMMENTS(fixupmpif=yes,fixupmpif=no)

    # Check that pmpi_wtime and pmpi_wtick can be in the mpif.h file
    AC_MSG_CHECKING([that unused externals are ok])
    rm -f conftest*
    cat > conftest.f <<EOF
        program main
        external bar
        end
EOF
    if $F77 $FFLAGS -o conftest conftest.f >conftest.out 2>&1 ; then
	AC_MSG_RESULT(yes)
	MPIFPMPI=",PMPI_WTIME, PMPI_WTICK"
    else 
	AC_MSG_RESULT(no)
	MPIFPMPI=""
	if test -s conftest.out ; then cat conftest.out >> config.log ; fi
	print_error "Removed PMPI_WTIME and PMPI_WTICK from mpif.h"
    fi   
    AC_SUBST(MPIFPMPI)
    rm -f conftest* 
    # Check for extra Fortran types
    PAC_TEST_FORTTYPES
    # Defines FORT_INT1=1, FORT_INT2=1, FORT_INT4=1, FORT_INT8=1,
    # FORT_INT16=1, FORT_REAL4=1, 
    # FORT_REAL8=1, FORT_REAL16=1, FORT_COMPLEX8=1, FORT_COMPLEX16=1,
    # FORT_COMPLEX32=1, FORT_DOUBLE_COMPLEX=1 if the types are available.
    # For each defined type, find the corresponding C MPI_DATATYPE.
    # If none can be found, use MPI_DATATYPE_NULL.
    for c_type in char short int long "long long" float double "long double"; do
	PAC_GET_TYPE_SIZE($c_type,typelen)
    done
    if test -z "$FORT_REAL_LEN" ; then
        PAC_FORTRAN_GET_REAL_SIZE(fort_real_len)
	if test -z "$fort_real_len" ; then
	    print_error "Unable to determine the length of a FORTRAN real"
	    print_error "You can set the environment variable FORT_REAL_LEN"
	    print_error "with the number of bytes in a FORTRAN real and rerun"
	    print_error "configure."
	fi
    else 
	fort_real_len=$FORT_REAL_LEN
    fi
    # Set the corresponding MPI_Datatypes
    char_mpi=1
    short_mpi=4
    int_mpi=6
    long_mpi=8
    long_long_mpi=13
    float_mpi=10
    double_mpi=11
    long_double_mpi=13
    # Warning: float_cplx is Fortran COMPLEX, not (float,float)
    float_cplx_mpi=23
    # Warning: double_cplx is Fortran DOUBLE COMPLEX, not (double,double)
    double_cplx_mpi=24
    for len in 1 2 4 8 16 ; do
        eval testval=\$"FORT_INT$len"
        AC_MSG_CHECKING(for Fortran INTEGER*$len)
        found=0
	if test "$testval" = 1 ; then
	    for c_type in char short int long "long_long" ; do
		eval typelen=\$"${c_type}"_len
		if test $len = "$typelen" ; then
		    # Fortran type FORT_INT$len corresponds to C type
		    # $ctype
		    eval FORT_INT$len=\$"${c_type}_mpi"
		    AC_MSG_RESULT(found)
		    found=1
		    break
		fi 
            done
        fi
        if test $found = 0 ; then
	    eval FORT_INT$len=0
            AC_MSG_RESULT(not supported)
        fi
    done
    for len in 4 8 16 ; do
	# Use len2 for Complex.
        len2=`expr $len + $len`
	lenby2=`expr $len / 2`
        eval testval=\$"FORT_REAL$len"
        AC_MSG_CHECKING(for Fortran REAL*$len and COMPLEX*$len2)
        found=0
	if test "$testval" = 1 ; then
	    for c_type in float double "long_double" ; do
		eval typelen=\$"${c_type}"_len
		if test $len = "$typelen" ; then
		    # Fortran type FORT_REAL$len corresponds to C type
		    # $ctype
		    eval FORT_REAL$len=\$"${c_type}_mpi"
		    # Notes that we may not have been able to determine 
		    # fort_real_len
		    # The corresponding Complex type
		    if test "$fort_real_len" = "$len" ; then 
			eval FORT_COMPLEX$len2=$float_cplx_mpi
		    elif test "$fort_real_len" = "$lenby2" ; then
			eval FORT_COMPLEX$len2=$double_cplx_mpi
		    else
			eval FORT_COMPLEX$len2=0
		    fi
		    AC_MSG_RESULT(found)
		    found=1
		    break
		fi 
            done
        fi
        if test $found = 0 ; then
	    eval FORT_REAL$len=0
            eval FORT_COMPLEX$len2=0
            AC_MSG_RESULT(not supported)
        fi
    done
    AC_SUBST(FORT_INT1)
    AC_SUBST(FORT_INT2)
    AC_SUBST(FORT_INT4)
    AC_SUBST(FORT_INT8)
    AC_SUBST(FORT_INT16)
    AC_SUBST(FORT_REAL4)
    AC_SUBST(FORT_REAL8)
    AC_SUBST(FORT_REAL16)
    AC_SUBST(FORT_COMPLEX8)
    AC_SUBST(FORT_COMPLEX16)
    AC_SUBST(FORT_COMPLEX32)
fi
#
# Check for Fortran 90
# Currently, we allow Fortran 90, but build for Fortran 77.  
# The following definitions must be provided for Fortran 90
# F90     - Name of F90 compiler
# F90INC  - How to specify include/use module directory (often -I<dir>)
# F90FLAGS - Flags to F90 for compilation
# F90LINKER - Name of F90 linker (often $F90)
# F90LIB_PATH - How to specify library search paths (often -L<dir>)
# If F90 is defined but not the other items, take them from the
#   Fortran 77 values
if test -z "$F90" -a -z "$NO_F90"; then
    if test "$f90nag" = 0 ; then
        # Try to find an F90 compiler
        PAC_PROGRAMS_CHECK(F90,f95 f90 xlf90 pgf90)
        if test "$F90" = "xlf90" -a $DEVICE = "ch_mpl" -a \
		-z "$F90LINKER" ; then
	    # When using ch_mpl, we must use the mpxlf script to link with
	    F90LINKER="mpxlf"
	    F90TESTLINKER="$F90"
        fi
    fi
fi
if test -n "$F90" ; then  
    F90_SUFFIX="f90"
    # ???? Why is there a test for f90nag = 0?  Is this because 
    # when set, the NAG f90 is used for f77?
    if test "$f90nag" = 0 ; then 
        if test -z "$USER_SET_F90INC" -a -z "$F90INC" ; then 
	    F90INC=$FINC
        fi
        if test -z "$USER_SET_F90FLAGS" -a -z "$F90FLAGS" ; then
	    # We should check these individually; at least things like
            # Fortran shared library flags.
	    F90FLAGS="$FFLAGS"
        fi
        if test -z "$USER_SET_F90LINKER" -a -z "$F90LINKER" ; then
	    F90LINKER="$F90"
        fi
	PAC_CHECK_F90_COMPILER_OK(,F90="")
	if test -n "$F90" ; then
	    PAC_FORTRAN_INT_KIND(F90_INT8_KIND)
	    # Identify the Addresskind and offsetkind
	    OFFSET_KIND=$F90_INT8_KIND
	    PAC_GET_TYPE_SIZE(void *,address_size)
	    PAC_FORTRAN_INT_KIND(ADDRESS_KIND,$address_size)
	    if test "$OFFSET_KIND" = "-1" ; then
		# default to a 4 byte kind
		PAC_FORTRAN_INT_KIND(OFFSET_KIND,4)
            fi
	    AC_SUBST(ADDRESS_KIND)	    
	    AC_SUBST(OFFSET_KIND)
        fi
	# If we could not find acceptable kind values, turn off f90 
	# support.  Also, we require the MPI-IO routines as part of the
        # Fortran90 choice module.
	if test "$OFFSET_KIND" = "-1" -o "$ADDRESS_KIND" = "-1" -o \
	        "$ROMIO" != 1 ; then
	    do_f90modules="no"
	    NO_F90=1
        fi
	if test "$do_f90modules" = "yes" ; then
            echo "Setting up F90 Module support"
	    if test ! -d f90modules ; then mkdir f90modules ; fi
  	    eval top_srcdir_val="$top_srcdir"
            (cd f90modules ; export F90 ; export MPIR_HOME ; export VPATH ; \
	   	    export libbuild_dir ; export includebuild_dir ; \
		    export MAKE ; F90LINKER="$F90TESTLINKER" ; \
		    export F90LINKER ; \
 	   	    $top_srcdir_val/f90modules/configure --with-mpich)
 	    F90MODINC=`$MAKE -f f90modules/Makefile f90modflag`
	    F90SUFFIX=`$MAKE -f f90modules/Makefile f90suffix`
	fi
	AC_SUBST(F90MODINC)
	AC_SUBST(F90SUFFIX)
    fi
else
    # We need valid values for these because they are in the mpif.h file, 
    # even if Fortran 90 is not available.
    ADDRESS_KIND=4
    OFFSET_KIND=4
fi
if test -z "$F90TESTLINKER" ; then 
    F90TESTLINKER="$F90LINKER"
fi
# In order to prevent problems with Makefiles, we define the
# F90 and F90_SUFFIX
if test -z "$F90_SUFFIX" ; then F90_SUFFIX="f90" ; fi
if test -z "$F90" ; then F90="false" ; fi
AC_SUBST(F90)
AC_SUBST(F90INC)
AC_SUBST(F90FLAGS)
AC_SUBST(F90LINKER)
AC_SUBST(F90LIB_PATH)
AC_SUBST(f90nag)
AC_SUBST(F90_SUFFIX)
#
# Check that the C compiler will generate code that will work with Fortran.
# Fortran requires that doubles be accessible on float/integer boundaries.
# The following C-only code attempts to test this by forcing accesses to
# doubles on an odd number int boundary.
#
# The test program can core dump.  To avoid having core files around,
# we create a non-writable core file
if test $HAS_FORTRAN != 0 ; then
    # If we're cross-compiling, we can't actually tell.  Be quiet and hope
    # for the best.
    # we create an empty core file with no write permission to avoid problems
    # caused by dumping core.
    touch core
    chmod a-w core
    CC_F77_SAFE=1
    AC_MSG_CHECKING([that C compiler allows unaligned doubles])
    PAC_TEST_PROGRAM([
void fetch_double();
int main( argc, argv )
int argc;
char **argv;
{
int p[4];
double *p_val;
fetch_double( (double *)&(p[0]) );
p_val = (double *)&(p[0]);
if (*p_val != 1.0) return 1;
fetch_double( (double *)&(p[1]) );
p_val = (double *)&(p[1]);
if (*p_val != 1.0) return 1;
return 0;
}
void fetch_double( v )
double *v;
{
*v = 1.0;
}
],CC_F77_SAFE=1,CC_F77_SAFE=0)
    if test $CC_F77_SAFE = 0 ; then 
        AC_MSG_RESULT(no!)
	if test -n "$MPICH_WARNING_SEP" ; then echo '>'$MPICH_WARNING_SEP ; fi
        print_error "Your C compiler $CC does not support unaligned accesses"
        print_error "to doubles.  This is required for interoperation with "
        print_error "Fortran (the Fortran standard requires it)."
	if test -n "$MPICH_WARNING_SEP" ; then echo '<'$MPICH_WARNING_SEP ; fi
        # See if the compiler is gcc and allows munaligned-doubles
        hasopt=0
        if test "$CC" = "gcc" ; then
            PAC_CHECK_COMPILER_OPTION(-munaligned-doubles,hasopt=1,hasopt=0)
            if test "$hasopt" = 1 ; then
		AC_MSG(Adding -munaligned-double to CFLAGS)
                CFLAGS="$CFLAGS -munaligned-doubles"
            fi
        fi
        if test "$hasopt" = 0 ; then
	if test -n "$MPICH_WARNING_SEP" ; then echo '>'$MPICH_WARNING_SEP ; fi
        print_error "Some C compilers support special options that allow"
	print_error "unaligned access; for gcc, try -munaligned-doubles."
	print_error "Configure will continue, but some Fortran programs"
	print_error "may fail.  Another option is to use a Fortran option"
	print_error "that forces all double precision quantities to be"
	print_error "double aligned; for SunOS, the option is -dalign."
	if test -n "$MPICH_WARNING_SEP" ; then echo '<'$MPICH_WARNING_SEP ; fi
        fi
    else
	AC_MSG_RESULT(yes)
    fi
    # Remove the core file that we created
    chmod +w core
    rm -f core
fi
# Check for byte ordering
PAC_WORDS_BIGENDIAN
#
# Check for xdr available and properly installed (our FreeBSD machines
# have incorrect xdr header files, for examples).  Currently, we just
# set a dummy function body and see if rpc/xdr.h is available and
# can be included.
#
# Just to complicate things, some systems have "xdr.h" that is complete
# and can be used by itself; more frequently, xdr.h does NOT include
# definitions that it requires!  rpc.h seems to be more reliable.
#
if test "$IS_HETERO" = 1 ; then
    AC_COMPILE_CHECK("XDR includes and functions",[#include <rpc/rpc.h>],[
    int a=1;
    ],HAS_XDR=1,HAS_XDR=0)
    if test "$HAS_XDR" = 1 ; then
	AC_DEFINE(HAS_XDR)
    else 
        print_error  "XDR not available on this system" 
    fi
fi
# Check for the functions that may be needed by the ADI to implement
# Processor_name.  Save these defines in a special place.
SAVEDEFS="$DEFS"
DEFS=""
AC_FUNC_CHECK(uname,AC_DEFINE(HAVE_UNAME)haveuname=1)
PAC_CHECK_HEADERS(netdb.h)
AC_FUNC_CHECK(gethostbyname,AC_DEFINE(HAVE_GETHOSTBYNAME)havegethostbyname=1)
if test -z "$havegethostbyname" ; then
    # Try again after adding libnsl.  We do it this way instead of just
    # testing for nsl because some systems (IRIX for one) generate many
    # warning messages when libnsl and libc are combined (!)
    AC_HAVE_LIBRARY(nsl,LIB_LIST="$LIB_LIST -lnsl";havelibnsl=1)
    if test "$havelibnsl" = 1 ; then
	echo "checking for gethostbyname in libnsl"
        AC_FUNC_CHECK(gethostbyname,AC_DEFINE(HAVE_GETHOSTBYNAME)havegethostbyname=1)
    fi
fi
# If we have uname and gethostbyname, we can skip getdomainname ...
if test "$haveuname" != 1 -o "$havegethostbyname" != 1 ; then
    AC_HAVE_FUNCS(gethostname sysinfo)
    #
    # systeminfo is needed for sysinfo 
    PAC_CHECK_HEADERS(sys/systeminfo.h)
    #
    # getdomainname is special BECAUSE IT MAY BE USELESS (!Network computing 
    # indeed - stuff like this is why Windows95/NT WILL WIN). 
    AC_CHECK_FUNC(getdomainname,has_getdomainname=1,has_getdomainname=0)
    if test $has_getdomainname = 1 -a $cross_compiling = 0 ; then
        PAC_PROGRAM_CHECK(has_domainname,domainname,1,0,d_domainname)
        PAC_PROGRAM_CHECK(has_hostname,hostname,1,0,d_hostname)
        PAC_PROGRAM_CHECK(has_rup,rup,1,0,d_rup)
        # Form hostname.domainname, do rup to it
        # rup may not be enabled, but short of running a program to lookup the
        # local host, there does not seem to be a better alternative.
        #
        if test $has_domainname = 1 -a $has_hostname = 1 -a $has_rup = 1 ; then
changequote(,)
            fullhost=`$d_hostname | sed -e 's/^\([^\.]*\)\..*/\1/'`
changequote([,])
#	    echo $fullhost
            fullhost="${fullhost}.`$d_domainname`"
            response=`($d_rup $fullhost 2>&1) | egrep '(Unknown host|translation failed)'`
#	    echo $fullhost
            if test -n "$response" ; then
   print_error "The getdomainname system routine has been rendered USELESS"
   print_error "on your system.  This is not a bug and will not affect"
   print_error "MPICH.  Some MPE routines (particularly those that"
   print_error "interact with X Windows) may not work."
            else
                AC_DEFINE(HAVE_GETDOMAINNAME)
	    fi
        fi
    fi
fi
GETNAME_DEFS="$DEFS"
DEFS="$SAVEDEFS"
#
# Check for message archive routines (to be used for internationalization)
#
SAVEDEFS="$DEFS"
DEFS=""
# 
# Some systems have these in /usr/xpg2lib/libxpg.a (our Suns did)
# The includes (for nl_types) might be in /usr/xpg2include 
# This hasn't been handled yet.
AC_HAVE_FUNCS(catopen catclose catgets)
# Will need to generate binary form of file
# !!! We have a report that on Cray, gencat is a completely different command
# (parallel fscks?).  We're supposed to use 
# caterr -c cat_file msg_file.  Instead, we'll skip it
GENCAT="true"
if test -n "$device_td3" ; then 
 # May try caterr -c cat_file msg_file
 print_error "Configure needs the gencat program to generate message catalogs"
 print_error "Some (all?) Cray T3D systems have a program named gencat"
 print_error "that performs file system checks instead.  For this reason,"
 print_error "message catalogs will not be created for the T3D device."
 print_error "You may be able to use the caterr command instead."
 print_error "MPICH will work without the message catalogs (though the"
 print_error "ability to generate error messages in languages other than"
 print_error "US English will be lost)."
else
 PAC_PROGRAM_CHECK(has_gencat,gencat,1,0,d_gencat)
 GENCAT="gencat"
 if test $has_gencat = 1 ; then
    AC_DEFINE(HAVE_GENCAT)
    PAC_CHECK_HEADERS(nl_types.h)
    # Why separate NLS_DEFS?
    NLS_DEFS="$DEFS"
    # Having a separate message catalog directory allows unification 
    # of message catalogs.
    messagecat_dir=${messagecat_dir:-'${libdir}'}
    AC_SUBST(messagecat_dir)
 fi
fi
AC_SUBST(GENCAT)
DEFS="$SAVEDEFS"

AC_STDC_HEADERS

SAVEDEFS="$DEFS"
DEFS=""
PAC_CHECK_HEADERS(stdlib.h string.h)
PAC_CHECK_HEADERS(unistd.h)
PAC_CHECK_HEADER(stdarg.h,[AC_DEFINE(HAVE_STDARG_H)
havestdarg=1])
#
# It isn't enough to check for stdarg.  Even gcc doesn't get it right;
# on some systems, the gcc version of stdio.h loads stdarg.h WITH THE WRONG
# OPTIONS (causing it to choose the OLD STYLE va_start etc).
#
# The original test tried the two-arg version first; the old-style
# va_start took only a single arg.
# This turns out to be VERY tricky, because some compilers (e.g., Solaris) 
# are quite happy to accept the *wrong* number of arguments to a macro!
# Instead, we try to find a clean compile version, using our special
# TRY_COMPILE_CLEAN command
#
USE_STDARG=0
AC_SUBST(USE_STDARG)
#
AC_MSG_CHECKING([that stdarg is oldstyle])
PAC_TRY_COMPILE_CLEAN([#include <stdio.h>
#include <stdarg.h>],
[int func( int a, ... ){
int b;
va_list ap;
va_start( ap );
b = va_arg(ap, int);
printf( "%d-%d\n", a, b );
va_end(ap);
fflush(stdout);
return 0;
}
int main() { func( 1, 2 ); return 0;}],check_compile)
case $check_compile in 
    0)  AC_MSG_RESULT(yes)
        AC_DEFINE(USE_STDARG)
	AC_DEFINE(USE_OLDSTYLE_STDARG)
        USER_CFLAGS="$USER_CFLAGS -DUSE_STDARG -DUSE_OLDSTYLE_STDARG"
	USE_STDARG=1
	;;
    1)  AC_MSG_RESULT([hmm, warnings from compiler.  Trying newstyle])
	;;
    2)  AC_MSG_RESULT(no)
	;;
esac

if test -n "$havestdarg" -a "$USE_STDARG" != 1 ; then
    AC_MSG_CHECKING([stdarg is correct])
    PAC_TRY_COMPILE_CLEAN([
#include <stdio.h>
#include <stdarg.h>],[
int func( int a, ... ){
int b;
va_list ap;
va_start( ap, a );
b = va_arg(ap, int);
printf( "%d-%d\n", a, b );
va_end(ap);
fflush(stdout);
return 0;
}
int main() { func( 1, 2 ); return 0;}],check_compile)
case $check_compile in 
    0)  AC_MSG_RESULT(yes)
        AC_DEFINE(USE_STDARG)
        USE_STDARG=1
        USER_CFLAGS="$USER_CFLAGS -DUSE_STDARG"
	;;
    1)  AC_MSG_RESULT([yes with warnings])
        AC_DEFINE(USE_STDARG)
        USE_STDARG=1
        USER_CFLAGS="$USER_CFLAGS -DUSE_STDARG"
	;;
    2)  AC_MSG_RESULT(no)
	;;
esac
fi

# FIXME: In the above, this should go into the include files for the 
# device-specific case.

PAC_MALLOC_RETURNS_VOID()
USER_CFLAGS="$USER_CFLAGS $DEFS"
# FIXME: In the above, this should go into the include files for the 
# device-specific case.  IS THIS NEEDED?!!
DEFS="$SAVEDEFS $DEFS"
#
# System is used only in MPE; i860's do not support it.
# Should only be in mpe configure? (actually used in dbxerr.c?)
AC_HAVE_FUNCS(system)
#
# Nice is used only in env/init.c
AC_HAVE_FUNCS(nice)
#
# Look for headers that might have memset()....
# (string.h might also, but it is also needed by MPE)
PAC_CHECK_HEADERS(memory.h)
#
# Turn off F77
# One problem with this is that some part of the ar will fail.  Lets hope
# it isn't fatal.  We've tried to fix this by defining MPI_FOBJECTS
# as the object files created from Fortran.
if test $NOF77 = 1 ; then
  F77="echo no Fortran compiler"
  FLINKER="$F77"
fi
#
#
# Check for erroneous C compilers
broken=0
do_test=1
if test $cross_compiling = 1 ; then
   if test "$CC" = mpcc ; then 
	TESTCC=xlc
   elif test "$CC" = mpCC ; then
        TESTCC=xlC
   else
        do_test=0
   fi
else 
    # If not cross compiling, testcc is just the compiler
    TESTCC="$CC"
fi
# 
# Should eventually use a file like $file.run to see if the program should
# be run or just compiled.  And eventually, this should be run EARLY,
# before checking for things like functions and include files.
#
PAC_CHECK_COMPILER_OK(cc_works=1,cc_works=0)
if test $cc_works = 0 ; then
    print_error "Could not compile a simple file with $CC!"
    print_error "Check for license and path restrictions on $CC."
    exit 1
fi
if test $NOF77 = 0 ; then
    PAC_CHECK_F77_COMPILER_OK(,NOF77=1;HAS_FORTRAN=0;HAS_F77=0;
       AC_DEFINE(MPID_NO_FORTRAN)
       dnl CFLAGS="-DMPID_NO_FORTRAN $CFLAGS"
       F77="echo no Fortran compiler"
       FLINKER="$F77"
       MPI_FOBJECTS="")
    # 
    # This test will allow us to make MPI_BOTTOM a 0 pointer on
    # some (many?) systems.  Currently here just for testing.
    if test $NOF77 = 0 ; then
        PAC_FORTRAN_HAS_POINTER(f77_pointer=1,f77_pointer=0)
    fi
    # In order to use the Fortran linker to with C programs, it may be
    # necessary to add some libraries from the C linker.  We HOPE that we
    # we can use the -v option with the compiler to extract the libraries
    # KNOWN SYSTEMS WITH GRATUITOUS DIFFERENCES
    # Solaris SunPro compiler wants -# instead of -v
    # Code from /tmp/petsc/bin/findftnlibs ...
    # Create the sample programs
    #trap  '/bin/rm -f t1$$.c t1$$.f t1$$c t1$$u t1$$f t1$$.o t1$$' 0 2 3 10
    cat > t1$$.f <<EOF
      program main
      end
EOF
    cat > t1$$.c <<EOF
      int main() { return 0; }
EOF
    cecho_option="-v"
    # Compile and link with the -v option; extract library options
    # Some compilers will generate multiple refs.  We may need to 
    # know about that, but for now, we depend on finding unique differences
    # We split on , as well as blank because some systems (AIX4) use exec 
    # notation with , separating args.
    # We can't split on , and blank, since for some systems (Solaris), the
    # comma is important in some options.
    # Rather, we try to identify
    # , separated: ... /bin/ld(ld,options,moreoptions)
    # blank separated: ... bin/ld option option ...
    # Another option to look for: -Y P,dirlist (Solaris ld)
    # If this is found, we need to convert it to -L ..
    $CC -o t1$$ $cecho_option t1$$.c 2>&1 | grep '/ld' > t1$$c1
    if test ! -s t1$$c1 ; then
        AC_MSG_CHECKING(for C compiler option to echo steps)
	cecho_option='-#'
        $CC -o t1$$ $cecho_option t1$$.c 2>&1 | grep '/ld' > t1$$c1
        if test -s t1$$c1 ; then
	    AC_MSG_RESULT([$cecho_option])
        else
	    # We can't put # in an MSG_RESULT string
	    pound="#"
            AC_MSG_RESULT([unknown (neither -v (common) or -$pound (unusual))])
        fi
    fi
    # 
    # Try to detect , separated form
    echo "Checking for C libraries needed with Fortran linker" >>config.log
    echo "C linker output:" >>config.log
    cat t1$$c1 >>config.log
    if grep 'ld,' t1$$c1 >/dev/null 2>&1 ; then
        cat t1$$c1 | tr ',' '\012' | \
            sed -n -e '/^-l/p' -e '/^-L/p' | \
  	    sed -e 's/^P,/-P,/g' | sort | uniq > t1$$c
    else
        cat t1$$c1 | sed -e 's/-Y P,/-L/g' | \
	    tr ' ' '\012' | \
            sed -n -e '/^-l/p' -e '/^-L/p' | \
	    sed -e 's/^P,/-P,/g' | sort | uniq > t1$$c
    fi
    $F77 -o t1$$ -v t1$$.f 2>&1 | grep '/ld' > t1$$f1
    echo "Fortran linker output:" >>config.log
    cat t1$$f1 >> config.log
    if grep 'ld,' t1$$f1 >/dev/null 2>&1 ; then
        cat t1$$f1 | tr ',' '\012' | \
            sed -n -e '/^-l/p' -e '/^-L/p' -e '/^P,/p' | \
	    sed -e 's/^P,/-P,/g' | sort | uniq > t1$$f
    else
        cat t1$$f1 | sed -e 's/-Y P,/-L/g' | \
	    tr ' ' '\012' | \
            sed -n -e '/^-l/p' -e '/^-L/p' -e '/^P,/p' | \
	    sed -e 's/^P,/-P,/g' | sort | uniq > t1$$f
    fi
    # For lines of the form -La:b:c, convert them into -La\\-Lb\\-Lc
    # where \\ is a newline
    if grep '\-L.*:' t1$$f >/dev/null 2>&1 ; then
	rm -f t1$$f2 t1$$f3
	grep '\-L.*:' t1$$f | sed -e 's/:/ -L/g' | tr ' ' '\012' | \
		sed -e '/^-L *$/d' > t1$$f2
	grep -v '\-L.*:' t1$$f > t1$$f3
	cat t1$$f2 t1$$f3 | sort | uniq > t1$$f
	rm -f t1$$f2 t1$$f3
    fi
    if grep '\-L.*:' t1$$c >/dev/null 2>&1 ; then
	rm -f t1$$c2 t1$$c3
	grep '\-L.*:' t1$$c | sed -e 's/:/ -L/g' | tr ' ' '\012' | \
		sed -e '/^-L *$/d' > t1$$c2
	grep -v '\-L.*:' t1$$c > t1$$c3
	cat t1$$c2 t1$$c3 | sort | uniq > t1$$c
	rm -f t1$$c2 t1$$c3
    fi

    # Now, remove common libraries/search paths
    cat t1$$c t1$$f | sort | uniq -u > t1$$u
    #
    # Finally, since the ORDER is important, we extract those lines from
    # the original t1$$f file
    #echo 'u'
    #cat t1$$u
    #echo 'f'
    #cat t1$$f
    #echo 'c'
    #cat t1$$c
    #set -x
    #echo 'results'
    foundany=0
    # Find lines in the C linker output that are not in the Fortran linker 
    # output
    for line in `cat t1$$c` ; do
        #line=`echo $line | sed -e 's/-/\\\\-/'`
        pureline=`echo $line | sed -e 's/-/./'`
#        if grep "'""$line\$""'" t1$$u 2>&1 >/dev/null ; then
        if grep "$pureline\$" t1$$u 2>&1 >/dev/null ; then
            # Special case: P,dirpath needs to be expanded
	    matchnum=`expr "$line" : '-P,'`
    	    if test "$matchnum" -eq 3 ; then
	        newline=`echo $line | sed -e 's/^-P,/-L/g' -e 's/:/ -L/g'`
	        line=$newline
            fi
	    $F77 -o t1$$ t1$$.f $line 2>&1 | grep 'undefined reference' > tout
	    if test ! -s tout ; then
	    	echo "Fortran linker needs $line"
           	FLIB_LIST="$FLIB_LIST $line"
            	foundany=1
	    else
	        print_error "$line which is in the C linker"
		print_error "does not work with Fortran programs and is not"
	        print_error "being added to the Fortran linker line.  This"
	        print_error "may cause problems when linking Fortran programs." 
	    fi
	    /bin/rm tout
        fi
    done
    /bin/rm -f t1$$.c t1$$.f t1$$c t1$$u t1$$f t1$$.o t1$$ t1$$c1 t1$$f1 tout

    # Add a test here for MPI_FINT
    PAC_FORTRAN_GET_INTEGER_SIZE(f_integer_size)
    if test "$f_integer_size" != "unavailable" ; then
	AC_MSG_CHECKING([for C integer type for MPI_Fint])
        AC_MSG_RESULT()
	for c_type in int long short "long long" ; do
	    PAC_GET_TYPE_SIZE($c_type,type_len)
            if test "$type_len" = "$f_integer_size" ; then
                MPI_FINT_FOUND=yes
		MPI_FINT=$c_type
	        break
	    fi
        done
        AC_MSG(C integer type for MPI_Fint is)
	if test "$MPI_FINT_FOUND" = yes ; then 
   	    AC_MSG_RESULT($MPI_FINT)
        else
	    AC_MSG_RESULT(could not find matching C type!)
	fi
    fi
    # Finally, add FLIBS to FLIB_LIST
    # (FLIBS may have been set when finding how to access command-line
    # arguments)
    FLIB_LIST="$FLIB_LIST $FLIBS"
fi

if test $do_test = 1 ; then
    PAC_CORRECT_COMPILER()
fi
#
if test "$RANLIB" != ":" ; then
    PAC_RANLIB_WORKS
fi
#
# Some Sun SOLARIS systems don't have AR (at least, not in a typical user
# path)
# Remove any arguments from the string AR
ARTEST=`expr "$AR" : "\(.*\) "`
PAC_PROGRAM_CHECK(ARFOUND,$ARTEST,1,,ARLOC)
if test -z "$ARLOC" ; then 
    # Check for /usr/ccs/bin/ar ; Solaris likes to hide anything remotely
    # useful in this directory
    print_error "The library archiver $AR is not in your path"
    print_error "MPICH cannot be built without this program, which"
    print_error "should be part of ANY program development environment."
    if test -x /usr/ccs/bin/ar ; then 
        print_error "You need /usr/ccs/bin in your path."
    else
        print_error "Check your path; contact your system vendor if your"
        print_error "path appears to be ok."
    fi
    exit 1
fi
#
#
# Check for long pointers.  All such options are placed into DEFS (see
# autoconf manual, AC _ DEFINE)
#
# replace these with autoconf-2 style tests for
# SIZEOF_VOID_P
# SIZEOF_INT
# Then the test in the files should be
# #if SIZEOF_INT != SIZEOF_VOID_P 
# ...
# Alternately, do the test here and use a different value such as 
# USE_INTEGER_INDEX
PAC_POINTER_64_BITS()
PAC_INT_LT_POINTER()
if test -n "$F77IDX" ; then
    AC_DEFINE(POINTER_64_BITS)
fi
dnl
PAC_GET_TYPE_SIZE(void *,address_size)
if test "$address_size" != "unknown" ; then
    AC_MSG_CHECKING([for C integer type for MPI_Aint])
    AC_MSG_RESULT()
    for c_type in int long short "long long" ; do
        PAC_GET_TYPE_SIZE($c_type,type_len)
        if test "$type_len" = "$address_size" ; then
            MPI_AINT_FOUND=yes
	    MPI_AINT=$c_type
            break
        fi
    done
    AC_MSG(C integer type for MPI_Aint is)
    if test "$MPI_AINT_FOUND" = yes ; then 
        AC_MSG_RESULT($MPI_AINT)
    else
        AC_MSG_RESULT(could not find matching C type!)
    fi
fi
# 
# Do not test 
# PROBLEM: ROMIO depends on long long in some cases.  For now, leave it
# outside the -no_short_longs test
PAC_LONG_LONG_INT()
if test "$NOSHORTLONGS" = 0 ; then
    # If not cross-compiling, we could dynamically check
    dnl The A C _LONG_DOUBLE macro is junk (it doesn't check that 
    dnl long double exists at all!
    PAC_LONG_DOUBLE()
    PAC_CHECK_SIZEOF(double,SIZEOF_DOUBLE)
    PAC_CHECK_SIZEOF(long double,SIZEOF_LONG_DOUBLE)
    if test $SIZEOF_DOUBLE -eq $SIZEOF_LONG_DOUBLE ; then
	# Suppress long double if == double?
	# NOSHORTLONGS=1
     print_error "If you get warning messages about long doubles not supported"
     print_error "on $ARCH, use the -no_short_longs argument to configure."
    fi
fi

#
# Check for structure alignment using util/structlayout.c
if test "$cross_compiling" = 0 ; then
   if test -n "$TESTCC" ; then
       CCsav="$CC"
       CC="$TESTCC"
   fi
   AC_MSG_CHECKING([for structure alignment])
   rm -f conftest*
   cat confdefs.h $srcdir/util/structlayout.c > conftest.c
   eval $compile
   if test ! -s conftest ; then
	AC_MSG_RESULT([Could not build executable program to test alignment])
   else
	if test -x conftest && (./conftest; exit) 1>conftestout ; then
	    if test -s conftestout ; then
  	        alignvalue=`cat conftestout`
            else
	        alignvalue="Unknown"
            fi
	    AC_MSG_RESULT($alignvalue)
	else
	    AC_MSG_RESULT(Execution of test program failed)
	fi
   fi
   rm -f conftest*
   if test -n "$TESTCC" ; then
       CC="$CCsav"
   fi
   # Make this the default.  Eventually, use the --enable stuff to allow
   # a user to turn this off.
   AC_DEFINE(USE_BASIC_ALIGNMENT)
fi

#### was
# We must not make USER_CFLAGS all of CFLAGS...
#
dnl definitions should be passed to the configuration file
dnl CFLAGS="$CFLAGS $DEFS"
# We really should use MPICHCONF_H instead of CONFIG_H
CFLAGS="$CFLAGS -DHAVE_MPICHCONF_H"
#
AC_DEFINE(MPI_ADI2)
# Don't include mpid/ch2 since that has default versions of the include
# files.  If a device needs them, it should copy or link them into
# its directory.

# For now, add user_cflags to ccflags.  This is needed to ensure that 
# the few defines needed by mpi.h are included.
CCFLAGS="$CCFLAGS $USER_CFLAGS"

mpich_includes="-I$top_srcdir/include -I$includebuild_dir -I$rootbuild_dir/mpid/$DEVICE"
if test "$top_srcdir" != "$rootbuild_dir" ; then
    mpich_includes="$mpich_includes -I$top_srcdir/mpid/$DEVICE"
fi

AC_SUBST(mpich_includes)
if test "$MEMDEBUG" = "1" ; then 
    AC_DEFINE(MPIR_MEMDEBUG)
    AC_DEFINE(MPIR_OBJDEBUG) 
fi
if test "$TRDEBUG" = "1" ; then 
	AC_DEFINE(DEBUG_TRACE)
fi
if test "$PTRDEBUG" = 1 ; then 
	AC_DEFINE(MPIR_PTRDEBUG)
fi

# We really need separate library directories and path indicators.

LIB_PATH_LEADER="-L"
AC_SUBST(LIB_PATH_LEADER)
LIB_PATH="-L$libbuild_dir $LIB_PATH"
#
if test -n "$F90" ; then
    if test -z "$USER_SET_F90LIB_PATH" -a -z "$F90LIB_PATH" ; then
	F90LIB_PATH="$FLIB_PATH_LEADER$FLIB_PATH"
    fi
fi
# Add any user libraries
if test -n "$USERLIB" ; then
    LIB_LIST="$LIB_LIST $USERLIB"
fi
#
# mpirun needs sync to try and fix NFS problems on some machines.  Some
# users may not have sync in their path, so we try to find it here.
SYNCLOC=""
PAC_PROGRAM_CHECK(SYNCFOUND,sync,1,,SYNCLOC)
if test -z "$SYNCLOC" ; then SYNCLOC=true ; fi
#
#
# if the device uses the machines file and there is no machines.$ARCH, 
# create one using hostname (or uname)
#
# Where should util be if it is not local?  top_srcdir?  bindir?
if test $DEVICE_KIND = network ; then
    if test ! -s util/machines/machines.$ARCH ; then
        if test ! -d util ; then mkdir util ; fi
        if test ! -d util/machines ; then mkdir util/machines ; fi
        HOST=""
        PAC_PROGRAM_CHECK(HOSTNAME_PGM,hostname,,,hostname)
        if test -x "$hostname" ; then
	    HOST="`$hostname`"
        fi
        # Note that uname -n may not produce a usable hostname.  
	# Any suggestions?
        if test "$HOST" = "" ; then
	    HOST="`uname -n`"
        fi
   	cat > util/machines/machines.$ARCH <<EOF
# Change this file to contain the machines that you want to use
# to run MPI jobs on.  The format is one host name per line, with either
#    hostname
# or 
#    hostname:n
# where n is the number of processors in an SMP.  The hostname should
# be the same as the result from the command "hostname"
$HOST
$HOST
$HOST
$HOST
$HOST
EOF
	print_machines_message=1
    fi
fi
if test $DEVICE = ch_p4mpd  ; then
    if test ! -d mpid ; then mkdir mpid ; fi
    if test ! -d mpid/mpd  ; then mkdir mpid/mpd ; fi
    if test -s mpid/mpd/mpd.hosts  ; then
	/bin/rm -f mpid/mpd/mpd.hosts
    fi
   	cat > mpid/mpd/mpd.hosts <<EOF
$HOST
$HOST
$HOST
$HOST
$HOST
EOF
fi
#
# Make sure that configure is group writable
#
chmod g+w configure > /dev/null 2>&1
#
# BASE_LIB_LIST lets us separate the MPI library from the other libs
BASE_LIB_LIST="$LIB_LIST"
# used to be LIB_LIST="$LIB_LIST -lmpi" I switched it, inspired by HPUX
LIB_LIST="-l$MPILIBNAME $LIB_LIST"
#
# Generate the name for the MPI-C, MPI-CC, and MPI-F77 compilers (for use
# in Makefiles that should not be MPICH dependent
MPICC=$binbuild_dir/mpicc
if test $NOF77 = 0 ; then
	MPIF77=$binbuild_dir/mpif77
else
        # should this be "true"?
	MPIF77=""
fi
MPIF90=$binbuild_dir/mpif90
MPICPLUSPLUS=$binbuild_dir/mpiCC
### FIXME: IS THIS CORRECT OR NEEDED???
LIB_DIR=$exec_prefix
#
# Some mpi2 commands supported (for the testing scripts)
HAS_MPI2=1
#
#  Configure ROMIO if specified
#
if test $ROMIO = 1 ; then
  if test -d ${top_srcdir}/romio ; then 
      echo "Configuring ROMIO, for support of MPI-IO"
      # Check first for some ROMIO-specific requirements
      PAC_MACRO_NAME_IN_MACRO(,ROMIO=0)
      if test $ROMIO = 0 ; then
          print_error "Cannot build ROMIO with the C compiler $CC"
      fi
  else
      ROMIO=0
  fi
fi
if test $ROMIO = 1 -a -d ${top_srcdir}/romio ; then
  # If integer*8 not supported, then tell ROMIO not to use it.
  # We do this indirectly by telling ROMIO to use an offset type of int.
  if test -z "$FORT_INT8" -o "$FORT_INT8" = 0 ; then
      if test -z "$f_integer_size" -o "$f_integer_size" = "unavailable" ; then
	  f_integer_size=4
      fi
      if test "$OFFSET_KIND" = 8 ; then
	   # F90 has an 8-byte integer kind but F77 doesn't support it
           # as integer*8.
	   if test "$F90" != "FC" ; then
               ROMIO_ARGS="$ROMIO_ARGS -longlongsize=int"
           fi
      else 	   
          ROMIO_ARGS="$ROMIO_ARGS -longlongsize=int"
      fi
  fi
  if test ! -d romio ; then mkdir romio ; fi
  (cd romio ; \
  ${top_srcdir}/romio/configure -arch="$ARCH" $ROMIO_ARGS -file_system="$FILE_SYSTEM" \
            -mpi=mpich -from_mpich \
	    -make="$MAKE" \
            -mpiincdir=$includebuild_dir \
	    -mpibindir=$binbuild_dir \
            -mpilib=$libbuild_dir/lib$MPILIBNAME.a \
            -mpiolib=$libbuild_dir/lib$MPILIBNAME.a \
            -cc="$CC" -cflags="$ROMIO_CFLAGS $CC_SHARED_OPT" \
            -fc="$FC" -fflags="$ROMIO_FFLAGS $FC_SHARED_OPT" -f90="$F90" $romio_config_args )
  /bin/rm -f include/mpio.h ${top_srcdir}/include/mpio.h
  cp romio/include/mpio.h include
  ROMIO_LFLAGS="`$MAKE -f romio/Makefile romio_lflags`"
  ROMIO_TCFLAGS="`$MAKE -f romio/Makefile romio_tcflags`"
  ROMIO_TCPPFLAGS="`$MAKE -f romio/Makefile romio_tcppflags`"
  ROMIO_TFFLAGS="`$MAKE -f romio/Makefile romio_tfflags`"
  LIB_LIST="$LIB_LIST `$MAKE -f romio/Makefile romio_liblist`"
  BASE_LIB_LIST="$BASE_LIB_LIST `$MAKE -f romio/Makefile romio_liblist`"
# mpif.h prepared for ROMIO at end of configure
  # If a VPATH build, the examples dir may not exist
  if test ! -d examples ; then mkdir examples ; fi
  if test ! -d examples/test ; then mkdir examples/test ; fi
  (cd examples; \rm -f io; ln -s ../romio/test io; \
   (cd test; \rm -f io; ln -s ../../romio/test io))
  echo "Finished configuring ROMIO"
fi
if test "$ROMIO" = 1 ; then
    NEWTESTDIRS="$NEWTESTDIRS io"
fi
#
# Substitute variables
# Variables used in scripts only
AC_SUBST(AUTOMOUNTFIX)dnl
if test -z "$RSHCOMMAND" ; then
    RSHCOMMAND=$rshcommand
fi
AC_SUBST(RSHCOMMAND)dnl
# FINC contains an @MPIR_HOME@, so it needs to come first
AC_SUBST(FINCARG)dnl
AC_SUBST(FINC)dnl
AC_SUBST(SYNCLOC)dnl
# Variables defined ONLY for the doc/port file:
AC_SUBST(CONFIGURE_ARGS)dnl
AC_SUBST(NODEVDEBUG)dnl
AC_SUBST(PKTSIZE)dnl
dnl AC_SUBST(PREALLOC)dnl
dnl AC_SUBST(PREPOST)dnl
dnl AC_SUBST(USERNDV)dnl
AC_SUBST(LIMITEDBUFFERS)dnl
AC_SUBST(ADI_COLLECTIVE)dnl
AC_SUBST(cross_compiling)dnl
# Variables used by Makefile.in's:
AC_SUBST(ASM)dnl
AC_SUBST(ASMFILES_O)dnl
AC_SUBST(AR)dnl
AC_SUBST(ARCH)dnl
AC_SUBST(BASE_LIB_LIST)dnl
AC_SUBST(CC)dnl
AC_SUBST(CFLAGS)dnl
AC_SUBST(CLINKER)dnl
AC_SUBST(CCFLAGS)dnl
AC_SUBST(CCLINKER)dnl
AC_SUBST(CPP_COMPILER)dnl
AC_SUBST(CPP_DIR)dnl
AC_SUBST(CPPFLAGS)dnl
AC_SUBST(LDFLAGS)dnl
AC_SUBST(CPPLDFLAGS)dnl
AC_SUBST(CPRP)dnl
AC_SUBST(DEFAULT_MACHINE)dnl
AC_SUBST(DEVCFLAGS)dnl
AC_SUBST(DEVCFILES)dnl
AC_SUBST(DEVOFILES)dnl
AC_SUBST(DEV_DEFS)dnl
AC_SUBST(DEVICE)dnl
AC_SUBST(DEVICE_MAKE_INCLUDE)dnl
AC_SUBST(F77)dnl
AC_SUBST(F77_EXTRA_FLAG)dnl
AC_SUBST(FAST_COPY)dnl
AC_SUBST(FFLAGS)dnl
AC_SUBST(FLIB_PATH)dnl
AC_SUBST(FLIB_PATH_LEADER)dnl
AC_SUBST(FLIB_LIST)dnl
AC_SUBST(FLINKER)dnl
AC_SUBST(GETNAME_DEFS)dnl
AC_SUBST(HAS_FORTRAN)dnl
AC_SUBST(HAS_MPI2)dnl
AC_SUBST(INCLUDE_PATH)dnl
AC_SUBST(LIB_LIST)dnl
AC_SUBST(LIB_PATH)dnl
AC_SUBST(LIB_DIR)dnl
AC_SUBST(MAKE)dnl
AC_SUBST(MPE_DIR)dnl
AC_SUBST(MPE_MPI_EXT_C)dnl
AC_SUBST(MPE_MPI_EXT_O)dnl
AC_SUBST(ENABLE_MPEDBG)
MPICH_VERSION="MPICH $MPIVERSION"
AC_SUBST(CONFIGURE_ARGS_CLEAN)dnl 
dnl initutil 
dnl We can't put the quotes in '"' because the sed line generated by configure
dnl also uses quotes.
q='"'
AC_DEFINE_UNQUOTED(CONFIGURE_ARGS_CLEAN,$q$CONFIGURE_ARGS_CLEAN$q)
AC_DEFINE_UNQUOTED(MPIRUN_MACHINE,$q$DEFAULT_MACHINE$q)
AC_DEFINE_UNQUOTED(MPIRUN_DEVICE,$q$DEVICE$q)
# This is used in mpif77/mpif90 to perform source editing for the 
# Globus approach to using vendor MPI's .  Other codes could also
# use this approach to intercept MPI calls.  The variable must
# be set in the device-specific setup file
AC_SUBST(MPICH_SED_FORTRAN_SOURCE)
# COMM is currently used in mpirun.ch_p4.in to decide if SMP support is
# turned on
AC_SUBST(COMM)
dnl This is used to make sure that we get the correct mpirun.
AC_SUBST(MPICH_VERSION)dnl
dnl do we need mpir_home?
AC_SUBST(MPIR_HOME)dnl
dnl AC_SUBST(MPIFDEP)dnl delete usage of this
AC_SUBST(MPI_FOBJECTS)dnl
AC_SUBST(MPI_AINT)dnl
AC_SUBST(MPI_FINT)dnl
AC_SUBST(MPILIBNAME)dnl
dnl The next four should not be needed; they should build on bindir
AC_SUBST(MPICC)dnl
AC_SUBST(MPIF77)dnl
AC_SUBST(MPIF90)dnl
AC_SUBST(MPICPLUSPLUS)dnl
dnl
AC_SUBST(MEMDEBUG)dnl
dnl Where is GLOBUSDIR needed?
AC_SUBST(GLOBUSDIR)dnl
AC_SUBST(NLS_DEFS)dnl
AC_SUBST(NEWTESTDIRS)dnl
AC_SUBST(OPTFLAGS)dnl
AC_SUBST(OPTFLAGSC)dnl
AC_SUBST(OPTFLAGSF)dnl
dnl Where are p4_arch/p4_dir used?
AC_SUBST(P4_ARCH)dnl
AC_SUBST(P4_DIR)dnl
AC_SUBST(RHS_COMMAND)dnl
# P4_MDEPCFLAGS now used only in doc/port.in - delete this
AC_SUBST(P4_MDEPCFLAGS)dnl
AC_SUBST(PREFIX)dnl
AC_SUBST(RANLIB)dnl
AC_SUBST(USER_CFLAGS)dnl
AC_SUBST(ROMIO)dnl
AC_SUBST(ROMIO_LFLAGS)dnl
AC_SUBST(ROMIO_TCFLAGS)dnl
AC_SUBST(ROMIO_TCPPFLAGS)dnl
AC_SUBST(ROMIO_TFFLAGS)dnl
dnl why is this?  Why not test on CCC or CPP_COMPILER?
AC_SUBST(buildcpp)dnl
AC_SUBST(NOF77)dnl
AC_SUBST(NOMPE)dnl
AC_SUBST(MPE_OPTS)dnl
AC_SUBST(JUMPSHOT_OPTS)dnl
#
# src/env/farg.f and farg90.f
# 
AC_SUBST(F77IARGC)dnl
AC_SUBST(F77GETARGDECL)dnl
AC_SUBST(F77GETARG)dnl
AC_SUBST(F90IARGC)dnl
AC_SUBST(F90GETARGDECL)dnl
AC_SUBST(F90GETARG)dnl
AC_SUBST(F90UNIX)dnl
# End configuration file
#
# Make sure we remove any configuration file incase there is out-of-date data.
/bin/rm -f mpichconf.h ${top_srcdir}/include/mpichconf.h

# Make the directories that do not contain Makefiles (should they?) but 
# are needed for the subsequent directories.
if test ! -d src ; then mkdir src ; fi
AC_OUTPUT(Makefile util/Makefile examples/Makefile src/pt2pt/Makefile src/coll/Makefile src/context/Makefile src/dmpi/Makefile src/env/Makefile src/topol/Makefile src/profile/Makefile src/util/Makefile src/infoexport/Makefile examples/basic/Makefile src/misc2/Makefile src/external/Makefile )
#
# Once we've done one output of the header file, we don't need to do it
# again.  By defining the header as null, we hope to avoid messages about
# "mpichconf.h unchanged"
CONFIG_HEADERS=""
export CONFIG_HEADERS
PAC_OUTPUT_EXEC(util/mpicc util/mpiCC util/mpif77 util/mpif90 util/mpiinstall util/chkserv util/chkmachine, a+x )
rm -f $includebuild_dir/mpidefs.h $includebuild_dir/mpif.h 
rm -f $top_srcdir/include/mpidefs.h $top_srcdir/include/mpif.h
PAC_OUTPUT_EXEC(include/mpidefs.h include/mpif.h,a+r)

# Get the files needed by USER programs into the includebuild_dir
if test ! -s $includebuild_dir/mpi.h ; then
    cp ${top_srcdir}/include/mpi.h $includebuild_dir
    cp ${top_srcdir}/include/mpi_errno.h $includebuild_dir
fi
if test ! -s $includebuild_dir/mpidefs.h ; then 
    cp ${top_srcdir}/include/mpidefs.h $includebuild_dir
    cp ${top_srcdir}/include/mpif.h $includebuild_dir
fi
#
# add ROMIO part of mpif.h if it exists
if test -f romio/include/mpiof.h -a $ROMIO = 1 ; then
  echo "preparing mpif.h for ROMIO"
  # don't include MPI_OFFSET_KIND from romio
  sed -e '/MPI_OFFSET_KIND/d' romio/include/mpiof.h | \
  cat $includebuild_dir/mpif.h - > mpif-tmp.h
  rm -f $includebuild_dir/mpif.h
  mv mpif-tmp.h $includebuild_dir/mpif.h
fi
if test -n "$F90" ; then
    # Remove all comments from mpif.h
    /bin/rm -f $includebuild_dir/mpif.h.copy
    cp $includebuild_dir/mpif.h $includebuild_dir/mpif.h.copy
    if test "$fixupmpif" = "no" ; then
	# Regular Fortran doesn't have ! for comments, so we just delete them
        sed -e '/^C/d' -e 's/\!.*$//g' $includebuild_dir/mpif.h.copy > $includebuild_dir/mpif.h
    else
        sed -e 's/^C/\!/g' $includebuild_dir/mpif.h.copy > $includebuild_dir/mpif.h
    fi
    /bin/rm -f $includebuild_dir/mpif.h.copy
else
    # ROMIO might have added ! comments to mpif.h
    if test -z "$fixupmpif" -o "$fixupmpif" = "no" ; then
        /bin/rm -f $includebuild_dir/mpif.h.copy
        cp $includebuild_dir/mpif.h $includebuild_dir/mpif.h.copy
	# Regular Fortran doesn't have ! for comments, so we just delete them
        sed -e '/^C/d' -e 's/\!.*$//g' $includebuild_dir/mpif.h.copy > $includebuild_dir/mpif.h
        /bin/rm -f $includebuild_dir/mpif.h.copy
    fi
fi

PAC_OUTPUT_EXEC(src/env/farg.f src/env/farg90.f)
#
# Configure the tests (now that the compiler scripts are built)
echo "Configuring the test suite..."
unset CONFIG_FILES
if test ! -d examples/test ; then 
    mkdir examples/test
fi
if test "$HAS_F77" != "0" ; then \
    ( cd examples/test ; \
       $srcdir/examples/test/configure -basecc="$CC" -cc="$MPICC" \
                                       -basefc="$F77" -fc="$MPIF77" \
				       -make="$MAKE" -device="$DEVICE" \
				       -f77_extra_flag="$F77_EXTRA_FLAG" \
			               -mpichpath="$binbuild_dir" \
			               -cflags="$CFLAGS" )
				 
else
    ( cd examples/test ; \
       $srcdir/examples/test/configure  -basecc="$CC" -cc="$MPICC" -nof77 \
					-make="$MAKE" \
					-mpichpath="$binbuild_dir" \
			                -cflags="$CFLAGS" \	
				        -device="$DEVICE" )
fi
if test ! -d examples/perftest ; then 
    mkdir examples/perftest
fi
echo "Configuring the performance tests ..."
if test "$HAS_F77" != "0" ; then
    ( cd examples/perftest ; \
       $srcdir/examples/perftest/configure -cc="$MPICC" -basecc="$CC" \
				-fc="$MPIF77" -basefc="$F77" \
				-f77_extra_flag="$F77_EXTRA_FLAG" \
				-make="$MAKE" )
else
    ( cd examples/perftest ; \
       $srcdir/examples/perftest/configure -cc="$MPICC" -basecc="$CC" -nof77 \
				-make="$MAKE" )
fi
#
# Configure JUST the correct device file
CONFIG_FILES="mpid/$DEVICE/Makefile"
if test -f $srcdir/mpid/tests/Makefile.in ; then
    CONFIG_FILES="$CONFIG_FILES mpid/tests/Makefile"
fi
export CONFIG_FILES
${CONFIG_SHELL-/bin/sh} ./config.status
CONFIG_FILES=""
#
# Set the final choices of flags
#
# If the test suite is part of the directory, generate its makefiles
# This should have it's own configure
if test -d tsuite ; then
    CONFIG_FILES="tsuite/Makefile tsuite/coll/Makefile tsuite/mpitc2/Makefile"
    export CONFIG_FILES
    ${CONFIG_SHELL-/bin/sh} ./config.status
fi
#
# If the bugs directory is available, generate its makefiles
if test -d bugs ; then
    CONFIG_FILES=""
    if test -s bugs/Makefile.in ; then
	CONFIG_FILES="bugs/Makefile.in"
    fi
    for dir in irecv fort sockperf srleak ssend testsendrecv wait ; do
	if test -s bugs/$dir/Makefile.in ; then
	    CONFIG_FILES="$CONFIG_FILES bugs/$dir/Makefile"
	fi
    done
    export CONFIG_FILES
    ${CONFIG_SHELL-/bin/sh} ./config.status
fi
#
# If the xmpi directory is available, generate its files
if test -d xmpi ; then 
    CONFIG_FILES="xmpi/buildinfo.tcl"
    export CONFIG_FILES
    ${CONFIG_SHELL-/bin/sh} ./config.status
fi
#
# If the mpich-ibm testsuite is available, generate its files
if test -d examples/test/mpitc ; then
    CONFIG_FILES="examples/test/mpitc examples/test/mpitc/ccl examples/test/mpitc/comm examples/test/mpitc/dtyp examples/test/mpitc/env examples/test/mpitc/group examples/test/mpitc/pt2pt examples/test/mpitc/topo"
    export CONFIG_FILES
    ${CONFIG_SHELL-/bin/sh} ./config.status
fi
#
# If the doc/port.in file is available, generate it
if test -f $srcdir/doc/port.in ; then
    PAC_OUTPUT_EXEC(doc/port doc/portbuild doc/portperf doc/porttest,a+x)
fi
#
if test ! -f .mpich -a -z "$nobanner" ; then
  print_error "--->"
  print_error You should register your copy of MPICH with us by sending mail
  print_error to majordomo@mcs.anl.gov containing the message
  print_error subscribe mpi-users
  print_error This will allow us to notify you of new releases of MPICH.
  print_error " "
  print_error "You can also check the MPICH home page at "
  print_error "http://www.mcs.anl.gov/mpi/mpich/index.html"

  if test "$print_machines_message" = 1 ; then
      print_error "Created util/machines/machines.$ARCH with five copies of $HOST"
      print_error "You may want to edit this file to add and delete hosts"
      print_error "(These hosts are used by mpirun.)"
  fi
  print_error "---< "
fi
echo 'Configuration completed.'
exit 0
