update to TEA 3.4
authorJeff Hobbs <hobbs@users.sourceforge.net>
Fri, 2 Dec 2005 22:16:07 +0000 (22:16 +0000)
committerJeff Hobbs <hobbs@users.sourceforge.net>
Fri, 2 Dec 2005 22:16:07 +0000 (22:16 +0000)
ChangeLog
configure
configure.in
tclconfig/tcl.m4

index fd468e5e0df6f3fa933b978210c29f2990e12ce9..ce385a80d40aa79cdc9931de943601bc822ca52d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-12-02  Jeff Hobbs  <jeffh@ActiveState.com>
+
+       * tclconfig/tcl.m4, configure.in, configure: update to TEA 3.4
+
 2005-11-10  Jean-Claude Wippler  <jcw@equi4.com>
 
        * Makefile.in: added missing mkclvfs.tcl dependency
index 4bb5f95667e7594a86a94fe5fdea1ab39e363c08..87167870054ed5a759f6faed88bd4a348cf2b92a 100755 (executable)
--- a/configure
+++ b/configure
@@ -308,7 +308,7 @@ ac_includes_default="\
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CYGPATH EXEEXT PKG_LIB_FILE PKG_STUB_LIB_FILE PKG_STUB_SOURCES PKG_STUB_OBJECTS PKG_TCL_SOURCES PKG_HEADERS PKG_INCLUDES PKG_LIBS PKG_CFLAGS TCL_VERSION TCL_BIN_DIR TCL_SRC_DIR TCL_LIB_FILE TCL_LIB_FLAG TCL_LIB_SPEC TCL_STUB_LIB_FILE TCL_STUB_LIB_FLAG TCL_STUB_LIB_SPEC TCL_LIBS TCL_DEFS TCL_EXTRA_CFLAGS TCL_LD_FLAGS TCL_SHLIB_LD_LIBS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC OBJEXT CPP INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA SET_MAKE RANLIB ac_ct_RANLIB EGREP MATH_LIBS PKG_SOURCES PKG_OBJECTS TCL_TOP_DIR_NATIVE TCL_GENERIC_DIR_NATIVE TCL_UNIX_DIR_NATIVE TCL_WIN_DIR_NATIVE TCL_BMAP_DIR_NATIVE TCL_TOOL_DIR_NATIVE TCL_PLATFORM_DIR_NATIVE TCL_INCLUDES CLEANFILES TCL_THREADS SHARED_BUILD AR TCLSH_PROG CELIB_DIR LIBOBJS DL_LIBS CFLAGS_DEBUG CFLAGS_OPTIMIZE CFLAGS_WARNING STLIB_LD SHLIB_LD SHLIB_CFLAGS SHLIB_LD_LIBS LDFLAGS_DEBUG LDFLAGS_OPTIMIZE LD_LIBRARY_PATH_VAR TCL_DBGX CFLAGS_DEFAULT LDFLAGS_DEFAULT MAKE_LIB MAKE_SHARED_LIB MAKE_STATIC_LIB MAKE_STUB_LIB RANLIB_STUB LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CYGPATH EXEEXT PKG_LIB_FILE PKG_STUB_LIB_FILE PKG_STUB_SOURCES PKG_STUB_OBJECTS PKG_TCL_SOURCES PKG_HEADERS PKG_INCLUDES PKG_LIBS PKG_CFLAGS TCL_VERSION TCL_BIN_DIR TCL_SRC_DIR TCL_LIB_FILE TCL_LIB_FLAG TCL_LIB_SPEC TCL_STUB_LIB_FILE TCL_STUB_LIB_FLAG TCL_STUB_LIB_SPEC TCL_LIBS TCL_DEFS TCL_EXTRA_CFLAGS TCL_LD_FLAGS TCL_SHLIB_LD_LIBS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC OBJEXT CPP INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA SET_MAKE RANLIB ac_ct_RANLIB EGREP MATH_LIBS PKG_SOURCES PKG_OBJECTS TCL_TOP_DIR_NATIVE TCL_GENERIC_DIR_NATIVE TCL_UNIX_DIR_NATIVE TCL_WIN_DIR_NATIVE TCL_BMAP_DIR_NATIVE TCL_TOOL_DIR_NATIVE TCL_PLATFORM_DIR_NATIVE TCL_INCLUDES CLEANFILES TCL_THREADS SHARED_BUILD AR CELIB_DIR LIBOBJS DL_LIBS CFLAGS_DEBUG CFLAGS_OPTIMIZE CFLAGS_WARNING STLIB_LD SHLIB_LD SHLIB_CFLAGS SHLIB_LD_LIBS LDFLAGS_DEBUG LDFLAGS_OPTIMIZE LD_LIBRARY_PATH_VAR TCL_DBGX CFLAGS_DEFAULT LDFLAGS_DEFAULT MAKE_LIB MAKE_SHARED_LIB MAKE_STATIC_LIB MAKE_STUB_LIB RANLIB_STUB TCLSH_PROG LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -1322,7 +1322,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
     # TEA extensions pass this us the version of TEA they think they
     # are compatible with.
-    TEA_VERSION="3.2"
+    TEA_VERSION="3.4"
 
     echo "$as_me:$LINENO: checking for correct TEA configuration" >&5
 echo $ECHO_N "checking for correct TEA configuration... $ECHO_C" >&6
@@ -1333,15 +1333,15 @@ echo "$as_me: error:
 The PACKAGE_NAME variable must be defined by your TEA configure.in" >&2;}
    { (exit 1); exit 1; }; }
     fi
-    if test x"3.2" = x ; then
+    if test x"3.4" = x ; then
        { { echo "$as_me:$LINENO: error:
 TEA version not specified." >&5
 echo "$as_me: error:
 TEA version not specified." >&2;}
    { (exit 1); exit 1; }; }
-    elif test "3.2" != "${TEA_VERSION}" ; then
-       echo "$as_me:$LINENO: result: warning: requested TEA version \"3.2\", have \"${TEA_VERSION}\"" >&5
-echo "${ECHO_T}warning: requested TEA version \"3.2\", have \"${TEA_VERSION}\"" >&6
+    elif test "3.4" != "${TEA_VERSION}" ; then
+       echo "$as_me:$LINENO: result: warning: requested TEA version \"3.4\", have \"${TEA_VERSION}\"" >&5
+echo "${ECHO_T}warning: requested TEA version \"3.4\", have \"${TEA_VERSION}\"" >&6
     else
        echo "$as_me:$LINENO: result: ok (TEA ${TEA_VERSION})" >&5
 echo "${ECHO_T}ok (TEA ${TEA_VERSION})" >&6
@@ -1474,6 +1474,14 @@ else
 
            # First check to see if --with-tcl was specified.
            if test x"${with_tclconfig}" != x ; then
+               case ${with_tclconfig} in
+                   */tclConfig.sh )
+                       if test -f ${with_tclconfig}; then
+                           { echo "$as_me:$LINENO: WARNING: --with-tcl argument should refer to directory containing tclConfig.sh, not to tclConfig.sh itself" >&5
+echo "$as_me: WARNING: --with-tcl argument should refer to directory containing tclConfig.sh, not to tclConfig.sh itself" >&2;}
+                           with_tclconfig=`echo ${with_tclconfig} | sed 's!/tclConfig\.sh$!!'`
+                       fi ;;
+               esac
                if test -f "${with_tclconfig}/tclConfig.sh" ; then
                    ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
                else
@@ -1487,10 +1495,16 @@ echo "$as_me: error: ${with_tclconfig} directory doesn't contain tclConfig.sh" >
            if test x"${ac_cv_c_tclconfig}" = x ; then
                for i in \
                        ../tcl \
+                       `ls -dr ../tcl[8-9].[0-9].[0-9]* 2>/dev/null` \
+                       `ls -dr ../tcl[8-9].[0-9] 2>/dev/null` \
                        `ls -dr ../tcl[8-9].[0-9]* 2>/dev/null` \
                        ../../tcl \
+                        `ls -dr ../../tcl[8-9].[0-9].[0-9]* 2>/dev/null` \
+                        `ls -dr ../../tcl[8-9].[0-9] 2>/dev/null` \
                        `ls -dr ../../tcl[8-9].[0-9]* 2>/dev/null` \
                        ../../../tcl \
+                        `ls -dr ../../../tcl[8-9].[0-9].[0-9]* 2>/dev/null` \
+                        `ls -dr ../../../tcl[8-9].[0-9] 2>/dev/null` \
                        `ls -dr ../../../tcl[8-9].[0-9]* 2>/dev/null` ; do
                    if test -f "$i/unix/tclConfig.sh" ; then
                        ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
@@ -1499,6 +1513,20 @@ echo "$as_me: error: ${with_tclconfig} directory doesn't contain tclConfig.sh" >
                done
            fi
 
+           # on Darwin, check in Framework installation locations
+           if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tclconfig}" = x ; then
+               for i in `ls -d ~/Library/Frameworks 2>/dev/null` \
+                       `ls -d /Library/Frameworks 2>/dev/null` \
+                       `ls -d /Network/Library/Frameworks 2>/dev/null` \
+                       `ls -d /System/Library/Frameworks 2>/dev/null` \
+                       ; do
+                   if test -f "$i/Tcl.framework/tclConfig.sh" ; then
+                       ac_cv_c_tclconfig=`(cd $i/Tcl.framework; pwd)`
+                       break
+                   fi
+               done
+           fi
+
            # check in a few common install locations
            if test x"${ac_cv_c_tclconfig}" = x ; then
                for i in `ls -d ${exec_prefix}/lib 2>/dev/null` \
@@ -1518,6 +1546,8 @@ echo "$as_me: error: ${with_tclconfig} directory doesn't contain tclConfig.sh" >
            if test x"${ac_cv_c_tclconfig}" = x ; then
                for i in \
                        ${srcdir}/../tcl \
+                       `ls -dr ${srcdir}/../tcl[8-9].[0-9].[0-9]* 2>/dev/null` \
+                       `ls -dr ${srcdir}/../tcl[8-9].[0-9] 2>/dev/null` \
                        `ls -dr ${srcdir}/../tcl[8-9].[0-9]* 2>/dev/null` ; do
                    if test -f "$i/unix/tclConfig.sh" ; then
                    ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
@@ -3937,7 +3967,9 @@ echo "${ECHO_T}$ac_cv_header_net_errno_h" >&6
 
 fi
 if test $ac_cv_header_net_errno_h = yes; then
-  cat >>confdefs.h <<\_ACEOF
+
+
+cat >>confdefs.h <<\_ACEOF
 #define HAVE_NET_ERRNO_H 1
 _ACEOF
 
@@ -4501,7 +4533,10 @@ fi
 
     echo "$as_me:$LINENO: checking dirent.h" >&5
 echo $ECHO_N "checking dirent.h... $ECHO_C" >&6
-    cat >conftest.$ac_ext <<_ACEOF
+    if test "${tcl_cv_dirent_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
@@ -4557,18 +4592,21 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  tcl_ok=yes
+  tcl_cv_dirent_h=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-tcl_ok=no
+tcl_cv_dirent_h=no
 fi
 rm -f conftest.err conftest.$ac_objext \
       conftest$ac_exeext conftest.$ac_ext
+fi
+
 
-    if test $tcl_ok = no; then
-       cat >>confdefs.h <<\_ACEOF
+    if test $tcl_cv_dirent_h = no; then
+
+cat >>confdefs.h <<\_ACEOF
 #define NO_DIRENT_H 1
 _ACEOF
 
@@ -4716,7 +4754,8 @@ fi
 if test $ac_cv_header_errno_h = yes; then
   :
 else
-  cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define NO_ERRNO_H 1
 _ACEOF
 
@@ -4863,7 +4902,8 @@ fi
 if test $ac_cv_header_float_h = yes; then
   :
 else
-  cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define NO_FLOAT_H 1
 _ACEOF
 
@@ -5010,7 +5050,8 @@ fi
 if test $ac_cv_header_values_h = yes; then
   :
 else
-  cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define NO_VALUES_H 1
 _ACEOF
 
@@ -5155,12 +5196,14 @@ echo "${ECHO_T}$ac_cv_header_limits_h" >&6
 
 fi
 if test $ac_cv_header_limits_h = yes; then
-  cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define HAVE_LIMITS_H 1
 _ACEOF
 
 else
-  cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define NO_LIMITS_H 1
 _ACEOF
 
@@ -5363,7 +5406,8 @@ fi
 rm -f conftest*
 
     if test $tcl_ok = 0; then
-       cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define NO_STDLIB_H 1
 _ACEOF
 
@@ -5551,7 +5595,8 @@ rm -f conftest*
     # set and why.
 
     if test $tcl_ok = 0; then
-       cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define NO_STRING_H 1
 _ACEOF
 
@@ -5697,7 +5742,8 @@ fi
 if test $ac_cv_header_sys_wait_h = yes; then
   :
 else
-  cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define NO_SYS_WAIT_H 1
 _ACEOF
 
@@ -5844,7 +5890,8 @@ fi
 if test $ac_cv_header_dlfcn_h = yes; then
   :
 else
-  cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define NO_DLFCN_H 1
 _ACEOF
 
@@ -6125,30 +6172,33 @@ echo "$as_me: error: could not find tcl source file '${srcdir}/$i'" >&2;}
     echo "$as_me:$LINENO: checking for Tcl private include files" >&5
 echo $ECHO_N "checking for Tcl private include files... $ECHO_C" >&6
 
+    TCL_SRC_DIR_NATIVE=`${CYGPATH} ${TCL_SRC_DIR}`
+    TCL_TOP_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}\"
+    TCL_GENERIC_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/generic\"
+    TCL_UNIX_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/unix\"
+    TCL_WIN_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/win\"
+    TCL_BMAP_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/bitmaps\"
+    TCL_TOOL_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/tools\"
+    TCL_COMPAT_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/compat\"
+
     if test "${TEA_PLATFORM}" = "windows"; then
