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 <<.
Usage: ${progname} -arch=ARCH_TYPE -comm=COMM_TYPE -device=DEVICE
                   [-prefix=INSTALL_DIR]  [-c++[=C++_COMPILER]]
                   [-cc=C_COMPILER] [-fc=FORTRAN_COMPILER]
                   [-clinker=C_LINKER] [-flinker=FORTRAN_LINKER]
                   [-mpe] [-nompe] [-nof77] [-f90nag] [-opt=OPTFLAGS] 
	           [-make=MAKEPGM]
                   [-cflags=CFLAGS] [-fflags=FFLAGS]
                   [-optcc=C_OPTFLAGS] [-optf77=F77_OPTFLAGS]
                   [-lib=LIBRARY] [-mpilibname=MPINAME]
                   [-no_mpegraphics] [-no_short_longs] [-memdebug]
                   [-x11_lib=X11LIB] [-x11_inc=X11INC]
                   [-mpedbg] [-nompedbg] [-cross] [-devdebug] [-nodevdebug] 
                   [-debug] [-nodebug]
		   [-var_pkt] [-pkt_size=LENGTH] [-adi_collective]
                   [-adi_coll_world]
                   [-wish=WISH] [-tcldir=TCLDIR] [-tkdir=TKDIR]
                   [-fortnames=FORTRANNAMES]
                   [-ar_nolocal] [-automountfix=AUTOMOUNTFIX]
                   [-noranlib] [-rsh=RSHCOMMAND] [-rshnol]
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)
   C++_COMPILER = default is to use g++ (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
   WISH         = Name of tcl/tk wish executable.  Configure will attempt
                  to find a version of wish for you, but if there is
                  no wish in your path or you need to use a different version,
                  use this option.  Used only for the display tools 
                  (nupshot and upshot).  tk 3.x required for nupshot;
                  tk 3.x or 4.x for upshot.
   TCLDIR       = Directory containing tcl.  Must have lib/libtcl.a and
                  include/tcl.h .  Used only for nupshot.
   TKDIR        = Directory containing tk 3.3, 3.4, 3.5, or 3.6.  Must have 
                  lib/libtk.a and include/tk.h .  Used only for nupshot.  
                  May be the same as TCLDIR.
   FORTRANNAMES = Form of the Fortran names.  See below.
   X11LIB       = Full path name for libX11.a
   X11INC       = Full path name for X11.h
   AUTOMOUNTFIX = Command to fix automounters
   RSHCOMMAND   = Command to use for remote shell
   MPILIBNAME   = Name to use instead of mpi in the name of the MPI
                  library.  If set, libMPILIBNAME will be used instead
                  or libmpi.  This can be used on systems with
                  several different MPI implementations.

One and only one 'arch', 'comm', and 'prefix' argument should be
provided.  'arch' MUST be specified before 'comm'.

If '-c++' is included as an option, then the C++ interface is also built.  By
default, g++ is used as the c++ compiler.  THIS IS CURRENTLY UNSUPPORTED.

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.

If '-mpe' is included as an option, then the MPE 'helper' libraries will also
be built.  '-nompe' causes the MPE libraries to not be built.  The default is
'-mpe'.  If '-no_mpegraphics' is used, then the MPE routines that make use of
X11 graphics will NOT be built; this is appropriate for systems that either do
not have the X11 include files or that do not support X11 graphics (some
message-passing systems cannot interoperate with X11).  The options -x11_inc
and -x11_lib may be used to specify the locations of the X11 include files and
libraries in the event that configure cannot find them (they should both be
specified in that case).

The option '-mpedbg' enables the '-mpedbg' command line switch in MPI
programs.  When used with an MPI program, the default error handler (i.e.,
MPI_COMM_WORLD's error handler) tries to start xterm's running dbx for each
process that detects an error.  This option is intended primarily for
workstation environments but should work on some MPPs (such as IBM SP2).

The option '-nof77' prevents the compilation of routines that require a
Fortran compiler.  If this option is selected, you may not use the Fortran
interface to MPI.

The option '-f90nag' allows you to use the NAG Fortran 90 instead of Fortran
77.  This is a preliminary version and is based on the version for NeXTs.

The option '-opt' allows you to specify 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

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 of bugs in
the system make.

The option '-no_short_longs' may be used to suppress support for ANSI C types
'long long int' and 'long double' when they are the same size as 'long' and
'double' respectively.  Some systems allow these long ANSI 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.

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).

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., '-device=ch_p4' or
'-device=ch_tcp').

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 '-nodevdebug' disables the debugging code in the MPI ADI code.
This should be used only when you are sure that everything is working
correctly.  (This option is also present to remind benchmarkers that the low
level code by default may contain debugging code.)  Note also that some of the
device code (in mpid/*) has had the debugging code removed from the source
code.  '-devdebug' turns on the debugging code.  '-nodevdebug' is the default.

The option '-var_pkt' allows you to set the message size at which MPICH
changes from its short to long message protocol.

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.  The option '-adi_coll_world' asks the ADI to
try and use any collective operations that are supported only on the
MPI_COMM_WORLD communicator (and any communicator with a similiar group).
This is also untested.


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 -device=ch_p4 -arch=sun4
  make

Known devices are chameleon, 
        ch_nx     (native Intel NX calls), 
        ch_mpl    (native IBM EUI or MPL calls),
        ch_nc     (native nCUBE calls, requires -arch=ncube),
        ch_cmmd   (native TMC CM-5 CMMD calls), 
        ch_p4     (p4)
	ch_nexus  (Nexus)
        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),
        meiko     (for Meiko CS2, using elan tport library), and
	nx        (for Intel Paragon),
	t3d	  (for the Cray T3D, using Cray shmem library).

Known architectures include (case is important)
        sun4      (SUN OS 4.x)
        solaris   (Solaris)
	solaris86 (Solaris on Intel platforms)
        hpux      (HP 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)
        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)
	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 (-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.
.
}
#
ARCH=""
CPP_DIR=""
LIB_PATH=""
FLIB_PATH=""
OPTFLAGS=""
OPTFLAGSF=""
NOF77=0
AR_LOCAL=l
NOSHORTLONGS=0
HAS_FORTRAN=1
MPILIBNAME=mpi
# Nag F90 names are call f90_unix_MP_getarg(i,s) and 
# f90_unix_MP_iargc().
F77GETARG="call getarg(i,s)"
F77IARGC="iargc()"
F90UNIX="C"
MPI_FOBJECTS="\$(MPI_FOBJECTS)"
CFLAGS=""
# We use @ because configure uses %
AUTOMOUNTFIX='sed -e s@/tmp_mnt/@/@g'
#
# By not setting FFLAGS, we get the values from the environment
MPE_GRAPHICS="-DMPE_GRAPHICS"
MAKE=make
P4_MDEPCFLAGS=""
ASMFILES_O=""
PREFIX=""
DEVCFLAGS=""
CONFIGURE_ARGS="$*"
DEFAULT_MACHINE=''
DEVICE_KIND=MPP
cross_compiling=0
is_adi1=0
debug_version=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"
#
# -mpe
MPE_DIR="mpe"
# -devdebug
DEVDEBUGCFLAGS="-DMPID_DEBUG_NONE -DMPID_STAT_NONE"
#
# 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
# 
MPIVERSION=`cat include/patchlevel.h | awk '{print $3}' | sed -e 's/\.[0-9]//' | tr '\012' '.'`
# Also check for exp version by looking for "mpich-exp" in the directory
# path
mpidirname=`pwd | sed -e 's%^.*/mpich-exp$%FOUND%g'`
if test "$mpidirname" = "FOUND" ; then
    MPIVERSION="$MPIVERSION (experimental)"
fi
echo "Configuring MPICH Version $MPIVERSION"
#
# 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 | --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 ;;

     -arch=* | --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
       ARCH=`echo $package|sed s/-/_/g`
       eval "arch_`echo $package|sed s/-/_/g`=1"
       ;;

     -bopt=* | --bopt=*)
       package=`echo $arg|sed 's/-*bopt=//'`
       # 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 bopt value" ; exit 1
       fi
       BOPT=`echo $package|sed s/-/_/g`
       eval "bopt_`echo $package|sed s/-/_/g`=1" ;;

     -comm=* | --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" 
       # Handle possible synonyms
       if test -n "$comm_ch_eui" ; then
           comm_ch_mpl=1
           COMM=ch_mpl
       fi
	;;

     -device=* | --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
       DEVICE=$package    #|sed s/-/_/g`
       # Can't have - in variable names
       package=`echo $package | 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
       ;;

     -adi1)
        CFLAGS="$CFLAGS -DMPI_ADI1"
	is_adi1=1
	;;

     -mpedbg | --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"
	;;

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

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

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

     -mpilibname=*)
	MPILIBNAME=`echo A$arg|sed 's/A-*mpilibname=//'`
	;;

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

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

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

     -no_short_longs | --no_short_longs)
	NOSHORTLONGS=1
	;;

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

     -cross)
	cross_compiling=1
	;;

     -var_pkt | --var_pkt)
        VARPKT=1
	DEVCFLAGS="$DEVCFLAGS -DMPID_PKT_VAR_SIZE"
	;;

     -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
	;;

     -adi_coll_world | --adi_coll_world)
	ADI_COLL_WORLD=1
	;;

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

     -f90nag)
        # Insert module 
	F90UNIX="      use f90_unix"
	FC=f90
	# Still to do - make sure that the Fortran interface is correctly
	# selected.
        ;;

     -c++ | --c++)
       CPP_DIR="src/c++"
       CPP_COMPILER="g++"
       echo Compiling C++ interface with g++ ;;

     -c++=* | --c++=*)
       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="src/c++"
       CPP_COMPILER=`echo $package`		
       echo Compiling C++ interface with $package ;;

     -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=//'`"
	;;

     -clinker=* | --clinker=*)
	CLINKER=`echo $arg|sed 's/-*clinker=//'`
	USERCLINKER=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" ;;

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

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

     -mpe | --mpe)
       MPE_DIR="mpe"
       echo "Make will build MPE routines" ;;
 
     -nompe | --nompe)
       MPE_DIR=""
       echo "Make will not build MPE routines" ;;
 
     -no_mpegraphics | --no_mpegraphics)
       MPE_GRAPHICS=""
       echo "Make will not build MPE graphics routines" ;;

     -x11_lib=* | --x11_lib=* )
       USERXLIB=1
       X11LIB="`echo $arg|sed 's/-*x11_lib=//'`"
       ;;

     -x11_inc=* | --x11_inc=* )
       USERXLIB=1
       X11INC="`echo $arg|sed 's/-*x11_inc=//'`"
       ;;

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

     -nof77 | --nof77)
       echo "Don't build the Fortran interfaces"
       NOF77=1
       HAS_FORTRAN=0
       CFLAGS="-DMPID_NO_FORTRAN $CFLAGS"
       MPI_FOBJECTS="" ;;
	
     -wish=* | --wish=*)
	wishloc="`echo $arg|sed 's/-*wish=//'`"
       ;;

     -tkdir=* | --tkdir=*)
	TK_DIR="`echo $arg|sed 's/-*tkdir=//'`"
       ;;

     -tcldir=* | --tcldir=*)
	TCL_DIR="`echo $arg|sed 's/-*tcldir=//'`"
       ;;

     -automountfix=* | --automountfix=*)
	AUTOMOUNTFIX="`echo $arg | sed 's/-*automountfix=//'`"
	;;

     -nobanner)
	nobanner=1
	;;

     -echo )
	set -x 
        configure_echo=1
	;;

     -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" 
	;;
    esac
  fi
