#!/bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated automatically using autoconf.
# Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.

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

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

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

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

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

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

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

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

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

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

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

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

     *) ;;
    esac
  fi
done

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

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

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

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

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


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


if test -z "$CC"; then
  # Extract the first word of `gcc', so it can be a program name with args.
  set dummy gcc; word=$2
  echo checking for $word
  IFS="${IFS= 	}"; saveifs="$IFS"; IFS="${IFS}:"
  for dir in $PATH; do
    test -z "$dir" && dir=.
    if test -f $dir/$word; then
      CC="gcc"
      break
    fi
  done
  IFS="$saveifs"
fi
test -z "$CC" && CC="cc"
test -n "$CC" && test -n "$verbose" && echo "	setting CC to $CC"

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

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

CC=${CC-cc}


echo checking for pid_t in sys/types.h
echo checking how to run the C preprocessor
if test -z "$CPP"; then
  # This must be in double quotes, not single quotes, because CPP may get
  # substituted into the Makefile and ``${CC-cc}'' will simply confuse
  # make.  It must be expanded now.
  CPP="${CC-cc} -E"
  cat > conftest.c <<EOF
#include "confdefs.h"
#include <stdio.h>
Syntax Error
EOF
err=`eval "($CPP conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  :
else
  rm -rf conftest*
  CPP=/lib/cpp
fi
rm -f conftest*
fi
test ".${verbose}" != "." && echo "	setting CPP to $CPP"

echo '#include "confdefs.h"
#include <sys/types.h>' > conftest.c
eval "$CPP conftest.c > conftest.out 2>&1"
if egrep "pid_t" conftest.out >/dev/null 2>&1; then
  :
else
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining" pid_t to be int
echo "#define" pid_t int >> confdefs.h
DEFS="$DEFS -Dpid_t=int"
SEDDEFS="${SEDDEFS}\${SEDdA}pid_t\${SEDdB}pid_t\${SEDdC}int\${SEDdD}
\${SEDuA}pid_t\${SEDuB}pid_t\${SEDuC}int\${SEDuD}
\${SEDeA}pid_t\${SEDeB}pid_t\${SEDeC}int\${SEDeD}
"
}

fi
rm -f conftest*


#
# On a few systems, libm.a is the same as libc.a
#
echo checking for sin
cat > conftest.c <<EOF
#include "confdefs.h"
#include <ctype.h>
int main() { exit(0); }
int t() { 
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_sin) || defined (__stub___sin)
choke me
#else
/* Override any gcc2 internal prototype to avoid an error.  */
extern char sin(); sin();
#endif
 }
EOF
if eval $compile; then
  :
else
  rm -rf conftest*
  LIBS="-lm" ; test -n "$verbose" && echo "	Adding -lm to library list"
fi
rm -f conftest*

#
# Ok, lets find the tk source trees so we can use the headers
# If the directory (presumably symlink) named "tk" exists, use that one
# in preference to any others.  Same logic is used when choosing library
# and again with Tcl.
#
no_tk=true
echo "checking for Tk source directory"
TKHDIR=""
for i in `ls -d ${srcdir}/../tk* 2>/dev/null` ${srcdir}/../tk ; do
  if test -f $i/tk.h ; then
    TKHDIR="-I$i"
  fi
done
# if we can't find it, see if one is installed
if test x"$TKHDIR" = x ; then
  echo checking for tk.h
cat > conftest.c <<EOF
#include "confdefs.h"
#include <tk.h>
EOF
err=`eval "($CPP conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  rm -rf conftest*
  installed=1

else
  rm -rf conftest*
  installed=0
fi
rm -f conftest*

  if test $installed -eq 0 ; then
    TKHDIR="# no Tk directory found"
    test -n "$verbose" && echo "	WARNING: Can't find Tk directory"
  fi
else
  test -n "$verbose" && echo "	defining TKHDIR to be $i"
  no_tk=
fi

#
# Ok, lets find the tk library
# First, look for one uninstalled.  
#
TKLIB=""
echo "checking for Tk library"
for i in `ls -d ../tk* 2>/dev/null` ../tk ; do
  if test -f "$i/libtk.a" ; then
    TKLIB=$i/libtk.a
  fi
done    
# If not found, look for installed version
if test x"$TKLIB" = x ; then
  LIBS_save="${LIBS}"
LIBS="${LIBS} -ltk"
have_lib=""
echo checking for -ltk
cat > conftest.c <<EOF
#include "confdefs.h"

int main() { exit(0); }
int t() { main(); }
EOF
if eval $compile; then
  rm -rf conftest*
  have_lib="1"

fi
rm -f conftest*
LIBS="${LIBS_save}"
if test -n "${have_lib}"; then
   :; installed=1
else
   :; installed=0
fi

  if test $installed -eq 1 ; then
    TKLIB="-ltk"
  fi
fi

# If still not found, assume Tk simply hasn't been built yet
if test x"$TKLIB" = x ; then
  for i in `ls -d ../tk* 2>/dev/null` ../tk ; do
    if test -f "$i/tk.h" ; then
      TKLIB=$i/libtk.a
    fi
  done    
fi

if test x"$TKLIB" = x ; then
    TKLIB="# no Tk library found"
    echo "	WARNING: Can't find Tk library"
    echo "      continuing, however you won't be able to build Tk-based programs"
else
    test -n "$verbose" && echo "	defining TKLIB to be $TKLIB"
fi

#
# Ok, lets find the tcl source trees so we can use the headers
#
# Warning: transition of version 9 to 10 will break this algorithm
# because 10 sorts before 9.
#
echo "checking for Tcl source directory"
TCLHDIR=""
for i in `ls -d ${srcdir}/../tcl* 2>/dev/null` ${srcdir}/../tcl ; do
  if test -f $i/tclInt.h ; then
    TCLHDIR="-I$i"
  fi
done
# if we can't find it, see if one is installed
if test x"$TCLHDIR" = x ; then
  echo checking for tclInt.h