-       TCL_TOP_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}`\"
-       TCL_GENERIC_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/generic`\"
-       TCL_UNIX_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/unix`\"
-       TCL_WIN_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/win`\"
-       TCL_BMAP_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/bitmaps`\"
-       TCL_TOOL_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/tools`\"
-       TCL_COMPAT_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/compat`\"
        TCL_PLATFORM_DIR_NATIVE=${TCL_WIN_DIR_NATIVE}
-
-       TCL_INCLUDES="-I${TCL_GENERIC_DIR_NATIVE} -I${TCL_PLATFORM_DIR_NATIVE}"
     else
-       TCL_TOP_DIR_NATIVE='$(TCL_SRC_DIR)'
-       TCL_GENERIC_DIR_NATIVE='${TCL_TOP_DIR_NATIVE}/generic'
-       TCL_UNIX_DIR_NATIVE='${TCL_TOP_DIR_NATIVE}/unix'
-       TCL_WIN_DIR_NATIVE='${TCL_TOP_DIR_NATIVE}/win'
-       TCL_BMAP_DIR_NATIVE='${TCL_TOP_DIR_NATIVE}/bitmaps'
-       TCL_TOOL_DIR_NATIVE='${TCL_TOP_DIR_NATIVE}/tools'
-       TCL_COMPAT_DIR_NATIVE='${TCL_TOP_DIR_NATIVE}/compat'
        TCL_PLATFORM_DIR_NATIVE=${TCL_UNIX_DIR_NATIVE}
-
-       # substitute these in "relaxed" so that TCL_INCLUDES still works
-       # without requiring the other vars to be defined in the Makefile
-       eval "TCL_INCLUDES=\"-I${TCL_GENERIC_DIR_NATIVE} -I${TCL_PLATFORM_DIR_NATIVE}\""
+    fi
+    # We want to ensure these are substituted so as not to require
+    # any *_NATIVE vars be defined in the Makefile
+    TCL_INCLUDES="-I${TCL_GENERIC_DIR_NATIVE} -I${TCL_PLATFORM_DIR_NATIVE}"
+    if test "`uname -s`" = "Darwin"; then
+        # If Tcl was built as a framework, attempt to use
+        # the framework's Headers and PrivateHeaders directories
+        case ${TCL_DEFS} in
+           *TCL_FRAMEWORK*)
+               if test -d "${TCL_BIN_DIR}/Headers" -a -d "${TCL_BIN_DIR}/PrivateHeaders"; then
+               TCL_INCLUDES="-I\"${TCL_BIN_DIR}/Headers\" -I\"${TCL_BIN_DIR}/PrivateHeaders\" ${TCL_INCLUDES}"; else
+               TCL_INCLUDES="${TCL_INCLUDES} ${TCL_INCLUDE_SPEC} `echo "${TCL_INCLUDE_SPEC}" | sed -e 's/Headers/PrivateHeaders/'`"; fi
+               ;;
+       esac
     fi
 
 
@@ -6197,23 +6247,33 @@ if test "${enable_threads+set}" = set; then
   enableval="$enable_threads"
   tcl_ok=$enableval
 else
-  tcl_ok=
+  tcl_ok=yes
 fi;
 
+    if test "${enable_threads+set}" = set; then
+       enableval="$enable_threads"
+       tcl_ok=$enableval
+    else
+       tcl_ok=yes
+    fi
+
     if test "$tcl_ok" = "yes" -o "${TCL_THREADS}" = 1; then
        TCL_THREADS=1
 
        if test "${TEA_PLATFORM}" != "windows" ; then
            # We are always OK on Windows, so check what this platform wants.
-           cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define USE_THREAD_ALLOC 1
 _ACEOF
 
-           cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define _REENTRANT 1
 _ACEOF
 
-           cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define _THREAD_SAFE 1
 _ACEOF
 
@@ -6597,216 +6657,6 @@ echo "$as_me: WARNING: \"Don t know how to find pthread lib on your system - thr
                fi
            fi
 
-           # Does the pthread-implementation provide
-           # 'pthread_attr_setstacksize' ?
-
-           ac_saved_libs=$LIBS
-           LIBS="$LIBS $THREADS_LIBS"
-
-for ac_func in pthread_attr_setstacksize
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
-if eval "test \"\${$as_ac_var+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
-   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define $ac_func innocuous_$ac_func
-
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.
-    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-    <limits.h> exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef $ac_func
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $ac_func ();
-/* 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_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-char (*f) () = $ac_func;
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-int
-main ()
-{
-return f != $ac_func;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-        { ac_try='test -z "$ac_c_werror_flag"
-                        || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-        { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  eval "$as_ac_var=yes"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-eval "$as_ac_var=no"
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
-           LIBS=$ac_saved_libs
-
-for ac_func in readdir_r
-do
-as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_func" >&5
-echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
-if eval "test \"\${$as_ac_var+set}\" = set"; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
-   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define $ac_func innocuous_$ac_func
-
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char $ac_func (); below.
-    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-    <limits.h> exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef $ac_func
-
-/* Override any gcc2 internal prototype to avoid an error.  */
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
-char $ac_func ();
-/* 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_$ac_func) || defined (__stub___$ac_func)
-choke me
-#else
-char (*f) () = $ac_func;
-#endif
-#ifdef __cplusplus
-}
-#endif
-
-int
-main ()
-{
-return f != $ac_func;
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-        { ac_try='test -z "$ac_c_werror_flag"
-                        || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-        { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  eval "$as_ac_var=yes"
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-eval "$as_ac_var=no"
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
-if test `eval echo '${'$as_ac_var'}'` = yes; then
-  cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
        fi
     else
        TCL_THREADS=0
@@ -6815,16 +6665,17 @@ done
     echo "$as_me:$LINENO: checking for building with threads" >&5
 echo $ECHO_N "checking for building with threads... $ECHO_C" >&6
     if test "${TCL_THREADS}" = "1"; then
-       cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define TCL_THREADS 1
 _ACEOF
 
        #LIBS="$LIBS $THREADS_LIBS"
-       echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+       echo "$as_me:$LINENO: result: yes (default)" >&5
+echo "${ECHO_T}yes (default)" >&6
     else
-       echo "$as_me:$LINENO: result: no (default)" >&5
-echo "${ECHO_T}no (default)" >&6
+       echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
     fi
     # TCL_THREADS sanity checking.  See if our request for building with
     # threads is the same as the way Tcl was built.  If not, warn the user.
@@ -6832,21 +6683,23 @@ echo "${ECHO_T}no (default)" >&6
        *THREADS=1*)
            if test "${TCL_THREADS}" = "0"; then
                { echo "$as_me:$LINENO: WARNING:
-    Building ${PACKAGE_NAME} without threads enabled, but building against Tcl
-    that IS thread-enabled." >&5
+    Building ${PACKAGE_NAME} without threads enabled, but building against Tcl
+    that IS thread-enabled.  It is recommended to use --enable-threads." >&5
 echo "$as_me: WARNING:
-    Building ${PACKAGE_NAME} without threads enabled, but building against Tcl
-    that IS thread-enabled." >&2;}
+    Building ${PACKAGE_NAME} without threads enabled, but building against Tcl
+    that IS thread-enabled.  It is recommended to use --enable-threads." >&2;}
            fi
            ;;
        *)
            if test "${TCL_THREADS}" = "1"; then
                { echo "$as_me:$LINENO: WARNING:
-    --enable-threads requested, but attempting building against a Tcl
-    that is NOT thread-enabled." >&5
+    --enable-threads requested, but building against a Tcl that is NOT
+    thread-enabled.  This is an OK configuration that will also run in
+    a thread-enabled core." >&5
 echo "$as_me: WARNING:
-    --enable-threads requested, but attempting building against a Tcl
-    that is NOT thread-enabled." >&2;}
+    --enable-threads requested, but building against a Tcl that is NOT
+    thread-enabled.  This is an OK configuration that will also run in
+    a thread-enabled core." >&2;}
            fi
            ;;
     esac
@@ -6878,7 +6731,8 @@ echo "${ECHO_T}shared" >&6
        echo "$as_me:$LINENO: result: static" >&5
 echo "${ECHO_T}static" >&6
        SHARED_BUILD=0
-       cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define STATIC_BUILD 1
 _ACEOF
 
@@ -6886,50 +6740,6 @@ _ACEOF
 
 
 
-    # Allow the user to provide this setting in the env
-    if test "x${TCLSH_PROG}" = "x" ; then
-       echo "$as_me:$LINENO: checking for tclsh" >&5
-echo $ECHO_N "checking for tclsh... $ECHO_C" >&6
-
-       if test "${ac_cv_path_tclsh+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-
-       search_path=`echo ${PATH} | sed -e 's/:/ /g'`
-       if test "${TEA_PLATFORM}" != "windows" -o \
-               \( "$do64bit_ok" = "no" -a "$doWince" = "no" \) ; then
-           # Do not allow target tclsh in known cross-compile builds,
-           # as we need one we can run on this system
-           search_path="${TCL_BIN_DIR} ${TCL_BIN_DIR}/../bin ${exec_prefix}/bin ${prefix}/bin ${search_path}"
-       fi
-       for dir in $search_path ; do
-           for j in `ls -r $dir/tclsh[8-9]*${EXEEXT} 2> /dev/null` \
-                   `ls -r $dir/tclsh*${EXEEXT} 2> /dev/null` ; do
-               if test x"$ac_cv_path_tclsh" = x ; then
-                   if test -f "$j" ; then
-                       ac_cv_path_tclsh=$j
-                       break
-                   fi
-               fi
-           done
-       done
-
-fi
-
-
-       if test -f "$ac_cv_path_tclsh" ; then
-           TCLSH_PROG=$ac_cv_path_tclsh
-           echo "$as_me:$LINENO: result: $TCLSH_PROG" >&5
-echo "${ECHO_T}$TCLSH_PROG" >&6
-       else
-           { { echo "$as_me:$LINENO: error: No tclsh found in PATH: $search_path" >&5
-echo "$as_me: error: No tclsh found in PATH: $search_path" >&2;}
-   { (exit 1); exit 1; }; }
-       fi
-    fi
-
-
-
 
 
     # Step 0: Enable 64 bit support?
@@ -7151,47 +6961,41 @@ fi
        windows)
            # This is a 2-stage check to make sure we have the 64-bit SDK
            # We have to know where the SDK is installed.
-           if test "$do64bit" = "yes" ; then
+           # This magic is based on MS Platform SDK for Win2003 SP1 - hobbs
+           # MACHINE is IX86 for LINK, but this is used by the manifest,
+           # which requires x86|amd64|ia64.
+           MACHINE="X86"
+           if test "$do64bit" != "no" ; then
                if test "x${MSSDK}x" = "xx" ; then
-                   MSSDK="C:/Progra~1/Microsoft SDK"
+                   MSSDK="C:/Progra~1/Microsoft Platform SDK"
                fi
-               # Ensure that this path has no spaces to work in autoconf
-
-    if test "${TEA_PLATFORM}" = "windows" ; then
-       # we need TCLSH_PROG defined to get Windows short pathnames
-
-
-       echo "$as_me:$LINENO: checking short pathname for MSSDK (${MSSDK})" >&5
-echo $ECHO_N "checking short pathname for MSSDK (${MSSDK})... $ECHO_C" >&6
-
-       shortpath=
-       case "${MSSDK}" in
-           *\ *)
-               # Only do this if we need to.
-               shortpath=`echo "puts [file attributes {${MSSDK}} -shortname] ; exit" | ${TCLSH_PROG} 2>/dev/null`
-               ;;
-       esac
-       if test "x${shortpath}" = "x" ; then
-           echo "$as_me:$LINENO: result: not changed" >&5
-echo "${ECHO_T}not changed" >&6
-       else
-           MSSDK=$shortpath
-           echo "$as_me:$LINENO: result: ${MSSDK}" >&5
-echo "${ECHO_T}${MSSDK}" >&6
-       fi
-    fi
-
-               if test ! -d "${MSSDK}/bin/win64" ; then
-                   { echo "$as_me:$LINENO: WARNING: could not find 64-bit SDK to enable 64bit mode" >&5
-echo "$as_me: WARNING: could not find 64-bit SDK to enable 64bit mode" >&2;}
+               MSSDK=`echo "$MSSDK" | sed -e  's!\\\!/!g'`
+               PATH64=""
+               case "$do64bit" in
+                   amd64|x64|yes)
+                       MACHINE="AMD64" ; # default to AMD64 64-bit build
+                       PATH64="${MSSDK}/Bin/Win64/x86/AMD64"
+                       ;;
+                   ia64)
+                       MACHINE="IA64"
+                       PATH64="${MSSDK}/Bin/Win64"
+                       ;;
+               esac
+               if test ! -d "${PATH64}" ; then
+                   { echo "$as_me:$LINENO: WARNING: Could not find 64-bit $MACHINE SDK to enable 64bit mode" >&5
+echo "$as_me: WARNING: Could not find 64-bit $MACHINE SDK to enable 64bit mode" >&2;}
+                   { echo "$as_me:$LINENO: WARNING: Ensure latest Platform SDK is installed" >&5
+echo "$as_me: WARNING: Ensure latest Platform SDK is installed" >&2;}
                    do64bit="no"
                else
+                   echo "$as_me:$LINENO: result:    Using 64-bit $MACHINE mode" >&5
+echo "${ECHO_T}   Using 64-bit $MACHINE mode" >&6
                    do64bit_ok="yes"
                fi
            fi
 
            if test "$doWince" != "no" ; then
-               if test "$do64bit" = "yes" ; then
+               if test "$do64bit" != "no" ; then
                    { { echo "$as_me:$LINENO: error: Windows/CE and 64-bit builds incompatible" >&5
 echo "$as_me: error: Windows/CE and 64-bit builds incompatible" >&2;}
    { (exit 1); exit 1; }; }
@@ -7259,33 +7063,9 @@ echo "$as_me: error: Cannot find celib support library directory" >&2;}
        else
            no_celib=
            CELIB_DIR=${ac_cv_c_celibconfig}
+           CELIB_DIR=`echo "$CELIB_DIR" | sed -e 's!\\\!/!g'`
            echo "$as_me:$LINENO: result: found $CELIB_DIR" >&5
 echo "${ECHO_T}found $CELIB_DIR" >&6
-
-    if test "${TEA_PLATFORM}" = "windows" ; then
-       # we need TCLSH_PROG defined to get Windows short pathnames
-
-
-       echo "$as_me:$LINENO: checking short pathname for CELIB_DIR (${ac_cv_c_celibconfig})" >&5
-echo $ECHO_N "checking short pathname for CELIB_DIR (${ac_cv_c_celibconfig})... $ECHO_C" >&6
-
-       shortpath=
-       case "${ac_cv_c_celibconfig}" in
-           *\ *)
-               # Only do this if we need to.
-               shortpath=`echo "puts [file attributes {${ac_cv_c_celibconfig}} -shortname] ; exit" | ${TCLSH_PROG} 2>/dev/null`
-               ;;
-       esac
-       if test "x${shortpath}" = "x" ; then
-           echo "$as_me:$LINENO: result: not changed" >&5
-echo "${ECHO_T}not changed" >&6
-       else
-           CELIB_DIR=$shortpath
-           echo "$as_me:$LINENO: result: ${CELIB_DIR}" >&5
-echo "${ECHO_T}${CELIB_DIR}" >&6
-       fi
-    fi
-
        fi
     fi
 
@@ -7323,57 +7103,8 @@ echo "${ECHO_T}${CELIB_DIR}" >&6
                        SDKROOT="C:/Windows CE Tools"
                    fi
                fi
-               # Ensure that this path has no spaces to work in autoconf
-
-    if test "${TEA_PLATFORM}" = "windows" ; then
-       # we need TCLSH_PROG defined to get Windows short pathnames
-
-
-       echo "$as_me:$LINENO: checking short pathname for WCEROOT (${WCEROOT})" >&5
-echo $ECHO_N "checking short pathname for WCEROOT (${WCEROOT})... $ECHO_C" >&6
-
-       shortpath=
-       case "${WCEROOT}" in
-           *\ *)
-               # Only do this if we need to.
-               shortpath=`echo "puts [file attributes {${WCEROOT}} -shortname] ; exit" | ${TCLSH_PROG} 2>/dev/null`
-               ;;
-       esac
-       if test "x${shortpath}" = "x" ; then
-           echo "$as_me:$LINENO: result: not changed" >&5
-echo "${ECHO_T}not changed" >&6
-       else
-           WCEROOT=$shortpath
-           echo "$as_me:$LINENO: result: ${WCEROOT}" >&5
-echo "${ECHO_T}${WCEROOT}" >&6
-       fi
-    fi
-
-
-    if test "${TEA_PLATFORM}" = "windows" ; then
-       # we need TCLSH_PROG defined to get Windows short pathnames
-
-
-       echo "$as_me:$LINENO: checking short pathname for SDKROOT (${SDKROOT})" >&5
-echo $ECHO_N "checking short pathname for SDKROOT (${SDKROOT})... $ECHO_C" >&6
-
-       shortpath=
-       case "${SDKROOT}" in
-           *\ *)
-               # Only do this if we need to.
-               shortpath=`echo "puts [file attributes {${SDKROOT}} -shortname] ; exit" | ${TCLSH_PROG} 2>/dev/null`
-               ;;
-       esac
-       if test "x${shortpath}" = "x" ; then
-           echo "$as_me:$LINENO: result: not changed" >&5
-echo "${ECHO_T}not changed" >&6
-       else
-           SDKROOT=$shortpath
-           echo "$as_me:$LINENO: result: ${SDKROOT}" >&5
-echo "${ECHO_T}${SDKROOT}" >&6
-       fi
-    fi
-
+               WCEROOT=`echo "$WCEROOT" | sed -e 's!\\\!/!g'`
+               SDKROOT=`echo "$SDKROOT" | sed -e 's!\\\!/!g'`
                if test ! -d "${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}" \
                    -o ! -d "${WCEROOT}/EVC/${OSVERSION}/bin"; then
                    { { echo "$as_me:$LINENO: error: could not find PocketPC SDK or target compiler to enable WinCE mode $CEVERSION,$TARGETCPU,$ARCH,$PLATFORM" >&5
@@ -7398,27 +7129,37 @@ echo "$as_me: error: could not find PocketPC SDK or target compiler to enable Wi
                    runtime=-MD
                fi
 
-                if test "$do64bit" = "yes" ; then
+                if test "$do64bit" != "no" ; then
                    # All this magic is necessary for the Win64 SDK RC1 - hobbs
-                   CC="${MSSDK}/Bin/Win64/cl.exe"
-                   CFLAGS="${CFLAGS} -I${MSSDK}/Include/prerelease \
-                       -I${MSSDK}/Include/Win64/crt \
-                       -I${MSSDK}/Include"
-                   RC="${MSSDK}/bin/rc.exe"
-                   lflags="-MACHINE:IA64 -LIBPATH:${MSSDK}/Lib/IA64 \
-                       -LIBPATH:${MSSDK}/Lib/Prerelease/IA64 -nologo"
-                   LINKBIN="${MSSDK}/bin/win64/link.exe"
+                   CC="\"${PATH64}/cl.exe\""
+                   CFLAGS="${CFLAGS} -I\"${MSSDK}/Include\" -I\"${MSSDK}/Include/crt\" -I\"${MSSDK}/Include/crt/sys\""
+                   RC="\"${MSSDK}/bin/rc.exe\""
+                   lflags="-nologo -MACHINE:${MACHINE} -LIBPATH:\"${MSSDK}/Lib/${MACHINE}\""
+                   LINKBIN="\"${PATH64}/link.exe\""
                    CFLAGS_DEBUG="-nologo -Zi -Od -W3 ${runtime}d"
                    CFLAGS_OPTIMIZE="-nologo -O2 -W2 ${runtime}"
+                   # Avoid 'unresolved external symbol __security_cookie'
+                   # errors, c.f. http://support.microsoft.com/?id=894573
+
+    vars="bufferoverflowU.lib"
+    for i in $vars; do
+       if test "${TEA_PLATFORM}" = "windows" -a "$GCC" = "yes" ; then
+           # Convert foo.lib to -lfoo for GCC.  No-op if not *.lib
+           i=`echo "$i" | sed -e 's/^\([^-].*\)\.lib$/-l\1/i'`
+       fi
+       PKG_LIBS="$PKG_LIBS $i"
+    done
+
+
                elif test "$doWince" != "no" ; then
                    CEBINROOT="${WCEROOT}/EVC/${OSVERSION}/bin"
                    if test "${TARGETCPU}" = "X86"; then
-                       CC="${CEBINROOT}/cl.exe"
+                       CC="\"${CEBINROOT}/cl.exe\""
                    else
-                       CC="${CEBINROOT}/cl${ARCH}.exe"
+                       CC="\"${CEBINROOT}/cl${ARCH}.exe\""
                    fi
                    CFLAGS="$CFLAGS -I\"${CELIB_DIR}/inc\" -I\"${CEINCLUDE}\""
-                   RC="${WCEROOT}/Common/EVC/bin/rc.exe"
+                   RC="\"${WCEROOT}/Common/EVC/bin/rc.exe\""
                    arch=`echo ${ARCH} | awk '{print tolower($0)}'`
                    defs="${ARCH} _${ARCH}_ ${arch} PALM_SIZE _MT _WINDOWS"
                    if test "${SHARED_BUILD}" = "1" ; then
@@ -7426,16 +7167,19 @@ echo "$as_me: error: could not find PocketPC SDK or target compiler to enable Wi
                        defs="${defs} _DLL"
                    fi
                    for i in $defs ; do
-                       cat >>confdefs.h <<_ACEOF
+
+cat >>confdefs.h <<_ACEOF
 #define $i 1
 _ACEOF
 
                    done
-                   cat >>confdefs.h <<_ACEOF
+
+cat >>confdefs.h <<_ACEOF
 #define _WIN32_WCE $CEVERSION
 _ACEOF
 
-                   cat >>confdefs.h <<_ACEOF
+
+cat >>confdefs.h <<_ACEOF
 #define UNDER_CE $CEVERSION
 _ACEOF
 
@@ -7443,7 +7187,7 @@ _ACEOF
                    CFLAGS_OPTIMIZE="-nologo -Ox"
                    lversion=`echo ${CEVERSION} | sed -e 's/\(.\)\(..\)/\1\.\2/'`
                    lflags="-MACHINE:${ARCH} -LIBPATH:\"${CELIBPATH}\" -subsystem:windowsce,${lversion} -nologo"
-                   LINKBIN="${CEBINROOT}/link.exe"
+                   LINKBIN="\"${CEBINROOT}/link.exe\""
 
                else
                    RC="rc"
@@ -7494,9 +7238,14 @@ _ACEOF
        AIX-*)
            if test "${TCL_THREADS}" = "1" -a "$GCC" != "yes" ; then
                # AIX requires the _r compiler when gcc isn't being used
-               if test "${CC}" != "cc_r" ; then
-                   CC=${CC}_r
-               fi
+               case "${CC}" in
+                   *_r)
+                       # ok ...
+                       ;;
+                   *)
+                       CC=${CC}_r
+                       ;;
+               esac
                echo "$as_me:$LINENO: result: Using $CC for compiling with threads" >&5
 echo "${ECHO_T}Using $CC for compiling with threads" >&6
            fi
@@ -7644,7 +7393,8 @@ fi
 
            if test $libbsd = yes; then
                MATH_LIBS="$MATH_LIBS -lbsd"
-               cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define USE_DELTA_FOR_TZ 1
 _ACEOF
 
@@ -7688,7 +7438,8 @@ _ACEOF
            ;;
        HP-UX-*.11.*)
            # Use updated header definitions where possible
-           cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define _XOPEN_SOURCE_EXTENDED 1
 _ACEOF
 
@@ -7771,12 +7522,13 @@ fi
                DL_OBJS="tclLoadShl.o"
                DL_LIBS="-ldld"
                LDFLAGS="$LDFLAGS -Wl,-E"
-               LD_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
+               LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.'
                LD_LIBRARY_PATH_VAR="SHLIB_PATH"
            fi
            if test "$GCC" = "yes" ; then
                SHLIB_LD="gcc -shared"
                SHLIB_LD_LIBS='${LIBS}'
+               LD_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
            fi
 
            # Users may want PA-RISC 1.1/2.0 portable code - needs HP cc
@@ -8581,16 +8333,146 @@ rm -f conftest*
            esac
            ;;
        Darwin-*)
+           CFLAGS_OPTIMIZE="-Os"
            SHLIB_CFLAGS="-fno-common"
-           SHLIB_LD="cc -dynamiclib \${LDFLAGS}"
+           if test $do64bit = yes; then
+               do64bit_ok=yes
+               CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5"
+           fi
+           SHLIB_LD='${CC} -dynamiclib ${CFLAGS} ${LDFLAGS}'
+           echo "$as_me:$LINENO: checking if ld accepts -single_module flag" >&5
+echo $ECHO_N "checking if ld accepts -single_module flag... $ECHO_C" >&6
+if test "${tcl_cv_ld_single_module+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+               hold_ldflags=$LDFLAGS
+               LDFLAGS="$LDFLAGS -dynamiclib -Wl,-single_module"
+               cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+int i;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  tcl_cv_ld_single_module=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+tcl_cv_ld_single_module=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+               LDFLAGS=$hold_ldflags
+fi
+echo "$as_me:$LINENO: result: $tcl_cv_ld_single_module" >&5
+echo "${ECHO_T}$tcl_cv_ld_single_module" >&6
+           if test $tcl_cv_ld_single_module = yes; then
+               SHLIB_LD="${SHLIB_LD} -Wl,-single_module"
+           fi
            SHLIB_LD_LIBS='${LIBS}'
            SHLIB_SUFFIX=".dylib"
            DL_OBJS="tclLoadDyld.o"
            DL_LIBS=""
-           LDFLAGS="$LDFLAGS -prebind -Wl,-search_paths_first"
+           # Don't use -prebind when building for Mac OS X 10.4 or later only:
+           test -z "${MACOSX_DEPLOYMENT_TARGET}" || \
+               test "`echo "${MACOSX_DEPLOYMENT_TARGET}" | awk -F. '{print $2}'`" -lt 4 && \
+               LDFLAGS="$LDFLAGS -prebind"
+           LDFLAGS="$LDFLAGS -headerpad_max_install_names"
+           echo "$as_me:$LINENO: checking if ld accepts -search_paths_first flag" >&5
+echo $ECHO_N "checking if ld accepts -search_paths_first flag... $ECHO_C" >&6
+if test "${tcl_cv_ld_search_paths_first+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+               hold_ldflags=$LDFLAGS
+               LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
+               cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+int i;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+        { ac_try='test -z "$ac_c_werror_flag"
+                        || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+        { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  tcl_cv_ld_search_paths_first=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+tcl_cv_ld_search_paths_first=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+               LDFLAGS=$hold_ldflags
+fi
+echo "$as_me:$LINENO: result: $tcl_cv_ld_search_paths_first" >&5
+echo "${ECHO_T}$tcl_cv_ld_search_paths_first" >&6
+           if test $tcl_cv_ld_search_paths_first = yes; then
+               LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
+           fi
            LD_SEARCH_FLAGS=""
            LD_LIBRARY_PATH_VAR="DYLD_LIBRARY_PATH"
-           CFLAGS_OPTIMIZE="-Os"
            ;;
        NEXTSTEP-*)
            SHLIB_CFLAGS=""
@@ -8602,11 +8484,12 @@ rm -f conftest*
            LD_SEARCH_FLAGS=""
            ;;
        OS/390-*)
-           CFLAGS_OPTIMIZE=""      # Optimizer is buggy
-           cat >>confdefs.h <<\_ACEOF
+           CFLAGS_OPTIMIZE=""          # Optimizer is buggy
+
+cat >>confdefs.h <<\_ACEOF
 #define _OE_SOCKETS 1
 _ACEOF
-  # needed in sys/socket.h
+
            ;;
        OSF1-1.0|OSF1-1.1|OSF1-1.2)
            # OSF/1 1.[012] from OSF, and derivatives, including Paragon OSF/1
@@ -8732,16 +8615,19 @@ _ACEOF
            UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
            TCL_LIB_VERSIONS_OK=nodots
            ;;
-       SunOS-5.[0-6]*)
+       SunOS-5.[0-6])
+           # Careful to not let 5.10+ fall into this case
 
            # Note: If _REENTRANT isn't defined, then Solaris
            # won't define thread-safe library routines.
 
-           cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define _REENTRANT 1
 _ACEOF
 
-           cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define _POSIX_PTHREAD_SEMANTICS 1
 _ACEOF
 
@@ -8768,11 +8654,13 @@ _ACEOF
            # Note: If _REENTRANT isn't defined, then Solaris
            # won't define thread-safe library routines.
 
-           cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define _REENTRANT 1
 _ACEOF
 
-           cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define _POSIX_PTHREAD_SEMANTICS 1
 _ACEOF
 
@@ -8802,10 +8690,21 @@ echo "$as_me: WARNING: 64bit mode not supported with GCC < 3.2 on $system" >&2;}
                                CFLAGS="$CFLAGS -xarch=v9"
                                LDFLAGS="$LDFLAGS -xarch=v9"
                            fi
+                           # Solaris 64 uses this as well
+                           #LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH_64"
                        fi
+               elif test "$arch" = "amd64 i386" ; then
+                   if test "$GCC" = "yes" ; then
+                       { echo "$as_me:$LINENO: WARNING: 64bit mode not supported with GCC on $system" >&5
+echo "$as_me: WARNING: 64bit mode not supported with GCC on $system" >&2;}
+                   else
+                       do64bit_ok=yes
+                       CFLAGS="$CFLAGS -xarch=amd64"
+                       LDFLAGS="$LDFLAGS -xarch=amd64"
+                   fi
                else
-                   { echo "$as_me:$LINENO: WARNING: \"64bit mode only supported sparcv9 system\"" >&5
-echo "$as_me: WARNING: \"64bit mode only supported sparcv9 system\"" >&2;}
+                   { echo "$as_me:$LINENO: WARNING: 64bit mode not supported for $arch" >&5
+echo "$as_me: WARNING: 64bit mode not supported for $arch" >&2;}
                fi
            fi
 
@@ -8913,9 +8812,9 @@ echo "${ECHO_T}$found" >&6
            ;;
     esac
 
-    if test "$do64bit" = "yes" -a "$do64bit_ok" = "no" ; then
-    { echo "$as_me:$LINENO: WARNING: \"64bit support being disabled -- don\'t know magic for this platform\"" >&5
-echo "$as_me: WARNING: \"64bit support being disabled -- don\'t know magic for this platform\"" >&2;}
+    if test "$do64bit" != "no" -a "$do64bit_ok" = "no" ; then
+       { echo "$as_me:$LINENO: WARNING: 64bit support being disabled -- don't know magic for this platform" >&5
+echo "$as_me: WARNING: 64bit support being disabled -- don't know magic for this platform" >&2;}
     fi
 
     # Step 4: If pseudo-static linking is in use (see K. B. Kenny, "Dynamic
@@ -8999,7 +8898,8 @@ rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
        echo "$as_me:$LINENO: result: $tcl_ok" >&5
 echo "${ECHO_T}$tcl_ok" >&6
        if test $tcl_ok = usable; then
-           cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define USE_SYS_EXEC_H 1
 _ACEOF
 
@@ -9065,7 +8965,8 @@ rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
            echo "$as_me:$LINENO: result: $tcl_ok" >&5
 echo "${ECHO_T}$tcl_ok" >&6
            if test $tcl_ok = usable; then
-               cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define USE_A_OUT_H 1
 _ACEOF
 
@@ -9131,7 +9032,8 @@ rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
                echo "$as_me:$LINENO: result: $tcl_ok" >&5
 echo "${ECHO_T}$tcl_ok" >&6
                if test $tcl_ok = usable; then
-                   cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define USE_SYS_EXEC_AOUT_H 1
 _ACEOF
 
@@ -9325,7 +9227,8 @@ rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 
     if test "x${tcl_cv_flag__isoc99_source}" = "xyes" ; then
-       cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define _ISOC99_SOURCE 1
 _ACEOF
 
@@ -9429,7 +9332,8 @@ rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 
     if test "x${tcl_cv_flag__largefile64_source}" = "xyes" ; then
-       cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define _LARGEFILE64_SOURCE 1
 _ACEOF
 
@@ -9550,19 +9454,22 @@ rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 
     if test "${tcl_cv_type_64bit}" = none ; then
-       cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define TCL_WIDE_INT_IS_LONG 1
 _ACEOF
 
        echo "$as_me:$LINENO: result: using long" >&5
 echo "${ECHO_T}using long" >&6
-    elif test "${tcl_cv_type_64bit}" = "__int64" ; then
+    elif test "${tcl_cv_type_64bit}" = "__int64" \
+               -a "${TEA_PLATFORM}" = "windows" ; then
        # We actually want to use the default tcl.h checks in this
        # case to handle both TCL_WIDE_INT_TYPE and TCL_LL_MODIFIER*
        echo "$as_me:$LINENO: result: using Tcl header defaults" >&5
 echo "${ECHO_T}using Tcl header defaults" >&6
     else
-       cat >>confdefs.h <<_ACEOF
+
+cat >>confdefs.h <<_ACEOF
 #define TCL_WIDE_INT_TYPE ${tcl_cv_type_64bit}
 _ACEOF
 
@@ -9625,7 +9532,8 @@ rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 
        if test "x${tcl_cv_struct_dirent64}" = "xyes" ; then
-           cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define HAVE_STRUCT_DIRENT64 1
 _ACEOF
 
@@ -9688,7 +9596,8 @@ rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 
        if test "x${tcl_cv_struct_stat64}" = "xyes" ; then
-           cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define HAVE_STRUCT_STAT64 1
 _ACEOF
 
@@ -9751,7 +9660,8 @@ rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 
        if test "x${tcl_cv_type_off64_t}" = "xyes" ; then
-           cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define HAVE_TYPE_OFF64_T 1
 _ACEOF
 
@@ -9797,7 +9707,8 @@ echo "${ECHO_T}yes (standard debugging)" >&6
 
 
     if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then
-       cat >>confdefs.h <<\_ACEOF
+
+cat >>confdefs.h <<\_ACEOF
 #define TCL_MEM_DEBUG 1
 _ACEOF
 
@@ -9890,47 +9801,34 @@ _ACEOF
 
 
 
-    # Allow the user to provide this setting in the env
-    if test "x${TCLSH_PROG}" = "x" ; then
-       echo "$as_me:$LINENO: checking for tclsh" >&5
+    echo "$as_me:$LINENO: checking for tclsh" >&5
 echo $ECHO_N "checking for tclsh... $ECHO_C" >&6
-
-       if test "${ac_cv_path_tclsh+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-
-       search_path=`echo ${PATH} | sed -e 's/:/ /g'`
-       if test "${TEA_PLATFORM}" != "windows" -o \
-               \( "$do64bit_ok" = "no" -a "$doWince" = "no" \) ; then
-           # Do not allow target tclsh in known cross-compile builds,
-           # as we need one we can run on this system
-           search_path="${TCL_BIN_DIR} ${TCL_BIN_DIR}/../bin ${exec_prefix}/bin ${prefix}/bin ${search_path}"
-       fi
-       for dir in $search_path ; do
-           for j in `ls -r $dir/tclsh[8-9]*${EXEEXT} 2> /dev/null` \
-                   `ls -r $dir/tclsh*${EXEEXT} 2> /dev/null` ; do
-               if test x"$ac_cv_path_tclsh" = x ; then
-                   if test -f "$j" ; then
-                       ac_cv_path_tclsh=$j
-                       break
-                   fi
-               fi
-           done
-       done
-
-fi
-
-
-       if test -f "$ac_cv_path_tclsh" ; then
-           TCLSH_PROG=$ac_cv_path_tclsh
-           echo "$as_me:$LINENO: result: $TCLSH_PROG" >&5
-echo "${ECHO_T}$TCLSH_PROG" >&6
-       else
-           { { echo "$as_me:$LINENO: error: No tclsh found in PATH: $search_path" >&5
-echo "$as_me: error: No tclsh found in PATH: $search_path" >&2;}
-   { (exit 1); exit 1; }; }
-       fi
+    if test -f "${TCL_BIN_DIR}/Makefile" ; then
+        # tclConfig.sh is in Tcl build directory
+        if test "${TEA_PLATFORM}" = "windows"; then
+            TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}"
+        else
+            TCLSH_PROG="${TCL_BIN_DIR}/tclsh"
+        fi
+    else
+        # tclConfig.sh is in install location
+        if test "${TEA_PLATFORM}" = "windows"; then
+            TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}"
+        else
+            TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}${TCL_DBGX}"
+        fi
+        list="`ls -d ${TCL_PREFIX}/bin     2>/dev/null` \
+              `ls -d ${TCL_BIN_DIR}/../bin 2>/dev/null`"
+        for i in $list ; do
+            if test -f "$i/${TCLSH_PROG}" ; then
+                REAL_TCL_BIN_DIR="`cd "$i"; pwd`"
+                break
+            fi
+        done
+        TCLSH_PROG="${REAL_TCL_BIN_DIR}/${TCLSH_PROG}"
     fi
+    echo "$as_me:$LINENO: result: ${TCLSH_PROG}" >&5
+echo "${ECHO_T}${TCLSH_PROG}" >&6
 
 
 
@@ -10625,7 +10523,6 @@ s,@CLEANFILES@,$CLEANFILES,;t t
 s,@TCL_THREADS@,$TCL_THREADS,;t t
 s,@SHARED_BUILD@,$SHARED_BUILD,;t t
 s,@AR@,$AR,;t t
-s,@TCLSH_PROG@,$TCLSH_PROG,;t t
 s,@CELIB_DIR@,$CELIB_DIR,;t t
 s,@LIBOBJS@,$LIBOBJS,;t t
 s,@DL_LIBS@,$DL_LIBS,;t t
@@ -10647,6 +10544,7 @@ s,@MAKE_SHARED_LIB@,$MAKE_SHARED_LIB,;t t
 s,@MAKE_STATIC_LIB@,$MAKE_STATIC_LIB,;t t
 s,@MAKE_STUB_LIB@,$MAKE_STUB_LIB,;t t
 s,@RANLIB_STUB@,$RANLIB_STUB,;t t
+s,@TCLSH_PROG@,$TCLSH_PROG,;t t
 s,@LTLIBOBJS@,$LTLIBOBJS,;t t
 CEOF
 
index ea6923624b03fb37d6f82fafdc21ee66179a3c91..0fc805302a0f06f968aadefac4fba2616e05ea23 100644 (file)
@@ -21,7 +21,7 @@ AC_INIT([vfs], [1.3])
 # as well as PKG_LIB_FILE and PKG_STUB_LIB_FILE.
 #--------------------------------------------------------------------
 
-TEA_INIT([3.2])
+TEA_INIT([3.4])
 
 AC_CONFIG_AUX_DIR(tclconfig)
 
index f50373c54fb3377fc6fd4b307e3d882a937ca3ee..22f7b756776dcf29162edc362d13aa5848ad7217 100644 (file)
@@ -4,7 +4,7 @@
 #      a Tcl extension.
 #
 # Copyright (c) 1999-2000 Ajuba Solutions.
-# Copyright (c) 2002-2003 ActiveState Corporation.
+# Copyright (c) 2002-2005 ActiveState Corporation.
 #
 # See the file "license.terms" for information on usage and redistribution
 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 
 AC_PREREQ(2.50)
 
+# Possible values for key variables defined:
+#
+# TEA_WINDOWINGSYSTEM - win32 aqua x11 (mirrors 'tk windowingsystem')
+# TEA_PLATFORM        - windows unix
+#
+
 #------------------------------------------------------------------------
 # TEA_PATH_TCLCONFIG --
 #
@@ -50,6 +56,13 @@ AC_DEFUN(TEA_PATH_TCLCONFIG, [
 
            # First check to see if --with-tcl was specified.
            if test x"${with_tclconfig}" != x ; then
+               case ${with_tclconfig} in
+                   */tclConfig.sh )
+                       if test -f ${with_tclconfig}; then
+                           AC_MSG_WARN([--with-tcl argument should refer to directory containing tclConfig.sh, not to tclConfig.sh itself])
+                           with_tclconfig=`echo ${with_tclconfig} | sed 's!/tclConfig\.sh$!!'`
+                       fi ;;
+               esac
                if test -f "${with_tclconfig}/tclConfig.sh" ; then
                    ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
                else
@@ -61,10 +74,16 @@ AC_DEFUN(TEA_PATH_TCLCONFIG, [
            if test x"${ac_cv_c_tclconfig}" = x ; then
                for i in \
                        ../tcl \
+                       `ls -dr ../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
+                       `ls -dr ../tcl[[8-9]].[[0-9]] 2>/dev/null` \
                        `ls -dr ../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
                        ../../tcl \
+                        `ls -dr ../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
+                        `ls -dr ../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
                        `ls -dr ../../tcl[[8-9]].[[0-9]]* 2>/dev/null` \
                        ../../../tcl \
+                        `ls -dr ../../../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
+                        `ls -dr ../../../tcl[[8-9]].[[0-9]] 2>/dev/null` \
                        `ls -dr ../../../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
                    if test -f "$i/unix/tclConfig.sh" ; then
                        ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
@@ -73,6 +92,20 @@ AC_DEFUN(TEA_PATH_TCLCONFIG, [
                done
            fi
 
+           # on Darwin, check in Framework installation locations
+           if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tclconfig}" = x ; then
+               for i in `ls -d ~/Library/Frameworks 2>/dev/null` \
+                       `ls -d /Library/Frameworks 2>/dev/null` \
+                       `ls -d /Network/Library/Frameworks 2>/dev/null` \
+                       `ls -d /System/Library/Frameworks 2>/dev/null` \
+                       ; do
+                   if test -f "$i/Tcl.framework/tclConfig.sh" ; then
+                       ac_cv_c_tclconfig=`(cd $i/Tcl.framework; pwd)`
+                       break
+                   fi
+               done
+           fi
+
            # check in a few common install locations
            if test x"${ac_cv_c_tclconfig}" = x ; then
                for i in `ls -d ${exec_prefix}/lib 2>/dev/null` \
@@ -92,6 +125,8 @@ AC_DEFUN(TEA_PATH_TCLCONFIG, [
            if test x"${ac_cv_c_tclconfig}" = x ; then
                for i in \
                        ${srcdir}/../tcl \
+                       `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
+                       `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]] 2>/dev/null` \
                        `ls -dr ${srcdir}/../tcl[[8-9]].[[0-9]]* 2>/dev/null` ; do
                    if test -f "$i/unix/tclConfig.sh" ; then
                    ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
