#!/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] [--no-create]
#        [--prefix=PREFIX] [--exec-prefix=PREFIX] [--with-PACKAGE] [TARGET]
# Ignores all args except --srcdir, --prefix, --exec-prefix, --no-create, and
# --with-PACKAGE 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, 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 ;;

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

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

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

     -no-create | --no-create | --no-creat | --no-crea | --no-cre | --no-cr | --no-c | --no- | --no)
        no_create=1 ;;

     -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 's/-*with-//'`
       # Delete all the valid chars; see if any are left.
       if test -n "`echo $package|sed 's/[-a-zA-Z0-9_]*//g'`"; then
         echo "configure: $package: invalid package name" >&2; exit 1
       fi
       eval "with_`echo $package|sed s/-/_/g`=1" ;;

     *) ;;
    esac
  fi
done

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

rm -f conftest*
compile='${CC-cc} $DEFS 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=web2c/web2c.c

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






if test -z "$prefix"
then
  echo checking for tex to derive installation directory prefix
  saveifs="$IFS"; IFS="$IFS:"
  for dir in $PATH; do
    test -z "$dir" && dir=.
    if test $dir != . && test -f $dir/tex; then
      # Not all systems have dirname.
      prefix=`echo $dir|sed 's%/[^/][^/]*$%%'`
      break
    fi
  done
  IFS="$saveifs"
fi


if test -z "$CC"; then
  echo checking for gcc
  saveifs="$IFS"; IFS="${IFS}:"
  for dir in $PATH; do
    test -z "$dir" && dir=.
    if test -f $dir/gcc; then
      CC="gcc"
      break
    fi
  done
  IFS="$saveifs"
fi
test -z "$CC" && CC="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*

echo checking how to run the C preprocessor
if test -z "$CPP"; then
  CPP='${CC-cc} -E'
  cat > conftest.c <<EOF
#include <stdio.h>
EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  :
else
  CPP=/lib/cpp
fi
rm -f conftest*
fi

if test -n "$GCC"; then
  echo checking whether -traditional is needed
  pattern="Autoconf.*'x'"
  prog='#include <sgtty.h>
Autoconf TIOCGETP'
  cat > conftest.c <<EOF
$prog
EOF
eval "$CPP $DEFS conftest.c > conftest.out 2>&1"
if egrep "$pattern" conftest.out >/dev/null 2>&1; then
  need_trad=1
fi
rm -f conftest*


  if test -z "$need_trad"; then
    prog='#include <termio.h>
Autoconf TCGETA'
    cat > conftest.c <<EOF
$prog
EOF
eval "$CPP $DEFS conftest.c > conftest.out 2>&1"
if egrep "$pattern" conftest.out >/dev/null 2>&1; then
  need_trad=1
fi
rm -f conftest*

  fi
  test -n "$need_trad" && CC="$CC -traditional"
fi

# 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.  (Sigh.)
if test -z "$INSTALL"; then
  echo checking for install
  saveifs="$IFS"; IFS="${IFS}:"
  for dir in $PATH; do
    test -z "$dir" && dir=.
    case $dir in
    /etc|/usr/sbin|/usr/etc|/usr/afsws/bin) ;;
    *)
      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}
INSTALL_PROGRAM=${INSTALL_PROGRAM-'$(INSTALL)'}
INSTALL_DATA=${INSTALL_DATA-'$(INSTALL)'}

if test -z "$RANLIB"; then
  echo checking for ranlib
  saveifs="$IFS"; IFS="${IFS}:"
  for dir in $PATH; do
    test -z "$dir" && dir=.
    if test -f $dir/ranlib; then
      RANLIB="ranlib"
      break
    fi
  done
  IFS="$saveifs"
fi
test -z "$RANLIB" && RANLIB="@:"

if test -z "$YACC"; then
  echo checking for bison
  saveifs="$IFS"; IFS="${IFS}:"
  for dir in $PATH; do
    test -z "$dir" && dir=.
    if test -f $dir/bison; then
      YACC="bison -y"
      break
    fi
  done
  IFS="$saveifs"
fi
test -z "$YACC" && YACC=""

if test -z "$YACC"; then
  echo checking for byacc
  saveifs="$IFS"; IFS="${IFS}:"
  for dir in $PATH; do
    test -z "$dir" && dir=.
    if test -f $dir/byacc; then
      YACC="byacc"
      break
    fi
  done
  IFS="$saveifs"
fi
test -z "$YACC" && YACC="yacc"


if test -z "$LEX"; then
  echo checking for flex
  saveifs="$IFS"; IFS="${IFS}:"
  for dir in $PATH; do
    test -z "$dir" && dir=.
    if test -f $dir/flex; then
      LEX="flex"
      break
    fi
  done
  IFS="$saveifs"
fi
test -z "$LEX" && LEX="lex"

if test -z "$LEXLIB"
then
  case "$LEX" in
  flex*)
    if test -r /usr/local/lib/libfl.a
    then LEXLIB=/usr/local/lib/libfl.a
    elif test -r ${prefix}/lib/libfl.a
    then LEXLIB=${prefix}/lib/libfl.a
    else LEXLIB="-lfl"
    fi
    ;;
  *) LEXLIB="-ll" ;;
  esac
fi

echo checking for ln -s
rm -f conftestdata
if ln -s X conftestdata 2>/dev/null
then
  rm -f conftestdata
  LN_S="ln -s"
else
  LN_S=ln
fi



echo checking for AIX
cat > conftest.c <<EOF
#ifdef _AIX
  yes
#endif

EOF
eval "$CPP $DEFS conftest.c > conftest.out 2>&1"
if egrep "yes" conftest.out >/dev/null 2>&1; then
  DEFS="$DEFS -D_ALL_SOURCE=1"
SEDDEFS="${SEDDEFS}\${SEDdA}_ALL_SOURCE\${SEDdB}_ALL_SOURCE\${SEDdC}1\${SEDdD}
\${SEDuA}_ALL_SOURCE\${SEDuB}_ALL_SOURCE\${SEDuC}1\${SEDuD}
\${SEDeA}_ALL_SOURCE\${SEDeB}_ALL_SOURCE\${SEDeC}1\${SEDeD}
"
fi
rm -f conftest*


echo checking for DYNIX/ptx libseq
cat > conftest.c <<EOF
#if defined(_SEQUENT_)
  yes
#endif

EOF
eval "$CPP $DEFS conftest.c > conftest.out 2>&1"
if egrep "yes" conftest.out >/dev/null 2>&1; then
  SEQUENT=1
fi
rm -f conftest*

test -n "$SEQUENT" && test -f /usr/lib/libseq.a &&
  LIBS="$LIBS -lseq"

echo checking for POSIXized ISC
if test -d /etc/conf/kconfig.d &&
  grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1
then
  ISC=1 # If later tests want to check for ISC.
  DEFS="$DEFS -D_POSIX_SOURCE=1"
SEDDEFS="${SEDDEFS}\${SEDdA}_POSIX_SOURCE\${SEDdB}_POSIX_SOURCE\${SEDdC}1\${SEDdD}
\${SEDuA}_POSIX_SOURCE\${SEDuB}_POSIX_SOURCE\${SEDuC}1\${SEDuD}
\${SEDeA}_POSIX_SOURCE\${SEDeB}_POSIX_SOURCE\${SEDeC}1\${SEDeD}
"
  if test -n "$GCC"; then
    CC="$CC -posix"
  else
    CC="$CC -Xp"
  fi
fi

echo checking for minix/config.h
cat > conftest.c <<EOF
#include <minix/config.h>
EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  MINIX=1
fi
rm -f conftest*

# The Minix shell can't assign to the same variable on the same line!
if test -n "$MINIX"; then
  DEFS="$DEFS -D_POSIX_SOURCE=1"
SEDDEFS="${SEDDEFS}\${SEDdA}_POSIX_SOURCE\${SEDdB}_POSIX_SOURCE\${SEDdC}1\${SEDdD}
\${SEDuA}_POSIX_SOURCE\${SEDuB}_POSIX_SOURCE\${SEDuC}1\${SEDuD}
\${SEDeA}_POSIX_SOURCE\${SEDeB}_POSIX_SOURCE\${SEDeC}1\${SEDeD}
"
  DEFS="$DEFS -D_POSIX_1_SOURCE=2"
SEDDEFS="${SEDDEFS}\${SEDdA}_POSIX_1_SOURCE\${SEDdB}_POSIX_1_SOURCE\${SEDdC}2\${SEDdD}
\${SEDuA}_POSIX_1_SOURCE\${SEDuB}_POSIX_1_SOURCE\${SEDuC}2\${SEDuD}
\${SEDeA}_POSIX_1_SOURCE\${SEDeB}_POSIX_1_SOURCE\${SEDeC}2\${SEDeD}
"
  DEFS="$DEFS -D_MINIX=1"
SEDDEFS="${SEDDEFS}\${SEDdA}_MINIX\${SEDdB}_MINIX\${SEDdC}1\${SEDdD}
\${SEDuA}_MINIX\${SEDuB}_MINIX\${SEDuC}1\${SEDuD}
\${SEDeA}_MINIX\${SEDeB}_MINIX\${SEDeC}1\${SEDeD}
"
fi

echo checking for directory library header
echo checking for dirent.h
cat > conftest.c <<EOF
#include <dirent.h>
EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  DEFS="$DEFS -DDIRENT=1"
SEDDEFS="${SEDDEFS}\${SEDdA}DIRENT\${SEDdB}DIRENT\${SEDdC}1\${SEDdD}
\${SEDuA}DIRENT\${SEDuB}DIRENT\${SEDuC}1\${SEDuD}
\${SEDeA}DIRENT\${SEDeB}DIRENT\${SEDeC}1\${SEDeD}
" dirheader=dirent.h
fi
rm -f conftest*

if test -z "$dirheader"; then
echo checking for sys/ndir.h
cat > conftest.c <<EOF
#include <sys/ndir.h>
EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  DEFS="$DEFS -DSYSNDIR=1"
SEDDEFS="${SEDDEFS}\${SEDdA}SYSNDIR\${SEDdB}SYSNDIR\${SEDdC}1\${SEDdD}
\${SEDuA}SYSNDIR\${SEDuB}SYSNDIR\${SEDuC}1\${SEDuD}
\${SEDeA}SYSNDIR\${SEDeB}SYSNDIR\${SEDeC}1\${SEDeD}
" dirheader=sys/ndir.h
fi
rm -f conftest*

fi
if test -z "$dirheader"; then
echo checking for sys/dir.h
cat > conftest.c <<EOF
#include <sys/dir.h>
EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  DEFS="$DEFS -DSYSDIR=1"
SEDDEFS="${SEDDEFS}\${SEDdA}SYSDIR\${SEDdB}SYSDIR\${SEDdC}1\${SEDdD}
\${SEDuA}SYSDIR\${SEDuB}SYSDIR\${SEDuC}1\${SEDuD}
\${SEDeA}SYSDIR\${SEDeB}SYSDIR\${SEDeC}1\${SEDeD}
" dirheader=sys/dir.h
fi
rm -f conftest*

fi
if test -z "$dirheader"; then
echo checking for ndir.h
cat > conftest.c <<EOF
#include <ndir.h>
EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  DEFS="$DEFS -DNDIR=1"
SEDDEFS="${SEDDEFS}\${SEDdA}NDIR\${SEDdB}NDIR\${SEDdC}1\${SEDdD}
\${SEDuA}NDIR\${SEDuB}NDIR\${SEDuC}1\${SEDuD}
\${SEDeA}NDIR\${SEDeB}NDIR\${SEDeC}1\${SEDeD}
" dirheader=ndir.h
fi
rm -f conftest*

fi

echo checking for closedir return value
cat > conftest.c <<EOF
#include <sys/types.h>
#include <$dirheader>
int closedir(); main() { exit(0); }
EOF
eval $compile
if test -s conftest && (./conftest; exit) 2>/dev/null; then
  :
else
  DEFS="$DEFS -DVOID_CLOSEDIR=1"
SEDDEFS="${SEDDEFS}\${SEDdA}VOID_CLOSEDIR\${SEDdB}VOID_CLOSEDIR\${SEDdC}1\${SEDdD}
\${SEDuA}VOID_CLOSEDIR\${SEDuB}VOID_CLOSEDIR\${SEDuC}1\${SEDuD}
\${SEDeA}VOID_CLOSEDIR\${SEDeB}VOID_CLOSEDIR\${SEDeC}1\${SEDeD}
"
fi
rm -f conftest*

echo checking for Xenix
cat > conftest.c <<EOF
#if defined(M_XENIX) && !defined(M_UNIX)
  yes
#endif

EOF
eval "$CPP $DEFS conftest.c > conftest.out 2>&1"
if egrep "yes" conftest.out >/dev/null 2>&1; then
  XENIX=1
fi
rm -f conftest*

if test -n "$XENIX"; then
  DEFS="$DEFS -DVOID_CLOSEDIR=1"
SEDDEFS="${SEDDEFS}\${SEDdA}VOID_CLOSEDIR\${SEDdB}VOID_CLOSEDIR\${SEDdC}1\${SEDdD}
\${SEDuA}VOID_CLOSEDIR\${SEDuB}VOID_CLOSEDIR\${SEDuC}1\${SEDuD}
\${SEDeA}VOID_CLOSEDIR\${SEDeB}VOID_CLOSEDIR\${SEDeC}1\${SEDeD}
"
  LIBS="$LIBS -lx"
  case "$DEFS" in
  *SYSNDIR*) ;;
  *) LIBS="-ldir $LIBS" ;; # Make sure -ldir precedes any -lx.
  esac
fi


echo checking for directory library header
echo checking for dirent.h
cat > conftest.c <<EOF
#include <dirent.h>
EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  DEFS="$DEFS -DDIRENT=1"
SEDDEFS="${SEDDEFS}\${SEDdA}DIRENT\${SEDdB}DIRENT\${SEDdC}1\${SEDdD}
\${SEDuA}DIRENT\${SEDuB}DIRENT\${SEDuC}1\${SEDuD}
\${SEDeA}DIRENT\${SEDeB}DIRENT\${SEDeC}1\${SEDeD}
" dirheader=dirent.h
fi
rm -f conftest*

if test -z "$dirheader"; then
echo checking for sys/ndir.h
cat > conftest.c <<EOF
#include <sys/ndir.h>
EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  DEFS="$DEFS -DSYSNDIR=1"
SEDDEFS="${SEDDEFS}\${SEDdA}SYSNDIR\${SEDdB}SYSNDIR\${SEDdC}1\${SEDdD}
\${SEDuA}SYSNDIR\${SEDuB}SYSNDIR\${SEDuC}1\${SEDuD}
\${SEDeA}SYSNDIR\${SEDeB}SYSNDIR\${SEDeC}1\${SEDeD}
" dirheader=sys/ndir.h
fi
rm -f conftest*

fi
if test -z "$dirheader"; then
echo checking for sys/dir.h
cat > conftest.c <<EOF
#include <sys/dir.h>
EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  DEFS="$DEFS -DSYSDIR=1"
SEDDEFS="${SEDDEFS}\${SEDdA}SYSDIR\${SEDdB}SYSDIR\${SEDdC}1\${SEDdD}
\${SEDuA}SYSDIR\${SEDuB}SYSDIR\${SEDuC}1\${SEDuD}
\${SEDeA}SYSDIR\${SEDeB}SYSDIR\${SEDeC}1\${SEDeD}
" dirheader=sys/dir.h
fi
rm -f conftest*

fi
if test -z "$dirheader"; then
echo checking for ndir.h
cat > conftest.c <<EOF
#include <ndir.h>
EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  DEFS="$DEFS -DNDIR=1"
SEDDEFS="${SEDDEFS}\${SEDdA}NDIR\${SEDdB}NDIR\${SEDdC}1\${SEDdD}
\${SEDuA}NDIR\${SEDuB}NDIR\${SEDuC}1\${SEDuD}
\${SEDeA}NDIR\${SEDeB}NDIR\${SEDeC}1\${SEDeD}
" dirheader=ndir.h
fi
rm -f conftest*

fi

echo checking for closedir return value
cat > conftest.c <<EOF
#include <sys/types.h>
#include <$dirheader>
int closedir(); main() { exit(0); }
EOF
eval $compile
if test -s conftest && (./conftest; exit) 2>/dev/null; then
  :
else
  DEFS="$DEFS -DVOID_CLOSEDIR=1"
SEDDEFS="${SEDDEFS}\${SEDdA}VOID_CLOSEDIR\${SEDdB}VOID_CLOSEDIR\${SEDdC}1\${SEDdD}
\${SEDuA}VOID_CLOSEDIR\${SEDuB}VOID_CLOSEDIR\${SEDuC}1\${SEDuD}
\${SEDeA}VOID_CLOSEDIR\${SEDeB}VOID_CLOSEDIR\${SEDeC}1\${SEDeD}
"
fi
rm -f conftest*

echo checking for limits.h
cat > conftest.c <<EOF
#include <limits.h>
EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  :
else
  DEFS="$DEFS -DLIMITS_H_MISSING=1"
SEDDEFS="${SEDDEFS}\${SEDdA}LIMITS_H_MISSING\${SEDdB}LIMITS_H_MISSING\${SEDdC}1\${SEDdD}
\${SEDuA}LIMITS_H_MISSING\${SEDuB}LIMITS_H_MISSING\${SEDuC}1\${SEDuD}
\${SEDeA}LIMITS_H_MISSING\${SEDeB}LIMITS_H_MISSING\${SEDeC}1\${SEDeD}
"
fi
rm -f conftest*

echo checking for float.h
cat > conftest.c <<EOF
#include <float.h>
EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  :
else
  DEFS="$DEFS -DFLOAT_H_MISSING=1"
SEDDEFS="${SEDDEFS}\${SEDdA}FLOAT_H_MISSING\${SEDdB}FLOAT_H_MISSING\${SEDdC}1\${SEDdD}
\${SEDuA}FLOAT_H_MISSING\${SEDuB}FLOAT_H_MISSING\${SEDuC}1\${SEDuD}
\${SEDeA}FLOAT_H_MISSING\${SEDeB}FLOAT_H_MISSING\${SEDeC}1\${SEDeD}
"
fi
rm -f conftest*

echo checking for ANSI C header files
cat > conftest.c <<EOF
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <float.h>
EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  # SunOS string.h does not declare mem*, contrary to ANSI.
echo '#include <string.h>' > conftest.c
eval "$CPP $DEFS conftest.c > conftest.out 2>&1"
if egrep "memchr" conftest.out >/dev/null 2>&1; then
  # SGI's /bin/cc from Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
cat > conftest.c <<EOF
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
#define XOR(e,f) (((e) && !(f)) || (!(e) && (f)))
int main () { int i; for (i = 0; i < 256; i++)
if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
exit (0); }

EOF
eval $compile
if test -s conftest && (./conftest; exit) 2>/dev/null; then
  DEFS="$DEFS -DSTDC_HEADERS=1"
SEDDEFS="${SEDDEFS}\${SEDdA}STDC_HEADERS\${SEDdB}STDC_HEADERS\${SEDdC}1\${SEDdD}
\${SEDuA}STDC_HEADERS\${SEDuB}STDC_HEADERS\${SEDuC}1\${SEDuD}
\${SEDeA}STDC_HEADERS\${SEDeB}STDC_HEADERS\${SEDeC}1\${SEDeD}
"
fi
rm -f conftest*
fi
rm -f conftest*

fi
rm -f conftest*

for hdr in string.h memory.h
do
trhdr=HAVE_`echo $hdr | tr '[a-z]./' '[A-Z]__'`
echo checking for ${hdr}
cat > conftest.c <<EOF
#include <${hdr}>
EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  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

echo checking for unistd.h
cat > conftest.c <<EOF
#include <unistd.h>
EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  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 return type of signal handlers
cat > conftest.c <<EOF
#include <sys/types.h>
#include <signal.h>
#ifdef signal
#undef signal
#endif
extern void (*signal ()) ();
main() { exit(0); } 
t() { int i; }
EOF
if eval $compile; then
  DEFS="$DEFS -DRETSIGTYPE=void"
SEDDEFS="${SEDDEFS}\${SEDdA}RETSIGTYPE\${SEDdB}RETSIGTYPE\${SEDdC}void\${SEDdD}
\${SEDuA}RETSIGTYPE\${SEDuB}RETSIGTYPE\${SEDuC}void\${SEDuD}
\${SEDeA}RETSIGTYPE\${SEDeB}RETSIGTYPE\${SEDeC}void\${SEDeD}
"
else
  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}
"
fi
rm -f conftest*



prog='/* Ultrix mips cc rejects this.  */
typedef int charset[2]; const charset x;
/* SunOS 4.1.1 cc rejects this. */
char const *const *p;
char **p2;
/* HPUX 7.0 cc rejects these. */
++p;
p2 = (char const* const*) p;'
echo checking for working const
cat > conftest.c <<EOF

main() { exit(0); } 
t() { $prog }
EOF
if eval $compile; then
  :
else
  DEFS="$DEFS -Dconst="
SEDDEFS="${SEDDEFS}\${SEDdA}const\${SEDdB}const\${SEDdC}\${SEDdD}
\${SEDuA}const\${SEDuB}const\${SEDuC}\${SEDuD}
\${SEDeA}const\${SEDeB}const\${SEDeC}\${SEDeD}
"
fi
rm -f conftest*

echo checking for unsigned characters
cat > conftest.c <<EOF
/* volatile prevents gcc2 from optimizing the test away on sparcs.  */
#if !__STDC__
#define volatile
#endif
main() {
#ifdef __CHAR_UNSIGNED__
  exit(1); /* No need to redefine it.  */
#else
  volatile char c = 255; exit(c < 0);
#endif
}
EOF
eval $compile
if test -s conftest && (./conftest; exit) 2>/dev/null; then
  DEFS="$DEFS -D__CHAR_UNSIGNED__=1"
SEDDEFS="${SEDDEFS}\${SEDdA}__CHAR_UNSIGNED__\${SEDdB}__CHAR_UNSIGNED__\${SEDdC}1\${SEDdD}
\${SEDuA}__CHAR_UNSIGNED__\${SEDuB}__CHAR_UNSIGNED__\${SEDuC}1\${SEDuD}
\${SEDeA}__CHAR_UNSIGNED__\${SEDeB}__CHAR_UNSIGNED__\${SEDeC}1\${SEDeD}
"
fi
rm -f conftest*

echo checking byte ordering
cat > conftest.c <<EOF
main () {
  /* Are we little or big endian?  From Harbison&Steele.  */
  union
  {
    long l;
    char c[sizeof (long)];
  } u;
  u.l = 1;
  exit (u.c[sizeof (long) - 1] == 1);
}
EOF
eval $compile
if test -s conftest && (./conftest; exit) 2>/dev/null; then
  :
else
  DEFS="$DEFS -DWORDS_BIGENDIAN=1"
SEDDEFS="${SEDDEFS}\${SEDdA}WORDS_BIGENDIAN\${SEDdB}WORDS_BIGENDIAN\${SEDdC}1\${SEDdD}
\${SEDuA}WORDS_BIGENDIAN\${SEDuB}WORDS_BIGENDIAN\${SEDuC}1\${SEDuD}
\${SEDeA}WORDS_BIGENDIAN\${SEDeB}WORDS_BIGENDIAN\${SEDeC}1\${SEDeD}
"
fi
rm -f conftest*


echo checking how to declare yytext
# Figure out what yytext is by creating a minimal parser and
# examining the (preprocessed, in case macros are used) output.
if test -z "$DECLARE_YYTEXT"
then
  echo "%%" | $LEX
  DECLARE_YYTEXT=`eval $CPP lex.yy.c |
    sed -n '/extern.*yytext/s/^.*extern/extern/p'`
  rm -f lex.yy.c
fi
DEFS="$DEFS -D'DECLARE_YYTEXT="$DECLARE_YYTEXT"'"
SEDDEFS="${SEDDEFS}\${SEDdA}DECLARE_YYTEXT\${SEDdB}DECLARE_YYTEXT\${SEDdC}"$DECLARE_YYTEXT"\${SEDdD}
\${SEDuA}DECLARE_YYTEXT\${SEDuB}DECLARE_YYTEXT\${SEDuC}"$DECLARE_YYTEXT"\${SEDuD}
\${SEDeA}DECLARE_YYTEXT\${SEDeB}DECLARE_YYTEXT\${SEDeC}"$DECLARE_YYTEXT"\${SEDeD}
"


echo checking for window system libraries
cat > conftest.c <<EOF
#include "$srcdir/lib/c-auto.h.in"
#ifndef HP2627WIN
#include <nonexistxyz.kkk>
#endif

EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  HP2627WIN=t

fi
rm -f conftest*
cat > conftest.c <<EOF
#include "$srcdir/lib/c-auto.h.in"
#ifndef SUNWIN
#include <nonexistxyz.kkk>
#endif

EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  SUNWIN=t

fi
rm -f conftest*
cat > conftest.c <<EOF
#include "$srcdir/lib/c-auto.h.in"
#ifndef TEKTRONIXWIN
#include <nonexistxyz.kkk>
#endif

EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  TEKTRONIXWIN=t

fi
rm -f conftest*
cat > conftest.c <<EOF
#include "$srcdir/lib/c-auto.h.in"
#ifndef UNITERMWIN
#include <nonexistxyz.kkk>
#endif

EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  UNITERMWIN=t

fi
rm -f conftest*
cat > conftest.c <<EOF
#include "$srcdir/lib/c-auto.h.in"
#ifndef XVIEWWIN
#include <nonexistxyz.kkk>
#endif

EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  XVIEWWIN=t

fi
rm -f conftest*
cat > conftest.c <<EOF
#include "$srcdir/lib/c-auto.h.in"
#ifndef X11WIN
#include <nonexistxyz.kkk>
#endif

EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  X11WIN=t

fi
rm -f conftest*
cat > conftest.c <<EOF
#include "$srcdir/lib/c-auto.h.in"
#ifndef X10WIN
#include <nonexistxyz.kkk>
#endif

EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  X10WIN=t

fi
rm -f conftest*
if test -n "$XVIEWWIN"; then
  wlibs="$wlibs -lxview -lolgx"
  (cd $srcdir/mf/MFwindow; rm -f sun.c; $LN_S sun-xview.c sun.c)
fi
if test -n "$X11WIN"; then
  echo checking for X11 headers and libraries
dir=""
cat > conftest.c <<EOF
#include <X11/Intrinsic.h>
EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  :
else
  if test -r /usr/local/include/X11/Intrinsic.h; then
    dir=/usr/local/include

  elif test -r /usr/openwin/include/X11/Box.h; then
    dir=/usr/openwin/include
  elif test -r /usr/openwin/share/include/X11/Box.h; then
    dir=/usr/openwin/share/include

  elif test -r /usr/include/X11R4/X11/Intrinsic.h; then
    dir=/usr/include/X11R4
  elif test -r /usr/include/X11R5/X11/Intrinsic.h; then
    dir=/usr/include/X11R5

  elif test -r /usr/lpp/X11/Xamples/include/X11/Intrinsic.h; then
    dir=/usr/lpp/X11/Xamples/include

  elif test -r /usr/X11/include/X11/Intrinsic.h; then
    dir=/usr/X11/include
  elif test -r /usr/X11R5/include/X11/Intrinsic.h; then
    dir=/usr/X11R5/include

  elif test -r /usr/include/X11/Intrinsic.h; then
    dir= # everyone's cc searches /usr/include, right?
  else
    no_x=t
  fi

fi
rm -f conftest*
if test -n "$dir"; then
  xincludedir=-I$dir
  echo "(using $xincludedir)"
elif test -n "$no_x"; then 
  # Not all programs may use this symbol, but it won't hurt to define it.
  xincludedir=-DX_DISPLAY_MISSING
fi

#
# Now check for the libraries.  Amazing how every single X vendor puts
# these in a different place, and all because MIT thought they should go
# in /usr/lib.
dir1=""
if test -r /usr/local/lib/libXt.a; then
  dir1=/usr/local/lib

elif test -r /usr/openwin/lib/libXt.a; then
  dir1=/usr/openwin/lib

elif test -r /usr/lib/X11R4/libXt.sl; then
  dir1=/usr/lib/X11R4
elif test -r /usr/lib/X11R4/libXt.a; then
  dir1=/usr/lib/X11R4
elif test -r /usr/lib/X11R5/libXt.a; then
  dir1=/usr/lib/X11R5

elif test -r /usr/lpp/X11/Xamples/lib/Xt/libXt.a; then
  dir1=/usr/lpp/X11/Xamples/lib/Xt

elif test -r /usr/X11/lib/libXt.a; then
  dir1=/usr/X11/lib
elif test -r /usr/X11R5/lib/libXt.a; then
  dir1=/usr/X11R5/lib
fi
dir2=""
if test -r /usr/lpp/X11/Xamples/lib/Xmu/libXmu.a; then
  dir2=/usr/lpp/X11/Xamples/lib/Xmu
fi
test -n "$dir1" && xlibdir=-L$dir1
test -n "$dir2" && xlibdir="$xlibdir -L$dir2"
test -n "$xlibdir" && echo "(using $xlibdir)"

  wlibs="$wlibs -lXt -lX11"
  (cd $srcdir/mf/MFwindow; rm -f x11.c; $LN_S x11-Xt.c x11.c)
fi
if test -n "$X10WIN"; then
  wlibs="$wlibs -lX"
fi
if test -n "$SUNWIN"; then
  wlibs="$wlibs -lsuntool -lsunwindow -lpixrect"
fi
echo checking for ISC X window libraries
if test -n "$ISC"; then
  wlibs="$wlibs -lnsl_s -linet"
  echo "(adding -lnsl_s -linet to wlibs)"
fi


echo checking for small TeX/MF/BibTeX
# Do TeX first.
# If `small' version is not wanted, do nothing -- make will copy the
# default change file.
cat > conftest.c <<EOF
#include "$srcdir/lib/c-auto.h.in"
#ifndef SMALLTeX
#include <nonexistxyz.kkk>
#endif

EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  SMALLTeX=t

fi
rm -f conftest*
if test -n "$SMALLTeX"; then
  echo "(small TeX, creating tex/ctex.ch)"
  (cd $srcdir/tex && rm -f ctex.ch && sed -f small.sed < tex.ch > ctex.ch)
  DEFS="$DEFS -DGLUERATIO_TYPE=float"
SEDDEFS="${SEDDEFS}\${SEDdA}GLUERATIO_TYPE\${SEDdB}GLUERATIO_TYPE\${SEDdC}float\${SEDdD}
\${SEDuA}GLUERATIO_TYPE\${SEDuB}GLUERATIO_TYPE\${SEDuC}float\${SEDuD}
\${SEDeA}GLUERATIO_TYPE\${SEDeB}GLUERATIO_TYPE\${SEDeC}float\${SEDeD}
"
fi

# Metafont next.
cat > conftest.c <<EOF
#include "$srcdir/lib/c-auto.h.in"
#ifndef SMALLMF
#include <nonexistxyz.kkk>
#endif

EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  SMALLMF=t

fi
rm -f conftest*
if test -n "$SMALLMF"; then
  echo "(small Metafont, creating mf/cmf.ch)"
  (cd $srcdir/mf && rm -f cmf.ch && sed -f small.sed < mf.ch > cmf.ch)
