Subject: Backport various improvements from Tcl 8.5

From: "jan.nijtmans" <[email-masked]>
Date: Tue, 12 Feb 2013 23:13:29 +0000

---
 unix/configure |  16 ++--
 unix/tcl.m4    |  16 ++--
 win/configure  |  37 +++++----
 win/tcl.m4     | 258 ++++++++++++++++++++++++++++++++++++++++++++-------------
 4 files changed, 234 insertions(+), 93 deletions(-)

diff --git a/unix/configure b/unix/configure
index 8d7b7f7..c85dada 100755
--- a/unix/configure
+++ b/unix/configure
@@ -12,18 +12,18 @@ ac_help=
 ac_default_prefix=/usr/local
 # Any additions from configure.in:
 ac_help="$ac_help
-  --enable-man-symlinks   use symlinks for the manpages"
+  --enable-man-symlinks   use symlinks for the manpages (default: off)"
 ac_help="$ac_help
   --enable-man-compression=PROG
-		      compress the manpages with PROG"
+		      compress the manpages with PROG (default: off)"
 ac_help="$ac_help
   --enable-man-suffix=STRING
 		      use STRING as a suffix to manpage file names
 		      (default: tcl)"
 ac_help="$ac_help
-  --enable-threads        build with threads"
+  --enable-threads        build with threads (default: off)"
 ac_help="$ac_help
-  --enable-shared         build and link with shared libraries [--enable-shared]"
+  --enable-shared         build and link with shared libraries (default: on)"
 ac_help="$ac_help
   --enable-64bit          enable 64bit support (where applicable)"
 ac_help="$ac_help
@@ -35,14 +35,14 @@ ac_help="$ac_help
 ac_help="$ac_help
   --disable-load          disallow dynamic loading and "load" command"
 ac_help="$ac_help
-  --enable-symbols        build with debugging symbols [--disable-symbols]"
+  --enable-symbols        build with debugging symbols (default: off)"
 ac_help="$ac_help
   --enable-langinfo	  use nl_langinfo if possible to determine
-			  encoding at startup, otherwise use old heuristic"
+			  encoding at startup, otherwise use old heuristic (default: on)"
 ac_help="$ac_help
   --enable-dtrace         build with DTrace support [--disable-dtrace]"
 ac_help="$ac_help
-  --enable-framework      package shared libraries in MacOSX frameworks [--disable-framework]"
+  --enable-framework      package shared libraries in MacOSX frameworks (default: off)"
 
 # Initialize some variables set by options.
 # The variables have the same names as the options, with
@@ -1884,7 +1884,7 @@ EOF
 	    echo "$ac_t""yes" 1>&6
 	fi
     else
-	echo "$ac_t""no" 1>&6
+	echo "$ac_t""no (default)" 1>&6
     fi