@@ -147,6 +182,13 @@ AC_DEFUN(TEA_PATH_TKCONFIG, [
 
            # First check to see if --with-tkconfig was specified.
            if test x"${with_tkconfig}" != x ; then
+               case ${with_tkconfig} in
+                   */tkConfig.sh )
+                       if test -f ${with_tkconfig}; then
+                           AC_MSG_WARN([--with-tk argument should refer to directory containing tkConfig.sh, not to tkConfig.sh itself])
+                           with_tkconfig=`echo ${with_tkconfig} | sed 's!/tkConfig\.sh$!!'`
+                       fi ;;
+               esac
                if test -f "${with_tkconfig}/tkConfig.sh" ; then
                    ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
                else
@@ -158,10 +200,16 @@ AC_DEFUN(TEA_PATH_TKCONFIG, [
            if test x"${ac_cv_c_tkconfig}" = x ; then
                for i in \
                        ../tk \
+                       `ls -dr ../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
+                       `ls -dr ../tk[[8-9]].[[0-9]] 2>/dev/null` \
                        `ls -dr ../tk[[8-9]].[[0-9]]* 2>/dev/null` \
                        ../../tk \
+                       `ls -dr ../../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
+                       `ls -dr ../../tk[[8-9]].[[0-9]] 2>/dev/null` \
                        `ls -dr ../../tk[[8-9]].[[0-9]]* 2>/dev/null` \
                        ../../../tk \
+                       `ls -dr ../../../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
+                       `ls -dr ../../../tk[[8-9]].[[0-9]] 2>/dev/null` \
                        `ls -dr ../../../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
                    if test -f "$i/unix/tkConfig.sh" ; then
                        ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
@@ -169,6 +217,21 @@ AC_DEFUN(TEA_PATH_TKCONFIG, [
                    fi
                done
            fi
+
+           # on Darwin, check in Framework installation locations
+           if test "`uname -s`" = "Darwin" -a x"${ac_cv_c_tkconfig}" = x ; then
+               for i in `ls -d ~/Library/Frameworks 2>/dev/null` \
+                       `ls -d /Library/Frameworks 2>/dev/null` \
+                       `ls -d /Network/Library/Frameworks 2>/dev/null` \
+                       `ls -d /System/Library/Frameworks 2>/dev/null` \
+                       ; do
+                   if test -f "$i/Tk.framework/tkConfig.sh" ; then
+                       ac_cv_c_tkconfig=`(cd $i/Tk.framework; pwd)`
+                       break
+                   fi
+               done
+           fi
+
            # check in a few common install locations
            if test x"${ac_cv_c_tkconfig}" = x ; then
                for i in `ls -d ${exec_prefix}/lib 2>/dev/null` \
@@ -187,6 +250,8 @@ AC_DEFUN(TEA_PATH_TKCONFIG, [
            if test x"${ac_cv_c_tkconfig}" = x ; then
                for i in \
                        ${srcdir}/../tk \
+                       `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]].[[0-9]]* 2>/dev/null` \
+                       `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]] 2>/dev/null` \
                        `ls -dr ${srcdir}/../tk[[8-9]].[[0-9]]* 2>/dev/null` ; do
                    if test -f "$i/unix/tkConfig.sh" ; then
                        ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
@@ -195,6 +260,7 @@ AC_DEFUN(TEA_PATH_TKCONFIG, [
                done
            fi
        ])
+
        if test x"${ac_cv_c_tkconfig}" = x ; then
            TK_BIN_DIR="# no Tk configs found"
            AC_MSG_WARN("Cannot find Tk configuration definitions")
@@ -205,7 +271,6 @@ AC_DEFUN(TEA_PATH_TKCONFIG, [
            AC_MSG_RESULT([found $TK_BIN_DIR/tkConfig.sh])
        fi
     fi
-
 ])
 
 #------------------------------------------------------------------------
@@ -326,6 +391,21 @@ AC_DEFUN(TEA_LOAD_TKCONFIG, [
         TK_STUB_LIB_PATH=${TK_BUILD_STUB_LIB_PATH}
     fi
 
+    # Ensure windowingsystem is defined
+    if test "${TEA_PLATFORM}" = "unix" ; then
+       case ${TK_DEFS} in
+           *MAC_OSX_TK*)
+               AC_DEFINE(MAC_OSX_TK, 1, [Are we building against Mac OS X TkAqua?])
+               TEA_WINDOWINGSYSTEM="aqua"
+               ;;
+           *)
+               TEA_WINDOWINGSYSTEM="x11"
+               ;;
+       esac
+    elif test "${TEA_PLATFORM}" = "windows" ; then
+       TEA_WINDOWINGSYSTEM="win32"
+    fi
+
     #
     # eval is required to do the TK_DBGX substitution
     #
@@ -394,7 +474,7 @@ AC_DEFUN(TEA_ENABLE_SHARED, [
     else
        AC_MSG_RESULT([static])
        SHARED_BUILD=0
-       AC_DEFINE(STATIC_BUILD)
+       AC_DEFINE(STATIC_BUILD, 1, [Is this a static build?])
     fi
     AC_SUBST(SHARED_BUILD)
 ])
@@ -402,12 +482,18 @@ AC_DEFUN(TEA_ENABLE_SHARED, [
 #------------------------------------------------------------------------
 # TEA_ENABLE_THREADS --
 #
-#      Specify if thread support should be enabled.  If "yes" is
-#      specified as an arg (optional), threads are enabled by default.
+#      Specify if thread support should be enabled.  If "yes" is specified
+#      as an arg (optional), threads are enabled by default, "no" means
+#      threads are disabled.  "yes" is the default.
+#
 #      TCL_THREADS is checked so that if you are compiling an extension
 #      against a threaded core, your extension must be compiled threaded
 #      as well.
 #
+#      Note that it is legal to have a thread enabled extension run in a
+#      threaded or non-threaded Tcl core, but a non-threaded extension may
+#      only run in a non-threaded Tcl core.
+#
 # Arguments:
 #      none
 #      
@@ -427,16 +513,24 @@ AC_DEFUN(TEA_ENABLE_SHARED, [
 
 AC_DEFUN(TEA_ENABLE_THREADS, [
     AC_ARG_ENABLE(threads, [  --enable-threads        build with threads],
-       [tcl_ok=$enableval], [tcl_ok=$1])
+       [tcl_ok=$enableval], [tcl_ok=yes])
+
+    if test "${enable_threads+set}" = set; then
+       enableval="$enable_threads"
+       tcl_ok=$enableval
+    else
+       tcl_ok=yes
+    fi
 
     if test "$tcl_ok" = "yes" -o "${TCL_THREADS}" = 1; then
        TCL_THREADS=1
 
        if test "${TEA_PLATFORM}" != "windows" ; then
            # We are always OK on Windows, so check what this platform wants.
-           AC_DEFINE(USE_THREAD_ALLOC)
-           AC_DEFINE(_REENTRANT)
-           AC_DEFINE(_THREAD_SAFE)
+            AC_DEFINE(USE_THREAD_ALLOC, 1,
+                [Do we want to use the threaded memory allocator?])
+           AC_DEFINE(_REENTRANT, 1, [Do we want the reentrant OS API?])
+           AC_DEFINE(_THREAD_SAFE, 1, [Do we want the thread-safe OS API?])
            AC_CHECK_LIB(pthread,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
            if test "$tcl_ok" = "no"; then
                # Check a little harder for __pthread_mutex_init in the
@@ -475,14 +569,14 @@ AC_DEFUN(TEA_ENABLE_THREADS, [
                fi
            fi
 
-           # Does the pthread-implementation provide
-           # 'pthread_attr_setstacksize' ?
-
-           ac_saved_libs=$LIBS
-           LIBS="$LIBS $THREADS_LIBS"
-           AC_CHECK_FUNCS(pthread_attr_setstacksize)
-           LIBS=$ac_saved_libs
-           AC_CHECK_FUNCS(readdir_r)
+dnl        # Not needed in TEA
+dnl        # Does the pthread-implementation provide
+dnl        # 'pthread_attr_setstacksize' ?
+dnl
+dnl        ac_saved_libs=$LIBS
+dnl        LIBS="$LIBS $THREADS_LIBS"
+dnl        AC_CHECK_FUNCS(pthread_attr_setstacksize)
+dnl        LIBS=$ac_saved_libs
        fi
     else
        TCL_THREADS=0
@@ -490,11 +584,11 @@ AC_DEFUN(TEA_ENABLE_THREADS, [
     # Do checking message here to not mess up interleaved configure output
     AC_MSG_CHECKING([for building with threads])
     if test "${TCL_THREADS}" = "1"; then
-       AC_DEFINE(TCL_THREADS)
+       AC_DEFINE(TCL_THREADS, 1, [Are we building with threads enabled?])
        #LIBS="$LIBS $THREADS_LIBS"
-       AC_MSG_RESULT([yes])
+       AC_MSG_RESULT([yes (default)])
     else
-       AC_MSG_RESULT([no (default)])
+       AC_MSG_RESULT([no])
     fi
     # TCL_THREADS sanity checking.  See if our request for building with
     # threads is the same as the way Tcl was built.  If not, warn the user.
@@ -502,15 +596,16 @@ AC_DEFUN(TEA_ENABLE_THREADS, [
        *THREADS=1*)
            if test "${TCL_THREADS}" = "0"; then
                AC_MSG_WARN([
-    Building ${PACKAGE_NAME} without threads enabled, but building against Tcl
-    that IS thread-enabled.])
+    Building ${PACKAGE_NAME} without threads enabled, but building against Tcl
+    that IS thread-enabled.  It is recommended to use --enable-threads.])
            fi
            ;;
        *)
            if test "${TCL_THREADS}" = "1"; then
                AC_MSG_WARN([
-    --enable-threads requested, but attempting building against a Tcl
-    that is NOT thread-enabled.])
+    --enable-threads requested, but building against a Tcl that is NOT
+    thread-enabled.  This is an OK configuration that will also run in
+    a thread-enabled core.])
            fi
            ;;
     esac
@@ -575,7 +670,7 @@ AC_DEFUN(TEA_ENABLE_SYMBOLS, [
     AC_SUBST(LDFLAGS_DEFAULT)
 
     if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then
-       AC_DEFINE(TCL_MEM_DEBUG)
+       AC_DEFINE(TCL_MEM_DEBUG, 1, [Is memory debugging enabled?])
     fi
 
     if test "$tcl_ok" != "yes" -a "$tcl_ok" != "no"; then
@@ -614,22 +709,20 @@ AC_DEFUN(TEA_ENABLE_LANGINFO, [
 
     HAVE_LANGINFO=0
     if test "$langinfo_ok" = "yes"; then
-       if test "$langinfo_ok" = "yes"; then
-           AC_CHECK_HEADER(langinfo.h,[langinfo_ok=yes],[langinfo_ok=no])
-       fi
+       AC_CHECK_HEADER(langinfo.h,[langinfo_ok=yes],[langinfo_ok=no])
     fi
     AC_MSG_CHECKING([whether to use nl_langinfo])
     if test "$langinfo_ok" = "yes"; then
-       AC_TRY_COMPILE([#include <langinfo.h>],
-               [nl_langinfo(CODESET);],[langinfo_ok=yes],[langinfo_ok=no])
-       if test "$langinfo_ok" = "no"; then
-           langinfo_ok="no (could not compile with nl_langinfo)";
-       fi
-       if test "$langinfo_ok" = "yes"; then
-           AC_DEFINE(HAVE_LANGINFO)
+       AC_CACHE_VAL(tcl_cv_langinfo_h,
+           AC_TRY_COMPILE([#include <langinfo.h>], [nl_langinfo(CODESET);],
+                   [tcl_cv_langinfo_h=yes],[tcl_cv_langinfo_h=no]))
+       AC_MSG_RESULT($tcl_cv_langinfo_h)
+       if test $tcl_cv_langinfo_h = yes; then
+           AC_DEFINE(HAVE_LANGINFO, 1, [Do we have nl_langinfo()?])
        fi
+    else 
+       AC_MSG_RESULT([$langinfo_ok])
     fi
-    AC_MSG_RESULT([$langinfo_ok])
 ])
 
 #--------------------------------------------------------------------
@@ -813,22 +906,38 @@ dnl AC_CHECK_TOOL(AR, ar, :)
        windows)
            # This is a 2-stage check to make sure we have the 64-bit SDK
            # We have to know where the SDK is installed.
-           if test "$do64bit" = "yes" ; then
+           # This magic is based on MS Platform SDK for Win2003 SP1 - hobbs
+           # MACHINE is IX86 for LINK, but this is used by the manifest,
+           # which requires x86|amd64|ia64.
+           MACHINE="X86"
+           if test "$do64bit" != "no" ; then
                if test "x${MSSDK}x" = "xx" ; then
-                   MSSDK="C:/Progra~1/Microsoft SDK"
+                   MSSDK="C:/Progra~1/Microsoft Platform SDK"
                fi
-               # Ensure that this path has no spaces to work in autoconf
-               TEA_PATH_NOSPACE(MSSDK, ${MSSDK})
-               if test ! -d "${MSSDK}/bin/win64" ; then
-                   AC_MSG_WARN([could not find 64-bit SDK to enable 64bit mode])
+               MSSDK=`echo "$MSSDK" | sed -e  's!\\\!/!g'`
+               PATH64=""
+               case "$do64bit" in
+                   amd64|x64|yes)
+                       MACHINE="AMD64" ; # default to AMD64 64-bit build
+                       PATH64="${MSSDK}/Bin/Win64/x86/AMD64"
+                       ;;
+                   ia64)
+                       MACHINE="IA64"
+                       PATH64="${MSSDK}/Bin/Win64"
+                       ;;
+               esac
+               if test ! -d "${PATH64}" ; then
+                   AC_MSG_WARN([Could not find 64-bit $MACHINE SDK to enable 64bit mode])
+                   AC_MSG_WARN([Ensure latest Platform SDK is installed])
                    do64bit="no"
                else
+                   AC_MSG_RESULT([   Using 64-bit $MACHINE mode])
                    do64bit_ok="yes"
                fi
            fi
 
            if test "$doWince" != "no" ; then
-               if test "$do64bit" = "yes" ; then
+               if test "$do64bit" != "no" ; then
                    AC_MSG_ERROR([Windows/CE and 64-bit builds incompatible])
                fi
                if test "$GCC" = "yes" ; then
@@ -869,9 +978,8 @@ dnl AC_CHECK_TOOL(AR, ar, :)
                        SDKROOT="C:/Windows CE Tools"
                    fi
                fi
-               # Ensure that this path has no spaces to work in autoconf
-               TEA_PATH_NOSPACE(WCEROOT, ${WCEROOT})
-               TEA_PATH_NOSPACE(SDKROOT, ${SDKROOT})
+               WCEROOT=`echo "$WCEROOT" | sed -e 's!\\\!/!g'`
+               SDKROOT=`echo "$SDKROOT" | sed -e 's!\\\!/!g'`
                if test ! -d "${SDKROOT}/${OSVERSION}/${PLATFORM}/Lib/${TARGETCPU}" \
                    -o ! -d "${WCEROOT}/EVC/${OSVERSION}/bin"; then
                    AC_MSG_ERROR([could not find PocketPC SDK or target compiler to enable WinCE mode [$CEVERSION,$TARGETCPU,$ARCH,$PLATFORM]])
@@ -894,27 +1002,27 @@ dnl AC_CHECK_TOOL(AR, ar, :)
                    runtime=-MD
                fi
 
-                if test "$do64bit" = "yes" ; then
+                if test "$do64bit" != "no" ; then
                    # All this magic is necessary for the Win64 SDK RC1 - hobbs
-                   CC="${MSSDK}/Bin/Win64/cl.exe"
-                   CFLAGS="${CFLAGS} -I${MSSDK}/Include/prerelease \
-                       -I${MSSDK}/Include/Win64/crt \
-                       -I${MSSDK}/Include"
-                   RC="${MSSDK}/bin/rc.exe"
-                   lflags="-MACHINE:IA64 -LIBPATH:${MSSDK}/Lib/IA64 \
-                       -LIBPATH:${MSSDK}/Lib/Prerelease/IA64 -nologo"
-                   LINKBIN="${MSSDK}/bin/win64/link.exe"
+                   CC="\"${PATH64}/cl.exe\""
+                   CFLAGS="${CFLAGS} -I\"${MSSDK}/Include\" -I\"${MSSDK}/Include/crt\" -I\"${MSSDK}/Include/crt/sys\""
+                   RC="\"${MSSDK}/bin/rc.exe\""
+                   lflags="-nologo -MACHINE:${MACHINE} -LIBPATH:\"${MSSDK}/Lib/${MACHINE}\""
+                   LINKBIN="\"${PATH64}/link.exe\""
                    CFLAGS_DEBUG="-nologo -Zi -Od -W3 ${runtime}d"
                    CFLAGS_OPTIMIZE="-nologo -O2 -W2 ${runtime}"
+                   # Avoid 'unresolved external symbol __security_cookie'
+                   # errors, c.f. http://support.microsoft.com/?id=894573
+                   TEA_ADD_LIBS([bufferoverflowU.lib])
                elif test "$doWince" != "no" ; then
                    CEBINROOT="${WCEROOT}/EVC/${OSVERSION}/bin"
                    if test "${TARGETCPU}" = "X86"; then
-                       CC="${CEBINROOT}/cl.exe"
+                       CC="\"${CEBINROOT}/cl.exe\""
                    else
-                       CC="${CEBINROOT}/cl${ARCH}.exe"
+                       CC="\"${CEBINROOT}/cl${ARCH}.exe\""
                    fi
                    CFLAGS="$CFLAGS -I\"${CELIB_DIR}/inc\" -I\"${CEINCLUDE}\""
-                   RC="${WCEROOT}/Common/EVC/bin/rc.exe"
+                   RC="\"${WCEROOT}/Common/EVC/bin/rc.exe\""
                    arch=`echo ${ARCH} | awk '{print tolower([$]0)}'`
                    defs="${ARCH} _${ARCH}_ ${arch} PALM_SIZE _MT _WINDOWS"
                    if test "${SHARED_BUILD}" = "1" ; then
@@ -922,15 +1030,15 @@ dnl AC_CHECK_TOOL(AR, ar, :)
                        defs="${defs} _DLL"
                    fi
                    for i in $defs ; do
-                       AC_DEFINE_UNQUOTED($i)
+                       AC_DEFINE_UNQUOTED($i, 1, [WinCE def ]$i)
                    done
-                   AC_DEFINE_UNQUOTED(_WIN32_WCE, $CEVERSION)
-                   AC_DEFINE_UNQUOTED(UNDER_CE, $CEVERSION)
+                   AC_DEFINE_UNQUOTED(_WIN32_WCE, $CEVERSION, [_WIN32_WCE version])
+                   AC_DEFINE_UNQUOTED(UNDER_CE, $CEVERSION, [UNDER_CE version])
                    CFLAGS_DEBUG="-nologo -Zi -Od"
                    CFLAGS_OPTIMIZE="-nologo -Ox"
                    lversion=`echo ${CEVERSION} | sed -e 's/\(.\)\(..\)/\1\.\2/'`
                    lflags="-MACHINE:${ARCH} -LIBPATH:\"${CELIBPATH}\" -subsystem:windowsce,${lversion} -nologo"
-                   LINKBIN="${CEBINROOT}/link.exe"
+                   LINKBIN="\"${CEBINROOT}/link.exe\""
                    AC_SUBST(CELIB_DIR)
                else
                    RC="rc"
@@ -981,9 +1089,14 @@ dnl AC_CHECK_TOOL(AR, ar, :)
        AIX-*)
            if test "${TCL_THREADS}" = "1" -a "$GCC" != "yes" ; then
                # AIX requires the _r compiler when gcc isn't being used
-               if test "${CC}" != "cc_r" ; then
-                   CC=${CC}_r
-               fi
+               case "${CC}" in
+                   *_r)
+                       # ok ...
+                       ;;
+                   *)
+                       CC=${CC}_r
+                       ;;
+               esac
                AC_MSG_RESULT([Using $CC for compiling with threads])
            fi
            LIBS="$LIBS -lc"
@@ -1053,7 +1166,7 @@ dnl AC_CHECK_TOOL(AR, ar, :)
            AC_CHECK_LIB(bsd, gettimeofday, libbsd=yes, libbsd=no)
            if test $libbsd = yes; then
                MATH_LIBS="$MATH_LIBS -lbsd"
-               AC_DEFINE(USE_DELTA_FOR_TZ)
+               AC_DEFINE(USE_DELTA_FOR_TZ, 1, [Do we need a special AIX hack for timezones?])
            fi
            ;;
        BeOS*)
@@ -1094,7 +1207,7 @@ dnl AC_CHECK_TOOL(AR, ar, :)
            ;;
        HP-UX-*.11.*)
            # Use updated header definitions where possible
-           AC_DEFINE(_XOPEN_SOURCE_EXTENDED)
+           AC_DEFINE(_XOPEN_SOURCE_EXTENDED, 1, [Do we want to use the XOPEN network library?])
 
            SHLIB_SUFFIX=".sl"
            AC_CHECK_LIB(dld, shl_load, tcl_ok=yes, tcl_ok=no)
@@ -1105,12 +1218,13 @@ dnl AC_CHECK_TOOL(AR, ar, :)
                DL_OBJS="tclLoadShl.o"
                DL_LIBS="-ldld"
                LDFLAGS="$LDFLAGS -Wl,-E"
-               LD_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
+               LD_SEARCH_FLAGS='+s +b ${LIB_RUNTIME_DIR}:.'
                LD_LIBRARY_PATH_VAR="SHLIB_PATH"
            fi
            if test "$GCC" = "yes" ; then
                SHLIB_LD="gcc -shared"
                SHLIB_LD_LIBS='${LIBS}'
+               LD_SEARCH_FLAGS='-Wl,+s,+b,${LIB_RUNTIME_DIR}:.'
            fi
 
            # Users may want PA-RISC 1.1/2.0 portable code - needs HP cc
@@ -1387,16 +1501,40 @@ dnl AC_CHECK_TOOL(AR, ar, :)
            esac
            ;;
        Darwin-*)
+           CFLAGS_OPTIMIZE="-Os"
            SHLIB_CFLAGS="-fno-common"
-           SHLIB_LD="cc -dynamiclib \${LDFLAGS}"
+           if test $do64bit = yes; then
+               do64bit_ok=yes
+               CFLAGS="$CFLAGS -arch ppc64 -mpowerpc64 -mcpu=G5"
+           fi
+           SHLIB_LD='${CC} -dynamiclib ${CFLAGS} ${LDFLAGS}'
+           AC_CACHE_CHECK([if ld accepts -single_module flag], tcl_cv_ld_single_module, [
+               hold_ldflags=$LDFLAGS
+               LDFLAGS="$LDFLAGS -dynamiclib -Wl,-single_module"
+               AC_TRY_LINK(, [int i;], tcl_cv_ld_single_module=yes, tcl_cv_ld_single_module=no)
+               LDFLAGS=$hold_ldflags])
+           if test $tcl_cv_ld_single_module = yes; then
+               SHLIB_LD="${SHLIB_LD} -Wl,-single_module"
+           fi
            SHLIB_LD_LIBS='${LIBS}'
            SHLIB_SUFFIX=".dylib"
            DL_OBJS="tclLoadDyld.o"
            DL_LIBS=""
-           LDFLAGS="$LDFLAGS -prebind -Wl,-search_paths_first"
+           # Don't use -prebind when building for Mac OS X 10.4 or later only:
+           test -z "${MACOSX_DEPLOYMENT_TARGET}" || \
+               test "`echo "${MACOSX_DEPLOYMENT_TARGET}" | awk -F. '{print [$]2}'`" -lt 4 && \
+               LDFLAGS="$LDFLAGS -prebind"
+           LDFLAGS="$LDFLAGS -headerpad_max_install_names"
+           AC_CACHE_CHECK([if ld accepts -search_paths_first flag], tcl_cv_ld_search_paths_first, [
+               hold_ldflags=$LDFLAGS
+               LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
+               AC_TRY_LINK(, [int i;], tcl_cv_ld_search_paths_first=yes, tcl_cv_ld_search_paths_first=no)
+               LDFLAGS=$hold_ldflags])
+           if test $tcl_cv_ld_search_paths_first = yes; then
+               LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
+           fi
            LD_SEARCH_FLAGS=""
            LD_LIBRARY_PATH_VAR="DYLD_LIBRARY_PATH"
-           CFLAGS_OPTIMIZE="-Os"
            ;;
        NEXTSTEP-*)
            SHLIB_CFLAGS=""
@@ -1408,8 +1546,9 @@ dnl AC_CHECK_TOOL(AR, ar, :)
            LD_SEARCH_FLAGS=""
            ;;
        OS/390-*)
-           CFLAGS_OPTIMIZE=""      # Optimizer is buggy
-           AC_DEFINE(_OE_SOCKETS)  # needed in sys/socket.h
+           CFLAGS_OPTIMIZE=""          # Optimizer is buggy
+           AC_DEFINE(_OE_SOCKETS, 1,   # needed in sys/socket.h
+               [Should OS/390 do the right thing with sockets?])
            ;;      
        OSF1-1.0|OSF1-1.1|OSF1-1.2)
            # OSF/1 1.[012] from OSF, and derivatives, including Paragon OSF/1
@@ -1535,13 +1674,15 @@ dnl AC_CHECK_TOOL(AR, ar, :)
            UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
            TCL_LIB_VERSIONS_OK=nodots
            ;;
-       SunOS-5.[[0-6]]*)
+       SunOS-5.[[0-6]])
+           # Careful to not let 5.10+ fall into this case
 
            # Note: If _REENTRANT isn't defined, then Solaris
            # won't define thread-safe library routines.
 
-           AC_DEFINE(_REENTRANT)
-           AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
+           AC_DEFINE(_REENTRANT, 1, [Do we want the reentrant OS API?])
+           AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1,
+               [Do we really want to follow the standard? Yes we do!])
 
            SHLIB_CFLAGS="-KPIC"
 
@@ -1565,8 +1706,9 @@ dnl AC_CHECK_TOOL(AR, ar, :)
            # Note: If _REENTRANT isn't defined, then Solaris
            # won't define thread-safe library routines.
 
-           AC_DEFINE(_REENTRANT)
-           AC_DEFINE(_POSIX_PTHREAD_SEMANTICS)
+           AC_DEFINE(_REENTRANT, 1, [Do we want the reentrant OS API?])
+           AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1,
+               [Do we really want to follow the standard? Yes we do!])
 
            SHLIB_CFLAGS="-KPIC"
     
@@ -1592,9 +1734,19 @@ dnl AC_CHECK_TOOL(AR, ar, :)
                                CFLAGS="$CFLAGS -xarch=v9"
                                LDFLAGS="$LDFLAGS -xarch=v9"
                            fi
+                           # Solaris 64 uses this as well
+                           #LD_LIBRARY_PATH_VAR="LD_LIBRARY_PATH_64"
                        fi
+               elif test "$arch" = "amd64 i386" ; then
+                   if test "$GCC" = "yes" ; then
+                       AC_MSG_WARN([64bit mode not supported with GCC on $system])
+                   else
+                       do64bit_ok=yes
+                       CFLAGS="$CFLAGS -xarch=amd64"
+                       LDFLAGS="$LDFLAGS -xarch=amd64"
+                   fi
                else
-                   AC_MSG_WARN("64bit mode only supported sparcv9 system")
+                   AC_MSG_WARN([64bit mode not supported for $arch])
                fi
            fi
            
@@ -1656,8 +1808,8 @@ dnl AC_CHECK_TOOL(AR, ar, :)
            ;;
     esac
 
-    if test "$do64bit" = "yes" -a "$do64bit_ok" = "no" ; then
-    AC_MSG_WARN("64bit support being disabled -- don\'t know magic for this platform")
+    if test "$do64bit" != "no" -a "$do64bit_ok" = "no" ; then
+       AC_MSG_WARN([64bit support being disabled -- don't know magic for this platform])
     fi
 
     # Step 4: If pseudo-static linking is in use (see K. B. Kenny, "Dynamic
@@ -1695,7 +1847,8 @@ dnl AC_CHECK_TOOL(AR, ar, :)
     ], tcl_ok=usable, tcl_ok=unusable)
        AC_MSG_RESULT([$tcl_ok])
        if test $tcl_ok = usable; then
-           AC_DEFINE(USE_SYS_EXEC_H)
+           AC_DEFINE(USE_SYS_EXEC_H, 1,
+               [Should we use <sys/exec.h> when doing dynamic loading?])
        else
            AC_MSG_CHECKING([a.out.h])
            AC_TRY_COMPILE([#include <a.out.h>],[
@@ -1712,7 +1865,8 @@ dnl AC_CHECK_TOOL(AR, ar, :)
            ], tcl_ok=usable, tcl_ok=unusable)
            AC_MSG_RESULT([$tcl_ok])
            if test $tcl_ok = usable; then
-               AC_DEFINE(USE_A_OUT_H)
+               AC_DEFINE(USE_A_OUT_H, 1,
+                   [Should we use <a.out.h> when doing dynamic loading?])
            else
                AC_MSG_CHECKING([sys/exec_aout.h])
                AC_TRY_COMPILE([#include <sys/exec_aout.h>],[
@@ -1729,7 +1883,8 @@ dnl AC_CHECK_TOOL(AR, ar, :)
                ], tcl_ok=usable, tcl_ok=unusable)
                AC_MSG_RESULT([$tcl_ok])
                if test $tcl_ok = usable; then
-                   AC_DEFINE(USE_SYS_EXEC_AOUT_H)
+                   AC_DEFINE(USE_SYS_EXEC_AOUT_H, 1,
+                       [Should we use <sys/exec_aout.h> when doing dynamic loading?])
                else
                    DL_OBJS=""
                fi
@@ -1931,9 +2086,9 @@ int main() {
 }], tcl_cv_api_serial=sgtty, tcl_cv_api_serial=none, tcl_cv_api_serial=none)
     fi])
     case $tcl_cv_api_serial in