cat > conftest.c <<EOF
#include "confdefs.h"
#include <tclInt.h>
EOF
err=`eval "($CPP conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  rm -rf conftest*
  installed=1

else
  rm -rf conftest*
  installed=0
fi
rm -f conftest*

  if test $installed -eq 0 ; then
    TCLHDIR="# no Tcl directory found"
    echo "	ERROR: Can't find Tcl directory"
  fi
else
  test -n "$verbose" && echo "	defining TCLHDIR to be $i"
fi

#
# Ok, lets find the tcl library
# First, look for the latest uninstalled
#
TCLLIB=""
echo "checking for Tcl library"
for i in `ls -d ../tcl* 2>/dev/null` ../tcl ; do
  if test -f "$i/libtcl.a" ; then
    TCLLIB=$i/libtcl.a
  fi
done    
# If not found, look for installed version
if test x"$TCLLIB" = x ; then
  LIBS_save="${LIBS}"
LIBS="${LIBS} -ltcl"
have_lib=""
echo checking for -ltcl
cat > conftest.c <<EOF
#include "confdefs.h"

int main() { exit(0); }
int t() { main(); }
EOF
if eval $compile; then
  rm -rf conftest*
  have_lib="1"

fi
rm -f conftest*
LIBS="${LIBS_save}"
if test -n "${have_lib}"; then
   :; installed=1
else
   :; installed=0
fi

  if test $installed -eq 1 ; then
    TCLLIB="-ltcl"
  fi
fi
# If still not found, assume Tcl simply hasn't been built yet
if test x"$TCLLIB" = x ; then
  for i in `ls -d ../tcl* 2>/dev/null` ../tcl ; do
    if test -f "$i/tcl.h" ; then
      TCLLIB=$i/libtcl.a
    fi
  done    
fi

if test x"$TCLLIB" = x ; then
    TCLLIB="# no Tcl library found"
    echo "	ERROR: Can't find Tcl library"
else
    test -n "$verbose" && echo "	defining TCLLIB to be $TCLLIB"
fi



#
# Look for various header files
#
echo checking for sys/sysmacros.h
cat > conftest.c <<EOF
#include "confdefs.h"
#include <sys/sysmacros.h>
EOF
err=`eval "($CPP conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining HAVE_SYSMACROS_H"
echo "#define" HAVE_SYSMACROS_H 1 >> confdefs.h
DEFS="$DEFS -DHAVE_SYSMACROS_H=1"
SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_SYSMACROS_H\${SEDdB}HAVE_SYSMACROS_H\${SEDdC}1\${SEDdD}
\${SEDuA}HAVE_SYSMACROS_H\${SEDuB}HAVE_SYSMACROS_H\${SEDuC}1\${SEDuD}
\${SEDeA}HAVE_SYSMACROS_H\${SEDeB}HAVE_SYSMACROS_H\${SEDeC}1\${SEDeD}
"
}


fi
rm -f conftest*

echo checking for stdlib.h
cat > conftest.c <<EOF
#include "confdefs.h"
#include <stdlib.h>
EOF
err=`eval "($CPP conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  :
else
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining NO_STDLIB_H"
echo "#define" NO_STDLIB_H 1 >> confdefs.h
DEFS="$DEFS -DNO_STDLIB_H=1"
SEDDEFS="${SEDDEFS}\${SEDdA}NO_STDLIB_H\${SEDdB}NO_STDLIB_H\${SEDdC}1\${SEDdD}
\${SEDuA}NO_STDLIB_H\${SEDuB}NO_STDLIB_H\${SEDuC}1\${SEDuD}
\${SEDeA}NO_STDLIB_H\${SEDeB}NO_STDLIB_H\${SEDeC}1\${SEDeD}
"
}

fi
rm -f conftest*

echo checking for unistd.h
cat > conftest.c <<EOF
#include "confdefs.h"
#include <unistd.h>
EOF
err=`eval "($CPP conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining HAVE_UNISTD_H"
echo "#define" HAVE_UNISTD_H 1 >> confdefs.h
DEFS="$DEFS -DHAVE_UNISTD_H=1"
SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_UNISTD_H\${SEDdB}HAVE_UNISTD_H\${SEDdC}1\${SEDdD}
\${SEDuA}HAVE_UNISTD_H\${SEDuB}HAVE_UNISTD_H\${SEDuC}1\${SEDuD}
\${SEDeA}HAVE_UNISTD_H\${SEDeB}HAVE_UNISTD_H\${SEDeC}1\${SEDeD}
"
}


fi
rm -f conftest*

echo checking for sys/wait.h
cat > conftest.c <<EOF
#include "confdefs.h"
#include <sys/wait.h>
EOF
err=`eval "($CPP conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining HAVE_SYS_WAIT_H"
echo "#define" HAVE_SYS_WAIT_H 1 >> confdefs.h
DEFS="$DEFS -DHAVE_SYS_WAIT_H=1"
SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_SYS_WAIT_H\${SEDdB}HAVE_SYS_WAIT_H\${SEDdC}1\${SEDdD}
\${SEDuA}HAVE_SYS_WAIT_H\${SEDuB}HAVE_SYS_WAIT_H\${SEDuC}1\${SEDuD}
\${SEDeA}HAVE_SYS_WAIT_H\${SEDeB}HAVE_SYS_WAIT_H\${SEDeC}1\${SEDeD}
"
}


fi
rm -f conftest*

echo checking for sys/stropts.h
cat > conftest.c <<EOF
#include "confdefs.h"
#include <sys/stropts.h>
EOF
err=`eval "($CPP conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining HAVE_STROPTS_H"
echo "#define" HAVE_STROPTS_H 1 >> confdefs.h
DEFS="$DEFS -DHAVE_STROPTS_H=1"
SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_STROPTS_H\${SEDdB}HAVE_STROPTS_H\${SEDdC}1\${SEDdD}
\${SEDuA}HAVE_STROPTS_H\${SEDuB}HAVE_STROPTS_H\${SEDuC}1\${SEDuD}
\${SEDeA}HAVE_STROPTS_H\${SEDeB}HAVE_STROPTS_H\${SEDeC}1\${SEDeD}
"
}


fi
rm -f conftest*

echo checking for sys/sysconfig.h
cat > conftest.c <<EOF
#include "confdefs.h"
#include <sys/sysconfig.h>
EOF
err=`eval "($CPP conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining HAVE_SYSCONF_H"
echo "#define" HAVE_SYSCONF_H 1 >> confdefs.h
DEFS="$DEFS -DHAVE_SYSCONF_H=1"
SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_SYSCONF_H\${SEDdB}HAVE_SYSCONF_H\${SEDdC}1\${SEDdD}
\${SEDuA}HAVE_SYSCONF_H\${SEDuB}HAVE_SYSCONF_H\${SEDuC}1\${SEDuD}
\${SEDeA}HAVE_SYSCONF_H\${SEDeB}HAVE_SYSCONF_H\${SEDeC}1\${SEDeD}
"
}


fi
rm -f conftest*

echo checking for sys/fcntl.h
cat > conftest.c <<EOF
#include "confdefs.h"
#include <sys/fcntl.h>
EOF
err=`eval "($CPP conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining HAVE_SYS_FCNTL_H"
echo "#define" HAVE_SYS_FCNTL_H 1 >> confdefs.h
DEFS="$DEFS -DHAVE_SYS_FCNTL_H=1"
SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_SYS_FCNTL_H\${SEDdB}HAVE_SYS_FCNTL_H\${SEDdC}1\${SEDdD}
\${SEDuA}HAVE_SYS_FCNTL_H\${SEDuB}HAVE_SYS_FCNTL_H\${SEDuC}1\${SEDuD}
\${SEDeA}HAVE_SYS_FCNTL_H\${SEDeB}HAVE_SYS_FCNTL_H\${SEDeC}1\${SEDeD}
"
}