fi

# And finally BibTeX.
cat > conftest.c <<EOF
#include "$srcdir/lib/c-auto.h.in"
#ifndef SMALLBibTeX
#include <nonexistxyz.kkk>
#endif

EOF
err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"`
if test -z "$err"; then
  SMALLBibTeX=t

fi
rm -f conftest*
if test -n "$SMALLBibTeX"; then
  echo "(small BibTeX, creating bibtex/cbibtex.ch)"
  (cd $srcdir/bibtex \
   && rm -f cbibtex.ch && sed -f small.sed < bibtex.ch > cbibtex.ch)
fi

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

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`:
#
# $0 $*

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

trap 'rm -f Makefile bibtex/Makefile dviutil/Makefile fontutil/Makefile \
lib/Makefile man/Makefile mf/Makefile mf/MFwindow/Makefile \
tex/Makefile web/Makefile web2c/Makefile lib/c-auto.h conftest*; exit 1' 1 3 15
CC='$CC'
INSTALL='$INSTALL'
INSTALL_PROGRAM='$INSTALL_PROGRAM'
INSTALL_DATA='$INSTALL_DATA'
RANLIB='$RANLIB'
YACC='$YACC'
LEX='$LEX'
LEXLIB='$LEXLIB'
LN_S='$LN_S'
xincludedir='$xincludedir'
xlibdir='$xlibdir'
wlibs='$wlibs'
LIBS='$LIBS'
srcdir='$srcdir'
prefix='$prefix'
exec_prefix='$exec_prefix'
prsub='$prsub'
EOF
cat >> config.status <<\EOF

top_srcdir=$srcdir
for file in .. Makefile bibtex/Makefile dviutil/Makefile fontutil/Makefile \
lib/Makefile man/Makefile mf/Makefile mf/MFwindow/Makefile \
tex/Makefile web/Makefile web2c/Makefile; do if [ "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
s%@CC@%$CC%g
s%@INSTALL@%$INSTALL%g
s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
s%@INSTALL_DATA@%$INSTALL_DATA%g
s%@RANLIB@%$RANLIB%g
s%@YACC@%$YACC%g
s%@LEX@%$LEX%g
s%@LEXLIB@%$LEXLIB%g
s%@LN_S@%$LN_S%g
s%@xincludedir@%$xincludedir%g
s%@xlibdir@%$xlibdir%g
s%@wlibs@%$wlibs%g
s%@LIBS@%$LIBS%g
s%@srcdir@%$srcdir%g
s%@DEFS@%-DHAVE_CONFIG_H%" $top_srcdir/${file}.in >> $file
fi; done

echo creating lib/c-auto.h
# 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
cat > conftest.sed <<CONFEOF
EOF
# Turn off quoting long enough to insert the sed commands.
cat >> config.status <<EOF
$SEDDEFS
EOF
cat >> config.status <<\EOF
CONFEOF
rm -f conftest.h
# Break up the sed commands because old seds have small limits.
cp $top_srcdir/lib/c-auto.h.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 40q conftest.sed > conftest.s1 # Like head -40.
  sed 1,40d conftest.sed > conftest.s2 # Like tail +41.
  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 "/* lib/c-auto.h.  Generated automatically by configure.  */" > conftest.h
cat conftest.h1 >> conftest.h
rm -f conftest.h1
if cmp -s lib/c-auto.h conftest.h 2>/dev/null; then
  # The file exists and we would not be changing it.
  rm -f conftest.h
else
  rm -f lib/c-auto.h
  mv conftest.h lib/c-auto.h
fi

EOF
chmod +x config.status
test -n "$no_create" || ./config.status