-       termios) AC_DEFINE(USE_TERMIOS);;
-       termio)  AC_DEFINE(USE_TERMIO);;
-       sgtty)   AC_DEFINE(USE_SGTTY);;
+       termios) AC_DEFINE(USE_TERMIOS, 1, [Use the termios API for serial lines]);;
+       termio)  AC_DEFINE(USE_TERMIO, 1, [Use the termio API for serial lines]);;
+       sgtty)   AC_DEFINE(USE_SGTTY, 1, [Use the sgtty API for serial lines]);;
     esac
     AC_MSG_RESULT([$tcl_cv_api_serial])
 ])
@@ -1972,6 +2127,7 @@ int main() {
 
 AC_DEFUN(TEA_MISSING_POSIX_HEADERS, [
     AC_MSG_CHECKING([dirent.h])
+    AC_CACHE_VAL(tcl_cv_dirent_h,
     AC_TRY_LINK([#include <sys/types.h>
 #include <dirent.h>], [
 #ifndef _POSIX_SOURCE
@@ -1991,24 +2147,25 @@ d = opendir("foobar");
 entryPtr = readdir(d);
 p = entryPtr->d_name;
 closedir(d);
-], tcl_ok=yes, tcl_ok=no)
+], tcl_cv_dirent_h=yes, tcl_cv_dirent_h=no))
 
-    if test $tcl_ok = no; then
-       AC_DEFINE(NO_DIRENT_H)
+    if test $tcl_cv_dirent_h = no; then
+       AC_DEFINE(NO_DIRENT_H, 1, [Do we have <dirent.h>?])
     fi
 
     AC_MSG_RESULT([$tcl_ok])
-    AC_CHECK_HEADER(errno.h, , [AC_DEFINE(NO_ERRNO_H)])
-    AC_CHECK_HEADER(float.h, , [AC_DEFINE(NO_FLOAT_H)])
-    AC_CHECK_HEADER(values.h, , [AC_DEFINE(NO_VALUES_H)])
+    AC_CHECK_HEADER(errno.h, , [AC_DEFINE(NO_ERRNO_H, 1, [Do we have <errno.h>?])])
+    AC_CHECK_HEADER(float.h, , [AC_DEFINE(NO_FLOAT_H, 1, [Do we have <float.h>?])])
+    AC_CHECK_HEADER(values.h, , [AC_DEFINE(NO_VALUES_H, 1, [Do we have <values.h>?])])
     AC_CHECK_HEADER(limits.h,
-       [AC_DEFINE(HAVE_LIMITS_H)], [AC_DEFINE(NO_LIMITS_H)])
+       [AC_DEFINE(HAVE_LIMITS_H, 1, [Do we have <limits.h>?])],
+       [AC_DEFINE(NO_LIMITS_H, 1, [Do we have <limits.h>?])])
     AC_CHECK_HEADER(stdlib.h, tcl_ok=1, tcl_ok=0)
     AC_EGREP_HEADER(strtol, stdlib.h, , tcl_ok=0)
     AC_EGREP_HEADER(strtoul, stdlib.h, , tcl_ok=0)
     AC_EGREP_HEADER(strtod, stdlib.h, , tcl_ok=0)
     if test $tcl_ok = 0; then
