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

#!/bin/sh
# From configure.in Revision: 3.7 



#------------------------------------------------------------------------------
#      command line looking for the --arch= option.
#------------------------------------------------------------------------------

# check whether --with-arch was given
withval="$with_arch"
if test -n "$withval"; then
  TCL_ARCH=.$withval
fi

if test x$TCL_ARCH = x
then
  echo "No architecture suffix will be used"
else
  echo "An architecture suffix of \"$TCL_ARCH\" will be appended to bin and lib directories."
fi


#------------------------------------------------------------------------------
#       Check for various programs used during the build.
#------------------------------------------------------------------------------

for p in 'bison -y' byacc
do
if test -z "$YACC"; then
  # Extract the first word of `$p', so it can be a program name with args.
  set dummy $p; 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
      YACC="$p"
      break
    fi
  done
  IFS="$saveifs"
fi

test -n "$YACC" && test -n "$verbose" && echo "	setting YACC to $YACC"

test -n "$YACC" && break
done
test -n "$YACC" || YACC="yacc"

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"

CC=${CC-cc}

if test -z "$MCS_CMD"; then
  # Extract the first word of `"mcs"', so it can be a program name with args.
  set dummy "mcs"; 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
      MCS_CMD="mcs -d"
      break
    fi
  done
  IFS="$saveifs"
fi
test -z "$MCS_CMD" && MCS_CMD="touch"
test -n "$MCS_CMD" && test -n "$verbose" && echo "	setting MCS_CMD to $MCS_CMD"


#------------------------------------------------------------------------------
#       Some versions of Sun OS require -ldl to link anything, even the
#       small, empty programs generated by configure.  I don't know why, but
#       we must check for it up front or other configure tests will fail.
#------------------------------------------------------------------------------

LIBS_save="${LIBS}"
LIBS="${LIBS} -ldl"
have_lib=""
echo checking for -ldl
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
   :; LIBS="$LIBS -ldl"
else
   :; 
fi



#------------------------------------------------------------------------------
#       Check for the existence of various libraries.  The order here
#       is important, so that then end up in the right order in the
#       command line generated by make.  On some SVR4, -lsocket must be
#       used with -lnsl, so a special check with both libraries, or the
#       check just fails since it doesn't link (yea, its strange).
#------------------------------------------------------------------------------

LIBS_save="${LIBS}"
LIBS="${LIBS} -lXbsd"
have_lib=""
echo checking for -lXbsd
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
   :; LIBS="$LIBS -lXbsd"
else
   :; 
fi


socket_libs=""
SAVED_LIBS=$LIBS
LIBS="$LIBS -lsocket"
LIBS_save="${LIBS}"
LIBS="${LIBS} -lnsl"
have_lib=""
echo checking for -lnsl
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
   :; socket_libs="-lsocket -lnsl"
else
   :; 
fi

LIBS=$SAVED_LIBS
if test -z "$socket_libs"; then
    LIBS_save="${LIBS}"
LIBS="${LIBS} -lsocket"
have_lib=""
echo checking for -lsocket
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
   :; socket_libs="$socket_libs -lsocket"
else
   :; 
fi

    LIBS_save="${LIBS}"
LIBS="${LIBS} -lnsl"
have_lib=""
echo checking for -lnsl
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
   :; socket_libs="$socket_libs -lnsl"
else
   :; 
fi

fi
LIBS="$LIBS $socket_libs"

#------------------------------------------------------------------------------
#       Check for additional libraries the Tcl/Tk does not check for.
#------------------------------------------------------------------------------

LIBS_save="${LIBS}"
LIBS="${LIBS} -lsun"
have_lib=""
echo checking for -lsun
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
   :; LIBS="$LIBS -lsun"
else
   :; 
fi

LIBS_save="${LIBS}"
LIBS="${LIBS} -lc_s"
have_lib=""
echo checking for -lc_s
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
   :; LIBS="$LIBS -lc_s"
else
   :; 
fi

LIBS_save="${LIBS}"
LIBS="${LIBS} -lieee"
have_lib=""
echo checking for -lieee
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
   :; LIBS="$LIBS -lieee"
else
   :; 
fi


#------------------------------------------------------------------------------
#       Some make programs require includes to be 
#         .include "file"
#     others...
#         include file
#------------------------------------------------------------------------------

echo checking how make handles includes
rm -fr conftestdir
if mkdir conftestdir; then
  cd conftestdir
  cat > Makeinclude <<EOF