diff --git a/unix/tcl.m4 b/unix/tcl.m4
index 2dc6576..889d817 100644
--- a/unix/tcl.m4
+++ b/unix/tcl.m4
@@ -517,7 +517,7 @@ AC_DEFUN([SC_BUILD_TCLSH], [
 AC_DEFUN([SC_ENABLE_SHARED], [
     AC_MSG_CHECKING([how to build libraries])
     AC_ARG_ENABLE(shared,
-	[  --enable-shared         build and link with shared libraries [--enable-shared]],
+	[  --enable-shared         build and link with shared libraries (default: on)],
 	[tcl_ok=$enableval], [tcl_ok=yes])
 
     if test "${enable_shared+set}" = set; then
@@ -558,7 +558,7 @@ AC_DEFUN([SC_ENABLE_FRAMEWORK], [
     if test "`uname -s`" = "Darwin" ; then
 	AC_MSG_CHECKING([how to package libraries])
 	AC_ARG_ENABLE(framework,
-	    [  --enable-framework      package shared libraries in MacOSX frameworks [--disable-framework]],
+	    [  --enable-framework      package shared libraries in MacOSX frameworks (default: off)],
 	    [enable_framework=$enableval], [enable_framework=no])
 	if test $enable_framework = yes; then
 	    if test $SHARED_BUILD = 0; then
@@ -610,7 +610,7 @@ AC_DEFUN([SC_ENABLE_FRAMEWORK], [
 #------------------------------------------------------------------------
 
 AC_DEFUN([SC_ENABLE_THREADS], [
-    AC_ARG_ENABLE(threads, [  --enable-threads        build with threads],
+    AC_ARG_ENABLE(threads, [  --enable-threads        build with threads (default: off)],
 	[tcl_ok=$enableval], [tcl_ok=no])
 
     if test "${TCL_THREADS}" = 1; then
@@ -687,7 +687,7 @@ AC_DEFUN([SC_ENABLE_THREADS], [
 	    AC_MSG_RESULT([yes])
 	fi
     else
-	AC_MSG_RESULT([no])
+	AC_MSG_RESULT([no (default)])
     fi
 
     AC_SUBST(TCL_THREADS)
@@ -725,7 +725,7 @@ AC_DEFUN([SC_ENABLE_THREADS], [
 
 AC_DEFUN([SC_ENABLE_SYMBOLS], [
     AC_MSG_CHECKING([for build with symbols])
-    AC_ARG_ENABLE(symbols, [  --enable-symbols        build with debugging symbols [--disable-symbols]],    [tcl_ok=$enableval], [tcl_ok=no])
+    AC_ARG_ENABLE(symbols, [  --enable-symbols        build with debugging symbols (default: off)],    [tcl_ok=$enableval], [tcl_ok=no])
 # FIXME: Currently, LDFLAGS_DEFAULT is not used, it should work like CFLAGS_DEFAULT.
     if test "$tcl_ok" = "no"; then
 	CFLAGS_DEFAULT='$(CFLAGS_OPTIMIZE)'
@@ -784,7 +784,7 @@ AC_DEFUN([SC_ENABLE_SYMBOLS], [
 AC_DEFUN([SC_ENABLE_LANGINFO], [
     AC_ARG_ENABLE(langinfo,
 	[  --enable-langinfo	  use nl_langinfo if possible to determine
-			  encoding at startup, otherwise use old heuristic],
+			  encoding at startup, otherwise use old heuristic (default: on)],
 	[langinfo_ok=$enableval], [langinfo_ok=yes])
 
     HAVE_LANGINFO=0
@@ -835,7 +835,7 @@ AC_DEFUN([SC_ENABLE_LANGINFO], [
 AC_DEFUN([SC_CONFIG_MANPAGES], [
     AC_MSG_CHECKING([whether to use symlinks for manpages])
     AC_ARG_ENABLE(man-symlinks,
-	    [  --enable-man-symlinks   use symlinks for the manpages],
+	    [  --enable-man-symlinks   use symlinks for the manpages (default: off)],
 	test "$enableval" != "no" && MAN_FLAGS="$MAN_FLAGS --symlinks",
 	enableval="no")
     AC_MSG_RESULT([$enableval])
@@ -843,7 +843,7 @@ AC_DEFUN([SC_CONFIG_MANPAGES], [
     AC_MSG_CHECKING([whether to compress the manpages])
     AC_ARG_ENABLE(man-compression,
 	    [  --enable-man-compression=PROG
-		      compress the manpages with PROG],
+		      compress the manpages with PROG (default: off)],
 	[case $enableval in
 	    yes) AC_MSG_ERROR([missing argument to --enable-man-compression]);;
 	    no)  ;;
diff --git a/win/configure b/win/configure
index 062e8a4..51a86a7 100755
--- a/win/configure
+++ b/win/configure
@@ -12,9 +12,9 @@ ac_help=
 ac_default_prefix=/usr/local
 # Any additions from configure.in:
 ac_help="$ac_help
-  --enable-threads        build with threads"
+  --enable-threads        build with threads (default: off)"
 ac_help="$ac_help
-  --enable-shared         build and link with shared libraries [--enable-shared]"
+  --enable-shared         build and link with shared libraries (default: on)"
 ac_help="$ac_help
   --enable-64bit          enable 64bit support (where applicable)"
 ac_help="$ac_help
@@ -22,7 +22,7 @@ ac_help="$ac_help
 ac_help="$ac_help
   --with-celib=DIR        use Windows/CE support library from DIR"
 ac_help="$ac_help
-  --enable-symbols        build with debugging symbols [--disable-symbols]"
+  --enable-symbols        build with debugging symbols (default: off)"
 
 # Initialize some variables set by options.
 # The variables have the same names as the options, with
@@ -1907,6 +1907,7 @@ else
 #include "confdefs.h"
 
 #define WIN32_LEAN_AND_MEAN
+#define INCL_WINSOCK_API_TYPEDEFS 1
 #include <windows.h>
 #undef WIN32_LEAN_AND_MEAN
 #include <winsock2.h>
@@ -1917,7 +1918,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:1921: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1922: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   tcl_cv_lpfn_decls=yes
 else
@@ -1949,12 +1950,12 @@ fi
 # call it from inline asm code.
 
 echo $ac_n "checking for alloca declaration in malloc.h""... $ac_c" 1>&6
-echo "configure:1953: checking for alloca declaration in malloc.h" >&5
+echo "configure:1954: checking for alloca declaration in malloc.h" >&5
 if eval "test \"`echo '$''{'tcl_cv_malloc_decl_alloca'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1958 "configure"
+#line 1959 "configure"
 #include "confdefs.h"
 
 #include <malloc.h>
@@ -1968,7 +1969,7 @@ int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:1972: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1973: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   tcl_cv_malloc_decl_alloca=yes
 else
@@ -1999,7 +2000,7 @@ fi

     echo $ac_n "checking for build with symbols""... $ac_c" 1>&6
-echo "configure:2003: checking for build with symbols" >&5
+echo "configure:2004: checking for build with symbols" >&5
     # Check whether --enable-symbols or --disable-symbols was given.
 if test "${enable_symbols+set}" = set; then
   enableval="$enable_symbols"
@@ -2063,7 +2064,7 @@ TCL_DBGX=${DBGX}
 #--------------------------------------------------------------------
 
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:2067: checking how to run the C preprocessor" >&5
+echo "configure:2068: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -2078,13 +2079,13 @@ else
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 2082 "configure"
+#line 2083 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2088: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2089: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -2095,13 +2096,13 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 2099 "configure"
+#line 2100 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2105: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2106: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -2112,13 +2113,13 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -nologo -E"
   cat > conftest.$ac_ext <<EOF
-#line 2116 "configure"
+#line 2117 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2122: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2123: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -2144,17 +2145,17 @@ echo "$ac_t""$CPP" 1>&6
 
 ac_safe=`echo "errno.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for errno.h""... $ac_c" 1>&6
-echo "configure:2148: checking for errno.h" >&5
+echo "configure:2149: checking for errno.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2153 "configure"
+#line 2154 "configure"
 #include "confdefs.h"
 #include <errno.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2158: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2159: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
diff --git a/win/tcl.m4 b/win/tcl.m4
index 708efc48..d33bb48 100644
--- a/win/tcl.m4
+++ b/win/tcl.m4
@@ -3,50 +3,117 @@
 #
 #	Locate the tclConfig.sh file and perform a sanity check on
 #	the Tcl compile flags
-#	Currently a no-op for Windows
 #
 # Arguments:
-#	PATCH_LEVEL	The patch level for Tcl if any.
+#	none
 #
 # Results:
 #
 #	Adds the following arguments to configure:
 #		--with-tcl=...
 #
-#	Sets the following vars:
-#		TCL_BIN_DIR	Full path to the tclConfig.sh file
+#	Defines the following vars:
+#		TCL_BIN_DIR	Full path to the directory containing
+#				the tclConfig.sh file
 #------------------------------------------------------------------------
 
 AC_DEFUN([SC_PATH_TCLCONFIG], [
-    AC_MSG_CHECKING([the location of tclConfig.sh])
+    #
+    # Ok, lets find the tcl configuration
+    # First, look for one uninstalled.
+    # the alternative search directory is invoked by --with-tcl
+    #
 
-    if test -d ../../tcl8.4$1/win;  then
-	TCL_BIN_DIR_DEFAULT=../../tcl8.4$1/win
-    elif test -d ../../tcl8.4/win;  then
-	TCL_BIN_DIR_DEFAULT=../../tcl8.4/win
-    else
-	TCL_BIN_DIR_DEFAULT=../../tcl/win
-    fi
+    if test x"${no_tcl}" = x ; then
+	# we reset no_tcl in case something fails here
+	no_tcl=true
+	AC_ARG_WITH(tcl, [  --with-tcl              directory containing tcl configuration (tclConfig.sh)], with_tclconfig=${withval})
+	AC_MSG_CHECKING([for Tcl configuration])
+	AC_CACHE_VAL(ac_cv_c_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
+		    AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
+		fi
+	    fi
 
-    AC_ARG_WITH(tcl, [  --with-tcl=DIR          use Tcl 8.4 binaries from DIR],
-	    TCL_BIN_DIR=$withval, TCL_BIN_DIR=`cd $TCL_BIN_DIR_DEFAULT; pwd`)
-    if test ! -d $TCL_BIN_DIR; then
-	AC_MSG_ERROR(Tcl directory $TCL_BIN_DIR does not exist)
-    fi
-    if test ! -f $TCL_BIN_DIR/tclConfig.sh; then
-	if test ! -f $TCL_BIN_DIR/../unix/tclConfig.sh; then
-	    AC_MSG_ERROR(There is no tclConfig.sh in $TCL_BIN_DIR:  perhaps you did not specify the Tcl *build* directory (not the toplevel Tcl directory) or you forgot to configure Tcl?)
+	    # then check for a private Tcl installation
+	    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/win/tclConfig.sh" ; then
+			ac_cv_c_tclconfig="`(cd $i/win; 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 ${libdir} 2>/dev/null` \
+			`ls -d ${exec_prefix}/lib 2>/dev/null` \
+			`ls -d ${prefix}/lib 2>/dev/null` \
+			`ls -d C:/Tcl/lib 2>/dev/null` \
+			`ls -d C:/Progra~1/Tcl/lib 2>/dev/null` \
+			; do
+		    if test -f "$i/tclConfig.sh" ; then
+			ac_cv_c_tclconfig="`(cd $i; pwd)`"
+			break
+		    fi
+		done
+	    fi
+
+	    # check in a few other private locations
+	    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/win/tclConfig.sh" ; then
+		    ac_cv_c_tclconfig="`(cd $i/win; pwd)`"
+		    break
+		fi
+		done
+	    fi
+	])
+
+	if test x"${ac_cv_c_tclconfig}" = x ; then
+	    TCL_BIN_DIR="# no Tcl configs found"
+	    AC_MSG_ERROR([Can't find Tcl configuration definitions. Use --with-tcl to specify a directory containing tclConfig.sh])
+	else
+	    no_tcl=
+	    TCL_BIN_DIR="${ac_cv_c_tclconfig}"
+	    AC_MSG_RESULT([found ${TCL_BIN_DIR}/tclConfig.sh])
 	fi
-	TCL_BIN_DIR=`cd ${TCL_BIN_DIR}/../unix; pwd`
     fi
-    AC_MSG_RESULT($TCL_BIN_DIR/tclConfig.sh)
 ])
 
 #------------------------------------------------------------------------
 # SC_PATH_TKCONFIG --
 #
 #	Locate the tkConfig.sh file
-#	Currently a no-op for Windows
 #
 # Arguments:
 #	none
@@ -56,31 +123,102 @@ AC_DEFUN([SC_PATH_TCLCONFIG], [
 #	Adds the following arguments to configure:
 #		--with-tk=...
 #
-#	Sets the following vars:
-#		TK_BIN_DIR	Full path to the tkConfig.sh file
+#	Defines the following vars:
+#		TK_BIN_DIR	Full path to the directory containing
+#				the tkConfig.sh file
 #------------------------------------------------------------------------
 
 AC_DEFUN([SC_PATH_TKCONFIG], [
-    AC_MSG_CHECKING([the location of tkConfig.sh])
+    #
+    # Ok, lets find the tk configuration
+    # First, look for one uninstalled.
+    # the alternative search directory is invoked by --with-tk
+    #
 
-    if test -d ../../tk8.4$1/win;  then
-	TK_BIN_DIR_DEFAULT=../../tk8.4$1/win
-    elif test -d ../../tk8.4/win;  then
-	TK_BIN_DIR_DEFAULT=../../tk8.4/win
-    else
-	TK_BIN_DIR_DEFAULT=../../tk/win
-    fi
+    if test x"${no_tk}" = x ; then
+	# we reset no_tk in case something fails here
+	no_tk=true
+	AC_ARG_WITH(tk, [  --with-tk               directory containing tk configuration (tkConfig.sh)], with_tkconfig=${withval})
+	AC_MSG_CHECKING([for Tk configuration])
+	AC_CACHE_VAL(ac_cv_c_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
+		    AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
+		fi
+	    fi
 
-    AC_ARG_WITH(tk, [  --with-tk=DIR          use Tk 8.4 binaries from DIR],
-	    TK_BIN_DIR=$withval, TK_BIN_DIR=`cd $TK_BIN_DIR_DEFAULT; pwd`)
-    if test ! -d $TK_BIN_DIR; then
-	AC_MSG_ERROR(Tk directory $TK_BIN_DIR does not exist)
-    fi
-    if test ! -f $TK_BIN_DIR/tkConfig.sh; then
-	AC_MSG_ERROR(There is no tkConfig.sh in $TK_BIN_DIR:  perhaps you did not specify the Tk *build* directory (not the toplevel Tk directory) or you forgot to configure Tk?)
-    fi
+	    # then check for a private Tk library
+	    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/win/tkConfig.sh" ; then
+			ac_cv_c_tkconfig="`(cd $i/win; pwd)`"
+			break
+		    fi
+		done
+	    fi
 
-    AC_MSG_RESULT([$TK_BIN_DIR/tkConfig.sh])
+	    # check in a few common install locations
+	    if test x"${ac_cv_c_tkconfig}" = x ; then
+		for i in `ls -d ${libdir} 2>/dev/null` \
+			`ls -d ${exec_prefix}/lib 2>/dev/null` \
+			`ls -d ${prefix}/lib 2>/dev/null` \
+			`ls -d C:/Tcl/lib 2>/dev/null` \
+			`ls -d C:/Progra~1/Tcl/lib 2>/dev/null` \
+			; do
+		    if test -f "$i/tkConfig.sh" ; then
+			ac_cv_c_tkconfig="`(cd $i; pwd)`"
+			break
+		    fi
+		done
+	    fi
+
+	    # check in a few other private locations
+	    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/win/tkConfig.sh" ; then
+			ac_cv_c_tkconfig="`(cd $i/win; pwd)`"
+			break
+		    fi
+		done
+	    fi
+	])
+
+	if test x"${ac_cv_c_tkconfig}" = x ; then
+	    TK_BIN_DIR="# no Tk configs found"
+	    AC_MSG_ERROR([Can't find Tk configuration definitions. Use --with-tk to specify a directory containing tkConfig.sh])
+	else
+	    no_tk=
+	    TK_BIN_DIR="${ac_cv_c_tkconfig}"
+	    AC_MSG_RESULT([found ${TK_BIN_DIR}/tkConfig.sh])
+	fi
+    fi
 ])
 
 #------------------------------------------------------------------------
@@ -103,13 +241,13 @@ AC_DEFUN([SC_PATH_TKCONFIG], [
 #------------------------------------------------------------------------
 
 AC_DEFUN([SC_LOAD_TCLCONFIG], [
-    AC_MSG_CHECKING([for existence of $TCL_BIN_DIR/tclConfig.sh])
+    AC_MSG_CHECKING([for existence of ${TCL_BIN_DIR}/tclConfig.sh])
 
-    if test -f "$TCL_BIN_DIR/tclConfig.sh" ; then
+    if test -f "${TCL_BIN_DIR}/tclConfig.sh" ; then
         AC_MSG_RESULT([loading])
-	. $TCL_BIN_DIR/tclConfig.sh
+	. "${TCL_BIN_DIR}/tclConfig.sh"
     else
-        AC_MSG_RESULT([file not found])
+        AC_MSG_RESULT([could not find ${TCL_BIN_DIR}/tclConfig.sh])
     fi
 
     #
@@ -158,7 +296,6 @@ AC_DEFUN([SC_LOAD_TCLCONFIG], [
 # SC_LOAD_TKCONFIG --
 #
 #	Load the tkConfig.sh file
-#	Currently a no-op for Windows
 #
 # Arguments:
 #
@@ -172,13 +309,13 @@ AC_DEFUN([SC_LOAD_TCLCONFIG], [
 #------------------------------------------------------------------------
 
 AC_DEFUN([SC_LOAD_TKCONFIG], [
-    AC_MSG_CHECKING([for existence of $TK_BIN_DIR/tkConfig.sh])
+    AC_MSG_CHECKING([for existence of ${TK_BIN_DIR}/tkConfig.sh])
 
-    if test -f "$TK_BIN_DIR/tkConfig.sh" ; then
+    if test -f "${TK_BIN_DIR}/tkConfig.sh" ; then
         AC_MSG_RESULT([loading])
-	. $TK_BIN_DIR/tkConfig.sh
+	. "${TK_BIN_DIR}/tkConfig.sh"
     else
-        AC_MSG_RESULT([could not find $TK_BIN_DIR/tkConfig.sh])
+        AC_MSG_RESULT([could not find ${TK_BIN_DIR}/tkConfig.sh])
     fi

@@ -211,8 +348,8 @@ AC_DEFUN([SC_LOAD_TKCONFIG], [
 AC_DEFUN([SC_ENABLE_SHARED], [
     AC_MSG_CHECKING([how to build libraries])
     AC_ARG_ENABLE(shared,
-	[  --enable-shared         build and link with shared libraries [--enable-shared]],
-    [tcl_ok=$enableval], [tcl_ok=yes])
+	[  --enable-shared         build and link with shared libraries (default: on)],
+	[tcl_ok=$enableval], [tcl_ok=yes])
 
     if test "${enable_shared+set}" = set; then
 	enableval="$enable_shared"
@@ -227,7 +364,7 @@ AC_DEFUN([SC_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
 ])
 
@@ -250,7 +387,7 @@ AC_DEFUN([SC_ENABLE_SHARED], [
 
 AC_DEFUN([SC_ENABLE_THREADS], [
     AC_MSG_CHECKING(for building with threads)
-    AC_ARG_ENABLE(threads, [  --enable-threads        build with threads],
+    AC_ARG_ENABLE(threads, [  --enable-threads        build with threads (default: off)],
 	[tcl_ok=$enableval], [tcl_ok=no])
 
     if test "$tcl_ok" = "yes"; then
@@ -270,7 +407,7 @@ AC_DEFUN([SC_ENABLE_THREADS], [
 #------------------------------------------------------------------------
 # SC_ENABLE_SYMBOLS --
 #
-#	Specify if debugging symbols should be used
+#	Specify if debugging symbols should be used.
 #	Memory (TCL_MEM_DEBUG) and compile (TCL_COMPILE_DEBUG) debugging
 #	can also be enabled.
 #
@@ -297,7 +434,7 @@ AC_DEFUN([SC_ENABLE_THREADS], [
 
 AC_DEFUN([SC_ENABLE_SYMBOLS], [
     AC_MSG_CHECKING([for build with symbols])
-    AC_ARG_ENABLE(symbols, [  --enable-symbols        build with debugging symbols [--disable-symbols]],    [tcl_ok=$enableval], [tcl_ok=no])
+    AC_ARG_ENABLE(symbols, [  --enable-symbols        build with debugging symbols (default: off)],    [tcl_ok=$enableval], [tcl_ok=no])
 # FIXME: Currently, LDFLAGS_DEFAULT is not used, it should work like CFLAGS_DEFAULT.
     if test "$tcl_ok" = "no"; then
 	CFLAGS_DEFAULT='$(CFLAGS_OPTIMIZE)'
@@ -1065,8 +1202,11 @@ print("manifest needed")
 	# Could do a CHECK_PROG for mt, but should always be with MSVC8+
 	# Could add 'if test -f' check, but manifest should be created
 	# in this compiler case
-	VC_MANIFEST_EMBED_DLL="mt.exe -nologo -manifest \[$]@.manifest $1 -outputresource:\[$]@\;2"
-	VC_MANIFEST_EMBED_EXE="mt.exe -nologo -manifest \[$]@.manifest $1 -outputresource:\[$]@\;1"
+	# Add in a manifest argument that may be specified
+	# XXX Needs improvement so that the test for existence accounts
+	# XXX for a provided (known) manifest
+	VC_MANIFEST_EMBED_DLL="if test -f \[$]@.manifest ; then mt.exe -nologo -manifest \[$]@.manifest $1 -outputresource:\[$]@\;2 ; fi"
+	VC_MANIFEST_EMBED_EXE="if test -f \[$]@.manifest ; then mt.exe -nologo -manifest \[$]@.manifest $1 -outputresource:\[$]@\;1 ; fi"
 	result=yes
 	if test "x$1" != x ; then
 	    result="yes ($1)"
-- 
cgit v0.12