-       AC_DEFINE(NO_STDLIB_H)
+       AC_DEFINE(NO_STDLIB_H, 1, [Do we have <stdlib.h>?])
     fi
     AC_CHECK_HEADER(string.h, tcl_ok=1, tcl_ok=0)
     AC_EGREP_HEADER(strstr, string.h, , tcl_ok=0)
@@ -2018,11 +2175,11 @@ closedir(d);
     # set and why.
 
     if test $tcl_ok = 0; then
-       AC_DEFINE(NO_STRING_H)
+       AC_DEFINE(NO_STRING_H, 1, [Do we have <string.h>?])
     fi
 
-    AC_CHECK_HEADER(sys/wait.h, , [AC_DEFINE(NO_SYS_WAIT_H)])
-    AC_CHECK_HEADER(dlfcn.h, , [AC_DEFINE(NO_DLFCN_H)])
+    AC_CHECK_HEADER(sys/wait.h, , [AC_DEFINE(NO_SYS_WAIT_H, 1, [Do we have <sys/wait.h>?])])
+    AC_CHECK_HEADER(dlfcn.h, , [AC_DEFINE(NO_DLFCN_H, 1, [Do we have <dlfcn.h>?])])
 
     # OS/390 lacks sys/param.h (and doesn't need it, by chance).
     AC_HAVE_HEADERS(sys/param.h)