done]

dnl Finish the initalization
AC_PREPARE()
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"
  print_error " "
fi
#
# 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 "$ADI_COLL_WORLD" = 1 ; then
    AC_DEFINE(MPID_COLL_WORLD)
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
#
PAC_GETWD(MPIR_TRIAL,src/pt2pt/Makefile.in)
MPIR_HOME=$MPIR_TRIAL
#
#
# Check that an ARCH was set
# If it wasn't set, try to guess using "util/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 util/tarch ; then
    echo "Trying to guess architecture ..."
    ARCH=`./util/tarch | sed s/-/_/g`
    if test -z "$ARCH" ; then
       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"
    echo "  configuring for \"$ARCH\" target architecture"
fi
if test -n "$arch_sgi" ; then
    arch_IRIX=1
    ARCH=IRIX
fi
if test -n "$arch_IRIX64" ; then
    arch_IRIX=1
fi
if test -n "$arch_IRIX32" ; then
    arch_IRIX=1
fi
if test -n "$arch_IRIXN32" ; then
    arch_IRIX=1
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 that a DEVICE was set
# If it wasn't set, try to guess using "util/tdevice"
#
if test -z "$DEVICE" -a -x util/tdevice ; then
		echo "Trying to guess device ..."
    DEVICE=`util/tdevice $ARCH`
    if test ! -n "$DEVICE" ; then
       print_error "Error: Couldn't guess device, you must" 
       print_error "       set a device with -device=<value>" 
       exit 1
    fi
    eval "device_$DEVICE=1" 
    echo "  configuring for \"$DEVICE\" device"
fi
#
# Check for a VALID device
if test ! -d mpid/$DEVICE ; then
    print_error "$DEVICE is not a valid device!" 
    exit 1
fi
#
#
# Set Default values of variables
CC=${CC:-cc}
F77=${FC:-f77}
if test -n "$FC" ; then
    USERF77=1
fi
# CLINKER and FLINKER are set by PAC _GET_CC and F77
#
# First, check for the basic CC and Ranlib 
if test -z "$USERCC" ; then
    AC_PROG_CC()
fi
# 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
AR="ar cr$AR_LOCAL"
# CPRP is the version of cp that accepts -r and -p arguments.
# See CRAY below
CPRP="cp"
INCLUDE_PATH=""
USER_INCLUDE_PATH=""
USER_DEFS=""
LIB_LIST=""
MPE_LIBS=""
# Fixup for make
PAC_MAKE_IS_GNUMAKE
PAC_MAKE_IS_BSD44
PAC_MAKE_IS_OSF
#
# Check that a DEVICE was set
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
if test -z "$ARCH" ; then
    print_error "You must set an architecture type with -arch=<value>"
    exit 1
