#!/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=tcl.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=":"
test -n "$RANLIB" && test -n "$verbose" && echo "	setting RANLIB to $RANLIB"

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


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*


#--------------------------------------------------------
# checking ARCH and shared library support
#--------------------------------------------------------
MACHINE=`${srcdir}/config.guess`;
echo "Machine is $MACHINE";
SHARE_ARCH=`${srcdir}/config.sep $MACHINE`;
echo "Shared Library Architechure is $SHARE_ARCH";

SOTCLREV=7.3
LD_DIR="-L$(LIB_DIR)"
SHAREDCC="rm -f \$*.o $(SHDIR)/\$*.o; \
	$(CC) -c $(CC_SWITCHES) $(PICFLAGS) $<; \
	mv \$*.o $(SHDIR)/\$*.o"

case "$SHARE_ARCH" in
   SVR4 )
      echo "SysV R4 share librariy supported"
       UNSHARED=
       PICFLAGS="-K pic" 
       SHLIBSO=libtcl.so.$SOTCLREV
       SHLIBSO_BLD="(cd shared; /usr/ccs/bin/ld -G -z text -h $(SHLIBSO) -o ../$(SHLIBSO) $(OBJS) ); \
$(INSTALL_DATA) $(SHLIBSO) $(LIB_DIR); \
rm -f $(LIB_DIR)/libtcl.so; \
(cd $(LIB_DIR); $LN_S ./$(SHLIBSO) libtcl.so);"
       SHLIBSA=
       SHLIBSA_BLD=
       SHDIR=shared
       PATCH=
	Patch=
	Patch1=
       ;;
   SUN ) 
      echo "SunOs4.1.x share librariy supported"
	Patch="Patch"
	Patch1="Patch :"
       PATCH="if test ! -f tclAppInit.in ; then cat Matherr.pat tclAppInit.c > _1_; mv tclAppInit.c tclAppInit.in; mv _1_ tclAppInit.c; cat Matherr.pat tclTest.c > _1_; mv tclTest.c tclTest.in; mv _1_ tclTest.c; fi;"
       UNSHARED="tclMtherr.o"
       PICFLAGS="-pic" 
       SHLIBSO=libtcl.so.$SOTCLREV
       SHLIBSO_BLD="(cd shared; ld -assert pure-text -o ../$(SHLIBSO) $(OBJS) ); \
	$(INSTALL_DATA) $(SHLIBSO) $(LIB_DIR)"
       SHLIBSA=libtcl.sa.$SOTCLREV
       SHLIBSA_BLD="rm -f $(SHLIBSA); \
ar cr $(SHLIBSA) $(UNSHAREDOBJS); \
$(RANLIB) $(SHLIBSA); \
$(INSTALL_DATA) $(SHLIBSA) $(LIB_DIR); \
$(RANLIB) $(LIB_DIR)/$(SHLIBSA)";
       SHDIR=shared
       ;;
   HP ) 
      echo "HP-UX 9.01 share library supported"
       UNSHARED=
       PICFLAGS="+z" 
       SHLIBSO=libtcl.sl
       SHLIBSO_BLD="(cd shared; ld -b -n -o ../$(SHLIBSO) $(OBJS) ); \
	$(INSTALL_DATA) $(SHLIBSO)"
       SHLIBSA=
       SHLIBSA_BLD=
       SHDIR=shared
       PATCH=
	Patch=
	Patch1=
       ;;
   IBM )
      echo "IBM RS6000 share library supported"
      UNSHARED=
      PATCH=
      Patch=
	Patch1=
      PICFLAGS="-bM\:SRE"
      SHLIBSO=libtcl.a
      SHLIBSO_BLD='cd shared;ar cr ./$(SHLIBSO)~ $(OBJS);dump -g $(SHLIBSO)~ | sed -n -e "s/^   *0-90-9*   *\(^  .^    *\)$$/\001/p" > $(SHLIBSO).syms;ld -o shr.o $(SHLIBSO)~ -H512 -T512 -bM\:SRE -bE\:$(SHLIBSO).syms $(REQUIREDLIBS) -lc -lm;rm -f $(SHLIBSO)~;ar cr $(SHLIBSO)~ shr.o ../$(UNSHAREDOBJS);rm -f $(SHLIBSO).syms $(SHLIBSO) shr.o;mv $(SHLIBSO)~ $(SHLIBSO);cd ..;'
      SHLIBSA=
      SHLIBSA_BLD=
      SHDIR=shared
      ;;