fi
rm -f conftest*




#
# Look for various functions
#
echo checking for memcpy
cat > conftest.c <<EOF
#include "confdefs.h"
#include <ctype.h>
int main() { exit(0); }
int t() { 
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_memcpy) || defined (__stub___memcpy)
choke me
#else
/* Override any gcc2 internal prototype to avoid an error.  */
extern char memcpy(); memcpy();
#endif
 }
EOF
if eval $compile; then
  :
else
  rm -rf conftest*
  {
test -n "$verbose" && \
echo "	defining NO_MEMCPY"
echo "#define" NO_MEMCPY 1 >> confdefs.h
DEFS="$DEFS -DNO_MEMCPY=1"
SEDDEFS="${SEDDEFS}\${SEDdA}NO_MEMCPY\${SEDdB}NO_MEMCPY\${SEDdC}1\${SEDdD}
\${SEDuA}NO_MEMCPY\${SEDuB}NO_MEMCPY\${SEDuC}1\${SEDuD}
\${SEDeA}NO_MEMCPY\${SEDeB}NO_MEMCPY\${SEDeC}1\${SEDeD}
"
}

fi
rm -f conftest*

echo checking for waitpid
cat > conftest.c <<EOF
#include "confdefs.h"
#include <ctype.h>
int main() { exit(0); }
int t() { 
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_waitpid) || defined (__stub___waitpid)
choke me
#else
/* Override any gcc2 internal prototype to avoid an error.  */
extern char waitpid(); waitpid();
#endif
 }
EOF
if eval $compile; then
  :
else
  rm -rf conftest*
  {
test -n "$verbose" && \
echo "	defining NOWAITPID"
echo "#define" NOWAITPID 1 >> confdefs.h
DEFS="$DEFS -DNOWAITPID=1"
SEDDEFS="${SEDDEFS}\${SEDdA}NOWAITPID\${SEDdB}NOWAITPID\${SEDdC}1\${SEDdD}
\${SEDuA}NOWAITPID\${SEDuB}NOWAITPID\${SEDuC}1\${SEDuD}
\${SEDeA}NOWAITPID\${SEDeB}NOWAITPID\${SEDeC}1\${SEDeD}
"
}

fi
rm -f conftest*

echo checking for wait4
cat > conftest.c <<EOF
#include "confdefs.h"
#include <ctype.h>
int main() { exit(0); }
int t() { 
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_wait4) || defined (__stub___wait4)
choke me
#else
/* Override any gcc2 internal prototype to avoid an error.  */
extern char wait4(); wait4();
#endif
 }
EOF
if eval $compile; then
  rm -rf conftest*
  {
test -n "$verbose" && \
echo "	defining HAVE_WAIT4"
echo "#define" HAVE_WAIT4 1 >> confdefs.h
DEFS="$DEFS -DHAVE_WAIT4=1"
SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_WAIT4\${SEDdB}HAVE_WAIT4\${SEDdC}1\${SEDdD}
\${SEDuA}HAVE_WAIT4\${SEDuB}HAVE_WAIT4\${SEDuC}1\${SEDuD}
\${SEDeA}HAVE_WAIT4\${SEDeB}HAVE_WAIT4\${SEDeC}1\${SEDeD}
"
}


fi
rm -f conftest*

echo checking for sysconf
cat > conftest.c <<EOF
#include "confdefs.h"
#include <ctype.h>
int main() { exit(0); }
int t() { 
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_sysconf) || defined (__stub___sysconf)
choke me
#else
/* Override any gcc2 internal prototype to avoid an error.  */
extern char sysconf(); sysconf();
#endif
 }
EOF
if eval $compile; then
  rm -rf conftest*
  {
test -n "$verbose" && \
echo "	defining HAVE_SYSCONF"
echo "#define" HAVE_SYSCONF 1 >> confdefs.h
DEFS="$DEFS -DHAVE_SYSCONF=1"
SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_SYSCONF\${SEDdB}HAVE_SYSCONF\${SEDdC}1\${SEDdD}
\${SEDuA}HAVE_SYSCONF\${SEDuB}HAVE_SYSCONF\${SEDuC}1\${SEDuD}
\${SEDeA}HAVE_SYSCONF\${SEDeB}HAVE_SYSCONF\${SEDeC}1\${SEDeD}
"
}


fi
rm -f conftest*


echo checking to see if wait expects union
echo checking for union wait
cat > conftest.c <<EOF
#include "confdefs.h"
#include <sys/types.h> 
#include <sys/wait.h>
int main() { exit(0); }
int t() { 
union wait x;
WIFEXITED(x);		/* Generates compiler error if WIFEXITED
			 * uses an int. */
 }
EOF
if eval $compile; then
  :
else
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining NO_UNION_WAIT"
echo "#define" NO_UNION_WAIT 1 >> confdefs.h
DEFS="$DEFS -DNO_UNION_WAIT=1"
SEDDEFS="${SEDDEFS}\${SEDdA}NO_UNION_WAIT\${SEDdB}NO_UNION_WAIT\${SEDdC}1\${SEDdD}
\${SEDuA}NO_UNION_WAIT\${SEDuB}NO_UNION_WAIT\${SEDuC}1\${SEDuD}
\${SEDeA}NO_UNION_WAIT\${SEDeB}NO_UNION_WAIT\${SEDeC}1\${SEDeD}
"
}

fi
rm -f conftest*


#
# check how signals work
#

# Check for the data type of the mask used in select().
# This picks up HP braindamage which defines fd_set and then 
# proceeds to ignore it and use int.
# Pattern matching on int could be loosened.
# Can't use ac_header_egrep since that doesn't see prototypes with K&R cpp.
echo checking mask type of select
if egrep "select\(size_t, int" /usr/include/sys/time.h >/dev/null 2>&1; then
  