fi
#
# Set comm from device?
if test -z "$COMM" ; then
    COMM=$DEVICE
    # Remember that COMM set as default, not explicitly, 7/13/95, bri@sgi.com
    default_comm=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
#
if test ! -d lib ; then 
   mkdir lib
fi
if test ! -d lib/$ARCH ; then 
   mkdir lib/$ARCH
fi
if test ! -d lib/$ARCH/$COMM ; then 
   mkdir lib/$ARCH/$COMM
fi

# Check all of the devices first; they need to be known 
# before doing the transport layer

# check whether --device=chameleon was given
if test -n "$device_chameleon"; then
  echo "Chameleon is no longer supported.  There are specific devices for"
  echo "each system that Chameleon provided (except for PVM, which is not"
  echo "supported)."
  exit 1
fi

# 
# Check for Unix Variants
AC_AIX
AC_MINIX
#

# This is a first cut at the information needed.  Information that I am
# providing is:
#
# 1. path to Nexus libraries && libraries to include
# 2. path to Nexus include files
# 3. compiler (if necessary)
# 4. path to debugger \___ for debugging Nexus
# 5. path to xterm    /    programs with xterm
# 5. ?
#
#  More can be needed if necessary.
if test -n "$device_ch_nexus"; then
  is_adi1=1
  DEVICE_KIND=network
  # find some way to find Nexus since there is no standard location for
  # it, currently (/usr/local/nexus ?)
  DEVCFLAGS="$DEVCFLAGS -DHAVE_GETTIMEOFDAY "
  case $ARCH in
    rs6000)
      # DCE threads assumed until QT works correctly
      # (only with full Nexus)
      # NEXUS_EXTRA_LIBS="-lpthreads"
      # MPL assumed.  We need to give user option between:
      #
      #  A.  MPL <-------------------\
      #  B.  TCP                      |----> need CC=mpxlc
      #  C.  MPL+TCP (preferred) <---/
      AC_PROGRAMS_CHECK(CCval,mpCC mpcc "$CC")
      if test -n "$CCval" ; then
	    CC=$CCval
	    if test "$CC" = mpcc ; then 
	        TESTCC=xlc
	    elif test "$CC" = mpCC ; then
        	TESTCC=xlC
	    fi
      else
            echo "Could not find mpCC or mpcc!"
	    exit 1
      fi
      ;;
    IRIX)
      # (only with full Nexus)
      dnl # PAC_FIND_USER_INCLUDE(qt, /usr/local/qt /usr/local/nexus/include /usr/local/iway/app/nexus/qt)
      #if [ "x$pac_inc_dir" != "x" ] ; then
      #  NEXUS_EXTRA_INC_PATH="-I$pac_inc_dir"
      #else
      #  print_error "Could not locate Quickthreads header file"
      #  exit 1
      #fi
      dnl # PAC_FIND_USER_LIB(qt, /usr/local/qt /usr/local/nexus/lib /usr/local/iway/app/nexus/lib)
      #if [ "x$pac_lib_dir" != "x" ] ; then
      #  NEXUS_EXTRA_LIB_PATH="-L$pac_lib_dir"
      #  NEXUS_EXTRA_LIBS="-lqt"
      #else
      #  print_error "Could not locate Quickthreads library"
      #  exit 1
      #fi
      # CC="ncc"
      ;;
    sun4)
      # FSU pthreads assumed until QT is tested.  We need a way to find
      # where the preferred threads library is located on the machine
      # (only with full Nexus)
      dnl # PAC_FIND_USER_INCLUDE(pthread, /usr/local/fsu-pthreads/include /usr/local/nexus/include /usr/local/iway/app/nexus/fsu-pthreads-2.6/include)
      #if [ "x$pac_inc_dir" != "x" ] ; then
      #	NEXUS_EXTRA_INC_PATH="-I$pac_inc_dir"
      #else
      #	print_error "Path to pthreads include files not found"
      #	exit 1
      #fi
      dnl # PAC_FIND_USER_LIB(gthreads, /usr/local/fsu-pthreads/lib /usr/local/nexus/lib /usr/local/iway/app/nexus/fsu-pthreads-2.6/lib)
      #if [ "x$pac_lib_dir" != "x" ] ; then
      #	NEXUS_EXTRA_LIB_PATH="-L$pac_lib_dir"
      #	NEXUS_EXTRA_LIBS="-lgthreads -lmalloc"
      #else
      #	print_error "Path to pthreads libraries not found"
      #	exit 1
      #fi
      # FSU pthreads requires gcc 2.7.0 to work properly. Or to have the
      # pthread include files to be munged for earlier versions.  Assume
      # that the default compiler can work with the installed include
      # files.

      # For interoperation with Fortran to work correctly, gcc 2.7.0
      # must be used with the -munaligned-doubles command line option
      # This isn't quite correct.  We need to check that the option is
      # accepted.  Note that there are MANY ANSI-C compilers for the Sun,
      # and only gcc uses these flags.
      CFLAGS="$CFLAGS -munaligned-doubles"
      ;;
    solaris)
      # More stuff, but I've never tried this version, so I don't know
      # them, yet.
      NEXUS_EXTRA_LIBS="";;
    alpha)
      # More stuff, but I've never tried this version, so I don't know
      # them, yet.
      NEXUS_EXTRA_LIBS="";;
    NeXT)
      # This should just work.  Thank goodness for one sane platform. :)
      NEXUS_EXTRA_LIBS="";;
    paragon)
      # More stuff, but I've never tried this version, so I don't know
      # them, yet.
      NEXUS_EXTRA_LIBS="";;
    freebsd)
      # Working on this version, but the department needs to upgrade to
      # 2.0.5 or later because of severe VM problems that hit earlier
      # versions and crash the entire machine.
      NEXUS_EXTRA_LIBS="";;
  esac
  # We must have an ANSI C compiler
  PAC_CHECK_CC_PROTOTYPES(notansi=0,notansi=1)
  if test $notansi = 1 ; then
      print_error "NEXUS requires an ANSI C compiler; $CC failed to"
      print_error "handle a routine prototype."
      exit 1
  fi
  # Need a way to find where Nexus is located.
  PAC_FIND_USER_INCLUDE(nexus,/usr/local/nexus/include /usr/local/iway/app/nexus/include /usr/local/iway/app/nexus/nexus/include)
  if test -n "$pac_inc_dir" ; then
      NEXUS_INCLUDE_PATH=-I$pac_inc_dir
  else
      print_error "Could not find NEXUS include files"
      exit 1
  fi
  PAC_FIND_USER_LIB(nexuslite_opt,/usr/local/nexus /usr/local/iway/app/nexus/lib /usr/local/iway/app/nexus/nexus/lib)
  if test -n "$pac_lib_dir" ; then
      NEXUS_LIB_PATH="-L$pac_lib_dir"
  else
      print_error "Could not find NEXUS library"
      exit 1
  fi
  #
  # Need a way to find which Nexus to use. (i.e., Lite vs. Full)
  # Lite is assumed currently
  #
  NEXUS_LIBS="-lnexuslite_opt"
  LIB_PATH="$LIB_PATH $NEXUS_LIB_PATH $NEXUS_EXTRA_LIB_PATH"
  LIB_LIST="$LIB_LIST $NEXUS_LIBS $NEXUS_EXTRA_LIBS"
  # These files are only included by files in mpich/mpid/ch_nexus/*.c
  # and not by the user.
  INCLUDE_PATH="$INCLUDE_PATH $NEXUS_INCLUDE_PATH $NEXUS_EXTRA_INC_PATH"

  # Determine where the XTERM and dbx/gdb executables live
  XTERMLOC=""
  PAC_PROGRAM_CHECK(XTERM,xterm,1,,XTERMLOC)
  GDBLOC=""
  PAC_PROGRAM_CHECK(GDB,gdb,1,,GDBLOC)
  DBXLOC=""
  PAC_PROGRAM_CHECK(DBX,dbx,1,,DBXLOC)
  AC_SUBST(XTERMLOC)
  AC_SUBST(GDBLOC)
  AC_SUBST(DBXLOC)