@@ -2056,19 +2213,8 @@ closedir(d);
 #--------------------------------------------------------------------
 
 AC_DEFUN(TEA_PATH_X, [
-    if test "${TEA_PLATFORM}" = "unix" ; then
-       case ${TK_DEFS} in
-           *MAC_OSX_TK*)
-               AC_DEFINE(MAC_OSX_TK)
-               TEA_WINDOWINGSYSTEM="aqua"
-               ;;
-           *)
-               TEA_PATH_UNIX_X
-               TEA_WINDOWINGSYSTEM="x11"
-               ;;
-       esac
-    elif test "${TEA_PLATFORM}" = "windows" ; then
-       TEA_WINDOWINGSYSTEM="windows"
+    if test "${TEA_WINDOWINGSYSTEM}" = "x11" ; then
+       TEA_PATH_UNIX_X
     fi
 ])
 
@@ -2191,15 +2337,15 @@ AC_DEFUN(TEA_BLOCKING_STYLE, [
        # code (JO, 5/31/97).
 
        OSF*)
-           AC_DEFINE(USE_FIONBIO)
+           AC_DEFINE(USE_FIONBIO, 1, [Should we use FIONBIO?])
            AC_MSG_RESULT([FIONBIO])
            ;;
        SunOS-4*)
-           AC_DEFINE(USE_FIONBIO)
+           AC_DEFINE(USE_FIONBIO, 1, [Should we use FIONBIO?])
            AC_MSG_RESULT([FIONBIO])
            ;;
        ULTRIX-4.*)
-           AC_DEFINE(USE_FIONBIO)
+           AC_DEFINE(USE_FIONBIO, 1, [Should we use FIONBIO?])
            AC_MSG_RESULT([FIONBIO])
            ;;
        *)
@@ -2240,7 +2386,7 @@ AC_DEFUN(TEA_TIME_HANDLER, [
            tcl_cv_member_tm_tzadj=yes, tcl_cv_member_tm_tzadj=no))
     AC_MSG_RESULT([$tcl_cv_member_tm_tzadj])
     if test $tcl_cv_member_tm_tzadj = yes ; then
-       AC_DEFINE(HAVE_TM_TZADJ)
+       AC_DEFINE(HAVE_TM_TZADJ, 1, [Should we use the tm_tzadj field of struct tm?])
     fi
 
     AC_MSG_CHECKING([tm_gmtoff in struct tm])
@@ -2249,7 +2395,7 @@ AC_DEFUN(TEA_TIME_HANDLER, [
            tcl_cv_member_tm_gmtoff=yes, tcl_cv_member_tm_gmtoff=no))
     AC_MSG_RESULT([$tcl_cv_member_tm_gmtoff])
     if test $tcl_cv_member_tm_gmtoff = yes ; then
-       AC_DEFINE(HAVE_TM_GMTOFF)
+       AC_DEFINE(HAVE_TM_GMTOFF, 1, [Should we use the tm_gmtoff field of struct tm?])
     fi
 
     #