EOF
  cat > Makefile <<EOF
include Makeinclude

all:
EOF
  if make >/dev/null 2>/dev/null; then
    MAKEINCLUDE="include"
    MAKEQUOTE=''
  else
    MAKEINCLUDE=".include"
    MAKEQUOTE='"'
  fi
  cd ..
  rm -fr conftestdir
fi



#------------------------------------------------------------------------------
#       Check for system header files.
#------------------------------------------------------------------------------

echo checking for values.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"

cat > conftest.c <<EOF
#include "confdefs.h"
#include <values.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_VALUES_H"
echo "#define" NO_VALUES_H 1 >> confdefs.h
DEFS="$DEFS -DNO_VALUES_H=1"
SEDDEFS="${SEDDEFS}\${SEDdA}NO_VALUES_H\${SEDdB}NO_VALUES_H\${SEDdC}1\${SEDdD}
\${SEDuA}NO_VALUES_H\${SEDuB}NO_VALUES_H\${SEDuC}1\${SEDuD}
\${SEDeA}NO_VALUES_H\${SEDeB}NO_VALUES_H\${SEDeC}1\${SEDeD}
"
}

fi
rm -f conftest*

echo checking for sys/socket.h
cat > conftest.c <<EOF
#include "confdefs.h"
#include <sys/socket.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_SOCKET_H"
echo "#define" NO_SYS_SOCKET_H 1 >> confdefs.h
DEFS="$DEFS -DNO_SYS_SOCKET_H=1"
SEDDEFS="${SEDDEFS}\${SEDdA}NO_SYS_SOCKET_H\${SEDdB}NO_SYS_SOCKET_H\${SEDdC}1\${SEDdD}
\${SEDuA}NO_SYS_SOCKET_H\${SEDuB}NO_SYS_SOCKET_H\${SEDuC}1\${SEDuD}
\${SEDeA}NO_SYS_SOCKET_H\${SEDeB}NO_SYS_SOCKET_H\${SEDeC}1\${SEDeD}
"
}

fi
rm -f conftest*


#------------------------------------------------------------------------------
#       Check for missing typedefs.
#------------------------------------------------------------------------------

echo checking for time_t
cat > conftest.c <<EOF
#include "confdefs.h"
#include <sys/types.h>
int main() { exit(0); }
int t() {  }
EOF
if eval $compile; then
  :
else
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining" time_t to be long
echo "#define" time_t long >> confdefs.h
DEFS="$DEFS -Dtime_t=long"
SEDDEFS="${SEDDEFS}\${SEDdA}time_t\${SEDdB}time_t\${SEDdC}long\${SEDdD}
\${SEDuA}time_t\${SEDuB}time_t\${SEDuC}long\${SEDuD}
\${SEDeA}time_t\${SEDeB}time_t\${SEDeC}long\${SEDeD}
"
}

fi
rm -f conftest*


#------------------------------------------------------------------------------
#       What type do signals return?
#------------------------------------------------------------------------------

echo checking for return type of signal handlers
cat > conftest.c <<EOF
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
#ifdef signal
#undef signal
#endif
extern void (*signal ()) ();
int main() { exit(0); }
int t() { int i; }
EOF
if eval $compile; then
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining" RETSIGTYPE to be void
echo "#define" RETSIGTYPE void >> confdefs.h
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
  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}
"
}

fi
rm -f conftest*



#------------------------------------------------------------------------------
#       Find out all about time handling differences.
#------------------------------------------------------------------------------

echo checking for whether time.h and sys/time.h may both be included
cat > conftest.c <<EOF
#include "confdefs.h"
#include <sys/types.h>
#include <sys/time.h>
#include <time.h>
int main() { exit(0); }
int t() { struct tm *tp; }
EOF
if eval $compile; then
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining TIME_WITH_SYS_TIME"
echo "#define" TIME_WITH_SYS_TIME 1 >> confdefs.h
DEFS="$DEFS -DTIME_WITH_SYS_TIME=1"
SEDDEFS="${SEDDEFS}\${SEDdA}TIME_WITH_SYS_TIME\${SEDdB}TIME_WITH_SYS_TIME\${SEDdC}1\${SEDdD}
\${SEDuA}TIME_WITH_SYS_TIME\${SEDuB}TIME_WITH_SYS_TIME\${SEDuC}1\${SEDuD}
\${SEDeA}TIME_WITH_SYS_TIME\${SEDeB}TIME_WITH_SYS_TIME\${SEDeC}1\${SEDeD}
"
}