fi

# Get the C compiler, Fortran compiler, and archiver
CARCH=$ARCH
case $DEVICE in
    ch_cenju3)       CARCH=cenju3 ;;
    ch_cmmd)         CARCH=cm5 ;;
    ch_mpl|ch_eui)   CARCH=ibmpoe ;;
    ch_meiko|meiko)  CARCH=meiko ;;
    ch_nx|nx)        CARCH=intelnx ;;
    ch_nc)           CARCH=ncube ;;
    ch_spp)          CARCH=convex_spp ;;
esac
PAC_GET_CC($CARCH)
if test $NOF77 = 0 ; then
    PAC_GET_F77($CARCH)
else
    HAS_F77=0
fi
PAC_GET_AR($CARCH)

#
# Special flags for dbx versions; this should go into aclocal eventually
if test "$CARCH" = "alpha" ; then
    MPE_CFLAGS="$MPE_CFLAGS -DDBX_IS_OSF"
fi
#
# Various systems have known special needs (particularly libraries);
# get thos here
#    
DEFAULT_MACHINE=$DEVICE
#
if test -n "$device_nx"; then
  DEFAULT_MACHINE="paragon"
  # Check for fast collective routines
  if test  -r /usr/lib/libjmc.a; then
    CFLAGS="$CFLAGS -DICCLIB"
    ICCLIB="iCClib"
  fi
fi

if test -n "$device_ch_shmem" -o -n "$device_ch_lfshmem" ; then
  if test -n "$arch_solaris" ; then
    AC_HAVE_LIBRARY(thread,LIB_LIST="$LIB_LIST -lthread")
  fi
  if test -n "$arch_ksr" ; then
    AC_HAVE_LIBRARY(rpc,LIB_LIST="$LIB_LIST -lrpc")
  fi
  if test -n "$arch_alpha" ; then
    AC_HAVE_LIBRARY(rpc,LIB_LIST="$LIB_LIST -lrpc")
  fi
fi
#
if test -n "$device_ch_meiko" -o -n "$device_meiko" ; then
  is_adi1=1
  DEFAULT_MACHINE="meiko"
  # Jim Cownie claims that -laio is no longer needed ...
  if test -s /opt/MEIKOcs2/lib/libmpsc.a ; then
      if test -n "$device_meiko" ; then
          LIB_LIST="$LIB_LIST -L/opt/MEIKOcs2/lib -lew -lelan"
      else
          LIB_LIST="$LIB_LIST -L/opt/MEIKOcs2/lib -lmpsc -lew -lelan"
      fi
  else
      print_error "Could not find the library /opt/MEIKOcs2/lib/libmpsc.a"
      print_error "Cannot build MEIKO version"
      exit 1
  fi
  # This include is needed for the elan.h files
  DEVCFLAGS="$DEVCFLAGS -I/opt/MEIKOcs2/include"
  # These were recommended by Jim Cownie
  if test -z "$OPTFLAGS" ; then
#      OPTFLAGS="-xcg92 -xO2"
       OPTFLAGS="-O"
  fi
  #RANLIB=true
fi
#
if test -n "$device_ch_mpl" ; then
    # Check for ANL default machine:
    if test -d /etc/FRAMES -a -d /mcs ; then
        DEFAULT_MACHINE="anlspx"
    fi
    # check for mpproto.h
    PAC_CHECK_HEADER(mpproto.h,pre_req=1,pre_req=0)
    if test $pre_req = 0 ; then
	print_error "Could not find the header file mpproto.h that is needed"
	print_error "by the ch_mpl device.  Check that you have"
	print_error "IBMs parallel operating environment (POE), which is "
	print_error "required for this device."
	exit 1
    fi
fi
#
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
#
# Shared-memory (processes) device.  Only need to set mpirun default machine.
if test -n "$device_ch_shmem" -o -n "$device_ch_lfshmem" ; then
   DEFAULT_MACHINE="smp"
   # Check for MMAP
   SAVEDEFS="$DEFS"
   DEFS=""
   # mmap doesn't help if it does not have MAP_ANONYMOUS
   AC_HAVE_FUNCS(mmap)
   AC_HAVE_FUNCS(msem_init)
   AC_HAVE_FUNCS(mutex_init)
   AC_HAVE_FUNCS(shmat)
   AC_HAVE_FUNCS(semop)
   PAC_HAVE_VOLATILE
   #
   # Look for sigaction routine (instead of signal)
   AC_HAVE_FUNCS(sigaction)
   AC_HAVE_FUNCS(signal)
   AC_HAVE_FUNCS(sigset)
   # Also need to get signal hander arg count 1? 3? 4? something else?
   PAC_SIGNALS_WORK
   AC_RETSIGTYPE
   #
   AC_HAVE_FUNCS(gettimeofday)
dnl   AC_MSG_CHECKING(for how many arguments gettimeofday takes)
dnl   AC_TEST_PROGRAM([#include <sys/time.h>
dnl   main() {struct timeval tp;
dnl   gettimeofday(&tp,(void*)0);return 0;}],AC_MSG_RESULT(two - whew),
dnl   DEV_CFLAGS="$DEV_CFLAGS -DUSE_WIERDGETTIMEOFDAY"
dnl   AC_MSG_RESULT(one!))
   AC_HAVE_FUNCS(BSDgettimeofday)

   DEV_DEFS="$DEFS"
   DEFS="$SAVEDEFS"
fi

if test -n "$device_ch_tcp" ; then
    DEVICE_KIND=network
    AC_VPRINTF
fi

if test -n "$device_ch_p4"; then
  echo "About to do p4 device"
  DEVICE_KIND=network
#  INCLUDE_PATH="$INCLUDE_PATH -I$MPIR_HOME/mpid/ch_p4/p4-1.4/include"
# This needs to get the other libraries as required for the specific
# architecture.  
#
# P4's arch specification is different from MPI's (sun4 vs. SUN, etc.)
# Here we set P4_ARCH to the right value, which we deduce from $ARCH and $COMM
# Note that the IRIX code further below may make further changes to 
# P4_ARCH
  if test "$ARCH" = "rs6000"; then
    case $COMM in
      eui|mpl)
        P4_ARCH=SP1_EUI ;;
      p4)
        P4_ARCH=RS6000 ;;
      *)
        P4_ARCH=RS6000 ;;
    esac