@@ -2257,7 +2403,7 @@ AC_DEFUN(TEA_TIME_HANDLER, [
     # (like convex) have timezone functions, etc.
     #
     AC_MSG_CHECKING([long timezone variable])
-    AC_CACHE_VAL(tcl_cv_var_timezone,
+    AC_CACHE_VAL(tcl_cv_timezone_long,
        AC_TRY_COMPILE([#include <time.h>],
            [extern long timezone;
            timezone += 1;
@@ -2265,7 +2411,7 @@ AC_DEFUN(TEA_TIME_HANDLER, [
            tcl_cv_timezone_long=yes, tcl_cv_timezone_long=no))
     AC_MSG_RESULT([$tcl_cv_timezone_long])
     if test $tcl_cv_timezone_long = yes ; then
-       AC_DEFINE(HAVE_TIMEZONE_VAR)
+       AC_DEFINE(HAVE_TIMEZONE_VAR, 1, [Should we use the global timezone variable?])
     else
        #
        # On some systems (eg IRIX 6.2), timezone is a time_t and not a long.
@@ -2279,7 +2425,7 @@ AC_DEFUN(TEA_TIME_HANDLER, [
                tcl_cv_timezone_time=yes, tcl_cv_timezone_time=no))
        AC_MSG_RESULT([$tcl_cv_timezone_time])
        if test $tcl_cv_timezone_time = yes ; then
-           AC_DEFINE(HAVE_TIMEZONE_VAR)
+           AC_DEFINE(HAVE_TIMEZONE_VAR, 1, [Should we use the global timezone variable?])
        fi
     fi
 ])
@@ -2308,6 +2454,7 @@ AC_DEFUN(TEA_BUGGY_STRTOD, [
     AC_CHECK_FUNC(strtod, tcl_strtod=1, tcl_strtod=0)
     if test "$tcl_strtod" = 1; then
        AC_MSG_CHECKING([for Solaris2.4/Tru64 strtod bugs])
+       AC_CACHE_VAL(tcl_cv_strtod_buggy,[
        AC_TRY_RUN([
            extern double strtod();
            int main()
@@ -2324,15 +2471,15 @@ AC_DEFUN(TEA_BUGGY_STRTOD, [
                    exit(1);
                }
                exit(0);
-           }], tcl_ok=1, tcl_ok=0, tcl_ok=0)
-       if test "$tcl_ok" = 1; then
+           }], tcl_cv_strtod_buggy=1, tcl_cv_strtod_buggy=0, tcl_cv_strtod_buggy=0)])
+       if test "$tcl_cv_strtod_buggy" = 1; then
            AC_MSG_RESULT([ok])
        else
            AC_MSG_RESULT([buggy])
            #LIBOBJS="$LIBOBJS fixstrtod.o"
            AC_LIBOBJ([fixstrtod])
            USE_COMPAT=1
-           AC_DEFINE(strtod, fixstrtod)
+           AC_DEFINE(strtod, fixstrtod, [Do we want to use the strtod() in compat?])
        fi
     fi
 ])
@@ -2381,7 +2528,8 @@ AC_DEFUN(TEA_TCL_LINK_LIBS, [
     #--------------------------------------------------------------------
 
     AC_CHECK_LIB(inet, main, [LIBS="$LIBS -linet"])
-    AC_CHECK_HEADER(net/errno.h, AC_DEFINE(HAVE_NET_ERRNO_H))
+    AC_CHECK_HEADER(net/errno.h, [
+       AC_DEFINE(HAVE_NET_ERRNO_H, 1, [Do we have <net/errno.h>?])])
 
     #--------------------------------------------------------------------
     #  Check for the existence of the -lsocket and -lnsl libraries.
@@ -2448,7 +2596,7 @@ AC_DEFUN(TEA_TCL_EARLY_FLAG,[
                [tcl_cv_flag_]translit($1,[A-Z],[a-z])=yes,
                [tcl_cv_flag_]translit($1,[A-Z],[a-z])=no)))
     if test ["x${tcl_cv_flag_]translit($1,[A-Z],[a-z])[}" = "xyes"] ; then
-       AC_DEFINE($1)
+       AC_DEFINE($1, 1, [Add the ]$1[ flag when building])
        tcl_flags="$tcl_flags $1"
     fi
 ])
@@ -2500,14 +2648,16 @@ AC_DEFUN(TEA_TCL_64BIT_FLAGS, [
             case 1: case (sizeof(]${tcl_type_64bit}[)==sizeof(long)): ; 
         }],tcl_cv_type_64bit=${tcl_type_64bit})])
     if test "${tcl_cv_type_64bit}" = none ; then
-       AC_DEFINE(TCL_WIDE_INT_IS_LONG)
+       AC_DEFINE(TCL_WIDE_INT_IS_LONG, 1, [Are wide integers to be implemented with C 'long's?])
        AC_MSG_RESULT([using long])
-    elif test "${tcl_cv_type_64bit}" = "__int64" ; then
+    elif test "${tcl_cv_type_64bit}" = "__int64" \
+               -a "${TEA_PLATFORM}" = "windows" ; then
        # We actually want to use the default tcl.h checks in this
        # case to handle both TCL_WIDE_INT_TYPE and TCL_LL_MODIFIER*
        AC_MSG_RESULT([using Tcl header defaults])
     else
-       AC_DEFINE_UNQUOTED(TCL_WIDE_INT_TYPE,${tcl_cv_type_64bit})
+       AC_DEFINE_UNQUOTED(TCL_WIDE_INT_TYPE,${tcl_cv_type_64bit},
+           [What type should be used to define wide integers?])
        AC_MSG_RESULT([${tcl_cv_type_64bit}])
 
        # Now check for auxiliary declarations
@@ -2517,7 +2667,7 @@ AC_DEFUN(TEA_TCL_64BIT_FLAGS, [
 #include <sys/dirent.h>],[struct dirent64 p;],
                tcl_cv_struct_dirent64=yes,tcl_cv_struct_dirent64=no)])
        if test "x${tcl_cv_struct_dirent64}" = "xyes" ; then
-           AC_DEFINE(HAVE_STRUCT_DIRENT64)
+           AC_DEFINE(HAVE_STRUCT_DIRENT64, 1, [Is 'struct dirent64' in <sys/types.h>?])
        fi
        AC_MSG_RESULT([${tcl_cv_struct_dirent64}])
 
@@ -2527,7 +2677,7 @@ AC_DEFUN(TEA_TCL_64BIT_FLAGS, [
 ],
                tcl_cv_struct_stat64=yes,tcl_cv_struct_stat64=no)])
        if test "x${tcl_cv_struct_stat64}" = "xyes" ; then
-           AC_DEFINE(HAVE_STRUCT_STAT64)
+           AC_DEFINE(HAVE_STRUCT_STAT64, 1, [Is 'struct stat64' in <sys/stat.h>?])
        fi
        AC_MSG_RESULT([${tcl_cv_struct_stat64}])
 
@@ -2537,7 +2687,7 @@ AC_DEFUN(TEA_TCL_64BIT_FLAGS, [
 ],
                tcl_cv_type_off64_t=yes,tcl_cv_type_off64_t=no)])
        if test "x${tcl_cv_type_off64_t}" = "xyes" ; then
-           AC_DEFINE(HAVE_TYPE_OFF64_T)
+           AC_DEFINE(HAVE_TYPE_OFF64_T, 1, [Is off64_t in <sys/types.h>?])
        fi
        AC_MSG_RESULT([${tcl_cv_type_off64_t}])
     fi