#
# add new platform here
# ...
#
   * )
      echo "Shared libraries unsupported in platform $SHARE_ARCH !!!"
      UNSHARED=
      PATCH=
	Patch=
	Patch1=
      PICFLAGS=
      SHLIBSO=
      SHLIBSO_BLD=
      SHLIBSA=
      SHLIBSA_BLD=
      SHDIR=
      LD_DIR=-L.
      ;;
esac

if test x$CC = xgcc -a x$SHLIBSO != x; then PICFLAGS="-fpic"; fi













#--------------------------------------------------------------------
#	Supply substitutes for missing POSIX library procedures, or
#	set flags so Tcl uses alternate procedures.
#--------------------------------------------------------------------

for func in getcwd opendir strerror strstr
do
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
  :
else
  rm -rf conftest*
  LIBOBJS="$LIBOBJS ${func}.o"
test -n "$verbose" && echo "	using ${func}.o instead"
fi
rm -f conftest*

done

for func in strtol tmpnam waitpid
do
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
  :
else
  rm -rf conftest*
  LIBOBJS="$LIBOBJS ${func}.o"
test -n "$verbose" && echo "	using ${func}.o instead"
fi
rm -f conftest*

done

echo checking for gettimeofday
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_gettimeofday) || defined (__stub___gettimeofday)
choke me
#else
/* Override any gcc2 internal prototype to avoid an error.  */
extern char gettimeofday(); gettimeofday();
#endif
 }
EOF
if eval $compile; then
  :
else
  rm -rf conftest*
  {
test -n "$verbose" && \
echo "	defining NO_GETTOD"
echo "#define" NO_GETTOD 1 >> confdefs.h
DEFS="$DEFS -DNO_GETTOD=1"
}

fi
rm -f conftest*

echo checking for getwd
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_getwd) || defined (__stub___getwd)
choke me
#else
/* Override any gcc2 internal prototype to avoid an error.  */
extern char getwd(); getwd();
#endif
 }
EOF
if eval $compile; then
  :
else
  rm -rf conftest*
  {
test -n "$verbose" && \
echo "	defining NO_GETWD"
echo "#define" NO_GETWD 1 >> confdefs.h
DEFS="$DEFS -DNO_GETWD=1"
}

fi
rm -f conftest*

echo checking for wait3
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_wait3) || defined (__stub___wait3)
choke me
#else
/* Override any gcc2 internal prototype to avoid an error.  */
extern char wait3(); wait3();
#endif
 }
EOF
if eval $compile; then
  :
else
  rm -rf conftest*
  {
test -n "$verbose" && \
echo "	defining NO_WAIT3"
echo "#define" NO_WAIT3 1 >> confdefs.h
DEFS="$DEFS -DNO_WAIT3=1"
}

fi
rm -f conftest*


#--------------------------------------------------------------------
#	Supply substitutes for missing POSIX header files.  Special
#	notes:
#	    - Sprite's dirent.h exists but is bogus.
#	    - stdlib.h doesn't define strtol, strtoul, or
#	      strtod insome versions of SunOS
#	    - some versions of string.h don't declare procedures such
#	      as strstr
#--------------------------------------------------------------------

for hdr in unistd.h
do
trhdr=HAVE_`echo $hdr | tr '[a-z]./' '[A-Z]__'`
echo checking for ${hdr}
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"

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"
}


fi
rm -f conftest*
done

echo checking for dirent.h
cat > conftest.c <<EOF
#include "confdefs.h"
#include <sys/types.h>
#include <dirent.h>
int main() { exit(0); }
int t() { 
DIR *d;
struct dirent *entryPtr;
char *p;
d = opendir("foobar");
entryPtr = readdir(d);
p = entryPtr->d_name;
closedir(d);
 }
EOF
if eval $compile; then
  rm -rf conftest*
  tcl_ok=1

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

echo '#include "confdefs.h"
#include <tcl_ok=0>' > conftest.c
eval "$CPP conftest.c > conftest.out 2>&1"
if egrep "Sprite version.* NOT POSIX" conftest.out >/dev/null 2>&1; then
  :
fi
rm -f conftest*

if test $tcl_ok = 0; then
    