########################################################################
#
# Document the IRIX p4 parameter selection a bit, 7/13/95, bri@sgi.com
#
#       OS      COMM    CPU             P4_ARCH         DEFAULT_MACHINE
#       --      ----    ---             -------         ---------------
#       6.x     shared  R8000           SGI_CH64        sgi_mp
#       6.x     shared  *               SGI_CH
#       6.x     *       R8000           SGI             sgi
#       6.x     *       *               SGI
#       5.x     shared  *               SGI_MP          sgi_mp
#       5.x     *       *               SGI
#       *       *       *               SGI
#
# What to do with R10000?  R5000?
########################################################################

  elif test "$ARCH" = "IRIX64" ; then
    P4_ARCH=SGI_CH64
    DEFAULT_MACHINE="sgi_mp"
  elif test "$ARCH" = "IRIX" ; then
    P4_ARCH=SGI
    if test $osversion = 6 ; then
        if test "$COMM" = "shared" ; then
  	    # Use IRIX64 for SGI_CH64
 	    P4_ARCH=SGI_CH32
#	    if test $cputype = 8000 ; then
#	        P4_ARCH=SGI_CH32
	        DEFAULT_MACHINE="sgi_mp"
#	    fi
	else
     	    P4_ARCH=SGI6
	    if test $cputype = 8000 ; then
	        P4_ARCH=SGI6
	        #DEFAULT_MACHINE="sgi"
	    fi
	fi
    elif test $osversion = 5 ; then 
        P4_ARCH=SGI
        if test "$COMM" = "shared" ; then
	    P4_ARCH=SGI_MP
	    DEFAULT_MACHINE="sgi_mp"
	fi
    fi  
  else
    # Note that this will change IRIXxxx to SGIxxx (i.e., IRIX32 to SGI32)
    P4_ARCH=`echo $ARCH | sed \
	    -e 's/sun4/SUN/g'              -e 's/intelnx/IPSC860/g'  \
	    -e 's/IRIX/SGI/g'              -e 's/hpux/HP/g'          \
	    -e 's/solaris86/I86_SOLARIS/g' -e 's/solaris/SUN_SOLARIS/g' \
	    -e 's/c2mp/CONVEX/g'           -e 's/uxpv/UXPV/g'          \
	    -e 's/alpha/ALPHA/g'           -e 's/dec5000/DEC5000/g'       \
	    -e 's/NeXT/NEXT/g'             -e 's/paragon/PARAGONIP/g'     \
	    -e 's/inteldelta/DELTA/g'      -e 's/symmetry/SYMMETRY/g'\
	    -e 's/cray/CRAY/g'             -e 's/tc2000/TC_2000/g'   \
	    -e 's/ksr/KSR/g'               -e 's/freebsd/FREEBSD/g'  \
	    -e 's/cm5/CM5/g'               -e 's/meiko/MEIKO_CS2/g'  \
            -e 's/rs6000/RS6000/g'	   -e 's/symm_ptx/SYMMETRY_PTX/g'`
  fi
echo "Done setting p4arch..."
#
echo "Configuring p4 subsystem..."
# Make sure that the lib Makefile gets remade
  if test -n "$SOCKSIZE" ; then
      otherargs="-socksize=$SOCKSIZE"
  fi
  if test -n "$configure_echo" ; then
      otherargs="$otherargs -echo"
  fi
  if test -n "$rshcommand" ; then
      otherargs="$otherargs -rsh=$rshcommand"
  fi
  if test -n "$rshnol" ; then
      otherargs="$otherargs -rshnol"
  fi
  if test "$USERCC" = 1 ; then 
      (cd mpid/ch_p4/p4-1.4 ; \
	./configure -p4arch=$P4_ARCH -p4make="$MAKE" -opt="$OPTFLAGS" -cc="$CC" -p4comm="$COMM" -cflags="$USER_CFLAGS" $otherargs )
      if test $? != 0 ; then
          print_error "Configure of the p4 sub-system may have failed!"
      fi
    else
      (cd mpid/ch_p4/p4-1.4 ; \
	./configure -p4arch=$P4_ARCH -p4make="$MAKE" -opt="$OPTFLAGS" -p4comm="$COMM" $otherargs )
      if test $? != 0 ; then
          print_error "Configure of the p4 sub-system may have failed"
      fi
  fi
  echo "Done configuring the p4 subsystem"
  P4_MDEPLIBS=`$MAKE -f mpid/ch_p4/p4-1.4/lib/Makefile p4mdeplibs | grep -v make`
  LIB_LIST="$LIB_LIST $P4_MDEPLIBS"
  #
  P4_MDEPCFLAGS=`$MAKE -f mpid/ch_p4/p4-1.4/lib/Makefile p4mdepcflags | grep -v make`
  if test -n "$P4_MDEPCFLAGS" ; then
      CFLAGS="$CFLAGS $P4_MDEPCFLAGS"
      # Note that USER_CFLAGS inherits all of CFLAGS.
  fi
  if test ! -d lib/$ARCH/ch_p4 ; then 
      mkdir lib/$ARCH/ch_p4
  fi 
#   
#   We need to change the makefile.protos in mpid/ch_p4/p4-1.4 to use
#   the correct libraries
#   if test -n "$COMM" ; then 
#       COMM="ch_p4_$COMM"
#   else
       COMM="ch_p4"
#   fi
  if test ! -d lib/$ARCH/$COMM ; then 
       mkdir lib/$ARCH/$COMM
  fi 
#   p4 library is intergrated with libmpi.a...
#   LIB_PATH="$LIB_PATH -L$lib/$ARCH/$COMM"
#   LIB_LIST="$LIB_LIST -lp4";
  IS_HETERO=1
  PAC_SIGNALS_WORK
  # For the timers, we try for gettimeofday.  Just for the device
  SAVEDEFS="$DEFS"
  AC_HAVE_FUNCS(gettimeofday)
dnl  AC_MSG_CHECKING(for how many arguments gettimeofday takes)
dnl  AC_TEST_PROGRAM([#include <sys/time.h>
dnl  main() {struct timeval tp;
dnl  gettimeofday(&tp,(void*)0);return 0;}],AC_MSG_RESULT(two - whew),
dnl  DEV_CFLAGS="$DEV_CFLAGS -DUSE_WIERDGETTIMEOFDAY"
dnl  AC_MSG_RESULT(one!))
  AC_HAVE_FUNCS(BSDgettimeofday)
  DEV_DEFS="$DEV_DEFS $DEFS"
  DEFS="$SAVEDEFS"
fi