@@ -2579,7 +2729,7 @@ AC_DEFUN(TEA_TCL_64BIT_FLAGS, [
 AC_DEFUN(TEA_INIT, [
     # TEA extensions pass this us the version of TEA they think they
     # are compatible with.
-    TEA_VERSION="3.2"
+    TEA_VERSION="3.4"
 
     AC_MSG_CHECKING([for correct TEA configuration])
     if test x"${PACKAGE_NAME}" = x ; then
@@ -3169,30 +3319,33 @@ AC_DEFUN(TEA_LIB_SPEC, [
 AC_DEFUN(TEA_PRIVATE_TCL_HEADERS, [
     AC_MSG_CHECKING([for Tcl private include files])
 
+    TCL_SRC_DIR_NATIVE=`${CYGPATH} ${TCL_SRC_DIR}`
+    TCL_TOP_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}\"
+    TCL_GENERIC_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/generic\"
+    TCL_UNIX_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/unix\"
+    TCL_WIN_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/win\"
+    TCL_BMAP_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/bitmaps\"
+    TCL_TOOL_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/tools\"
+    TCL_COMPAT_DIR_NATIVE=\"${TCL_SRC_DIR_NATIVE}/compat\"
+
     if test "${TEA_PLATFORM}" = "windows"; then
-       TCL_TOP_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}`\"
-       TCL_GENERIC_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/generic`\"
-       TCL_UNIX_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/unix`\"
-       TCL_WIN_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/win`\"
-       TCL_BMAP_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/bitmaps`\"
-       TCL_TOOL_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/tools`\"
-       TCL_COMPAT_DIR_NATIVE=\"`${CYGPATH} ${TCL_SRC_DIR}/compat`\"
        TCL_PLATFORM_DIR_NATIVE=${TCL_WIN_DIR_NATIVE}
-
-       TCL_INCLUDES="-I${TCL_GENERIC_DIR_NATIVE} -I${TCL_PLATFORM_DIR_NATIVE}"
     else
-       TCL_TOP_DIR_NATIVE='$(TCL_SRC_DIR)'
-       TCL_GENERIC_DIR_NATIVE='${TCL_TOP_DIR_NATIVE}/generic'
-       TCL_UNIX_DIR_NATIVE='${TCL_TOP_DIR_NATIVE}/unix'
-       TCL_WIN_DIR_NATIVE='${TCL_TOP_DIR_NATIVE}/win'
-       TCL_BMAP_DIR_NATIVE='${TCL_TOP_DIR_NATIVE}/bitmaps'
-       TCL_TOOL_DIR_NATIVE='${TCL_TOP_DIR_NATIVE}/tools'
-       TCL_COMPAT_DIR_NATIVE='${TCL_TOP_DIR_NATIVE}/compat'
        TCL_PLATFORM_DIR_NATIVE=${TCL_UNIX_DIR_NATIVE}
-
-       # substitute these in "relaxed" so that TCL_INCLUDES still works
-       # without requiring the other vars to be defined in the Makefile
-       eval "TCL_INCLUDES=\"-I${TCL_GENERIC_DIR_NATIVE} -I${TCL_PLATFORM_DIR_NATIVE}\""
+    fi
+    # We want to ensure these are substituted so as not to require
+    # any *_NATIVE vars be defined in the Makefile
+    TCL_INCLUDES="-I${TCL_GENERIC_DIR_NATIVE} -I${TCL_PLATFORM_DIR_NATIVE}"
+    if test "`uname -s`" = "Darwin"; then
+        # If Tcl was built as a framework, attempt to use
+        # the framework's Headers and PrivateHeaders directories
+        case ${TCL_DEFS} in
+           *TCL_FRAMEWORK*)
+               if test -d "${TCL_BIN_DIR}/Headers" -a -d "${TCL_BIN_DIR}/PrivateHeaders"; then
+               TCL_INCLUDES="-I\"${TCL_BIN_DIR}/Headers\" -I\"${TCL_BIN_DIR}/PrivateHeaders\" ${TCL_INCLUDES}"; else
+               TCL_INCLUDES="${TCL_INCLUDES} ${TCL_INCLUDE_SPEC} `echo "${TCL_INCLUDE_SPEC}" | sed -e 's/Headers/PrivateHeaders/'`"; fi
+               ;;
+       esac
     fi
 
     AC_SUBST(TCL_TOP_DIR_NATIVE)
@@ -3242,17 +3395,32 @@ AC_DEFUN(TEA_PUBLIC_TCL_HEADERS, [
                AC_MSG_ERROR([${with_tclinclude} directory does not contain tcl.h])
            fi
        else
+            # If Tcl was built as a framework, attempt to use
+            # the framework's Headers directory
+            case ${TCL_DEFS} in
+                *TCL_FRAMEWORK*)
+                    list="`ls -d ${TCL_BIN_DIR}/Headers 2>/dev/null`"
+                    ;;
+                *)
+                    list=""
+                    ;;
+            esac
            # Check order: pkg --prefix location, Tcl's --prefix location,
            # directory of tclConfig.sh, and Tcl source directory.
            # Looking in the source dir is not ideal, but OK.
 
            eval "temp_includedir=${includedir}"
-           list="`ls -d ${temp_includedir}      2>/dev/null` \
+           list="$list \
+               `ls -d ${temp_includedir}        2>/dev/null` \
                `ls -d ${TCL_PREFIX}/include     2>/dev/null` \
                `ls -d ${TCL_BIN_DIR}/../include 2>/dev/null` \
                `ls -d ${TCL_SRC_DIR}/generic    2>/dev/null`"
            if test "${TEA_PLATFORM}" != "windows" -o "$GCC" = "yes"; then
                list="$list /usr/local/include /usr/include"
+               if test x"${TCL_INCLUDE_SPEC}" != x ; then
+                   d=`echo "${TCL_INCLUDE_SPEC}" | sed -e 's/^-I//'`
+                   list="$list `ls -d ${d} 2>/dev/null`"
+               fi
            fi
            for i in $list ; do
                if test -f "$i/tcl.h" ; then
@@ -3300,25 +3468,36 @@ AC_DEFUN(TEA_PUBLIC_TCL_HEADERS, [
 AC_DEFUN(TEA_PRIVATE_TK_HEADERS, [
     AC_MSG_CHECKING([for Tk private include files])
 
+    TK_SRC_DIR_NATIVE=`${CYGPATH} ${TK_SRC_DIR}`
+    TK_TOP_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}\"
+    TK_UNIX_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/unix\"
+    TK_WIN_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/win\"
+    TK_GENERIC_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/generic\"
+    TK_XLIB_DIR_NATIVE=\"${TK_SRC_DIR_NATIVE}/xlib\"
     if test "${TEA_PLATFORM}" = "windows"; then
-       TK_TOP_DIR_NATIVE=\"`${CYGPATH} ${TK_SRC_DIR}`\"
-       TK_UNIX_DIR_NATIVE=\"`${CYGPATH} ${TK_SRC_DIR}/unix`\"
-       TK_WIN_DIR_NATIVE=\"`${CYGPATH} ${TK_SRC_DIR}/win`\"
-       TK_GENERIC_DIR_NATIVE=\"`${CYGPATH} ${TK_SRC_DIR}/generic`\"
-       TK_XLIB_DIR_NATIVE=\"`${CYGPATH} ${TK_SRC_DIR}/xlib`\"
        TK_PLATFORM_DIR_NATIVE=${TK_WIN_DIR_NATIVE}
-
-       TK_INCLUDES="-I${TK_GENERIC_DIR_NATIVE} -I${TK_PLATFORM_DIR_NATIVE} -I${TK_XLIB_DIR_NATIVE}"
     else
-       TK_TOP_DIR_NATIVE='${TK_SRC_DIR}'
-       TK_GENERIC_DIR_NATIVE='${TK_TOP_DIR_NATIVE}/generic'
-       TK_UNIX_DIR_NATIVE='${TK_TOP_DIR_NATIVE}/unix'
-       TK_WIN_DIR_NATIVE='${TK_TOP_DIR_NATIVE}/win'
        TK_PLATFORM_DIR_NATIVE=${TK_UNIX_DIR_NATIVE}
-
-       # substitute these in "relaxed" so that TK_INCLUDES still works
-       # without requiring the other vars to be defined in the Makefile
-       eval "TK_INCLUDES=\"-I${TK_GENERIC_DIR_NATIVE} -I${TK_PLATFORM_DIR_NATIVE}\""
+    fi
+    # We want to ensure these are substituted so as not to require
+    # any *_NATIVE vars be defined in the Makefile
+    TK_INCLUDES="-I${TK_GENERIC_DIR_NATIVE} -I${TK_PLATFORM_DIR_NATIVE}"
+    if test "${TEA_WINDOWINGSYSTEM}" = "win32" \
+       -o "${TEA_WINDOWINGSYSTEM}" = "aqua"; then
+       TK_INCLUDES="${TK_INCLUDES} -I${TK_XLIB_DIR_NATIVE}"
+    fi
+    if test "${TEA_WINDOWINGSYSTEM}" = "aqua"; then
+       TK_INCLUDES="${TK_INCLUDES} -I${TK_SRC_DIR_NATIVE}/macosx"
+    fi
+    if test "`uname -s`" = "Darwin"; then
+        # If Tk was built as a framework, attempt to use
+        # the framework's Headers and PrivateHeaders directories
+        case ${TK_DEFS} in
+           *TK_FRAMEWORK*)
+               if test -d "${TK_BIN_DIR}/Headers" -a -d "${TK_BIN_DIR}/PrivateHeaders"; then
+               TK_INCLUDES="-I\"${TK_BIN_DIR}/Headers\" -I\"${TK_BIN_DIR}/PrivateHeaders\" ${TK_INCLUDES}"; fi
+               ;;
+       esac
     fi
 
     AC_SUBST(TK_TOP_DIR_NATIVE)
@@ -3367,12 +3546,23 @@ AC_DEFUN(TEA_PUBLIC_TK_HEADERS, [
                AC_MSG_ERROR([${with_tkinclude} directory does not contain tk.h])
            fi
        else
+            # If Tk was built as a framework, attempt to use
+            # the framework's Headers directory.
+            case ${TK_DEFS} in
+                *TK_FRAMEWORK*)
+                    list="`ls -d ${TK_BIN_DIR}/Headers 2>/dev/null`"
+                    ;;
+                *)
+                    list=""
+                    ;;
+            esac
            # Check order: pkg --prefix location, Tcl's --prefix location,
            # directory of tclConfig.sh, and Tcl source directory.
            # Looking in the source dir is not ideal, but OK.
 
            eval "temp_includedir=${includedir}"
-           list="`ls -d ${temp_includedir}      2>/dev/null` \
+           list="$list \
+               `ls -d ${temp_includedir}        2>/dev/null` \
                `ls -d ${TK_PREFIX}/include      2>/dev/null` \
                `ls -d ${TCL_PREFIX}/include     2>/dev/null` \
                `ls -d ${TCL_BIN_DIR}/../include 2>/dev/null` \
@@ -3405,8 +3595,9 @@ AC_DEFUN(TEA_PUBLIC_TK_HEADERS, [
 
     AC_SUBST(TK_INCLUDES)
 
-    if test "${TEA_PLATFORM}" = "windows" ; then
-       # On Windows, we need the X compat headers
+    if test "${TEA_WINDOWINGSYSTEM}" = "win32" \
+       -o "${TEA_WINDOWINGSYSTEM}" = "aqua"; then
+       # On Windows and Aqua, we need the X compat headers
        AC_MSG_CHECKING([for X11 header files])
        if test ! -r "${INCLUDE_DIR_NATIVE}/X11/Xlib.h"; then
            INCLUDE_DIR_NATIVE="`${CYGPATH} ${TK_SRC_DIR}/xlib`"
@@ -3419,10 +3610,14 @@ AC_DEFUN(TEA_PUBLIC_TK_HEADERS, [
 
 #------------------------------------------------------------------------
 # TEA_PROG_TCLSH
-#      Locate a tclsh shell in the following directories:
-#              ${TCL_BIN_DIR}          ${TCL_BIN_DIR}/../bin
-#              ${exec_prefix}/bin      ${prefix}/bin
-#              ${PATH}
+#      Determine the fully qualified path name of the tclsh executable
+#      in the Tcl build directory or the tclsh installed in a bin
+#      directory. This macro will correctly determine the name
+#      of the tclsh executable even if tclsh has not yet been
+#      built in the build directory. The tclsh found is always
+#      associated with a tclConfig.sh file. This tclsh should be used
+#      only for running extension test cases. It should never be
+#      or generation of files (like pkgIndex.tcl) at build time.
 #
 # Arguments
 #      none
@@ -3433,48 +3628,45 @@ AC_DEFUN(TEA_PUBLIC_TK_HEADERS, [
 #------------------------------------------------------------------------
 
 AC_DEFUN(TEA_PROG_TCLSH, [
-    # Allow the user to provide this setting in the env
-    if test "x${TCLSH_PROG}" = "x" ; then
-       AC_MSG_CHECKING([for tclsh])
-
-       AC_CACHE_VAL(ac_cv_path_tclsh, [
-       search_path=`echo ${PATH} | sed -e 's/:/ /g'`
-       if test "${TEA_PLATFORM}" != "windows" -o \
-               \( "$do64bit_ok" = "no" -a "$doWince" = "no" \) ; then
-           # Do not allow target tclsh in known cross-compile builds,
-           # as we need one we can run on this system
-           search_path="${TCL_BIN_DIR} ${TCL_BIN_DIR}/../bin ${exec_prefix}/bin ${prefix}/bin ${search_path}"
-       fi
-       for dir in $search_path ; do
-           for j in `ls -r $dir/tclsh[[8-9]]*${EXEEXT} 2> /dev/null` \
-                   `ls -r $dir/tclsh*${EXEEXT} 2> /dev/null` ; do
-               if test x"$ac_cv_path_tclsh" = x ; then
-                   if test -f "$j" ; then
-                       ac_cv_path_tclsh=$j
-                       break
-                   fi
-               fi
-           done
-       done
-       ])
-
-       if test -f "$ac_cv_path_tclsh" ; then
-           TCLSH_PROG=$ac_cv_path_tclsh
-           AC_MSG_RESULT([$TCLSH_PROG])
-       else
-           AC_MSG_ERROR([No tclsh found in PATH: $search_path])
-       fi
-    fi
+    AC_MSG_CHECKING([for tclsh])
+    if test -f "${TCL_BIN_DIR}/Makefile" ; then
+        # tclConfig.sh is in Tcl build directory
+        if test "${TEA_PLATFORM}" = "windows"; then
+            TCLSH_PROG="${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}"
+        else
+            TCLSH_PROG="${TCL_BIN_DIR}/tclsh"
+        fi
+    else
+        # tclConfig.sh is in install location
+        if test "${TEA_PLATFORM}" = "windows"; then
+            TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}"
+        else
+            TCLSH_PROG="tclsh${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}${TCL_DBGX}"
+        fi
+        list="`ls -d ${TCL_PREFIX}/bin     2>/dev/null` \
+              `ls -d ${TCL_BIN_DIR}/../bin 2>/dev/null`"
+        for i in $list ; do
+            if test -f "$i/${TCLSH_PROG}" ; then
+                REAL_TCL_BIN_DIR="`cd "$i"; pwd`"
+                break
+            fi
+        done
+        TCLSH_PROG="${REAL_TCL_BIN_DIR}/${TCLSH_PROG}"
+    fi
+    AC_MSG_RESULT(${TCLSH_PROG})
     AC_SUBST(TCLSH_PROG)
 ])
 
 #------------------------------------------------------------------------
 # TEA_PROG_WISH
-#      Locate a wish shell in the following directories:
-#              ${TK_BIN_DIR}           ${TK_BIN_DIR}/../bin
-#              ${TCL_BIN_DIR}          ${TCL_BIN_DIR}/../bin
-#              ${exec_prefix}/bin      ${prefix}/bin
-#              ${PATH}
+#      Determine the fully qualified path name of the wish executable
+#      in the Tk build directory or the wish installed in a bin
+#      directory. This macro will correctly determine the name
+#      of the wish executable even if wish has not yet been
+#      built in the build directory. The wish found is always
+#      associated with a tkConfig.sh file. This wish should be used
+#      only for running extension test cases. It should never be
+#      or generation of files (like pkgIndex.tcl) at build time.
 #
 # Arguments
 #      none
@@ -3485,38 +3677,32 @@ AC_DEFUN(TEA_PROG_TCLSH, [
 #------------------------------------------------------------------------
 
 AC_DEFUN(TEA_PROG_WISH, [
-    # Allow the user to provide this setting in the env
-    if test "x${WISH_PROG}" = "x" ; then
-       AC_MSG_CHECKING([for wish])
-
-       AC_CACHE_VAL(ac_cv_path_wish, [
-       search_path=`echo ${PATH} | sed -e 's/:/ /g'`
-       if test "${TEA_PLATFORM}" != "windows" -o \
-               \( "$do64bit_ok" = "no" -a "$doWince" = "no" \) ; then
-           # Do not allow target wish in known cross-compile builds,
-           # as we need one we can run on this system
-           search_path="${TK_BIN_DIR} ${TK_BIN_DIR}/../bin ${TCL_BIN_DIR} ${TCL_BIN_DIR}/../bin ${exec_prefix}/bin ${prefix}/bin ${search_path}"
-       fi
-       for dir in $search_path ; do
-           for j in `ls -r $dir/wish[[8-9]]*${EXEEXT} 2> /dev/null` \
-                   `ls -r $dir/wish*${EXEEXT} 2> /dev/null` ; do
-               if test x"$ac_cv_path_wish" = x ; then
-                   if test -f "$j" ; then
-                       ac_cv_path_wish=$j
-                       break
-                   fi
-               fi
-           done
-       done
-       ])
-
-       if test -f "$ac_cv_path_wish" ; then
-       WISH_PROG=$ac_cv_path_wish
-           AC_MSG_RESULT([$WISH_PROG])
-       else
-           AC_MSG_ERROR([No wish found in PATH: $search_path])
-       fi
-    fi
+    AC_MSG_CHECKING([for wish])
+    if test -f "${TK_BIN_DIR}/Makefile" ; then
+        # tkConfig.sh is in Tk build directory
+        if test "${TEA_PLATFORM}" = "windows"; then
+            WISH_PROG="${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${TK_DBGX}${EXEEXT}"
+        else
+            WISH_PROG="${TK_BIN_DIR}/wish"
+        fi
+    else
+        # tkConfig.sh is in install location
+        if test "${TEA_PLATFORM}" = "windows"; then
+            WISH_PROG="wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${TK_DBGX}${EXEEXT}"
+        else
+            WISH_PROG="wish${TK_MAJOR_VERSION}.${TK_MINOR_VERSION}${TK_DBGX}"
+        fi
+        list="`ls -d ${TK_PREFIX}/bin     2>/dev/null` \
+              `ls -d ${TK_BIN_DIR}/../bin 2>/dev/null`"
+        for i in $list ; do
+            if test -f "$i/${WISH_PROG}" ; then
+                REAL_TK_BIN_DIR="`cd "$i"; pwd`"
+                break
+            fi
+        done
+        WISH_PROG="${REAL_TK_BIN_DIR}/${WISH_PROG}"
+    fi
+    AC_MSG_RESULT(${WISH_PROG})
     AC_SUBST(WISH_PROG)
 ])
 
@@ -3556,6 +3742,13 @@ AC_DEFUN(TEA_PATH_CONFIG, [
 
            # First check to see if --with-$1 was specified.
            if test x"${with_$1config}" != x ; then
+               case ${with_$1config} in
+                   */$1Config.sh )
+                       if test -f ${with_$1config}; then
+                           AC_MSG_WARN([--with-$1 argument should refer to directory containing $1Config.sh, not to $1Config.sh itself])
+                           with_$1config=`echo ${with_$1config} | sed 's!/$1Config\.sh$!!'`
+                       fi;;
+               esac
                if test -f "${with_$1config}/$1Config.sh" ; then
                    ac_cv_c_$1config=`(cd ${with_$1config}; pwd)`
                else
@@ -3567,13 +3760,25 @@ AC_DEFUN(TEA_PATH_CONFIG, [
            if test x"${ac_cv_c_$1config}" = x ; then
                for i in \
                        ../$1 \
-                       `ls -dr ../$1[[8-9]].[[0-9]]* 2>/dev/null` \
+                       `ls -dr ../$1*[[0-9]].[[0-9]]*.[[0-9]]* 2>/dev/null` \
+                       `ls -dr ../$1*[[0-9]].[[0-9]][[0-9]] 2>/dev/null` \
+                       `ls -dr ../$1*[[0-9]].[[0-9]] 2>/dev/null` \
+                       `ls -dr ../$1*[[0-9]].[[0-9]]* 2>/dev/null` \
                        ../../$1 \
-                       `ls -dr ../../$1[[8-9]].[[0-9]]* 2>/dev/null` \
+                       `ls -dr ../../$1*[[0-9]].[[0-9]]*.[[0-9]]* 2>/dev/null` \
+                       `ls -dr ../../$1*[[0-9]].[[0-9]][[0-9]] 2>/dev/null` \
+                       `ls -dr ../../$1*[[0-9]].[[0-9]] 2>/dev/null` \
+                       `ls -dr ../../$1*[[0-9]].[[0-9]]* 2>/dev/null` \
                        ../../../$1 \
-                       `ls -dr ../../../$1[[8-9]].[[0-9]]* 2>/dev/null` \
+                       `ls -dr ../../../$1*[[0-9]].[[0-9]]*.[[0-9]]* 2>/dev/null` \
+                       `ls -dr ../../../$1*[[0-9]].[[0-9]][[0-9]] 2>/dev/null` \
+                       `ls -dr ../../../$1*[[0-9]].[[0-9]] 2>/dev/null` \
+                       `ls -dr ../../../$1*[[0-9]].[[0-9]]* 2>/dev/null` \
                        ${srcdir}/../$1 \
-                       `ls -dr ${srcdir}/../$1[[8-9]].[[0-9]]* 2>/dev/null` \
+                       `ls -dr ${srcdir}/../$1*[[0-9]].[[0-9]]*.[[0-9]]* 2>/dev/null` \
+                       `ls -dr ${srcdir}/../$1*[[0-9]].[[0-9]][[0-9]] 2>/dev/null` \
+                       `ls -dr ${srcdir}/../$1*[[0-9]].[[0-9]] 2>/dev/null` \
+                       `ls -dr ${srcdir}/../$1*[[0-9]].[[0-9]]* 2>/dev/null` \
                        ; do
                    if test -f "$i/$1Config.sh" ; then
                        ac_cv_c_$1config=`(cd $i; pwd)`
@@ -3660,6 +3865,7 @@ AC_DEFUN(TEA_LOAD_CONFIG, [
     fi
 
     AC_SUBST($1_VERSION)
+    AC_SUBST($1_BIN_DIR)
     AC_SUBST($1_SRC_DIR)
 
     AC_SUBST($1_LIB_FILE)
@@ -3731,45 +3937,8 @@ AC_DEFUN(TEA_PATH_CELIB, [
        else
            no_celib=
            CELIB_DIR=${ac_cv_c_celibconfig}
+           CELIB_DIR=`echo "$CELIB_DIR" | sed -e 's!\\\!/!g'`
            AC_MSG_RESULT([found $CELIB_DIR])
-           TEA_PATH_NOSPACE(CELIB_DIR, ${ac_cv_c_celibconfig})
-       fi
-    fi
-])
-
-#------------------------------------------------------------------------
-# TEA_PATH_NOSPACE
-#      Ensure that the given path has no spaces.  This is necessary for
-#      CC (and consitutuent vars that build it up) to work in the
-#      tortured autoconf environment.  Currently only for Windows use.
-#
-# Arguments
-#      VAR  - name of the variable to set
-#      PATH - path to ensure no spaces in
-#
-# Results
-#      Sets $VAR to short path of $PATH if it can be found.
-#------------------------------------------------------------------------
-
-AC_DEFUN([TEA_PATH_NOSPACE], [
-    if test "${TEA_PLATFORM}" = "windows" ; then
-       # we need TCLSH_PROG defined to get Windows short pathnames
-       AC_REQUIRE([TEA_PROG_TCLSH])
-
-       AC_MSG_CHECKING([short pathname for $1 ($2)])
-
-       shortpath=
-       case "$2" in
-           *\ *)
-               # Only do this if we need to.
-               shortpath=`echo "puts [[file attributes {$2} -shortname]] ; exit" | ${TCLSH_PROG} 2>/dev/null`
-               ;;
-       esac
-       if test "x${shortpath}" = "x" ; then
-           AC_MSG_RESULT([not changed])
-       else
-           $1=$shortpath
-           AC_MSG_RESULT([${$1}])
        fi
     fi
 ])