fi
rm -f conftest*

echo checking for struct tm in time.h
cat > conftest.c <<EOF
#include "confdefs.h"
#include <sys/types.h>
#include <time.h>
int main() { exit(0); }
int t() { struct tm *tp; tp->tm_sec; }
EOF
if eval $compile; then
  :
else
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining TM_IN_SYS_TIME"
echo "#define" TM_IN_SYS_TIME 1 >> confdefs.h
DEFS="$DEFS -DTM_IN_SYS_TIME=1"
SEDDEFS="${SEDDEFS}\${SEDdA}TM_IN_SYS_TIME\${SEDdB}TM_IN_SYS_TIME\${SEDdC}1\${SEDdD}
\${SEDuA}TM_IN_SYS_TIME\${SEDuB}TM_IN_SYS_TIME\${SEDuC}1\${SEDuD}
\${SEDeA}TM_IN_SYS_TIME\${SEDeB}TM_IN_SYS_TIME\${SEDeC}1\${SEDeD}
"
}

fi
rm -f conftest*

decl='#include <sys/types.h>
'
case "$DEFS" in
  *TM_IN_SYS_TIME*) decl="$decl
#include <sys/time.h>
" ;;
  *) decl="$decl
#include <time.h>
" ;;
esac
echo checking for tm_zone in struct tm
cat > conftest.c <<EOF
#include "confdefs.h"
$decl
int main() { exit(0); }
int t() { struct tm tm; tm.tm_zone; }
EOF
if eval $compile; then
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining HAVE_TM_ZONE"
echo "#define" HAVE_TM_ZONE 1 >> confdefs.h
DEFS="$DEFS -DHAVE_TM_ZONE=1"
SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_TM_ZONE\${SEDdB}HAVE_TM_ZONE\${SEDdC}1\${SEDdD}
\${SEDuA}HAVE_TM_ZONE\${SEDuB}HAVE_TM_ZONE\${SEDuC}1\${SEDuD}
\${SEDeA}HAVE_TM_ZONE\${SEDeB}HAVE_TM_ZONE\${SEDeC}1\${SEDeD}
"
}


else
  rm -rf conftest*
  no_tm_zone=1
fi
rm -f conftest*

if test -n "$no_tm_zone"; then
echo checking for tzname
cat > conftest.c <<EOF
#include "confdefs.h"
#include <time.h>
#ifndef tzname /* For SGI.  */
extern char *tzname[]; /* RS6000 and others want it this way.  */
#endif
int main() { exit(0); }
int t() { atoi(*tzname); }
EOF
if eval $compile; then
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining HAVE_TZNAME"
echo "#define" HAVE_TZNAME 1 >> confdefs.h
DEFS="$DEFS -DHAVE_TZNAME=1"
SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_TZNAME\${SEDdB}HAVE_TZNAME\${SEDdC}1\${SEDdD}
\${SEDuA}HAVE_TZNAME\${SEDuB}HAVE_TZNAME\${SEDuC}1\${SEDuD}
\${SEDeA}HAVE_TZNAME\${SEDeB}HAVE_TZNAME\${SEDeC}1\${SEDeD}
"
}


fi
rm -f conftest*

fi


echo checking for tm_tzadj in struct tm
cat > conftest.c <<EOF
#include "confdefs.h"
#include <time.h>
int main() { exit(0); }
int t() { struct tm tm; tm.tm_tzadj; }
EOF
if eval $compile; then
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining HAVE_TM_TZADJ"
echo "#define" HAVE_TM_TZADJ 1 >> confdefs.h
DEFS="$DEFS -DHAVE_TM_TZADJ=1"
SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_TM_TZADJ\${SEDdB}HAVE_TM_TZADJ\${SEDdC}1\${SEDdD}
\${SEDuA}HAVE_TM_TZADJ\${SEDuB}HAVE_TM_TZADJ\${SEDuC}1\${SEDuD}
\${SEDeA}HAVE_TM_TZADJ\${SEDeB}HAVE_TM_TZADJ\${SEDeC}1\${SEDeD}
"
}


fi
rm -f conftest*