#
# This is incomplete
dnl if test -n "$device_ch_p4_1" ; then
dnl   AC_HAVE_FUNCS(gettimeofday)
dnl   LIB_LIST="$LIB_LIST /home/MPI/mpich/mpid/ch_p4/libp4.a"
dnl   IS_HETERO=1
dnl fi

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 stree 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
	if test $cputype = 8000 -o $cputype = 10000 ; then
	    if test -n "$arch_IRIX64" ; then
		CC="$CC -64 -mips4"
	        F77="$F77 -64 -mips4"
  	        CLINKER="$CC -64 -mips4"
	        FLINKER="$F77 -64 -mips4"
            elif test -n $arch_IRIXN32 ; then
		CC="$CC -n32"
		F77="$F77 -n32"
  	        CLINKER="$CC -n32"
	        FLINKER="$F77 -n32"
            else 
		CC="$CC -32"
		F77="$F77 -32"
  	        CLINKER="$CC -32"
	        FLINKER="$F77 -32"
            fi
	elif test $cputype -gt 4000 ; then
	    if test -n "$arch_IRIX64" ; then
		CC="$CC -64 -mips3"
		F77="$F77 -64 -mips3"
	        CLINKER="$CC -64 -mips3" # -non_shared"
	        FLINKER="$F77 -64 -mips3" # -non_shared"
            elif test -n $arch_IRIXN32 ; then
		CC="$CC -n32"
		F77="$F77 -n32"
  	        CLINKER="$CC -n32"
	        FLINKER="$F77 -n32"
            else 
		CC="$CC -32"
		F77="$F77 -32"
  	        CLINKER="$CC -32"
	        FLINKER="$F77 -32"
            fi
        else
	    # According to winfrid.tschiedel@mch.sni.de, need -n32 for R4000
#	    CFLAGS="$CFLAGS -n32 -mips3" 
#	    FFLAGS="$FFLAGS -n32 -mips3"
	    CC="$CC -n32"
	    F77="$F77 -n32"
	    CLINKER="$CC -n32 -mips3" # -non_shared"
	    FLINKER="$F77 -n32 -mips3" # -non_shared"
        fi
	if test -n "$P4_MDEPCFLAGS" ; then
  	    FFLAGS="$FFLAGS $P4_MDEPCFLAGS"
        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
   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/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
   if test -n "$arch_CRAYTS" ; then 
       AC_DEFINE(_TWO_WORD_FCD)
   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
   is_adi1=1
   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
   if test -s /mpp/bin/cam ; then 
        ASM="/mpp/bin/cam"
   elif test -s /mpp/bin/asm ; then
	ASM="/mpp/bin/asm"
   else
        print_error Cannot find assembler needed to build MPICH
        print_error Neither /mpp/bin/cam nor /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" ; 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

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
#
# check whether --comm=p4 was given
if test -n "$comm_p4"; then
  echo "Please use -device=ch_p4 instead of -device=chameleon -comm=p4"
  exit 1
fi

dnl if test -n "$arch_SX_4" ; then 
dnl     CFLAGS="$CFLAGS -pvctl,nomsg -DCHAR_PTR_IS_ADDRESS"
dnl fi
if test -n "$arch_SX_4" ; 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 -DUSE_FAST_SX4_LOCKS -DMPID_USE_SX4_VOPS"
#
       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"
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
# 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

#
# 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_tcp -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
if test -n "$arch_solaris" -o -n "$arch_SX_4" ; then
    AC_MSG_CHECKING(for how many arguments gettimeofday takes)
    AC_TEST_PROGRAM([#include <sys/time.h>
    main() {struct timeval tp;
    gettimeofday(&tp,(void*)0);return 0;}],AC_MSG_RESULT(two - whew),
    DEVCFLAGS="$DEVCFLAGS -DUSE_WIERDGETTIMEOFDAY"
    AC_MSG_RESULT(one!))
fi
#
#
# 
# Tests for X etc should go here ...
#
MPEGRAPHICS_SOURCE=""
MPEGRAPHICS_OBJS=""
MPEGRAPHICS_FSOURCE=""
MPEGRAPHICS_FOBJS=""
X_INC=""
X_LIB=""

if test -n "$MPE_DIR"; then
  MPE_DIR="$MPIR_HOME/$MPE_DIR"
  if test -n "$MPE_GRAPHICS"; then
   # FIND_X doesn't always work correctly when cross compiling, so we
   # try to be more careful and conservative
   PAC_FIND_X11
  fi
  if test -n "$MPE_GRAPHICS" -a -z "$no_x" ; then
    MPE_LIBS="-lmpe -lX11 -lm"
    MPEGRAPHICS_SOURCE="mpe_graphics.c xcolor.c xframe.c xinit.c xwmap.c xmouse.c"
    MPEGRAPHICS_OBJS="mpe_graphics.o xcolor.o xframe.o xinit.o xwmap.o xmouse.o"
    MPEGRAPHICS_FSOURCE="mpe_graphicsf.c"
    MPEGRAPHICS_FOBJS="mpe_graphicsf.o"
    if test -z "$x_includes" ; then
      X_INC=""
    else
      X_INC="-I$x_includes"
    fi
    if test -z "$x_libraries" ; then
      X_LIB=""
    else
      X_LIB="-L$x_libraries"
      MPE_LIBS="$X_LIB -lmpe -lX11 -lm"
    fi
    # On the Meiko CS2, you have to add additional libraries to satisfy
    # the externals needed by -X11.
    if test -n "$arch_meiko" ; then
        MPE_LIBS="$MPE_LIBS -lsocket -lnsl"
    fi
  else
    MPE_GRAPHICS=""
    MPE_LIBS="-lmpe"
  fi
else
  MPE_GRAPHICS=""
fi
#
# Check for remote shell program
#
RSH_COMMAND=
if test -z "$RSHCOMMAND" ; then
    PAC_PROGRAMS_CHECK(RSH_COMMAND,remsh rsh)
else
    RSH_COMMAND=$RSHCOMMAND
    echo "Using $RSHCOMMAND for remote shell"
fi
#
if test $HAS_F77 = 0 -a $NOF77 = 0 ; then
    NOF77=1
    HAS_FORTRAN=0
    CFLAGS="$CFLAGS -DMPID_NO_FORTRAN"
    MPI_FOBJECTS="" 
elif test $HAS_F77 = 1 ; then
    PAC_GET_FORTNAMES
    if test $HAS_FORTRAN = 0 ; then
	CFLAGS="$CFLAGS -DMPID_NO_FORTRAN"
        MPI_FOBJECTS=""
    elif test -n "$WDEF" ; then
        CFLAGS="$CFLAGS $WDEF"
    fi
fi
if test $HAS_FORTRAN != 0 ; then
    PAC_FORTRAN_HAS_INCDIR(FINC="-I@MPIR_HOME@/include",)
    # 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 -Iinclude for mpif.h)