{
test -n "$verbose" && \
echo "	defining" SELECT_MASK_TYPE to be int
echo "#define" SELECT_MASK_TYPE int >> confdefs.h
DEFS="$DEFS -DSELECT_MASK_TYPE=int"
SEDDEFS="${SEDDEFS}\${SEDdA}SELECT_MASK_TYPE\${SEDdB}SELECT_MASK_TYPE\${SEDdC}int\${SEDdD}
\${SEDuA}SELECT_MASK_TYPE\${SEDuB}SELECT_MASK_TYPE\${SEDuC}int\${SEDuD}
\${SEDeA}SELECT_MASK_TYPE\${SEDeB}SELECT_MASK_TYPE\${SEDeC}int\${SEDeD}
"
}

fi

# Check for the data type of the function used in signal(). This
# must be before the test for rearming.
echo checking return type of signal handlers
echo '#include "confdefs.h"
#include <signal.h>' > conftest.c
eval "$CPP conftest.c > conftest.out 2>&1"
if egrep "(void|sighandler_t).*signal" conftest.out >/dev/null 2>&1; then
  rm -rf conftest*
  retsigtype=void

else
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining" RETSIGTYPE to be int
echo "#define" RETSIGTYPE int >> confdefs.h
DEFS="$DEFS -DRETSIGTYPE=int"
SEDDEFS="${SEDDEFS}\${SEDdA}RETSIGTYPE\${SEDdB}RETSIGTYPE\${SEDdC}int\${SEDdD}
\${SEDuA}RETSIGTYPE\${SEDuB}RETSIGTYPE\${SEDuC}int\${SEDuD}
\${SEDeA}RETSIGTYPE\${SEDeB}RETSIGTYPE\${SEDeC}int\${SEDeD}
"
}
 retsigtype=int
fi
rm -f conftest*


# FIXME: check to see if alarm exists
# Check to see it signals need to be re-armed after use.
echo checking to see if signals need to be re-armed
cat > conftest.c <<EOF
#include "confdefs.h"

#include <signal.h>
#define RETSIGTYPE $retsigtype

void
sigquit_handler(n)
int n;
{
}

main()
{
	if (0 == fork()) {
		unlink("core");
		signal(SIGQUIT,sigquit_handler);
		kill(getpid(),SIGQUIT);
		kill(getpid(),SIGQUIT);
	} else {
		int status;

		wait(&status);
		exit(unlink("core")==-1?0:1);
	}
}
EOF
eval $compile
if test -s conftest && (./conftest; exit) 2>/dev/null; then
  :
else
  
{
test -n "$verbose" && \
echo "	defining REARM_SIG"
echo "#define" REARM_SIG 1 >> confdefs.h
DEFS="$DEFS -DREARM_SIG=1"
SEDDEFS="${SEDDEFS}\${SEDdA}REARM_SIG\${SEDdB}REARM_SIG\${SEDdC}1\${SEDdD}
\${SEDuA}REARM_SIG\${SEDuB}REARM_SIG\${SEDuC}1\${SEDuD}
\${SEDeA}REARM_SIG\${SEDeB}REARM_SIG\${SEDeC}1\${SEDeD}
"
}

fi
rm -fr conftest*

# HPUX7 has trouble with the big cat so split it
# Owen Rees <rtor@ansa.co.uk> 29Mar93 
SEDDEFS="${SEDDEFS}CONFEOF
cat >> conftest.sed <<CONFEOF
"
#
echo checking to see if stty reads from stdin or stdout
/bin/stty > /dev/null 2> /dev/null
if test $? -ne 0 ; then
    
{
test -n "$verbose" && \
echo "	defining STTY_READS_STDOUT"
echo "#define" STTY_READS_STDOUT 1 >> confdefs.h
DEFS="$DEFS -DSTTY_READS_STDOUT=1"
SEDDEFS="${SEDDEFS}\${SEDdA}STTY_READS_STDOUT\${SEDdB}STTY_READS_STDOUT\${SEDdC}1\${SEDdD}
\${SEDuA}STTY_READS_STDOUT\${SEDuB}STTY_READS_STDOUT\${SEDuC}1\${SEDuD}
\${SEDeA}STTY_READS_STDOUT\${SEDeB}STTY_READS_STDOUT\${SEDeC}1\${SEDeD}
"
}

fi

# Look for various features to determine what kind of pty
# we have. For some weird reason, ac_compile_check would not
# work, but ac_test_program does.
#
echo checking for HP style pty allocation
# following test fails on DECstations and other things that don't grok -c
# but that's ok, since they don't have PTYMs anyway
if test -c /dev/ptym/ptyp0 2>>/dev/null ; then
    
{
test -n "$verbose" && \
echo "	defining HAVE_PTYM"
echo "#define" HAVE_PTYM 1 >> confdefs.h
DEFS="$DEFS -DHAVE_PTYM=1"
SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_PTYM\${SEDdB}HAVE_PTYM\${SEDdC}1\${SEDdD}
\${SEDuA}HAVE_PTYM\${SEDuB}HAVE_PTYM\${SEDuC}1\${SEDuD}
\${SEDeA}HAVE_PTYM\${SEDeB}HAVE_PTYM\${SEDeC}1\${SEDeD}
"
}

fi

echo checking for HP style pty-trapping
echo '#include "confdefs.h"
#include <sys/ptyio.h>' > conftest.c
eval "$CPP conftest.c > conftest.out 2>&1"
if egrep "struct.*request_info" conftest.out >/dev/null 2>&1; then
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining HAVE_PTYTRAP"
echo "#define" HAVE_PTYTRAP 1 >> confdefs.h
DEFS="$DEFS -DHAVE_PTYTRAP=1"
SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_PTYTRAP\${SEDdB}HAVE_PTYTRAP\${SEDdC}1\${SEDdD}
\${SEDuA}HAVE_PTYTRAP\${SEDuB}HAVE_PTYTRAP\${SEDuC}1\${SEDuD}
\${SEDeA}HAVE_PTYTRAP\${SEDeB}HAVE_PTYTRAP\${SEDeC}1\${SEDeD}
"
}


fi
rm -f conftest*


echo checking for AIX new-style pty allocation
if test -r /dev/ptc -a -r /dev/pts ; then
    