echo checking for tm_gmtoff in struct tm
cat > conftest.c <<EOF
#include "confdefs.h"
#include <time.h>
int main() { exit(0); }
int t() { struct tm tm; tm.tm_gmtoff; }
EOF
if eval $compile; then
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining HAVE_TM_GMTOFF"
echo "#define" HAVE_TM_GMTOFF 1 >> confdefs.h
DEFS="$DEFS -DHAVE_TM_GMTOFF=1"
SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_TM_GMTOFF\${SEDdB}HAVE_TM_GMTOFF\${SEDdC}1\${SEDdD}
\${SEDuA}HAVE_TM_GMTOFF\${SEDuB}HAVE_TM_GMTOFF\${SEDuC}1\${SEDuD}
\${SEDeA}HAVE_TM_GMTOFF\${SEDeB}HAVE_TM_GMTOFF\${SEDeC}1\${SEDeD}
"
}


fi
rm -f conftest*


for func in gettimeofday
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


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

int main() { exit(0); }
int t() { 
extern long timezone;
timezone += 1;
exit (0);
 }
EOF
if eval $compile; then
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining HAVE_TIMEZONE_VAR"
echo "#define" HAVE_TIMEZONE_VAR 1 >> confdefs.h
DEFS="$DEFS -DHAVE_TIMEZONE_VAR=1"
SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_TIMEZONE_VAR\${SEDdB}HAVE_TIMEZONE_VAR\${SEDdC}1\${SEDdD}
\${SEDuA}HAVE_TIMEZONE_VAR\${SEDuB}HAVE_TIMEZONE_VAR\${SEDuC}1\${SEDuD}
\${SEDeA}HAVE_TIMEZONE_VAR\${SEDeB}HAVE_TIMEZONE_VAR\${SEDeC}1\${SEDeD}
"
}


fi
rm -f conftest*


#------------------------------------------------------------------------------
#     Test to see if "times" returns a status or the amount of
#     elapsed real time.
#------------------------------------------------------------------------------

echo "checking to see if 'times' returns the elapsed real time"
cat > conftest.c <<EOF
#include "confdefs.h"

#include <sys/types.h>
#include <sys/times.h>
main() {
struct tms cpu;
times (&cpu);
sleep (2);
if (times (&cpu) > 0)
     exit (0);
else 
     exit (1);
}

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


fi
rm -fr conftest*

#------------------------------------------------------------------------------
#     Determine if "." is used as separator for the manual directory
#     names.  i.e. man/man.1 vs man/man1
#------------------------------------------------------------------------------

echo "checking man directory/section separator (man/man.1 vs man/man1)"
mandirs="/usr/man/man.1 /usr/man/cat.1 /usr/share/man.1 /usr/share/man.1 
        /usr/man/cat.C"
gotdotdir="NO"
for d in $mandirs
do
    if test -d $d
    then
        gotdotdir="YES"
    fi
done

mandirs="/usr/man/man1   /usr/man/cat1   /usr/share/man1   /usr/share/man1
         /usr/man/man1.Z /usr/man/cat1.Z /usr/share/man1.Z /usr/share/man1.Z"
gotnodotdir="NO"
for d in $mandirs
do
    if test -d $d
    then
        gotnodotdir="YES"
    fi
done

if test $gotdotdir = YES -a $gotnodotdir = NO
then
    MAN_DIR_SEPARATOR="."
elif test $gotdotdir = NO -a $gotnodotdir = YES
then
    MAN_DIR_SEPARATOR=""
else
    MAN_DIR_SEPARATOR="."
    echo "WARNING: could not determine man directory/section separator"
    echo "         assuming man/man.1 (can override in Config.mk)."
fi


#------------------------------------------------------------------------------
# Define srcbasedir and bldbasedir as absolute paths.
#------------------------------------------------------------------------------

srcbasedir=`cd $srcdir;pwd`

bldbasedir=`pwd`


#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#                      Begin code from Tcl configure.in
#------------------------------------------------------------------------------

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

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"
SEDDEFS="${SEDDEFS}\${SEDdA}NO_GETTOD\${SEDdB}NO_GETTOD\${SEDdC}1\${SEDdD}
\${SEDuA}NO_GETTOD\${SEDuB}NO_GETTOD\${SEDuC}1\${SEDuD}
\${SEDeA}NO_GETTOD\${SEDeB}NO_GETTOD\${SEDeC}1\${SEDeD}
"
}

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