fi
#
# 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_HAVE_FUNCS(gethostname sysinfo uname)
#
# 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) | grep 'Unknown host'`
#	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
#
# systeminfo is needed for sysinfo 
PAC_CHECK_HEADERS(sys/systeminfo.h)
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
PAC_PROGRAM_CHECK(has_gencat,gencat,1,0,d_gencat)
if test $has_gencat = 1 ; then
    AC_DEFINE(HAVE_GENCAT)
    PAC_CHECK_HEADERS(nl_types.h)
    NLS_DEFS="$DEFS"
    # Generate the cataloge
    AC_MSG("Generating message catalogs")
    # WARNING: IRIX systems seem to use a DIFFERENT MESSAGE CATALOG FORMAT
    # AND (AS USUAL) MAY NOT WORK AS EXPECTED.  This is the "....cat.m" file.
    (cd src/env ; \
    for file in mpich.*.msg ; do \
	fileroot=`basename $file .msg` ; \
        /bin/rm -f $fileroot.cat ; \
        gencat $fileroot.cat $file ; \
        if test -s $fileroot.cat ; then \
	    cp $fileroot.cat ../../lib/$ARCH ; \
        fi ; \
        if test -s $fileroot.cat.m ; then \
	    cp $fileroot.cat.m ../../lib/$ARCH ; \
        fi ; \
    done \
    )
    if test -s src/env/mpich.En_US.cat ; then
	if test ! -s lib/$ARCH/mpich.cat ; then
	   (cd lib/$ARCH ; ln -s mpich.En_US.cat mpich.cat )
        fi
	AC_MSG_RESULT("done")
    else
        AC_MSG_RESULT("Could not create catalog; US English messages will be used")
    fi