{
test -n "$verbose" && \
echo "	defining HAVE_PTC_PTS"
echo "#define" HAVE_PTC_PTS 1 >> confdefs.h
DEFS="$DEFS -DHAVE_PTC_PTS=1"
SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_PTC_PTS\${SEDdB}HAVE_PTC_PTS\${SEDdC}1\${SEDdD}
\${SEDuA}HAVE_PTC_PTS\${SEDuB}HAVE_PTC_PTS\${SEDuC}1\${SEDuD}
\${SEDeA}HAVE_PTC_PTS\${SEDeB}HAVE_PTC_PTS\${SEDeC}1\${SEDeD}
"
}

fi

echo checking for SGI old-style pty allocation
if test -r /dev/ptc -a ! -r /dev/pts ; then
    
{
test -n "$verbose" && \
echo "	defining HAVE_PTC"
echo "#define" HAVE_PTC 1 >> confdefs.h
DEFS="$DEFS -DHAVE_PTC=1"
SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_PTC\${SEDdB}HAVE_PTC\${SEDdC}1\${SEDdD}
\${SEDuA}HAVE_PTC\${SEDuB}HAVE_PTC\${SEDuC}1\${SEDuD}
\${SEDeA}HAVE_PTC\${SEDeB}HAVE_PTC\${SEDeC}1\${SEDeD}
"
}

fi

echo checking for SVR4 style pty allocation
if test -r /dev/ptmx ; then
  
{
test -n "$verbose" && \
echo "	defining HAVE_PTMX"
echo "#define" HAVE_PTMX 1 >> confdefs.h
DEFS="$DEFS -DHAVE_PTMX=1"
SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_PTMX\${SEDdB}HAVE_PTMX\${SEDdC}1\${SEDdD}
\${SEDuA}HAVE_PTMX\${SEDuB}HAVE_PTMX\${SEDuC}1\${SEDuD}
\${SEDeA}HAVE_PTMX\${SEDeB}HAVE_PTMX\${SEDeC}1\${SEDeD}
"
}

  # aargg. Some systems need libpt.a to use /dev/ptmx
    echo checking for libpt.a
    echo checking for ptsname
cat > conftest.c <<EOF
#include "confdefs.h"
#include <ctype.h>
int main() { exit(0); }
int t() { 
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_ptsname) || defined (__stub___ptsname)
choke me
#else
/* Override any gcc2 internal prototype to avoid an error.  */
extern char ptsname(); ptsname();
#endif
 }
EOF
if eval $compile; then
  :
else
  rm -rf conftest*
  LIBS="${LIBS} -lpt"
fi
rm -f conftest*

fi

# In OSF/1 case, SVR4 are somewhat different.
# Gregory Depp <depp@osf.org> 17Aug93
echo checking for OSF/1 style pty allocation
if test -r /dev/ptmx_bsd ; then
    
{
test -n "$verbose" && \
echo "	defining HAVE_PTMX_BSD"
echo "#define" HAVE_PTMX_BSD 1 >> confdefs.h
DEFS="$DEFS -DHAVE_PTMX_BSD=1"
SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_PTMX_BSD\${SEDdB}HAVE_PTMX_BSD\${SEDdC}1\${SEDdD}
\${SEDuA}HAVE_PTMX_BSD\${SEDuB}HAVE_PTMX_BSD\${SEDuC}1\${SEDuD}
\${SEDeA}HAVE_PTMX_BSD\${SEDeB}HAVE_PTMX_BSD\${SEDeC}1\${SEDeD}
"
}

fi


tcgetattr=0
tcsetattr=0
echo checking for tcgetattr
cat > conftest.c <<EOF
#include "confdefs.h"
#include <ctype.h>
int main() { exit(0); }
int t() { 
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_tcgetattr) || defined (__stub___tcgetattr)
choke me
#else
/* Override any gcc2 internal prototype to avoid an error.  */
extern char tcgetattr(); tcgetattr();
#endif
 }
EOF
if eval $compile; then
  rm -rf conftest*
  tcgetattr=1

fi
rm -f conftest*

echo checking for tcsetattr
cat > conftest.c <<EOF
#include "confdefs.h"
#include <ctype.h>
int main() { exit(0); }
int t() { 
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_tcsetattr) || defined (__stub___tcsetattr)
choke me
#else
/* Override any gcc2 internal prototype to avoid an error.  */
extern char tcsetattr(); tcsetattr();
#endif
 }
EOF
if eval $compile; then
  rm -rf conftest*
  tcsetattr=1

fi
rm -f conftest*

if test $tcgetattr -eq 1 -a $tcsetattr -eq 1 ; then
    
{
test -n "$verbose" && \
echo "	defining POSIX"
echo "#define" POSIX 1 >> confdefs.h
DEFS="$DEFS -DPOSIX=1"
SEDDEFS="${SEDDEFS}\${SEDdA}POSIX\${SEDdB}POSIX\${SEDdC}1\${SEDdD}
\${SEDuA}POSIX\${SEDuB}POSIX\${SEDuC}1\${SEDuD}
\${SEDeA}POSIX\${SEDeB}POSIX\${SEDeC}1\${SEDeD}
"
}

fi

# first check for the pure bsd
echo checking for struct sgttyb
cat > conftest.c <<EOF
#include "confdefs.h"
#include <sgtty.h>
main()
{
  struct sgttyb tmp;
  exit(0);
}
EOF
eval $compile
if test -s conftest && (./conftest; exit) 2>/dev/null; then
  
{
test -n "$verbose" && \
echo "	defining HAVE_SGTTYB"
echo "#define" HAVE_SGTTYB 1 >> confdefs.h
DEFS="$DEFS -DHAVE_SGTTYB=1"
SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_SGTTYB\${SEDdB}HAVE_SGTTYB\${SEDdC}1\${SEDdD}
\${SEDuA}HAVE_SGTTYB\${SEDuB}HAVE_SGTTYB\${SEDuC}1\${SEDuD}
\${SEDeA}HAVE_SGTTYB\${SEDeB}HAVE_SGTTYB\${SEDeC}1\${SEDeD}
"
}
 PTY_TYPE=sgttyb

fi
rm -fr conftest*

# next check for the older style ttys
# note that if we detect termio.h (only), we still set PTY_TYPE=termios
# since that just controls which of pty_XXXX.c file is use and
# pty_termios.c is set up to handle pty_termio.
echo checking for struct termio
cat > conftest.c <<EOF
#include "confdefs.h"
#include <termio.h>
main()
{
  struct termio tmp;
  exit(0);
}
EOF
eval $compile
if test -s conftest && (./conftest; exit) 2>/dev/null; then
  