fi
rm -f conftest*
done

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"
SEDDEFS="${SEDDEFS}\${SEDdA}NO_DIRENT_H\${SEDdB}NO_DIRENT_H\${SEDdC}1\${SEDdD}
\${SEDuA}NO_DIRENT_H\${SEDuB}NO_DIRENT_H\${SEDuC}1\${SEDuD}
\${SEDeA}NO_DIRENT_H\${SEDeB}NO_DIRENT_H\${SEDeC}1\${SEDeD}
"
}

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"
SEDDEFS="${SEDDEFS}\${SEDdA}NO_ERRNO_H\${SEDdB}NO_ERRNO_H\${SEDdC}1\${SEDdD}
\${SEDuA}NO_ERRNO_H\${SEDuB}NO_ERRNO_H\${SEDuC}1\${SEDuD}
\${SEDeA}NO_ERRNO_H\${SEDeB}NO_ERRNO_H\${SEDeC}1\${SEDeD}
"
}

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"
SEDDEFS="${SEDDEFS}\${SEDdA}NO_FLOAT_H\${SEDdB}NO_FLOAT_H\${SEDdC}1\${SEDdD}
\${SEDuA}NO_FLOAT_H\${SEDuB}NO_FLOAT_H\${SEDuC}1\${SEDuD}
\${SEDeA}NO_FLOAT_H\${SEDeB}NO_FLOAT_H\${SEDeC}1\${SEDeD}
"
}

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"
SEDDEFS="${SEDDEFS}\${SEDdA}NO_LIMITS_H\${SEDdB}NO_LIMITS_H\${SEDdC}1\${SEDdD}
\${SEDuA}NO_LIMITS_H\${SEDuB}NO_LIMITS_H\${SEDuC}1\${SEDuD}
\${SEDeA}NO_LIMITS_H\${SEDeB}NO_LIMITS_H\${SEDeC}1\${SEDeD}
"
}

fi
rm -f conftest*

echo checking for stdlib.h
cat > conftest.c <<EOF
#include "confdefs.h"
#include <stdlib.h>
EOF
err=`eval "($CPP conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  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"
SEDDEFS="${SEDDEFS}\${SEDdA}NO_STDLIB_H\${SEDdB}NO_STDLIB_H\${SEDdC}1\${SEDdD}
\${SEDuA}NO_STDLIB_H\${SEDuB}NO_STDLIB_H\${SEDuC}1\${SEDuD}
\${SEDeA}NO_STDLIB_H\${SEDeB}NO_STDLIB_H\${SEDeC}1\${SEDeD}
"
}

fi
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"
SEDDEFS="${SEDDEFS}\${SEDdA}NO_STRING_H\${SEDdB}NO_STRING_H\${SEDdC}1\${SEDdD}
\${SEDuA}NO_STRING_H\${SEDuB}NO_STRING_H\${SEDuC}1\${SEDuD}
\${SEDeA}NO_STRING_H\${SEDeB}NO_STRING_H\${SEDeC}1\${SEDeD}
"
}

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"
SEDDEFS="${SEDDEFS}\${SEDdA}NO_SYS_TIME_H\${SEDdB}NO_SYS_TIME_H\${SEDdC}1\${SEDdD}
\${SEDuA}NO_SYS_TIME_H\${SEDuB}NO_SYS_TIME_H\${SEDuC}1\${SEDuD}
\${SEDeA}NO_SYS_TIME_H\${SEDeB}NO_SYS_TIME_H\${SEDeC}1\${SEDeD}
"
}

fi
rm -f conftest*

echo checking for sys/wait.h
cat > conftest.c <<EOF
#include "confdefs.h"
#include <sys/wait.h>
EOF
err=`eval "($CPP conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  :
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"
SEDDEFS="${SEDDEFS}\${SEDdA}NO_SYS_WAIT_H\${SEDdB}NO_SYS_WAIT_H\${SEDdC}1\${SEDdD}
\${SEDuA}NO_SYS_WAIT_H\${SEDuB}NO_SYS_WAIT_H\${SEDuC}1\${SEDuD}
\${SEDeA}NO_SYS_WAIT_H\${SEDeB}NO_SYS_WAIT_H\${SEDeC}1\${SEDeD}
"
}

fi
rm -f conftest*