fi
DEFS="$SAVEDEFS"
#
AC_STDC_HEADERS
SAVEDEFS="$DEFS"
DEFS=""
PAC_CHECK_HEADERS(stdlib.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).
#
if test -n "$havestdarg" ; then
    PAC_COMPILE_CHECK_FUNC(stdarg is correct,[
/* DEC Alpha compiler by default does NOT define __STDC__ but DOES
   accept prototypes */
#if !defined(__STDC__)
'bad text'
#endif
#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;}],AC_DEFINE(USE_STDARG))
fi
PAC_MALLOC_RETURNS_VOID()
USER_DEFS="$USER_DEFS $DEFS"
DEFS="$SAVEDEFS $DEFS"
#
# System is used only in MPE; i860's do not support it.
AC_HAVE_FUNCS(system)
#
# Nice is used only in env/init.c
AC_HAVE_FUNCS(nice)
#
# 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=true
  FLINKER=true
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;
       CFLAGS="-DMPID_NO_FORTRAN $CFLAGS"
       F77=true
       FLINKER=true
       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

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)
#
PAC_POINTER_64_BITS()
PAC_INT_LT_POINTER()
if test -n "$F77IDX" ; then
    AC_DEFINE(POINTER_64_BITS)
fi

# 
# Do not test 
if test "$NOSHORTLONGS" = 0 ; then
    # If not cross-compiling, we could dynamically check
    dnl The AC_LONG_DOUBLE macro is junk (it doesn't check that 
    dnl long double exists at all!
    PAC_LONG_DOUBLE()
    PAC_LONG_LONG_INT()
    PAC_CHECK_SIZEOF(double,doublesize)
    PAC_CHECK_SIZEOF(long double,longdoublesize)
    if test $doublesize -eq $longdoublesize ; 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
#
# Look for wish (the tcl/tk windowing shell; this is used by the new
# Upshot
#
if test -z "$wishloc" ; then
    PAC_FIND_WISH
fi
#
# Test that wish exists
if test -n "$wishloc" ; then
   namelen=`expr "$wishloc" : ".*"`
   if test $namelen -gt 26 ; then
	print_error "The path for wish, $wishloc, may be too long"
        print_error "for some Unix systems to accept as a command interpreter."
	print_error "This may cause problems when using upshot."
        print_error "(Some systems limit the length to 26 characters!)"
   fi
   if test ! -x $wishloc ; then
       wishloc=
   fi
fi
if test -z "$wishloc" ; then
    print_error "Could not find executable wish (needed for Upshot)"
fi
if test -z "$TCL_DIR" ; then
    PAC_FIND_TCL
fi
#
# Test the tcl was found
if test -z "$TCL_DIR" ; then
    print_error "Could not find libraries for TCL and TK (needed for Nupshot)"
fi
#
# Get TK version for Upshot.
TK_VERSION="3.6"
if test -n "$TK_DIR" -a $cross_compiling != 1 ; then
    if test -z "$XINCLUDES" ; then
	# Try to find X11 needed for TK_VERSION
	PAC_FIND_X11
    fi
    PAC_TK_VERSION
fi
#
# Set the location of the bitmaps
#
USER_CFLAGS="$CFLAGS $USER_DEFS"
CFLAGS="$CFLAGS $DEFS"
if test $is_adi1 = 0 ; then
    CFLAGS="$CFLAGS -DMPI_ADI2 -I../../mpid/ch2"
fi
LIB_PATH="-L$MPIR_HOME/lib/$ARCH/$COMM $LIB_PATH"
#
# hpux's Fortran compiler f77 (but not the POSIX version fort77) does
# not accept -L <dir> for library search path.
FLIB_PATH_LEADER="-L"
if test -n "$arch_hpux" -a "$F77" = "f77" ; then
   FLIB_PATH=`echo $LIB_PATH | sed -e 's/-L/-Wl,-L,/g'`
   FLIB_PATH_LEADER="-Wl,-L,"
else
   FLIB_PATH="$LIB_PATH"
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)
#
if test $DEVICE_KIND = network ; then
    if test ! -s util/machines/machines.$ARCH ; then
        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 <<.
$HOST
$HOST
$HOST
$HOST
$HOST
.
	echo "Created util/machines/machines.$ARCH with five copies of $HOST"
	echo "You may want to edit this file to add and delete hosts"
	echo "(These hosts are used by mpirun.)"
    fi
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=$MPIR_HOME/lib/$ARCH/$COMM/mpicc
MPIF77=$MPIR_HOME/lib/$ARCH/$COMM/mpif77
MPICPLUSPLUS=$MPIR_HOME/lib/$ARCH/$COMM/mpiCC
#
#
# Substitute variables
# Variables used in scripts only
AC_SUBST(AUTOMOUNTFIX)dnl
# We really need to unify RSHCOMMAND and RSH_COMMAND
RSHCOMMAND=$rshcommand
AC_SUBST(RSHCOMMAND)dnl
AC_SUBST(RSH_COMMAND)dnl
# FINC contains an @MPIR_HOME@, so it needs to come first
AC_SUBST(FINC)dnl
AC_SUBST(wishloc)dnl
AC_SUBST(TK_DIR)dnl
AC_SUBST(TCL_DIR)dnl
AC_SUBST(TK_VERSION)dnl
dnl not used AC_SUBST(BITMAP_DIR)dnl
AC_SUBST(SYNCLOC)dnl
# Variables defined ONLY for the doc/port file:
AC_SUBST(COMPRESSEDPKT)dnl
AC_SUBST(CONFIGURE_ARGS)dnl
AC_SUBST(CONFIGURE_ARGS_CLEAN)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(VARPKT)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(BOPT)dnl
AC_SUBST(CC)dnl
AC_SUBST(CFLAGS)dnl
AC_SUBST(CLINKER)dnl
AC_SUBST(CCC)dnl
AC_SUBST(CCFLAGS)dnl
AC_SUBST(CCLINKER)dnl
AC_SUBST(COMM)dnl
AC_SUBST(CPP_COMPILER)dnl
AC_SUBST(CPP_DIR)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(FAST_COPY)dnl
AC_SUBST(FFLAGS)dnl
AC_SUBST(FLIB_PATH)dnl
AC_SUBST(FLIB_PATH_LEADER)dnl
AC_SUBST(FLINKER)dnl
AC_SUBST(GETNAME_DEFS)dnl
AC_SUBST(HAS_FORTRAN)dnl
AC_SUBST(ICCLIB)dnl    Used by -device=nx
AC_SUBST(INCLUDE_PATH)dnl
AC_SUBST(LIB_LIST)dnl
AC_SUBST(LIB_PATH)dnl
AC_SUBST(MAKE)dnl
AC_SUBST(MPEGRAPHICS_FOBJS)dnl
AC_SUBST(MPEGRAPHICS_FSOURCE)dnl
AC_SUBST(MPEGRAPHICS_OBJS)dnl
AC_SUBST(MPEGRAPHICS_SOURCE)dnl
AC_SUBST(MPE_CFLAGS)dnl
AC_SUBST(MPE_DIR)dnl
AC_SUBST(MPE_GRAPHICS)dnl
AC_SUBST(MPE_LIBS)dnl
AC_SUBST(MPE_MPI_EXT_C)dnl
AC_SUBST(MPE_MPI_EXT_O)dnl
AC_SUBST(MPIR_HOME)dnl
AC_SUBST(MPI_FOBJECTS)dnl
AC_SUBST(MPILIBNAME)dnl
AC_SUBST(MPICC)dnl
AC_SUBST(MPIF77)dnl
AC_SUBST(MPICPLUSPLUS)dnl
AC_SUBST(MEMDEBUG)dnl
AC_SUBST(NLS_DEFS)dnl
AC_SUBST(OPTFLAGS)dnl
AC_SUBST(OPTFLAGSC)dnl
AC_SUBST(OPTFLAGSF)dnl
AC_SUBST(P4_ARCH)dnl
AC_SUBST(P4_DIR)dnl
AC_SUBST(RHS_COMMAND)dnl
# P4_MDEPCFLAGS now used only in doc/port.in
AC_SUBST(P4_MDEPCFLAGS)dnl
AC_SUBST(PREFIX)dnl
AC_SUBST(RANLIB)dnl
AC_SUBST(TOOLS_DIR)dnl
AC_SUBST(USER_CFLAGS)dnl
AC_SUBST(USER_INCLUDE_PATH)dnl
AC_SUBST(X_INC)dnl
AC_SUBST(X_LIB)dnl
#
# src/env/farg.f
# 
AC_SUBST(F77IARGC)dnl
AC_SUBST(F77GETARG)dnl
AC_SUBST(F90UNIX)dnl
# End configuration file
AC_OUTPUT(Makefile examples/Makefile examples/test/Makefile examples/test/pt2pt/Makefile examples/test/coll/Makefile examples/test/topol/Makefile examples/test/context/Makefile examples/test/env/Makefile examples/test/profile/Makefile examples/test/lederman/Makefile examples/contrib/Makefile examples/contrib/usingmpi/Makefile examples/contrib/life/Makefile examples/contrib/nuclei/Makefile examples/contrib/C++/Makefile examples/contrib/mandel-pvm/Makefile examples/perftest/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/c++/Makefile mpe/Makefile mpe/Makefile_nompi examples/basic/Makefile profiling/examples/Makefile profiling/lib/Makefile mpe/contrib/mandel/Makefile mpe/contrib/mastermind/Makefile mpe/contrib/life/Makefile mpe/test/Makefile )
PAC_OUTPUT_EXEC(examples/test/pt2pt/runtests examples/test/coll/runtests examples/test/topol/runtests examples/test/context/runtests examples/test/env/runtests examples/test/profile/runtests util/mpicc util/mpiCC util/mpif77 util/mpiinstall,a+x )
PAC_OUTPUT_EXEC(src/env/farg.f)
#
# Configure JUST the correct device file
CONFIG_FILES="mpid/$DEVICE/Makefile mpid/tests/Makefile"
if test -n "$device_ch_shmem" ; then
    if test -s mpid/ch_shmem/p2ptest/Makefile.in ; then
        CONFIG_FILES="$CONFIG_FILES mpid/ch_shmem/p2ptest/Makefile"
    fi
fi
if test -n "$device_ch_tcp" -a -s mpid/ch_tcp/p3/Makefile.in ; then
    CONFIG_FILES="$CONFIG_FILES  mpid/ch_tcp/p3/Makefile"
fi
export CONFIG_FILES
./config.status
CONFIG_FILES=""
#
# The programs that run on the front end need a different compiler
if test $cross_compiling != 1 ; then
    CONFIG_FILES="profiling/wrappergen/Makefile profiling/nupshot/Makefile"
    export CONFIG_FILES
    ./config.status
    CONFIG_FILES=""
else
    print_error Not creating Makefiles in profiling/wrappergen and nupshot
    print_error when cross-compiling for arch $ARCH and device $DEVICE.
    print_error profiling/nupshot and profiling/wrappergen both have
    print_error their own configure scripts.  You can use these on 
    print_error another platform to build these programs.
fi
#
# Scripts in util: Copy to lib directory
for src in mpicc mpiCC mpif77 mpiinstall ; do 
  (cd util ; cp $src ../lib/$ARCH/$COMM ) 
done
#
# Set the final choices of flags
if test "$MEMDEBUG" = "1" ; then
    /bin/rm -f include/mpisys.h
    (cd include ; echo "#define MPIR_MEMDEBUG" | cat - mpisys.h.in > mpisys.h)
else 
    /bin/rm -f include/mpisys.h
    cp include/mpisys.h.in include/mpisys.h
fi

#
# If the test suite is part of the directory, generate its makefiles
if test -d tsuite ; then
    CONFIG_FILES="tsuite/Makefile tsuite/coll/Makefile tsuite/pt2pt/Makefile tsuite/mpitc2/Makefile"
    export CONFIG_FILES
    ./config.status
fi
#
# If the bugs directory is available, generate its makefiles
if test -d bugs ; then
    CONFIG_FILES="bugs/Makefile bugs/irecv/Makefile bugs/fort/Makefile bugs/sockperf/Makefile bugs/srleak/Makefile bugs/ssend/Makefile bugs/testsendrecv/Makefile bugs/wait/Makefile"
    export CONFIG_FILES
    ./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.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.status
fi
#
# If the doc/port.in file is available, generate it
if test -f doc/port.in ; then
    PAC_OUTPUT_EXEC(doc/port doc/portbuild doc/portperf doc/porttest,a+x)
fi
#
# Remove the old config.status and copy new one; this allows mpireconfig to
# work with the current configuration.
# 
/bin/rm -f lib/$ARCH/$COMM/config.status
cp ./config.status lib/$ARCH/$COMM

#
# Try to update the upshot script
#if test -f profiling/upshot/bin/upshot.in
#    CONFIG_FILES="profiling/upshot/bin/upshot"
#    export CONFIG_FILES
#    ./config.status
#    (cd profiling/upshot/bin ; /bin/rm -f .run1 ; \
#	sed -e '1d' upshot > .run1 ; \
#    /bin/rm -f upshot ; /bin/mv .run1 upshot ; chmod a+x upshot )
#fi
exit 0