{
test -n "$verbose" && \
echo "	defining HAVE_TERMIO"
echo "#define" HAVE_TERMIO 1 >> confdefs.h
DEFS="$DEFS -DHAVE_TERMIO=1"
SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_TERMIO\${SEDdB}HAVE_TERMIO\${SEDdC}1\${SEDdD}
\${SEDuA}HAVE_TERMIO\${SEDuB}HAVE_TERMIO\${SEDuC}1\${SEDuD}
\${SEDeA}HAVE_TERMIO\${SEDeB}HAVE_TERMIO\${SEDeC}1\${SEDeD}
"
}
 PTY_TYPE=termios

fi
rm -fr conftest*

# now check for the new style ttys (not yet posix)
echo checking for struct termios
cat > conftest.c <<EOF
#include "confdefs.h"
#include <termios.h>
main()
{
  struct termios tmp;
  exit(0);
}
EOF
eval $compile
if test -s conftest && (./conftest; exit) 2>/dev/null; then
  
{
test -n "$verbose" && \
echo "	defining HAVE_TERMIOS"
echo "#define" HAVE_TERMIOS 1 >> confdefs.h
DEFS="$DEFS -DHAVE_TERMIOS=1"
SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_TERMIOS\${SEDdB}HAVE_TERMIOS\${SEDdC}1\${SEDdD}
\${SEDuA}HAVE_TERMIOS\${SEDuB}HAVE_TERMIOS\${SEDuC}1\${SEDuD}
\${SEDeA}HAVE_TERMIOS\${SEDeB}HAVE_TERMIOS\${SEDeC}1\${SEDeD}
"
}
 PTY_TYPE=termios

fi
rm -fr conftest*

# finally check for Cray style ttys
echo checking for Cray-style ptys
SETUID="@:"
cat > conftest.c <<EOF
#include "confdefs.h"

main(){
#ifdef CRAY
	return 0;
#else
	return 1;
#endif
}

EOF
eval $compile
if test -s conftest && (./conftest; exit) 2>/dev/null; then
  PTY_TYPE=unicos SETUID="chmod u+s"

fi
rm -fr conftest*
#
# Check for select and/or poll. If both exist, we prefer select.
# if neither exists, define SIMPLE_EVENT.
#
select=0
poll=0
echo checking for select
cat > conftest.c <<EOF
#include "confdefs.h"
#include <ctype.h>
int main() { exit(0); }
int t() { 
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_select) || defined (__stub___select)
choke me
#else
/* Override any gcc2 internal prototype to avoid an error.  */
extern char select(); select();
#endif
 }
EOF
if eval $compile; then
  rm -rf conftest*
  select=1

fi
rm -f conftest*

echo checking for poll
cat > conftest.c <<EOF
#include "confdefs.h"
#include <ctype.h>
int main() { exit(0); }
int t() { 
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_poll) || defined (__stub___poll)
choke me
#else
/* Override any gcc2 internal prototype to avoid an error.  */
extern char poll(); poll();
#endif
 }
EOF
if eval $compile; then
  rm -rf conftest*
  poll=1

fi
rm -f conftest*

if test $select -eq 1 ; then
  EVENT_TYPE=select
  test -n "$verbose" && echo "	found select"
elif test $poll -eq 1 ; then
  EVENT_TYPE=poll
  test -n "$verbose" && echo "	found poll"
else
  EVENT_TYPE=simple
    test -n "$verbose" && echo "	using simple"
  
{
test -n "$verbose" && \
echo "	defining SIMPLE_EVENT"
echo "#define" SIMPLE_EVENT 1 >> confdefs.h
DEFS="$DEFS -DSIMPLE_EVENT=1"
SEDDEFS="${SEDDEFS}\${SEDdA}SIMPLE_EVENT\${SEDdB}SIMPLE_EVENT\${SEDdC}1\${SEDdD}
\${SEDuA}SIMPLE_EVENT\${SEDuB}SIMPLE_EVENT\${SEDuC}1\${SEDuD}
\${SEDeA}SIMPLE_EVENT\${SEDeB}SIMPLE_EVENT\${SEDeC}1\${SEDeD}
"
}

fi

for func in getpty
do
trfunc=HAVE_`echo $func | tr '[a-z]' '[A-Z]'`
echo checking for ${func}
cat > conftest.c <<EOF
#include "confdefs.h"
#include <ctype.h>
int main() { exit(0); }
int t() { 
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_${func}) || defined (__stub___${func})
choke me
#else
/* Override any gcc2 internal prototype to avoid an error.  */
extern char ${func}(); ${func}();
#endif
 }
EOF
if eval $compile; then
  rm -rf conftest*
  {
test -n "$verbose" && \
echo "	defining ${trfunc}"
echo "#define" ${trfunc} 1 >> confdefs.h
DEFS="$DEFS -D${trfunc}=1"
SEDDEFS="${SEDDEFS}\${SEDdA}${trfunc}\${SEDdB}${trfunc}\${SEDdC}1\${SEDdD}
\${SEDuA}${trfunc}\${SEDuB}${trfunc}\${SEDuC}1\${SEDuD}
\${SEDeA}${trfunc}\${SEDeB}${trfunc}\${SEDeC}1\${SEDeD}
"
}


fi
rm -f conftest*
done

for func in _getpty
do
trfunc=HAVE_`echo $func | tr '[a-z]' '[A-Z]'`
echo checking for ${func}
cat > conftest.c <<EOF
#include "confdefs.h"
#include <ctype.h>
int main() { exit(0); }
int t() { 
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub_${func}) || defined (__stub___${func})
choke me
#else
/* Override any gcc2 internal prototype to avoid an error.  */
extern char ${func}(); ${func}();
#endif
 }
EOF
if eval $compile; then
  rm -rf conftest*
  {
test -n "$verbose" && \
echo "	defining ${trfunc}"
echo "#define" ${trfunc} 1 >> confdefs.h
DEFS="$DEFS -D${trfunc}=1"
SEDDEFS="${SEDDEFS}\${SEDdA}${trfunc}\${SEDdB}${trfunc}\${SEDdC}1\${SEDdD}
\${SEDuA}${trfunc}\${SEDuB}${trfunc}\${SEDuC}1\${SEDuD}
\${SEDeA}${trfunc}\${SEDeB}${trfunc}\${SEDeC}1\${SEDeD}
"
}


fi
rm -f conftest*
done


#
# Now check for the libraries. The first test merely looks in a few
# different places.
# 
if test "ISC_${ISC}" = "ISC_1"   ;    then
   # if on ISC check for -linet and add -linet to LIBS
   LIBS_save="${LIBS}"
LIBS="${LIBS} -linet"
have_lib=""
echo checking for -linet
cat > conftest.c <<EOF
#include "confdefs.h"