#--------------------------------------------------------------------
#       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"
SEDDEFS="${SEDDEFS}\${SEDdA}mode_t\${SEDdB}mode_t\${SEDdC}int\${SEDdD}
\${SEDuA}mode_t\${SEDuB}mode_t\${SEDuC}int\${SEDuD}
\${SEDeA}mode_t\${SEDeB}mode_t\${SEDeC}int\${SEDeD}
"
}

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

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"
SEDDEFS="${SEDDEFS}\${SEDdA}size_t\${SEDdB}size_t\${SEDdC}unsigned\${SEDdD}
\${SEDuA}size_t\${SEDuB}size_t\${SEDuC}unsigned\${SEDuD}
\${SEDeA}size_t\${SEDeB}size_t\${SEDeC}unsigned\${SEDeD}
"
}

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"
SEDDEFS="${SEDDEFS}\${SEDdA}uid_t\${SEDdB}uid_t\${SEDdC}int\${SEDdD}
\${SEDuA}uid_t\${SEDuB}uid_t\${SEDuC}int\${SEDuD}
\${SEDeA}uid_t\${SEDeB}uid_t\${SEDeC}int\${SEDeD}
"
}
 
{
test -n "$verbose" && \
echo "	defining" gid_t to be int
echo "#define" gid_t int >> confdefs.h
DEFS="$DEFS -Dgid_t=int"
SEDDEFS="${SEDDEFS}\${SEDdA}gid_t\${SEDdB}gid_t\${SEDdC}int\${SEDdD}
\${SEDuA}gid_t\${SEDuB}gid_t\${SEDuC}int\${SEDuD}
\${SEDeA}gid_t\${SEDeB}gid_t\${SEDeC}int\${SEDeD}
"
}

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"
SEDDEFS="${SEDDEFS}\${SEDdA}USE_DIRENT2_H\${SEDdB}USE_DIRENT2_H\${SEDdC}1\${SEDdD}
\${SEDuA}USE_DIRENT2_H\${SEDuB}USE_DIRENT2_H\${SEDuC}1\${SEDuD}
\${SEDeA}USE_DIRENT2_H\${SEDeB}USE_DIRENT2_H\${SEDeC}1\${SEDeD}
"
}

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"
SEDDEFS="${SEDDEFS}\${SEDdA}NO_UNION_WAIT\${SEDdB}NO_UNION_WAIT\${SEDdC}1\${SEDdD}
\${SEDuA}NO_UNION_WAIT\${SEDuB}NO_UNION_WAIT\${SEDuC}1\${SEDuD}
\${SEDeA}NO_UNION_WAIT\${SEDeB}NO_UNION_WAIT\${SEDeC}1\${SEDeD}
"
}

fi
rm -f conftest*


#------------------------------------------------------------------------------
#                       End code from Tcl configure.in
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
#                      Begin code from Tk configure.in
# Notes: Added check for X11_s.
# 
#------------------------------------------------------------------------------

#--------------------------------------------------------------------
#	Include sys/select.h if it exists and if it supplies things
#	that appear to be useful and aren't already in sys/types.h.
#	This appears to be true only on the RS/6000 under AIX.  Some
#	systems like OSF/1 have a sys/select.h that's of no use, and
#	other systems like SCO UNIX have a sys/select.h that's
#	pernicious.  If "fd_set" isn't defined anywhere then set a
#	special flag.
#--------------------------------------------------------------------

echo checking for sys/select.h
echo checking for fd_set
cat > conftest.c <<EOF
#include "confdefs.h"
#include <sys/types.h>
int main() { exit(0); }
int t() { fd_set readMask, writeMask; }
EOF
if eval $compile; then
  :
else
  rm -rf conftest*
  echo '#include "confdefs.h"
#include <sys/select.h>' > conftest.c
eval "$CPP conftest.c > conftest.out 2>&1"
if egrep "fd_mask" conftest.out >/dev/null 2>&1; then
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining HAVE_SYS_SELECT_H"
echo "#define" HAVE_SYS_SELECT_H 1 >> confdefs.h
DEFS="$DEFS -DHAVE_SYS_SELECT_H=1"
SEDDEFS="${SEDDEFS}\${SEDdA}HAVE_SYS_SELECT_H\${SEDdB}HAVE_SYS_SELECT_H\${SEDdC}1\${SEDdD}
\${SEDuA}HAVE_SYS_SELECT_H\${SEDuB}HAVE_SYS_SELECT_H\${SEDuC}1\${SEDuD}
\${SEDeA}HAVE_SYS_SELECT_H\${SEDeB}HAVE_SYS_SELECT_H\${SEDeC}1\${SEDeD}
"
}


else
  rm -rf conftest*
  