{
test -n "$verbose" && \
echo "	defining NO_DIRENT_H"
echo "#define" NO_DIRENT_H 1 >> confdefs.h
DEFS="$DEFS -DNO_DIRENT_H=1"
}

fi
echo checking for errno.h
cat > conftest.c <<EOF
#include "confdefs.h"
#include <errno.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_ERRNO_H"
echo "#define" NO_ERRNO_H 1 >> confdefs.h
DEFS="$DEFS -DNO_ERRNO_H=1"
}

fi
rm -f conftest*

echo checking for float.h
cat > conftest.c <<EOF
#include "confdefs.h"
#include <float.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_FLOAT_H"
echo "#define" NO_FLOAT_H 1 >> confdefs.h
DEFS="$DEFS -DNO_FLOAT_H=1"
}

fi
rm -f conftest*

echo checking for limits.h
cat > conftest.c <<EOF
#include "confdefs.h"
#include <limits.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_LIMITS_H"
echo "#define" NO_LIMITS_H 1 >> confdefs.h
DEFS="$DEFS -DNO_LIMITS_H=1"
}

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
  rm -rf conftest*
  tcl_ok=1

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

echo '#include "confdefs.h"
#include <stdlib.h>' > conftest.c
eval "$CPP conftest.c > conftest.out 2>&1"
if egrep "strtol" conftest.out >/dev/null 2>&1; then
  :
else
  rm -rf conftest*
  tcl_ok=0
fi
rm -f conftest*

echo '#include "confdefs.h"
#include <stdlib.h>' > conftest.c
eval "$CPP conftest.c > conftest.out 2>&1"
if egrep "strtoul" conftest.out >/dev/null 2>&1; then
  :
else
  rm -rf conftest*
  tcl_ok=0
fi
rm -f conftest*

echo '#include "confdefs.h"
#include <stdlib.h>' > conftest.c
eval "$CPP conftest.c > conftest.out 2>&1"
if egrep "strtod" conftest.out >/dev/null 2>&1; then
  :
else
  rm -rf conftest*
  tcl_ok=0
fi
rm -f conftest*

if test $tcl_ok = 0; then
    
{
test -n "$verbose" && \
echo "	defining NO_STDLIB_H"
echo "#define" NO_STDLIB_H 1 >> confdefs.h
DEFS="$DEFS -DNO_STDLIB_H=1"
}