int main() { exit(0); }
int t() { main(); }
EOF
if eval $compile; then
  rm -rf conftest*
  have_lib="1"

fi
rm -f conftest*
LIBS="${LIBS_save}"
if test -n "${have_lib}"; then
   
{
test -n "$verbose" && \
echo "	defining HAVE_LIBINET"
echo "#define" HAVE_LIBINET 1 >> confdefs.h
DEFS="$DEFS -DHAVE_LIBINET=1"
SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_LIBINET\${SEDdB}HAVE_LIBINET\${SEDdC}1\${SEDdD}
\${SEDuA}HAVE_LIBINET\${SEDuB}HAVE_LIBINET\${SEDuC}1\${SEDuD}
\${SEDeA}HAVE_LIBINET\${SEDeB}HAVE_LIBINET\${SEDeC}1\${SEDeD}
"
}

   LIBS="${LIBS} -linet"
fi

   # if on ISC we need <sys/bsdtypes.h> to get FD_SET macros
   for hdr in sys/bsdtypes.h
do
trhdr=HAVE_`echo $hdr | tr '[a-z]./' '[A-Z]__'`
echo checking for ${hdr}
cat > conftest.c <<EOF
#include "confdefs.h"
#include <${hdr}>
EOF
err=`eval "($CPP conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining ${trhdr}"
echo "#define" ${trhdr} 1 >> confdefs.h
DEFS="$DEFS -D${trhdr}=1"
SEDDEFS="${SEDDEFS}\${SEDdA}${trhdr}\${SEDdB}${trhdr}\${SEDdC}1\${SEDdD}
\${SEDuA}${trhdr}\${SEDuB}${trhdr}\${SEDuC}1\${SEDuD}
\${SEDeA}${trhdr}\${SEDeB}${trhdr}\${SEDeC}1\${SEDeD}
"
}


fi
rm -f conftest*
done

fi

#
# Look for X11
#

# If we find X, set shell vars x_includes and x_libraries to the paths.
no_x=true
echo checking for X include and library files with xmkmf
rm -fr conftestdir
if mkdir conftestdir; then
  cd conftestdir
  cat > Imakefile <<\EOF
acfindx:
	@echo "im_incroot=$(INCROOT); im_usrlibdir=$(USRLIBDIR); im_libdir=$(LIBDIR)"
EOF
  if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
    no_x=
    # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
    eval `make acfindx | grep -v make`
    # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
    if test ! -f $im_usrlibdir/libX11.a && test -f $im_libdir/libX11.a; then
      im_usrlibdir=$im_libdir
    fi
    case "$im_incroot" in
	/usr/include) ;;
	*) x_includes="$im_incroot" ;;
    esac
    case "$im_usrlibdir" in
	/usr/lib | /lib) ;;
	*) x_libraries="$im_usrlibdir" ;;
    esac
  fi
  cd ..
  rm -fr conftestdir
fi

if test -z "$im_usrlibdir"; then
echo checking for X include and library files directly
cat > conftest.c <<EOF
#include "confdefs.h"
#include <X11/Intrinsic.h>
EOF
err=`eval "($CPP conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  rm -rf conftest*
  no_x=

else
  rm -rf conftest*
  for dir in \
    /usr/local/include \
    /usr/unsupported/include \
    /usr/x386/include \
    /usr/local/x11r5/include \
    /usr/include/X11R5 \
    /usr/include/X11R4 \
    /usr/X11R5/include \
    /usr/X11/include \
    /usr/openwin/include \
    /usr/openwin/share/include \
    /usr/lpp/Xamples/include \
    ; \
  do
    if test -r $dir/X11/Intrinsic.h; then
      x_includes=$dir; no_x=
      break
    fi
  done
fi
rm -f conftest*

# Check for the libraries.  First see if replacing the `include' by
# `lib' works.
LIBS_save="${LIBS}"
LIBS="${LIBS} -lXt"
have_lib=""
echo checking for -lXt
cat > conftest.c <<EOF
#include "confdefs.h"

int main() { exit(0); }
int t() { main(); }
EOF
if eval $compile; then
  rm -rf conftest*
  have_lib="1"

fi
rm -f conftest*
LIBS="${LIBS_save}"
if test -n "${have_lib}"; then
   :; no_x=
else
   :; for dir in `echo "$x_includes" | sed s/include/lib/` \
  /usr/local/lib \
  /usr/unsupported/lib \
  /usr/x386/lib \
  /usr/local/x11r5/lib \
  /usr/lib/X11 \
  /usr/lib/X11R4 \
  /usr/X11R5/lib \
  /usr/X11/lib \
  /usr/openwin/lib \
  /usr/lpp/Xamples/lib \
  ; \
do
  for extension in a so sl; do
    if test -r $dir/libXt.$extension; then
      x_libraries=$dir; no_x=
      break 2
    fi
  done
done
fi

fi
if test -n "$verbose"; then
  test -n "$x_includes" && echo "	found X11 headers in $x_includes"
  test -n "$x_libraries" && echo "	found X11 libraries in $x_libraries"
fi

#
# Let a user override everything with an environment variable
#
if test x"$X11HDIR" != x ; then
    XINCLUDES="-I$X11HDIR"
    test -n "$verbose" && echo "	Using $X11HDIR for X headers"
else
    if test x"$x_includes" != x ; then
	XINCLUDES="-I$x_includes"
    fi
fi

if test x"$X11LIBS" != x ; then
    XLIBS="-L$X11LIBS -lX11"
    test -n "$verbose" && echo "	Using $X11LIBS for X libraries"
else
    if test x"$x_libraries" != x ; then
	XLIBS="-L$x_libraries -lX11"
    else
	XLIBS="-lX11"
    fi
fi

#
# HP-UX wants this instead of libX11
#
if test x"$x_libraries" = x ; then
  LIBS_save="${LIBS}"
LIBS="${LIBS} -lXwindow"
have_lib=""
echo checking for -lXwindow
cat > conftest.c <<EOF
#include "confdefs.h"

int main() { exit(0); }
int t() { main(); }
EOF
if eval $compile; then
  rm -rf conftest*
  have_lib="1"

fi
rm -f conftest*
LIBS="${LIBS_save}"
if test -n "${have_lib}"; then
   :; XLIBS="-lXwindow"
else
   :; 
fi

fi

if test "$no_x" != "true" && test "$no_tk" != "true" ; then
  XPROGS="expectk \$(LIBEXPECTK)"