{
test -n "$verbose" && \
echo "	defining NO_FD_SET"
echo "#define" NO_FD_SET 1 >> confdefs.h
DEFS="$DEFS -DNO_FD_SET=1"
SEDDEFS="${SEDDEFS}\${SEDdA}NO_FD_SET\${SEDdB}NO_FD_SET\${SEDdC}1\${SEDdD}
\${SEDuA}NO_FD_SET\${SEDuB}NO_FD_SET\${SEDuC}1\${SEDuD}
\${SEDeA}NO_FD_SET\${SEDeB}NO_FD_SET\${SEDeC}1\${SEDeD}
"
}

fi
rm -f conftest*

fi
rm -f conftest*


#--------------------------------------------------------------------
#	Locate the X11 header files and the X11 library archive.  Try
#	the ac_find_x macro first, but if it doesn't find the X stuff
#	(e.g. because there's no xmkmf program) then check through
#	a list of possible directories.
#--------------------------------------------------------------------

if test -z "$tk_ok"; then
  # Extract the first word of `xmkmf', so it can be a program name with args.
  set dummy xmkmf; 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
      tk_ok="1"
      break
    fi
  done
  IFS="$saveifs"
fi
test -z "$tk_ok" && tk_ok="0"
test -n "$tk_ok" && test -n "$verbose" && echo "	setting tk_ok to $tk_ok"

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

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

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

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

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

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

fi
if test -n "$verbose"; then
  test -n "$x_includes" && echo "	found X11 headers in $x_includes"
  test -n "$x_libraries" && echo "	found X11 libraries in $x_libraries"
fi
fi
if test "$XINCLUDE_DIR" != ""; then
     x_includes="$XINCLUDE_DIR"
fi
if test "$x_includes" = /usr/include; then
    XINCLUDES="# no special path needed"
elif test "$x_includes" != ""; then
    XINCLUDES=" -I$x_includes"
else
    echo checking for X11 header files
    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/unsupported/include /usr/local/include /usr/X386/include /usr/include/X11R4 /usr/X11R5/include /usr/include/X11R5 /usr/openwin/include /usr/X11/include"
        for i in $dirs ; do
	    if test -r $i/X11/Intrinsic.h; then
	        XINCLUDES=" -I$i"
	    fi
        done
    fi
fi
if test "$XINCLUDES" = nope; then
  echo "Warning:  couldn't find any X11 include files."
  XINCLUDES="# no include files found"
fi


if test "$XLIBRARY_DIR" != ""; then
    x_libraries="$XLIBRARY_DIR"
fi
if test "$x_libraries" = /usr/lib; then
    XLIBSW=-lX11
elif test "$x_libraries" != ""; then
    XLIBSW="-L$x_libraries -lX11"
else
    echo "checking for X11 library archive"
    LIBS_save="${LIBS}"
LIBS="${LIBS} -lX11_s"
have_lib=""
echo checking for -lX11_s
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
   :; XLIBSW="-lX11_s"
else
   :; XLIBSW=nope
fi

    if test "$XLIBSW" = nope; then
        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
   :; XLIBSW="-lX11"
else
   :; XLIBSW=nope
fi

    fi
    if test "$XLIBSW" = nope; then
	dirs=${XLIBRARY_DIR-"/usr/unsupported/lib /usr/local/lib /usr/X386/lib /usr/lib/X11R4 /usr/X11R5/lib /usr/lib/X11R5 /usr/openwin/lib /usr/X11/lib"}
        for i in $dirs ; do
	    if test -r $i/libX11.a; then
		XLIBSW="-L$i -lX11"
	    fi
	done
    fi
fi
if test "$XLIBSW" = 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
   :; XLIBSW=-lXwindow
else
   :; 
fi

fi
if test "$XLIBSW" = nope ; then
    echo "Warning:  couldn't find the X11 library archive.  Using -lX11."
    XLIBSW=-lX11
fi


#------------------------------------------------------------------------------
#                       End code from Tk configure.in
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

#------------------------------------------------------------------------------
#       Check for various Unix or library functions that can be used by TclX.
#       These must be after the library checks.
#------------------------------------------------------------------------------

for func in catgets getcwd select setitimer setvbuf sigaction setpgid
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 bzero bcopy gethostbyname fsync getpriority
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