fi
echo checking for string.h
cat > conftest.c <<EOF
#include "confdefs.h"
#include <string.h>
EOF
err=`eval "($CPP conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  rm -rf conftest*
  tcl_ok=1

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

echo '#include "confdefs.h"
#include <string.h>' > conftest.c
eval "$CPP conftest.c > conftest.out 2>&1"
if egrep "strstr" conftest.out >/dev/null 2>&1; then
  :
else
  rm -rf conftest*
  tcl_ok=0
fi
rm -f conftest*

echo '#include "confdefs.h"
#include <string.h>' > conftest.c
eval "$CPP conftest.c > conftest.out 2>&1"
if egrep "strerror" conftest.out >/dev/null 2>&1; then
  :
else
  rm -rf conftest*
  tcl_ok=0
fi
rm -f conftest*

if test $tcl_ok = 0; then
    
{
test -n "$verbose" && \
echo "	defining NO_STRING_H"
echo "#define" NO_STRING_H 1 >> confdefs.h
DEFS="$DEFS -DNO_STRING_H=1"
}

fi
echo checking for sys/time.h
cat > conftest.c <<EOF
#include "confdefs.h"
#include <sys/time.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_SYS_TIME_H"
echo "#define" NO_SYS_TIME_H 1 >> confdefs.h
DEFS="$DEFS -DNO_SYS_TIME_H=1"
}

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
  :
else
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining NO_SYS_WAIT_H"
echo "#define" NO_SYS_WAIT_H 1 >> confdefs.h
DEFS="$DEFS -DNO_SYS_WAIT_H=1"
}

fi
rm -f conftest*


#--------------------------------------------------------------------
#	On some systems strstr is broken: it returns a pointer even
#	even if the original string is empty.
#--------------------------------------------------------------------

cat > conftest.c <<EOF
#include "confdefs.h"

extern int strstr();
int main()
{
    exit(strstr("\0test", "test") ? 1 : 0);
}

EOF
eval $compile
if test -s conftest && (./conftest; exit) 2>/dev/null; then
  :
else
  LIBOBJS="$LIBOBJS strstr.o"
fi
rm -fr conftest*

#--------------------------------------------------------------------
#	Check for strtoul function.  This is tricky because under some
#	versions of AIX strtoul returns an incorrect terminator
#	pointer for the string "0".
#--------------------------------------------------------------------

echo checking for strtoul
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_strtoul) || defined (__stub___strtoul)
choke me
#else
/* Override any gcc2 internal prototype to avoid an error.  */
extern char strtoul(); strtoul();
#endif
 }
EOF
if eval $compile; then
  rm -rf conftest*
  tcl_ok=1

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

cat > conftest.c <<EOF
#include "confdefs.h"

extern int strtoul();
int main()
{
    char *string = "0";
    char *term;
    int value;
    value = strtoul(string, &term, 0);
    if ((value != 0) || (term != (string+1))) {
        exit(1);
    }
    exit(0);
}
EOF
eval $compile
if test -s conftest && (./conftest; exit) 2>/dev/null; then
  :
else
  tcl_ok=0
fi
rm -fr conftest*
if test $tcl_ok = 0; then
    LIBOBJS="$LIBOBJS strtoul.o"
fi

#--------------------------------------------------------------------
#	Check for the strtod function.  This is tricky because under
#	some versions of Linux it mis-parses the string "+".
#--------------------------------------------------------------------

echo checking for strtod
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_strtod) || defined (__stub___strtod)
choke me
#else
/* Override any gcc2 internal prototype to avoid an error.  */
extern char strtod(); strtod();
#endif
 }
EOF
if eval $compile; then
  rm -rf conftest*
  tcl_ok=1

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

cat > conftest.c <<EOF
#include "confdefs.h"

extern double strtod();
int main()
{
    char *string = "+";
    char *term;
    double value;
    value = strtod(string, &term);
    if (term != string) {
	exit(1);
    }
    exit(0);
}
EOF
eval $compile
if test -s conftest && (./conftest; exit) 2>/dev/null; then
  :
else
  tcl_ok=0
fi
rm -fr conftest*
if test $tcl_ok = 0; then
    LIBOBJS="$LIBOBJS strtod.o"
fi

#--------------------------------------------------------------------
#	Check for various typedefs and provide substitutes if
#	they don't exist.
#--------------------------------------------------------------------

echo checking for mode_t in sys/types.h
echo '#include "confdefs.h"
#include <sys/types.h>' > conftest.c
eval "$CPP conftest.c > conftest.out 2>&1"
if egrep "mode_t" conftest.out >/dev/null 2>&1; then
  :
else
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining" mode_t to be int
echo "#define" mode_t int >> confdefs.h
DEFS="$DEFS -Dmode_t=int"
}

fi
rm -f conftest*

echo checking for pid_t in sys/types.h
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"
}

fi
rm -f conftest*

echo checking for size_t in sys/types.h
echo '#include "confdefs.h"
#include <sys/types.h>' > conftest.c
eval "$CPP conftest.c > conftest.out 2>&1"
if egrep "size_t" conftest.out >/dev/null 2>&1; then
  :
else
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining" size_t to be unsigned
echo "#define" size_t unsigned >> confdefs.h
DEFS="$DEFS -Dsize_t=unsigned"
}

fi
rm -f conftest*

echo checking for uid_t in sys/types.h
echo '#include "confdefs.h"
#include <sys/types.h>' > conftest.c
eval "$CPP conftest.c > conftest.out 2>&1"
if egrep "uid_t" conftest.out >/dev/null 2>&1; then
  :
else
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining" uid_t to be int
echo "#define" uid_t int >> confdefs.h
DEFS="$DEFS -Duid_t=int"
}
 
{
test -n "$verbose" && \
echo "	defining" gid_t to be int
echo "#define" gid_t int >> confdefs.h
DEFS="$DEFS -Dgid_t=int"
}

fi
rm -f conftest*


#--------------------------------------------------------------------
#	If a system doesn't have an opendir function (man, that's old!)
#	then we have to supply a different version of dirent.h which
#	is compatible with the substitute version of opendir that's
#	provided.  This version only works with V7-style directories.
#--------------------------------------------------------------------

echo checking for opendir
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_opendir) || defined (__stub___opendir)
choke me
#else
/* Override any gcc2 internal prototype to avoid an error.  */
extern char opendir(); opendir();
#endif
 }
EOF
if eval $compile; then
  :
else
  rm -rf conftest*
  {
test -n "$verbose" && \
echo "	defining USE_DIRENT2_H"
echo "#define" USE_DIRENT2_H 1 >> confdefs.h
DEFS="$DEFS -DUSE_DIRENT2_H=1"
}

fi
rm -f conftest*


#--------------------------------------------------------------------
#	Check for the existence of sys_errlist (this is only needed if
#	there's no strerror, but I don't know how to conditionalize the
#	check).
#--------------------------------------------------------------------

echo checking for sys_errlist
cat > conftest.c <<EOF
#include "confdefs.h"

int main() { exit(0); }
int t() { 
extern char *sys_errlist[];
extern int sys_nerr;
sys_errlist[sys_nerr-1][0] = 0;
 }
EOF
if eval $compile; then
  :
else
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining NO_SYS_ERRLIST"
echo "#define" NO_SYS_ERRLIST 1 >> confdefs.h
DEFS="$DEFS -DNO_SYS_ERRLIST=1"
}

fi
rm -f conftest*


#--------------------------------------------------------------------
#	The check below checks whether <sys/wait.h> defines the type
#	"union wait" correctly.  It's needed because of weirdness in
#	HP-UX where "union wait" is defined in both the BSD and SYS-V
#	environments.  Checking the usability of WIFEXITED seems to do
#	the trick.
#--------------------------------------------------------------------

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"
}

fi
rm -f conftest*


#--------------------------------------------------------------------
#	Check to see whether the system supports the matherr function
#	and its associated type "struct exception".
#--------------------------------------------------------------------

echo checking for matherr support
cat > conftest.c <<EOF
#include "confdefs.h"
#include <math.h>
int main() { exit(0); }
int t() { 
struct exception x;
x.type = DOMAIN;
x.type = SING;
 }
EOF
if eval $compile; then
  rm -rf conftest*
  LIBOBJS="$LIBOBJS tclMtherr.o"; 
{
test -n "$verbose" && \
echo "	defining NEED_MATHERR"
echo "#define" NEED_MATHERR 1 >> confdefs.h
DEFS="$DEFS -DNEED_MATHERR=1"
}


fi
rm -f conftest*


# 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 -f Makefile; exit 1' 1 3 15
INSTALL='$INSTALL'
INSTALL_PROGRAM='$INSTALL_PROGRAM'
INSTALL_DATA='$INSTALL_DATA'
RANLIB='$RANLIB'
LN_S='$LN_S'
CC='$CC'
UNSHARED='$UNSHARED'
PATCH='$PATCH'
Patch='$Patch'
Patch1='$Patch1'
PICFLAGS='$PICFLAGS'
SHAREDCC='$SHAREDCC'
SHLIBSO='$SHLIBSO'
SHLIBSA='$SHLIBSA'
SHLIBSO_BLD='$SHLIBSO_BLD'
SHLIBSA_BLD='$SHLIBSA_BLD'
SHDIR='$SHDIR'
LD_DIR='$LD_DIR'
LIBOBJS='$LIBOBJS'
CPP='$CPP'
LIBS='$LIBS'
srcdir='$srcdir'
DEFS='$DEFS'
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%@LN_S@%$LN_S%g
s%@CC@%$CC%g
s%@UNSHARED@%$UNSHARED%g
s%@PATCH@%$PATCH%g
s%@Patch@%$Patch%g
s%@Patch1@%$Patch1%g
s%@PICFLAGS@%$PICFLAGS%g
s%@SHAREDCC@%$SHAREDCC%g
s%@SHLIBSO@%$SHLIBSO%g
s%@SHLIBSA@%$SHLIBSA%g
s%@SHLIBSO_BLD@%$SHLIBSO_BLD%g
s%@SHLIBSA_BLD@%$SHLIBSA_BLD%g
s%@SHDIR@%$SHDIR%g
s%@LD_DIR@%$LD_DIR%g
s%@LIBOBJS@%$LIBOBJS%g
s%@CPP@%$CPP%g
s%@LIBS@%$LIBS%g
s%@srcdir@%$srcdir%g
s%@DEFS@%$DEFS%
" $top_srcdir/${file}.in >> $file
fi; done


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

