#!/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" ;;

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

     *) ;;
    esac
  fi
done

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

# 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*
compile='${CC-cc} $CFLAGS $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=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: 1.19 



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

for arg in $configure_args
do
  # Handle --arch with a space before the argument.
  if test x$next_arch = xyes; then TCL_ARCH=.$arg; next_arch=
  else
    case $arg in
     --arch=*)
	TCL_ARCH=.`echo $arg | sed 's/[-a-z_]*=//'` ;;
     --arch)
	next_arch=yes ;;
    esac
  fi
done

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" -a -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" -a -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" -a -n "$verbose" && echo "	setting MCS_CMD to $MCS_CMD"


#------------------------------------------------------------------------------
#       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 various Unix or library functions that can be used by TclX.
#------------------------------------------------------------------------------

for func in catgets getcwd select setitimer setlinebuf sigaction setpgid
do
trfunc=HAVE_`echo $func | tr '[a-z]' '[A-Z]'`
echo checking for ${func}
cat > conftest.c <<EOF
#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
  {
test -n "$verbose" && \
echo "	defining ${trfunc}"
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 <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
  {
test -n "$verbose" && \
echo "	defining ${trfunc}"
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 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 <stdio.h>
Syntax Error
EOF
err=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  :
else
  CPP=/lib/cpp
fi
rm -f conftest*
fi
test ".${verbose}" != "." && echo "	setting CPP to $CPP"

cat > conftest.c <<EOF
#include <values.h>
EOF
err=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  :
else
  
{
test -n "$verbose" && \
echo "	defining NO_VALUES_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*


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

echo checking for SCO UNIX libintl
cat > conftest.c <<EOF
#if 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
  SCO_UNIX=1
fi
rm -f conftest*

test -n "$SCO_UNIX" && test -f /lib/libintl.a &&
  LIBS="$LIBS -lintl" # For strftime.

echo checking for strftime
cat > conftest.c <<EOF
#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
  LIBOBJS="$LIBOBJS strftime.o"
fi
rm -f conftest*

echo checking for random
cat > conftest.c <<EOF
#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
  LIBOBJS="$LIBOBJS random.o"
fi
rm -f conftest*

echo checking for rename
cat > conftest.c <<EOF
#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
  LIBOBJS="$LIBOBJS rename.o"
fi
rm -f conftest*



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

echo checking for time_t
cat > conftest.c <<EOF
#include <sys/types.h>
int main() { exit(0); }
int t() {  }
EOF
if eval $compile; then
  :
else
  
{
test -n "$verbose" && \
echo "	defining time_t to be long"
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 <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
  
{
test -n "$verbose" && \
echo "	defining RETSIGTYPE to be void"
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
  
{
test -n "$verbose" && \
echo "	defining RETSIGTYPE to be int"
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 <sys/types.h>
#include <sys/time.h>
#include <time.h>
int main() { exit(0); }
int t() { struct tm *tp; }
EOF
if eval $compile; then
  
{
test -n "$verbose" && \
echo "	defining TIME_WITH_SYS_TIME"
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 <sys/types.h>
#include <time.h>
int main() { exit(0); }
int t() { struct tm *tp; }
EOF
if eval $compile; then
  :
else
  
{
test -n "$verbose" && \
echo "	defining TM_IN_SYS_TIME"
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
$decl
int main() { exit(0); }
int t() { struct tm tm; tm.tm_zone; }
EOF
if eval $compile; then
  
{
test -n "$verbose" && \
echo "	defining HAVE_TM_ZONE"
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
  no_tm_zone=1
fi
rm -f conftest*

if test -n "$no_tm_zone"; then
echo checking for tzname
cat > conftest.c <<EOF
#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
  
{
test -n "$verbose" && \
echo "	defining HAVE_TZNAME"
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
$decl
int main() { exit(0); }
int t() { struct tm tm; tm.tm_tzadj; }
EOF
if eval $compile; then
  
{
test -n "$verbose" && \
echo "	defining HAVE_TM_TZADJ"
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
$decl
int main() { exit(0); }
int t() { struct tm tm; tm.tm_gmtoff; }
EOF
if eval $compile; then
  
{
test -n "$verbose" && \
echo "	defining HAVE_TM_GMTOFF"
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 <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
  {
test -n "$verbose" && \
echo "	defining ${trfunc}"
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

int main() { exit(0); }
int t() { 
extern long timezone;
timezone += 1;
exit (0);
 }
EOF
if eval $compile; then
  
{
test -n "$verbose" && \
echo "	defining HAVE_TIMEZONE_VAR"
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 <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"
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 -f 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 <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
  {
test -n "$verbose" && \
echo "	defining NO_GETTOD"
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
#--------------------------------------------------------------------

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

fi
rm -f conftest*

echo checking for dirent.h
cat > conftest.c <<EOF
#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
  tcl_ok=1
else
  tcl_ok=0
fi
rm -f conftest*

echo '#include <tcl_ok=0>' > conftest.c
eval "$CPP \$DEFS 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"
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 <errno.h>
EOF
err=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  :
else
  
{
test -n "$verbose" && \
echo "	defining NO_ERRNO_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 <float.h>
EOF
err=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  :
else
  
{
test -n "$verbose" && \
echo "	defining NO_FLOAT_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 <limits.h>
EOF
err=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  :
else
  
{
test -n "$verbose" && \
echo "	defining NO_LIMITS_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 <stdlib.h>
EOF
err=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  tcl_ok=1
else
  tcl_ok=0
fi
rm -f conftest*

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

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

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

if test $tcl_ok = 0; then
    
{
test -n "$verbose" && \
echo "	defining NO_STDLIB_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 <string.h>
EOF
err=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  tcl_ok=1
else
  tcl_ok=0
fi
rm -f conftest*

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

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

if test $tcl_ok = 0; then
    
{
test -n "$verbose" && \
echo "	defining NO_STRING_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 <sys/time.h>
EOF
err=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  :
else
  
{
test -n "$verbose" && \
echo "	defining NO_SYS_TIME_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 <sys/wait.h>
EOF
err=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  :
else
  
{
test -n "$verbose" && \
echo "	defining NO_SYS_WAIT_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 <sys/types.h>' > conftest.c
eval "$CPP \$DEFS conftest.c > conftest.out 2>&1"
if egrep "mode_t" conftest.out >/dev/null 2>&1; then
  :
else
  
{
test -n "$verbose" && \
echo "	defining mode_t to be int"
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 <sys/types.h>' > conftest.c
eval "$CPP \$DEFS conftest.c > conftest.out 2>&1"
if egrep "pid_t" conftest.out >/dev/null 2>&1; then
  :
else
  
{
test -n "$verbose" && \
echo "	defining pid_t to be int"
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 <sys/types.h>' > conftest.c
eval "$CPP \$DEFS conftest.c > conftest.out 2>&1"
if egrep "size_t" conftest.out >/dev/null 2>&1; then
  :
else
  
{
test -n "$verbose" && \
echo "	defining size_t to be unsigned"
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 <sys/types.h>' > conftest.c
eval "$CPP \$DEFS conftest.c > conftest.out 2>&1"
if egrep "uid_t" conftest.out >/dev/null 2>&1; then
  :
else
  
{
test -n "$verbose" && \
echo "	defining uid_t to be int"
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"
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 <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
  {
test -n "$verbose" && \
echo "	defining USE_DIRENT2_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 <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
  
{
test -n "$verbose" && \
echo "	defining NO_UNION_WAIT"
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 <sys/types.h>
int main() { exit(0); }
int t() { fd_set readMask, writeMask; }
EOF
if eval $compile; then
  :
else
  echo '#include <sys/select.h>' > conftest.c
eval "$CPP \$DEFS conftest.c > conftest.out 2>&1"
if egrep "fd_mask" conftest.out >/dev/null 2>&1; then
  
{
test -n "$verbose" && \
echo "	defining HAVE_SYS_SELECT_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
  
{
test -n "$verbose" && \
echo "	defining NO_FD_SET"
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" -a -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.
echo checking for X include and library files with xmkmf
rm -fr conftestdir
if mkdir conftestdir; then
  cd conftestdir
  cat > Imakefile <<EOF
acfindx:
	@echo "x_includes=$(INCROOT); x_libraries=$(USRLIBDIR)"
EOF
  if xmkmf >/dev/null 2>/dev/null && test -f Makefile; then
    eval `make acfindx`
  fi
  cd ..
  rm -fr conftestdir
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 <X11/Intrinsic.h>
EOF
err=`eval "($CPP \$DEFS conftest.c >/dev/null) 2>&1"`
if test -z "$err"; then
  :
else
  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

int main() { exit(0); }
int t() { main(); }
EOF
if eval $compile; then
  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

int main() { exit(0); }
int t() { main(); }
EOF
if eval $compile; then
  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

int main() { exit(0); }
int t() { main(); }
EOF
if eval $compile; then
  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


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

LIBS_save="${LIBS}"
LIBS="${LIBS} -lXbsd"
have_lib=""
echo checking for -lXbsd
cat > conftest.c <<EOF

int main() { exit(0); }
int t() { main(); }
EOF
if eval $compile; then
  have_lib="1"
fi
rm -f conftest*
LIBS="${LIBS_save}"
if test -n "${have_lib}"; then
   :; LIBS="$LIBS -lXbsd"
else
   :; 
fi

LIBS_save="${LIBS}"
LIBS="${LIBS} -lsocket"
have_lib=""
echo checking for -lsocket
cat > conftest.c <<EOF

int main() { exit(0); }
int t() { main(); }
EOF
if eval $compile; then
  have_lib="1"
fi
rm -f conftest*
LIBS="${LIBS_save}"
if test -n "${have_lib}"; then
   :; LIBS="$LIBS -lsocket"
else
   :; 
fi

LIBS_save="${LIBS}"
LIBS="${LIBS} -lnsl"
have_lib=""
echo checking for -lnsl
cat > conftest.c <<EOF

int main() { exit(0); }
int t() { main(); }
EOF
if eval $compile; then
  have_lib="1"
fi
rm -f conftest*
LIBS="${LIBS_save}"
if test -n "${have_lib}"; then
   :; LIBS="$LIBS -lnsl"
else
   :; 
fi


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

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

int main() { exit(0); }
int t() { main(); }
EOF
if eval $compile; then
  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

int main() { exit(0); }
int t() { main(); }
EOF
if eval $compile; then
  have_lib="1"
fi
rm -f conftest*
LIBS="${LIBS_save}"
if test -n "${have_lib}"; then
   :; LIBS="$LIBS -lc_s"
else
   :; 
fi


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




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
cat >conftest.def <<EOF
$DEFS
EOF
escape_ampersand_and_backslash='s%[&\\]%\\&%g'
DEFS=`sed "$escape_ampersand_and_backslash" <conftest.def`
rm -f conftest.def

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)
    exec /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'
LIBOBJS='$LIBOBJS'
MAN_DIR_SEPARATOR='$MAN_DIR_SEPARATOR'
srcbasedir='$srcbasedir'
bldbasedir='$bldbasedir'
tk_ok='$tk_ok'
XINCLUDES='$XINCLUDES'
XLIBSW='$XLIBSW'
prefix='$prefix'
execprefix='$execprefix'
LIBS='$LIBS'
srcdir='$srcdir'
prefix='$prefix'
exec_prefix='$exec_prefix'
prsub='$prsub'
EOF
cat >> config.status <<\EOF

top_srcdir=$srcdir

# Allow make-time overrides of the generated file list.
test -n "$gen_files" || gen_files="Makefile osSupport/Makefile src/Makefile tclsrc/Makefile tksrc/Makefile tktclsrc/Makefile tools/Makefile src/SYSLIBS tksrc/SYSLIBS"

for file in .. $gen_files; 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%@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%@LIBOBJS@%$LIBOBJS%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%@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
test -n "$gen_config" || gen_config=src/tclXconfig.h
echo creating $gen_config
# 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

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

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

while :
do
  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/$gen_config.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 "/* $gen_config.  Generated automatically by configure.  */" > conftest.h
cat conftest.h1 >> conftest.h
rm -f conftest.h1
if cmp -s $gen_config conftest.h 2>/dev/null; then
  # The file exists and we would not be changing it.
  rm -f conftest.h
else
  rm -f $gen_config
  mv conftest.h $gen_config
fi


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