#------------------------------------------------------------------------------
#       Check for missing functions that we need.  They will be
#       compiled in the osSupport directory. Must check for SCO
#       -lintl, which is were strftime is hidden.  Also done after library
#       checks.
#------------------------------------------------------------------------------

LIBS_save="${LIBS}"
LIBS="${LIBS} -lintl"
have_lib=""
echo checking for -lintl
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
   :; LIBS="$LIBS -lintl"
else
   :; 
fi


echo checking for strftime
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_strftime) || defined (__stub___strftime)
choke me
#else
/* Override any gcc2 internal prototype to avoid an error.  */
extern char strftime(); strftime();
#endif
 }
EOF
if eval $compile; then
  :
else
  rm -rf conftest*
  LIBOBJS="$LIBOBJS strftime.o"
fi
rm -f conftest*

echo checking for random
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_random) || defined (__stub___random)
choke me
#else
/* Override any gcc2 internal prototype to avoid an error.  */
extern char random(); random();
#endif
 }
EOF
if eval $compile; then
  :
else
  rm -rf conftest*
  LIBOBJS="$LIBOBJS random.o"
fi
rm -f conftest*

echo checking for rename
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_rename) || defined (__stub___rename)
choke me
#else
/* Override any gcc2 internal prototype to avoid an error.  */
extern char rename(); rename();
#endif
 }
EOF
if eval $compile; then
  :
else
  rm -rf conftest*
  LIBOBJS="$LIBOBJS rename.o"
fi
rm -f conftest*



#------------------------------------------------------------------------------
#       If Config.mk is not in the build directory, copy it local.
#------------------------------------------------------------------------------

if test ! -r Config.mk
then
    echo "Copying $srcdir/Config.mk to build directory"
    cp $srcdir/Config.mk  Config.mk || exit 1
fi

#------------------------------------------------------------------------------
#       Copy the tests to the build directory if they are not there.
#       We could do something fancier, but this is easy for now.
#------------------------------------------------------------------------------

if test ! -d tests
then
    echo "Copying $srcdir/tests contents to build directory"
    mkdir tests
    # Prevent line to long on some systems.
    CURDIR=`pwd`
    cd $srcdir/tests
    cp *.test *.tcl all $CURDIR/tests || exit 1
    cd $CURDIR
fi

#------------------------------------------------------------------------------
# Generate the make files.
#------------------------------------------------------------------------------




# 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 osSupport/Makefile src/Makefile tclsrc/Makefile tksrc/Makefile tktclsrc/Makefile tools/Makefile src/SYSLIBS tksrc/SYSLIBS src/tclXconfig.h conftest*; exit 1' 1 3 15
TCL_ARCH='$TCL_ARCH'
YACC='$YACC'
RANLIB='$RANLIB'
CC='$CC'
MCS_CMD='$MCS_CMD'
MAKEINCLUDE='$MAKEINCLUDE'
MAKEQUOTE='$MAKEQUOTE'
CPP='$CPP'
MAN_DIR_SEPARATOR='$MAN_DIR_SEPARATOR'
srcbasedir='$srcbasedir'
bldbasedir='$bldbasedir'
tk_ok='$tk_ok'
XINCLUDES='$XINCLUDES'
XLIBSW='$XLIBSW'
LIBOBJS='$LIBOBJS'
prefix='$prefix'
execprefix='$execprefix'
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 osSupport/Makefile src/Makefile tclsrc/Makefile tksrc/Makefile tktclsrc/Makefile tools/Makefile src/SYSLIBS tksrc/SYSLIBS"}
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%@TCL_ARCH@%$TCL_ARCH%g
s%@YACC@%$YACC%g
s%@RANLIB@%$RANLIB%g
s%@CC@%$CC%g
s%@MCS_CMD@%$MCS_CMD%g
s%@MAKEINCLUDE@%$MAKEINCLUDE%g
s%@MAKEQUOTE@%$MAKEQUOTE%g
s%@CPP@%$CPP%g
s%@MAN_DIR_SEPARATOR@%$MAN_DIR_SEPARATOR%g
s%@srcbasedir@%$srcbasedir%g
s%@bldbasedir@%$bldbasedir%g
s%@tk_ok@%$tk_ok%g
s%@XINCLUDES@%$XINCLUDES%g
s%@XLIBSW@%$XLIBSW%g
s%@LIBOBJS@%$LIBOBJS%g
s%@prefix@%$prefix%g
s%@execprefix@%$execprefix%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-"src/tclXconfig.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
# src/tclXconfig.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