else
  XPROGS="# no X support on this system"
  XINCLUDES=""
  XLIBS=""
  test -n "$verbose" && echo "	WARNING: No X based programs will be built"
fi

#
# Set up makefile substitutions
#











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

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

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

trap 'rm -fr Makefile expect_cf.h conftest*; exit 1' 1 3 15
CC='$CC'
RANLIB='$RANLIB'
CPP='$CPP'
XINCLUDES='$XINCLUDES'
XLIBS='$XLIBS'
XPROGS='$XPROGS'
TCLHDIR='$TCLHDIR'
TCLLIB='$TCLLIB'
TKHDIR='$TKHDIR'
TKLIB='$TKLIB'
PTY_TYPE='$PTY_TYPE'
EVENT_TYPE='$EVENT_TYPE'
SETUID='$SETUID'
LIBS='$LIBS'
srcdir='$srcdir'
prefix='$prefix'
exec_prefix='$exec_prefix'
prsub='$prsub'
extrasub='$extrasub'
EOF
cat >> config.status <<\EOF

top_srcdir=$srcdir

CONFIG_FILES=${CONFIG_FILES-"Makefile"}
for file in .. ${CONFIG_FILES}; do if test "x$file" != x..; then
  srcdir=$top_srcdir
  # Remove last slash and all that follows it.  Not all systems have dirname.
  dir=`echo $file|sed 's%/[^/][^/]*$%%'`
  if test "$dir" != "$file"; then
    test "$top_srcdir" != . && srcdir=$top_srcdir/$dir
    test ! -d $dir && mkdir $dir
  fi
  echo creating $file
  rm -f $file
  echo "# Generated automatically from `echo $file|sed 's|.*/||'`.in by configure." > $file
  sed -e "
$prsub
$extrasub
s%@CC@%$CC%g
s%@RANLIB@%$RANLIB%g
s%@CPP@%$CPP%g
s%@XINCLUDES@%$XINCLUDES%g
s%@XLIBS@%$XLIBS%g
s%@XPROGS@%$XPROGS%g
s%@TCLHDIR@%$TCLHDIR%g
s%@TCLLIB@%$TCLLIB%g
s%@TKHDIR@%$TKHDIR%g
s%@TKLIB@%$TKLIB%g
s%@PTY_TYPE@%$PTY_TYPE%g
s%@EVENT_TYPE@%$EVENT_TYPE%g
s%@SETUID@%$SETUID%g
s%@LIBS@%$LIBS%g
s%@srcdir@%$srcdir%g
s%@DEFS@%-DHAVE_CONFIG_H%" $top_srcdir/${file}.in >> $file
fi; done

CONFIG_HEADERS=${CONFIG_HEADERS-"expect_cf.h"}
for file in .. ${CONFIG_HEADERS}; do if test "x$file" != x..; then
echo creating $file

# These sed commands are put into SEDDEFS when defining a macro.
# They are broken into pieces to make the sed script easier to manage.
# They are passed to sed as "A NAME B NAME C VALUE D", where NAME
# is the cpp macro being defined and VALUE is the value it is being given.
# Each defining turns into a single global substitution command.
#
# SEDd sets the value in "#define NAME VALUE" lines.
SEDdA='s@^\([ 	]*\)#\([ 	]*define[ 	][ 	]*\)'
SEDdB='\([ 	][ 	]*\)[^ 	]*@\1#\2'
SEDdC='\3'
SEDdD='@g'
# SEDu turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
SEDuA='s@^\([ 	]*\)#\([ 	]*\)undef\([ 	][ 	]*\)'
SEDuB='\([ 	]\)@\1#\2define\3'
SEDuC=' '
SEDuD='\4@g'
# SEDe turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
SEDeA='s@^\([ 	]*\)#\([ 	]*\)undef\([ 	][ 	]*\)'
SEDeB='$@\1#\2define\3'
SEDeC=' '
SEDeD='@g'
rm -f conftest.sed
EOF
# Turn off quoting long enough to insert the sed commands.
rm -f conftest.sh
cat > conftest.sh <<EOF
$SEDDEFS
EOF

# Break up $SEDDEFS (now in conftest.sh) because some shells have a limit
# on the size of here documents.

# Maximum number of lines to put in a single here document.
maxshlines=9

while :
do
  # wc gives bogus results for an empty file on some systems.
  lines=`grep -c . conftest.sh`
  if test -z "$lines" || test "$lines" -eq 0; then break; fi
  rm -f conftest.s1 conftest.s2
  sed ${maxshlines}q conftest.sh > conftest.s1 # Like head -20.
  sed 1,${maxshlines}d conftest.sh > conftest.s2 # Like tail +21.
  # Write a limited-size here document to append to conftest.sed.
  echo 'cat >> conftest.sed <<CONFEOF' >> config.status
  cat conftest.s1 >> config.status
  echo 'CONFEOF' >> config.status
  rm -f conftest.s1 conftest.sh
  mv conftest.s2 conftest.sh
done
rm -f conftest.sh

# Now back to your regularly scheduled config.status.
cat >> config.status <<\EOF
# This sed command replaces #undef's with comments.  This is necessary, for
# example, in the case of _POSIX_SOURCE, which is predefined and required
# on some systems where configure will not decide to define it in
# expect_cf.h.
cat >> conftest.sed <<\CONFEOF
s,^[ 	]*#[ 	]*undef[ 	][ 	]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
CONFEOF
rm -f conftest.h
# Break up the sed commands because old seds have small limits.
maxsedlines=20
cp $top_srcdir/$file.in conftest.h1
while :
do
  lines=`grep -c . conftest.sed`
  if test -z "$lines" || test "$lines" -eq 0; then break; fi
  rm -f conftest.s1 conftest.s2 conftest.h2
  sed ${maxsedlines}q conftest.sed > conftest.s1 # Like head -20.
  sed 1,${maxsedlines}d conftest.sed > conftest.s2 # Like tail +21.
  sed -f conftest.s1 < conftest.h1 > conftest.h2
  rm -f conftest.s1 conftest.h1 conftest.sed
  mv conftest.h2 conftest.h1
  mv conftest.s2 conftest.sed
done
rm -f conftest.sed conftest.h
echo "/* $file.  Generated automatically by configure.  */" > conftest.h
cat conftest.h1 >> conftest.h
rm -f conftest.h1
if cmp -s $file conftest.h 2>/dev/null; then
  # The file exists and we would not be changing it.
  echo "$file is unchanged"
  rm -f conftest.h
else
  rm -f $file
  mv conftest.h $file
fi
fi; done



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

