#!/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
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=exp_global.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="$*"


# Make sure to not get the incompatible SysV /etc/install and
# /usr/sbin/install, which might be in PATH before a BSD-like install,
# or the SunOS /usr/etc/install directory, or the AIX /bin/install,
# or the AFS install, which mishandles nonexistent args, or
# /usr/ucb/install on SVR4, which tries to use the nonexistent group
# `staff'.  On most BSDish systems install is in /usr/bin, not /usr/ucb
# anyway.  Sigh.
if test "z${INSTALL}" = "z" ; then
  echo checking for install
  IFS="${IFS= 	}"; saveifs="$IFS"; IFS="${IFS}:"
  for dir in $PATH; do
    test -z "$dir" && dir=.
    case $dir in
    /etc|/usr/sbin|/usr/etc|/usr/afsws/bin|/usr/ucb) ;;
    *)
      if test -f $dir/installbsd; then
	INSTALL="$dir/installbsd -c" # OSF1
	INSTALL_PROGRAM='$(INSTALL)'
	INSTALL_DATA='$(INSTALL) -m 644'
	break
      fi
      if test -f $dir/install; then
	if grep dspmsg $dir/install >/dev/null 2>&1; then
	  : # AIX
	else
	  INSTALL="$dir/install -c"
	  INSTALL_PROGRAM='$(INSTALL)'
	  INSTALL_DATA='$(INSTALL) -m 644'
	  break
	fi
      fi
      ;;
    esac
  done
  IFS="$saveifs"
fi
INSTALL=${INSTALL-cp}
test -n "$verbose" && echo "	setting INSTALL to $INSTALL"
INSTALL_PROGRAM=${INSTALL_PROGRAM-'$(INSTALL)'}
test -n "$verbose" && echo "	setting INSTALL_PROGRAM to $INSTALL_PROGRAM"
INSTALL_DATA=${INSTALL_DATA-'$(INSTALL)'}
test -n "$verbose" && echo "	setting INSTALL_DATA to $INSTALL_DATA"

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"


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*


#
# Look for various header files
#
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 NOSTDLIB"
echo "#define" NOSTDLIB 1 >> confdefs.h
DEFS="$DEFS -DNOSTDLIB=1"
SEDDEFS="${SEDDEFS}\${SEDdA}NOSTDLIB\${SEDdB}NOSTDLIB\${SEDdC}1\${SEDdD}
\${SEDuA}NOSTDLIB\${SEDuB}NOSTDLIB\${SEDuC}1\${SEDuD}
\${SEDeA}NOSTDLIB\${SEDeB}NOSTDLIB\${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*

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


#
# 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*


#
# check how signals work
#

# 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 it 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
  rm -rf conftest*
  
{
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 -f 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
"

#
# 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=-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

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 -a $tcsetattr ; 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
  rm -rf conftest*
  
{
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 -f conftest*

# next check for the older style ttys
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
  rm -rf conftest*
  
{
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=termio

fi
rm -f 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
  rm -rf conftest*
  
{
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 -f 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
  rm -rf conftest*
  PTY_TYPE=unicos SETUID="chmod u+s"

fi
rm -f 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 $poll -a $select ; then
  EVENT_TYPE=select
  poll=0
elif test $poll ; then
  EVENT_TYPE=poll
elif test $select ; then
  EVENT_TYPE=select
else
  EVENT_TYPE=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


#
# Look for the X11 include files in various places.
#
Xbuild=1
echo checking for the X11 headers
XINCLUDES="# no special path needed"
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
  :
else
  rm -rf conftest*
  XINCLUDES="nope"
fi
rm -f conftest*
if test "$XINCLUDES" = "nope" ; then
  dirs="/usr/local/include/X11 /usr/unsupported/include/X11 /usr/openwin/include/X11 /usr/include/X11R5/X11 /usr/X11R5/include/X11 /usr/include/X11R4/X11"
  for i in $dirs ; do
    if test -r $i/Intrinsic.h; then
      XINCLUDES=" -I$i"
    fi
  done
fi

if test "$XINCLUDES" = "nope" ; then
  XINCLUDES="# no X support on this system"
  Xbuild=0
fi

#
# Now check for the libraries. The first test merely looks in a few
# different places.
# 
XLIBS="-lX11"
LIBS_save="${LIBS}"
LIBS="${LIBS} -lX11"
have_lib=""
echo checking for -lX11
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
   :; 
else
   :; XLIBS="nope"
fi

if test "$XLIBS" = "nope" ; then
  dirs="/usr/local/lib /usr/lib/X11R4 /usr/lib/X11R5 /usr/X11/lib /usr/lib/X11 /usr/openwin/lib"
  for i in $dirs ; do
    if test -r $i/libX11.a; then
      XLIBS="-L$i -lX11"
    fi
  done
fi

#
# HP-UX wants this instead of libX11
#
if test "$XLIBS" = "nope" ; 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 "$XLIBS" = "nope" ; then
  Xbuild=0
fi

XPROGS=""
if test $Xbuild = 1; then
  XPROGS="expectk \$(LIBEXPTK)"
else
  XPROGS="# no X support on this system"
  echo "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 exp_conf.h conftest*; exit 1' 1 3 15
INSTALL='$INSTALL'
INSTALL_PROGRAM='$INSTALL_PROGRAM'
INSTALL_DATA='$INSTALL_DATA'
RANLIB='$RANLIB'
CPP='$CPP'
XINCLUDES='$XINCLUDES'
XLIBS='$XLIBS'
XPROGS='$XPROGS'
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%@INSTALL@%$INSTALL%g
s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
s%@INSTALL_DATA@%$INSTALL_DATA%g
s%@RANLIB@%$RANLIB%g
s%@CPP@%$CPP%g
s%@XINCLUDES@%$XINCLUDES%g
s%@XLIBS@%$XLIBS%g
s%@XPROGS@%$XPROGS%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-"exp_conf.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
# exp_conf.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

