[Sumover-dev] [svn commit] r4144 - vic/branches/mpeg4

sumover-dev at cs.ucl.ac.uk sumover-dev at cs.ucl.ac.uk
Tue May 6 23:58:01 BST 2008


Author: douglask
Date: Tue May  6 23:57:51 2008
New Revision: 4144

Added:
   vic/branches/mpeg4/aclocal.m4
   vic/branches/mpeg4/tcl.m4
Removed:
   vic/branches/mpeg4/configure.in.x11
Modified:
   vic/branches/mpeg4/Makefile.in
   vic/branches/mpeg4/configure
   vic/branches/mpeg4/configure.in.head
   vic/branches/mpeg4/configure.in.tk

Log:
Later Tcl source distributions include a tcl.m4 file which has Tcl/Tk specific autoconf macros.

Using tcl.m4 is now the recommended approach to capture some important Tcl/Tk results in a configure script.

VIC wasn't able to build against Tcl/Tk 8.5, adding Tcl/Tk 8.5 support was a good opportunity for modifying configure.in to use tcl.m4.

configure.in.x11 is no longer required and has been deleted as tcl.m4 provides the X11 switches that were used to build the Tk that VIC is linking against.

To simplify things in Makefile.in and configure.in.tk, support for optionMenu.tcl and scrollbar.tcl filenames as supplied with Unix Tcl/Tk 7.5 and earlier has been dropped. Those files are now called optMenu.tcl and scrlbar.tcl respectively in newer versions of Tk. 


Modified: vic/branches/mpeg4/Makefile.in
==============================================================================
--- vic/branches/mpeg4/Makefile.in	(original)
+++ vic/branches/mpeg4/Makefile.in	Tue May  6 23:57:51 2008
@@ -80,7 +80,8 @@
 		$(LIBRARY_TK)/scale.tcl \
 		$(LIBRARY_TK)/tearoff.tcl \
 		$(LIBRARY_TK)/text.tcl \
-		@V_TKDOSNAMES@
+		$(LIBRARY_TK)/optMenu.tcl \
+		$(LIBRARY_TK)/scrlbar.tcl
 
 LIB_GRABBER = @V_LIB_GRABBER@
 INCLUDE_GRABBER = @V_INCLUDE_GRABBER@

Added: vic/branches/mpeg4/aclocal.m4
==============================================================================
--- (empty file)
+++ vic/branches/mpeg4/aclocal.m4	Tue May  6 23:57:51 2008
@@ -0,0 +1 @@
+builtin(include,tcl.m4)

Modified: vic/branches/mpeg4/configure
==============================================================================
--- vic/branches/mpeg4/configure	(original)
+++ vic/branches/mpeg4/configure	Tue May  6 23:57:51 2008
@@ -309,7 +309,7 @@
 # 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 build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX CPP EGREP V_INCLUDE_X11 V_LIB_X11 V_INCLUDE_TCL V_LIB_TCL V_LIBRARY_TCL V_TKDOSNAMES V_INCLUDE_TK V_LIB_TK V_LIBRARY_TK V_LIB_FFMPEG V_LIB_X264 V_INCLUDE_GRABBER V_LIB_GRABBER V_OBJ_GRABBER V_LIB_XIL V_OBJ_XIL V_OBJ V_LIB V_CODEC_LIB V_CPUDETECT_OBJ V_STATIC V_TAR_TARGET V_ALL V_CCOPT V_CCOPT_H261 V_TAR_EXTRA V_DEFINE V_SIGRET V_SHELL V_TARCMD V_INCLUDE V_BROKEN_OBJ V_OBJ_CRYPT LIBOBJS 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 build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX CPP EGREP TCL_VERSION TCL_PATCH_LEVEL 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 TK_VERSION TK_BIN_DIR TK_SRC_DIR TK_LIB_FILE TK_LIB_FLAG TK_LIB_SPEC TK_STUB_LIB_FILE TK_STUB_LIB_FLAG TK_STUB_LIB_SPEC V_INCLUDE_TCL V_LIBRARY_TCL V_LIB_TCL V_INCLUDE_TK V_LIBRARY_TK V_LIB_TK V_INCLUDE_X11 V_LIB_X11 V_LIB_FFMPEG V_LIB_X264 V_INCLUDE_GRABBER V_LIB_GRABBER V_OBJ_GRABBER V_LIB_XIL V_OBJ_XIL V_OBJ V_LIB V_CODEC_LIB V_CPUDETECT_OBJ V_STATIC V_TAR_TARGET V_ALL V_CCOPT V_CCOPT_H261 V_TAR_EXTRA V_DEFINE V_SIGRET V_SHELL V_TARCMD V_INCLUDE V_BROKEN_OBJ V_OBJ_CRYPT LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -872,10 +872,9 @@
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
 --with-fore=path	specify a pathname for fore atm
---with-ucltcl=path	specify a pathname for UCL's tcl
---with-tcl=path	specify a pathname for tcl
---with-ucltk=path	specify a pathname for UCL's tk
---with-tk=path	specify a pathname for tk
+  --with-tcl              directory containing tcl configuration
+                          (tclConfig.sh)
+  --with-tk               directory containing tk configuration (tkConfig.sh)
 --with-aix-shm=path	specify a pathname for the AIX shm X extension library file
 --with-qcam=dir     specify directory with qcam.h for Connectix QuickCam device driver
 --with-ffmpeginc=dir     specify the prefix directory of ffmpeg header
@@ -3709,856 +3708,546 @@
   aquatk=no
 fi;
 
-if test "$aquatk" != "yes" -a "$mingw" != "yes"; then
 
-xlibdirs="\
-	/usr/openwin/lib \
-	/usr/X11R6/lib64 \
-	/usr/lib64/X11R6 \
-	/usr/X11R6/lib \
-	/usr/lib/X11R6 \
-	/usr/X11R5/lib \
-	/usr/lib/X11R5 \
-	/usr/X11R4/lib \
-	/usr/lib/X11R4 \
-	/usr/local/lib \
-	/usr/X386/lib \
-	/usr/X11/lib \
-	/usr/unsupported/lib \
-	/import/X11R4/usr/lib"
-
-xincdirs="\
-	/usr/openwin/include \
-	/usr/X11R6/include \
-	/usr/include/X11R6 \
-	/usr/X11R5/include \
-	/usr/include/X11R5 \
-	/usr/X11R4/include \
-	/usr/include/X11R4 \
-	/usr/local/include \
-	/usr/X386/include \
-	/usr/X11/include \
-	/usr/lpp/X11/include \
-	/usr/unsupported/include \
-	/import/X11R4/include"
-
-
-echo "checking for X11 header files"
-if test "$x_includes" = NONE ; then
-	cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <X11/Intrinsic.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 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); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  x_includes=""
+    #
+    # Ok, lets find the tcl configuration
+    # First, look for one uninstalled.
+    # the alternative search directory is invoked by --with-tcl
+    #
+
+    if test x"${no_tcl}" = x ; then
+	# we reset no_tcl in case something fails here
+	no_tcl=true
+
+# Check whether --with-tcl or --without-tcl was given.
+if test "${with_tcl+set}" = set; then
+  withval="$with_tcl"
+  with_tclconfig=${withval}
+fi;
+	echo "$as_me:$LINENO: checking for Tcl configuration" >&5
+echo $ECHO_N "checking for Tcl configuration... $ECHO_C" >&6
+	if test "${ac_cv_c_tclconfig+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
 
-  x_includes=NONE
-fi
-rm -f conftest.err conftest.$ac_ext
-	if test "$x_includes" = NONE ; then
-	        for i in $xincdirs ; do
-			if test -r $i/X11/Intrinsic.h; then
-				x_includes=$i
-				break
-			fi
-	        done
-		if test "$x_includes" = NONE ; then
-			echo "can't find X includes"
-	       		exit 1
+
+	    # 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
+		    { { echo "$as_me:$LINENO: error: ${with_tclconfig} directory doesn't contain tclConfig.sh" >&5
+echo "$as_me: error: ${with_tclconfig} directory doesn't contain tclConfig.sh" >&2;}
+   { (exit 1); exit 1; }; }
 		fi
-	fi
-fi
-if test -n "$x_includes" ; then
-	V_INCLUDE_X11="-isystem $x_includes"
+	    fi
 
-fi
+	    # 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/unix/tclConfig.sh" ; then
+			ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
+			break
+		    fi
+		done
+	    fi
 
-echo "checking for X11 library archive"
-if test "$x_libraries" = NONE ; then
-	echo "$as_me:$LINENO: checking for XOpenDisplay in -lX11" >&5
-echo $ECHO_N "checking for XOpenDisplay in -lX11... $ECHO_C" >&6
-if test "${ac_cv_lib_X11_XOpenDisplay+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lX11  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
+	    # 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
 
-/* 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 XOpenDisplay ();
-int
-main ()
-{
-XOpenDisplay ();
-  ;
-  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
-  ac_cv_lib_X11_XOpenDisplay=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+	    # 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 /usr/local/lib 2>/dev/null` \
+			`ls -d /usr/contrib/lib 2>/dev/null` \
+			`ls -d /usr/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/unix/tclConfig.sh" ; then
+		    ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
+		    break
+		fi
+		done
+	    fi
 
-ac_cv_lib_X11_XOpenDisplay=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_X11_XOpenDisplay" >&5
-echo "${ECHO_T}$ac_cv_lib_X11_XOpenDisplay" >&6
-if test $ac_cv_lib_X11_XOpenDisplay = yes; then
-  x_libraries=""
-else
-  x_libraries=NONE
 fi
 
-	if test "$x_libraries" = NONE ; then
-		for i in $xlibdirs ; do
-			if test -r $i/libX11.a; then
-				x_libraries=$i
-				break
+
+	if test x"${ac_cv_c_tclconfig}" = x ; then
+	    TCL_BIN_DIR="# no Tcl configs found"
+	    { echo "$as_me:$LINENO: WARNING: Can't find Tcl configuration definitions" >&5
+echo "$as_me: WARNING: Can't find Tcl configuration definitions" >&2;}
+	    exit 0
+	else
+	    no_tcl=
+	    TCL_BIN_DIR=${ac_cv_c_tclconfig}
+	    echo "$as_me:$LINENO: result: found ${TCL_BIN_DIR}/tclConfig.sh" >&5
+echo "${ECHO_T}found ${TCL_BIN_DIR}/tclConfig.sh" >&6
+	fi
+    fi
+
+
+    echo "$as_me:$LINENO: checking for existence of ${TCL_BIN_DIR}/tclConfig.sh" >&5
+echo $ECHO_N "checking for existence of ${TCL_BIN_DIR}/tclConfig.sh... $ECHO_C" >&6
+
+    if test -f "${TCL_BIN_DIR}/tclConfig.sh" ; then
+        echo "$as_me:$LINENO: result: loading" >&5
+echo "${ECHO_T}loading" >&6
+	. "${TCL_BIN_DIR}/tclConfig.sh"
+    else
+        echo "$as_me:$LINENO: result: could not find ${TCL_BIN_DIR}/tclConfig.sh" >&5
+echo "${ECHO_T}could not find ${TCL_BIN_DIR}/tclConfig.sh" >&6
+    fi
+
+    # eval is required to do the TCL_DBGX substitution
+    eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
+    eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
+
+    # If the TCL_BIN_DIR is the build directory (not the install directory),
+    # then set the common variable name to the value of the build variables.
+    # For example, the variable TCL_LIB_SPEC will be set to the value
+    # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC
+    # instead of TCL_BUILD_LIB_SPEC since it will work with both an
+    # installed and uninstalled version of Tcl.
+    if test -f "${TCL_BIN_DIR}/Makefile" ; then
+        TCL_LIB_SPEC=${TCL_BUILD_LIB_SPEC}
+        TCL_STUB_LIB_SPEC=${TCL_BUILD_STUB_LIB_SPEC}
+        TCL_STUB_LIB_PATH=${TCL_BUILD_STUB_LIB_PATH}
+    elif test "`uname -s`" = "Darwin"; then
+	# If Tcl was built as a framework, attempt to use the libraries
+	# from the framework at the given location so that linking works
+	# against Tcl.framework installed in an arbitary location.
+	case ${TCL_DEFS} in
+	    *TCL_FRAMEWORK*)
+		if test -f "${TCL_BIN_DIR}/${TCL_LIB_FILE}"; then
+		    for i in "`cd ${TCL_BIN_DIR}; pwd`" \
+			     "`cd ${TCL_BIN_DIR}/../..; pwd`"; do
+			if test "`basename "$i"`" = "${TCL_LIB_FILE}.framework"; then
+			    TCL_LIB_SPEC="-F`dirname "$i"` -framework ${TCL_LIB_FILE}"
+			    break
 			fi
-       		done
-		if test "$x_libraries" = NONE ; then
-			echo "can't find X library"
-			exit 1
+		    done
 		fi
-	fi
-fi
+		if test -f "${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}"; then
+		    TCL_STUB_LIB_SPEC="-L${TCL_BIN_DIR} ${TCL_STUB_LIB_FLAG}"
+		    TCL_STUB_LIB_PATH="${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}"
+		fi
+		;;
+	esac
+    fi
 
-V_LIB_X11=-lX11
+    # eval is required to do the TCL_DBGX substitution
+    eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
+    eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
+    eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
+    eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
 
-if test -n "$V_SHM" ; then
-	if test -z "$x_libraries" ; then
-		echo "$as_me:$LINENO: checking for XShmAttach in -lXext" >&5
-echo $ECHO_N "checking for XShmAttach in -lXext... $ECHO_C" >&6
-if test "${ac_cv_lib_Xext_XShmAttach+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXext -lX11 $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
 
-/* 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 XShmAttach ();
-int
-main ()
-{
-XShmAttach ();
-  ;
-  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
-  ac_cv_lib_Xext_XShmAttach=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_lib_Xext_XShmAttach=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_Xext_XShmAttach" >&5
-echo "${ECHO_T}$ac_cv_lib_Xext_XShmAttach" >&6
-if test $ac_cv_lib_Xext_XShmAttach = yes; then
-  V_Xext="-lXext"
-else
-  V_Xext=NONE
-fi
 
-	else
-		echo "checking for libXext.a"
-		if test -f $x_libraries/libXext.a ; then
-			V_Xext="-lXext"
-		else
-			echo "warning: compiling without -lXext"
-		fi
-	fi
-	if test "$V_Xext" = NONE ; then
-		echo "warning: compiling without -lXext"
-	else
-		V_LIB_X11="$V_Xext $V_LIB_X11"
-	fi
-fi
 
-if test -n "$x_libraries" ; then
-	V_LIB_X11="-L$x_libraries $V_LIB_X11"
-	if test $solaris ; then
-		V_LIB_X11="-R$x_libraries $V_LIB_X11"
-	fi
-fi
 
 
-fi
 
 
-# Check whether --with-ucltcl or --without-ucltcl was given.
-if test "${with_ucltcl+set}" = set; then
-  withval="$with_ucltcl"
-  ucltcl=$withval
-else
-  ucltcl=""
-fi;
 
 
-# Check whether --with-tcl or --without-tcl was given.
-if test "${with_tcl+set}" = set; then
-  withval="$with_tcl"
-  d=$withval
+
+
+
+
+echo "$as_me:$LINENO: checking for a compatible version of Tcl" >&5
+echo $ECHO_N "checking for a compatible version of Tcl... $ECHO_C" >&6
+if test "${TCL_MAJOR_VERSION}" -gt 8  \
+  -o \( "${TCL_MAJOR_VERSION}" -eq 8 -a "${TCL_MINOR_VERSION}" -ge 4 \); then
+    echo "$as_me:$LINENO: result: Tcl ${TCL_VERSION}${TCL_PATCH_LEVEL}" >&5
+echo "${ECHO_T}Tcl ${TCL_VERSION}${TCL_PATCH_LEVEL}" >&6
+
+    if test "$aquatcl" = yes; then
+        echo "Using AquaTCL"
+        V_DEFINE="$V_DEFINE -DMAC_OSX_TCL"
+    fi
+
+elif test "${TCL_VERSION}" == "8.0" ; then
+    if test -f "${TCL_SRC_DIR}/generic/tcl2c.c" ; then
+        echo "$as_me:$LINENO: result: UCL Tcl ${TCL_VERSION}${TCL_PATCH_LEVEL}" >&5
+echo "${ECHO_T}UCL Tcl ${TCL_VERSION}${TCL_PATCH_LEVEL}" >&6
+    else
+        { { echo "$as_me:$LINENO: error: Found Tcl 8.0 which is not UCL Tcl 8.0" >&5
+echo "$as_me: error: Found Tcl 8.0 which is not UCL Tcl 8.0" >&2;}
+   { (exit 1); exit 1; }; }
+    fi
+
 else
-  d=""
+    { { echo "$as_me:$LINENO: error: Tcl $TCL_VERSION, compatible Tcl for VIC not found
+Use --with-tcl= option to indicate location of tclConfig.sh file for Tcl." >&5
+echo "$as_me: error: Tcl $TCL_VERSION, compatible Tcl for VIC not found
+Use --with-tcl= option to indicate location of tclConfig.sh file for Tcl." >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+
+    #
+    # Ok, lets find the tk configuration
+    # First, look for one uninstalled.
+    # the alternative search directory is invoked by --with-tk
+    #
+
+    if test x"${no_tk}" = x ; then
+	# we reset no_tk in case something fails here
+	no_tk=true
+
+# Check whether --with-tk or --without-tk was given.
+if test "${with_tk+set}" = set; then
+  withval="$with_tk"
+  with_tkconfig=${withval}
 fi;
+	echo "$as_me:$LINENO: checking for Tk configuration" >&5
+echo $ECHO_N "checking for Tk configuration... $ECHO_C" >&6
+	if test "${ac_cv_c_tkconfig+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
 
-if test "$aquatcl" == yes; then
-	echo "Using AquaTCL"
-        V_LIB_TCL="-framework Tcl"
-        V_DEFINE="$V_DEFINE -DMAC_OSX_TCL"
-        V_LIBRARY_TCL=/Library/Frameworks/Tcl.framework/Versions/8.4/Resources/Scripts
-        V_INCLUDE_TCL="-I/Library/Frameworks/Tcl.framework/Headers -I/Library/Frameworks/Tcl.framework/PrivateHeaders"
 
-elif test "$ucltcl" == yes; then
-	if test -z "$tcl"; then
-		# UCL defaults
-		ucltcl=../tcl-8.0
-	fi
-	if test ! -d "$ucltcl" ; then
-		echo "UCL tcl path: '$ucltcl' is not a directory"
-		exit 1
-	fi
-	V_INCLUDE_TCL="-I$ucltcl/generic"
-	case "$target" in
-	  *-*-freebsd*)
-		V_LIB_TCL="$ucltcl/unix/libtcl80.a"
-		;;
-	  *)
-		V_LIB_TCL="$ucltcl/unix/libtcl8.0.a"
-		;;
-	esac
+	    # 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
+			    { echo "$as_me:$LINENO: WARNING: --with-tk argument should refer to directory containing tkConfig.sh, not to tkConfig.sh itself" >&5
+echo "$as_me: WARNING: --with-tk argument should refer to directory containing tkConfig.sh, not to tkConfig.sh itself" >&2;}
+			    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
+		    { { echo "$as_me:$LINENO: error: ${with_tkconfig} directory doesn't contain tkConfig.sh" >&5
+echo "$as_me: error: ${with_tkconfig} directory doesn't contain tkConfig.sh" >&2;}
+   { (exit 1); exit 1; }; }
+		fi
+	    fi
 
-	V_LIBRARY_TCL=$ucltcl/library
-	echo "Using UCL's tcl-8.0: $ucltcl"
+	    # 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/unix/tkConfig.sh" ; then
+			ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
+			break
+		    fi
+		done
+	    fi
 
-elif test "$d" != "" ; then
-	echo "Not using UCL tcl - You're on your own!"
-	if test ! -d $d ; then
-		echo "'$d' is not a directory"
-		exit 1
-	fi
-	V_INCLUDE_TCL=-I$d/include
-	if test ! -r $d/include/tcl.h ; then
-		echo "can't find tcl.h in $d/include"
-		exit 1
-	fi
-	places="$d/lib64/libtcl8.4.so \
-		$d/lib64/libtcl8.4.dylib \
-		$d/lib64/libtcl8.4.a \
-		$d/lib64/libtcl.so \
-		$d/lib64/libtcl.dylib \
-		$d/lib64/libtcl.a \
-		$d/lib/libtcl8.4.so \
-		$d/lib/libtcl8.4.dylib \
-		$d/lib/libtcl8.4.a \
-		$d/lib/libtcl.so \
-		$d/lib/libtcl.dylib \
-		$d/lib/libtcl.a"
-	V_LIB_TCL=FAIL
-	for dir in $places; do
-		if test -r $dir ; then
-			V_LIB_TCL=$dir
+	    # 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
-	if test $V_LIB_TCL = FAIL ; then
-		echo "can't find libtcl.a in $d/lib"
-		exit 1
-	fi
-	places="$d/lib64/tcl-8.4 \
-		$d/lib64/tcl8.4 \
-		$d/lib64/tcl \
-		$d/lib/tcl-8.4 \
-		$d/lib/tcl8.4 \
-		$d/lib/tcl"
-	V_LIBRARY_TCL=FAIL
-	for dir in $places; do
-		if test -r $dir/init.tcl ; then
-			V_LIBRARY_TCL=$dir
+		    fi
+		done
+	    fi
+
+	    # 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 /usr/local/lib 2>/dev/null` \
+			`ls -d /usr/contrib/lib 2>/dev/null` \
+			`ls -d /usr/lib 2>/dev/null` \
+			; do
+		    if test -f "$i/tkConfig.sh" ; then
+			ac_cv_c_tkconfig=`(cd $i; pwd)`
 			break
-		fi
-	done
-	if test $V_LIBRARY_TCL = FAIL ; then
-		echo "can't find init.tcl in $d/lib/tcl"
-		exit 1
-	fi
-else
-	echo "Not using UCL tcl - You're on your own!"
-	cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <tcl.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 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); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
-  else
-    ac_cpp_err=
-  fi
-else
-  ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
-  V_INCLUDE_TCL=""
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+		    fi
+		done
+	    fi
 
-  V_INCLUDE_TCL=FAIL
-fi
-rm -f conftest.err conftest.$ac_ext
-	if test "$V_INCLUDE_TCL" = FAIL; then
-		echo "checking for tcl.h"
-		places="$PWD/../tcl-8.4 \
-			$PWD/../tcl8.4 \
-			$PWD/../tcl \
-			/usr/local/include/tcl8.4 \
-			/usr/src/local/tcl8.4 \
-			/usr/include/tcl8.4 \
-			/import/tcl/include/tcl8.4 \
-			$prefix/include \
-			$x_includes/tk \
-			$x_includes \
-			/usr/local/include \
-			/usr/contrib/include \
-			/usr/include"
-		for dir in $places; do
-			if test -r $dir/tcl.h ; then
-				V_INCLUDE_TCL=-I$dir
-			        break
-			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/unix/tkConfig.sh" ; then
+			ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
+			break
+		    fi
 		done
-		if test "$V_INCLUDE_TCL" = FAIL; then
-			echo "can't find tcl.h"
-			exit 1
-		fi
+	    fi
+
+fi
+
+
+	if test x"${ac_cv_c_tkconfig}" = x ; then
+	    TK_BIN_DIR="# no Tk configs found"
+	    { echo "$as_me:$LINENO: WARNING: Can't find Tk configuration definitions" >&5
+echo "$as_me: WARNING: Can't find Tk configuration definitions" >&2;}
+	    exit 0
+	else
+	    no_tk=
+	    TK_BIN_DIR=${ac_cv_c_tkconfig}
+	    echo "$as_me:$LINENO: result: found ${TK_BIN_DIR}/tkConfig.sh" >&5
+echo "${ECHO_T}found ${TK_BIN_DIR}/tkConfig.sh" >&6
 	fi
-	echo "$as_me:$LINENO: checking for main in -ltcl8.4" >&5
-echo $ECHO_N "checking for main in -ltcl8.4... $ECHO_C" >&6
-if test "${ac_cv_lib_tcl8_4_main+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ltcl8.4  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
+    fi
 
 
-int
-main ()
-{
-main ();
-  ;
-  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
-  ac_cv_lib_tcl8_4_main=yes
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+    echo "$as_me:$LINENO: checking for existence of ${TK_BIN_DIR}/tkConfig.sh" >&5
+echo $ECHO_N "checking for existence of ${TK_BIN_DIR}/tkConfig.sh... $ECHO_C" >&6
 
-ac_cv_lib_tcl8_4_main=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_tcl8_4_main" >&5
-echo "${ECHO_T}$ac_cv_lib_tcl8_4_main" >&6
-if test $ac_cv_lib_tcl8_4_main = yes; then
-  V_LIB_TCL="-ltcl8.4"
-else
-  V_LIB_TCL="FAIL"
-fi
-
-	if test "$V_LIB_TCL" = FAIL; then
-		echo "checking for libtcl.a"
-		places="$PWD/../tcl-8.4/unix \
-                        $PWD/../tcl8.4/unix \
-                        $PWD/../tcl/unix \
-			/usr/local/lib \
-			$prefix/lib \
-			$x_libraries \
-			/usr/contrib/lib \
-			/usr/local/lib \
-			/usr/lib \
-			$PWD/../tcl8.4 \
-			/usr/src/local/tcl8.4 \
-			/import/tcl/lib/tcl8.4"
-		for dir in $places; do
-			if test -r $dir/libtcl8.4.so -o -r $dir/libtcl8.4.dylib -o -r $dir/libtcl8.4.a; then
-				V_LIB_TCL="-L$dir -ltcl8.4"
-				break
-			fi
-			if test -r $dir/libtcl.so -o -r $dir/libtcl.dylib -o -r $dir/libtcl.a; then
-				V_LIB_TCL="-L$dir -ltcl"
-				break
-			fi
-		done
-		if test "$V_LIB_TCL" = FAIL; then
-			echo "can't find libtcl.a"
-			exit 1
-		else
-			if test $solaris ; then
-				V_LIB_TCL="-R$dir $V_LIB_TCL"
+    if test -f "${TK_BIN_DIR}/tkConfig.sh" ; then
+        echo "$as_me:$LINENO: result: loading" >&5
+echo "${ECHO_T}loading" >&6
+	. "${TK_BIN_DIR}/tkConfig.sh"
+    else
+        echo "$as_me:$LINENO: result: could not find ${TK_BIN_DIR}/tkConfig.sh" >&5
+echo "${ECHO_T}could not find ${TK_BIN_DIR}/tkConfig.sh" >&6
+    fi
+
+    # eval is required to do the TK_DBGX substitution
+    eval "TK_LIB_FILE=\"${TK_LIB_FILE}\""
+    eval "TK_STUB_LIB_FILE=\"${TK_STUB_LIB_FILE}\""
+
+    # If the TK_BIN_DIR is the build directory (not the install directory),
+    # then set the common variable name to the value of the build variables.
+    # For example, the variable TK_LIB_SPEC will be set to the value
+    # of TK_BUILD_LIB_SPEC. An extension should make use of TK_LIB_SPEC
+    # instead of TK_BUILD_LIB_SPEC since it will work with both an
+    # installed and uninstalled version of Tcl.
+    if test -f "${TK_BIN_DIR}/Makefile" ; then
+        TK_LIB_SPEC=${TK_BUILD_LIB_SPEC}
+        TK_STUB_LIB_SPEC=${TK_BUILD_STUB_LIB_SPEC}
+        TK_STUB_LIB_PATH=${TK_BUILD_STUB_LIB_PATH}
+    elif test "`uname -s`" = "Darwin"; then
+	# If Tk was built as a framework, attempt to use the libraries
+	# from the framework at the given location so that linking works
+	# against Tk.framework installed in an arbitary location.
+	case ${TK_DEFS} in
+	    *TK_FRAMEWORK*)
+		if test -f "${TK_BIN_DIR}/${TK_LIB_FILE}"; then
+		    for i in "`cd ${TK_BIN_DIR}; pwd`" \
+			     "`cd ${TK_BIN_DIR}/../..; pwd`"; do
+			if test "`basename "$i"`" = "${TK_LIB_FILE}.framework"; then
+			    TK_LIB_SPEC="-F`dirname "$i"` -framework ${TK_LIB_FILE}"
+			    break
 			fi
+		    done
 		fi
-	fi
-	echo "checking for tcl/init.tcl"
-	V_LIBRARY_TCL=FAIL
-	places="$PWD/../tcl-8.4/library \
-		$PWD/../tcl8.4/library \
-                $PWD/../tcl/library \
-		/System/Library/Frameworks/Tcl.framework/Versions/8.4/Resources/Scripts \
-		/usr/local/lib/tcl8.4 \
-		/usr/contrib/lib/tcl8.4 \
-		/usr/lib/tcl8.4 \
-		/usr/lib/tk/tcl8.4 \
-		/import/tcl/lib/tcl8.4 \
-		$prefix/lib/tcl8.4 \
-		$x_libraries/tcl8.4 \
-		/usr/local/lib/tcl \
-		/usr/lib/tcl \
-		$x_libraries/tcl"
-	for dir in $places; do
-		if test -r $dir/init.tcl; then
-			V_LIBRARY_TCL=$dir
-			break
+		if test -f "${TK_BIN_DIR}/${TK_STUB_LIB_FILE}"; then
+		    TK_STUB_LIB_SPEC="-L${TK_BIN_DIR} ${TK_STUB_LIB_FLAG}"
+		    TK_STUB_LIB_PATH="${TK_BIN_DIR}/${TK_STUB_LIB_FILE}"
 		fi
-	done
-	if test "$V_LIBRARY_TCL" = FAIL; then
-		echo "can't find tcl/init.tcl"
-		exit 1
-	fi
-fi
+		;;
+	esac
+    fi
 
+    # eval is required to do the TK_DBGX substitution
+    eval "TK_LIB_FLAG=\"${TK_LIB_FLAG}\""
+    eval "TK_LIB_SPEC=\"${TK_LIB_SPEC}\""
+    eval "TK_STUB_LIB_FLAG=\"${TK_STUB_LIB_FLAG}\""
+    eval "TK_STUB_LIB_SPEC=\"${TK_STUB_LIB_SPEC}\""
 
 
 
 
-# Check whether --with-ucltk or --without-ucltk was given.
-if test "${with_ucltk+set}" = set; then
-  withval="$with_ucltk"
-  ucltk=$withval
-else
-  ucltk=""
-fi;
 
 
-# Check whether --with-tk or --without-tk was given.
-if test "${with_tk+set}" = set; then
-  withval="$with_tk"
-  d=$withval
-else
-  d=""
-fi;
 
-if test "$aquatk" == yes; then
-	echo "Using AquaTk"
-        V_LIB_TK="-framework Tk"
-        V_DEFINE="$V_DEFINE -DMAC_OSX_TK"
-        V_LIBRARY_TK=/Library/Frameworks/Tk.framework/Versions/8.4/Resources/Scripts
-        V_INCLUDE_TK="-I/Library/Frameworks/Tk.framework/Headers -I/Library/Frameworks/Tk.framework/PrivateHeaders"
 
-elif test "$ucltk" == yes; then
-	if test -z "$tk"; then
-		# UCL defaults
-		ucltk=../tk-8.0
-	fi
-	if test ! -d "$ucltk" ; then
-		echo "UCL TK dir: '$ucltk' is not a directory"
-		exit 1
-	fi
-	V_INCLUDE_TK="-I$ucltk/generic"
 
-	case "$target" in
-	  *-*-freebsd*)
-		V_LIB_TK="$ucltk/unix/libtk80.a"
-		;;
-	  *)
-		V_LIB_TK="$ucltk/unix/libtk8.0.a"
-		;;
-	esac
-	V_LIBRARY_TK=$ucltk/library
-	echo "Using UCL's tk-8.0: $ucltk"
 
-elif test "$d" != "" ; then
-	echo "Not using UCL tk - You're on your own!"
-	if test ! -d $d ; then
-		echo "'$d' is not a directory"
-		exit 1
-	fi
-	V_INCLUDE_TK=-I$d/include
-	if test ! -r $d/include/tk.h ; then
-		echo "can't find tk.h in $d/include"
-		exit 1
-	fi
-	places="$d/lib64/libtk8.4.so \
-		$d/lib64/libtk8.4.a \
-		$d/lib64/libtk.so \
-		$d/lib64/libtk.a \
-		$d/lib/libtk8.4.so \
-		$d/lib/libtk8.4.a \
-		$d/lib/libtk.so \
-		$d/lib/libtk.a"
-	V_LIB_TK=FAIL
-	for dir in $places; do
-		if test -r $dir ; then
-			V_LIB_TK=$dir
-			break
-		fi
-	done
-	if test $V_LIB_TK = FAIL ; then
-		echo "can't find libtk.a in $d/lib"
-		exit 1
-	fi
-	places="$d/lib64/tk8.4 \
-		$d/lib64/tk \
-		$d/lib/tk8.4 \
-		$d/lib/tk"
-	V_LIBRARY_TK=FAIL
-	for dir in $places; do
-		if test -r $dir/tk.tcl ; then
-			V_LIBRARY_TK=$dir
-			break
-		fi
-	done
-	if test $V_LIBRARY_TK = FAIL ; then
-		echo "can't find tk.tcl in $d/lib/tk"
-		exit 1
-	fi
-else
-	echo "Not using UCL tk - You're on your own!"
-	cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-#include <tk.h>
-_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 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); } >/dev/null; then
-  if test -s conftest.err; then
-    ac_cpp_err=$ac_c_preproc_warn_flag
-    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
-  else
-    ac_cpp_err=
-  fi
+
+
+
+
+echo "$as_me:$LINENO: checking for a compatible version of Tk" >&5
+echo $ECHO_N "checking for a compatible version of Tk... $ECHO_C" >&6
+if test "${TCL_VERSION}" == "${TK_VERSION}"; then
+    echo "$as_me:$LINENO: result: Tk ${TK_VERSION}${TK_PATCH_LEVEL}" >&5
+echo "${ECHO_T}Tk ${TK_VERSION}${TK_PATCH_LEVEL}" >&6
+
+    if test "$aquatk" = yes; then
+        echo "Using AquaTk"
+        V_DEFINE="$V_DEFINE -DMAC_OSX_TK"
+    fi
+
 else
-  ac_cpp_err=yes
+    { { echo "$as_me:$LINENO: error: ${TCL_BIN_DIR}/tclConfig.sh is for Tcl ${TCL_VERSION}.
+${TK_BIN_DIR}/tkConfig.sh is for Tk ${TK_VERSION}.
+Tk ${TK_VERSION} needs Tcl ${TK_VERSION}
+Use --with-tcl= option to indicate location of tclConfig.sh file for Tcl.
+Use --with-tk= option to indicate location of tkConfig.sh file for Tk." >&5
+echo "$as_me: error: ${TCL_BIN_DIR}/tclConfig.sh is for Tcl ${TCL_VERSION}.
+${TK_BIN_DIR}/tkConfig.sh is for Tk ${TK_VERSION}.
+Tk ${TK_VERSION} needs Tcl ${TK_VERSION}
+Use --with-tcl= option to indicate location of tclConfig.sh file for Tcl.
+Use --with-tk= option to indicate location of tkConfig.sh file for Tk." >&2;}
+   { (exit 1); exit 1; }; }
 fi
-if test -z "$ac_cpp_err"; then
-  V_INCLUDE_TK=""
+
+if test -f "${TCL_BIN_DIR}/Makefile" ; then
+    # dealing with Tcl source tree
+    V_INCLUDE_TCL="-I${TCL_SRC_DIR}/generic"
+    V_LIBRARY_TCL="${TCL_SRC_DIR}/library"
+    V_LIB_TCL="-L${TCL_SRC_DIR}/unix ${TCL_LIB_FLAG}"
+
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+    # dealing with Tcl system install
+
+    if test -d "${TCL_BIN_DIR}/Headers" ; then
+        # Darwin / MacOS X
+        V_INCLUDE_TCL=-I${TCL_BIN_DIR}/Headers
+        V_LIBRARY_TCL=${TCL_BIN_DIR}/Resources/Scripts
+
+    else
+        V_INCLUDE_TCL=$TCL_INCLUDE_SPEC
 
-  V_INCLUDE_TK=FAIL
+        V_LIBRARY_TCL=FAIL
+        for dir in $TCL_PACKAGE_PATH; do
+            if test -r "${dir}/init.tcl" ; then
+                V_LIBRARY_TCL=$dir
+                break
+            elif test -r "${dir}/tcl${TCL_VERSION}/init.tcl" ; then
+                V_LIBRARY_TCL="${dir}/tcl${TCL_VERSION}"
+                break
+            fi
+        done
+        if test $V_LIBRARY_TCL = FAIL ; then
+            echo "can't find init.tcl in ${TCL_PACKAGE_PATH}"
+            exit 1
+        fi
+    fi
+    V_LIB_TCL=$TCL_LIB_SPEC
 fi
-rm -f conftest.err conftest.$ac_ext
-	if test "$V_INCLUDE_TK" = FAIL; then
-		echo "checking for tk.h"
-		V_INCLUDE_TK=""
-		places="$PWD/../tk8.4/generic \
-	                $PWD/../tk-8.4/generic \
-       		        $PWD/../tk/generic \
-			/usr/local/include \
-			$prefix/include \
-			/usr/contrib/include \
-			/usr/include/tcl \
-			/usr/include\
-			$x_includes/tk \
-			$x_includes \
-			$PWD/../tk8.4 \
-			/usr/src/local/tk8.4 \
-			/usr/include/tcl8.4 \
-			/import/tcl/include/tk8.4"
-		for dir in $places; do
-			if test -r $dir/tk.h ; then
-				V_INCLUDE_TK=-I$dir
-				break
-			fi
-		done
-		if test "$V_INCLUDE_TK" = FAIL; then
-			echo "can't find tk.h"
-			exit 1
-		fi
-	fi
-	echo "$as_me:$LINENO: checking for main in -ltk8.4" >&5
-echo $ECHO_N "checking for main in -ltk8.4... $ECHO_C" >&6
-if test "${ac_cv_lib_tk8_4_main+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ltk8.4  $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
 
 
-int
-main ()
-{
-main ();
-  ;
-  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
-  ac_cv_lib_tk8_4_main=yes
+
+
+
+
+if test -f "${TK_BIN_DIR}/Makefile" ; then
+    # dealing with Tk source tree
+    V_INCLUDE_TK="-I${TK_SRC_DIR}/generic"
+    V_LIBRARY_TK="${TK_SRC_DIR}/library"
+    V_LIB_TK="-L${TK_SRC_DIR}/unix ${TK_LIB_FLAG}"
+
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+    # dealing with Tk system install
 
-ac_cv_lib_tk8_4_main=no
-fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_tk8_4_main" >&5
-echo "${ECHO_T}$ac_cv_lib_tk8_4_main" >&6
-if test $ac_cv_lib_tk8_4_main = yes; then
-  V_LIB_TK="-ltk8.4"
-else
-  V_LIB_TK="FAIL"
-fi
-
-	if test "$V_LIB_TK" = FAIL; then
-		echo "checking for libtk8.4.a"
-		places="$PWD/../tk-8.4/unix \
-			$PWD/../tk8.4/unix \
-                	$PWD/../tk/unix \
-			/usr/local/lib \
-			/usr/contrib/lib \
-			/usr/lib \
-			/usr/lib/tk \
-			/import/tcl/lib \
-			$PWD/../tk8.4 \
-			/usr/src/local/tk8.4 \
-			$prefix/lib \
-			$x_libraries"
-		for dir in $places; do
-			if test -r $dir/libtk8.4.so -o -r $dir/libtk.dylib -o -r $dir/libtk8.4.a; then
-				V_LIB_TK="-L$dir -ltk8.4"
-				break
-			fi
-			if test -r $dir/libtk.so -o -r $dir/libtk.a; then
-				V_LIB_TK="-L$dir -ltk"
-				break
-			fi
-		done
-		if test "$V_LIB_TK" = FAIL; then
-			echo "can't find libtk.a"
-			exit 1
-		else
-			if test $solaris ; then
-				V_LIB_TK="-R$dir $V_LIB_TK"
-			fi
-		fi
-	fi
-	echo "checking for tk/tk.tcl"
-	V_LIBRARY_TK=FAIL
-	places="$PWD/../tk-8.4/library \
-		$PWD/../tk8.4/library \
-               	$PWD/../tk/library \
-		/usr/local/lib/tk8.4 \
-		/System/Library/Frameworks/Tk.framework/Versions/8.4/Resources/Scripts \
-		/usr/contrib/lib/tk8.4 \
-		/usr/lib/tk8.4 \
-		/usr/share/tk8.4 \
-		/usr/lib/tk/tk8.4 \
-		/import/tcl/lib/tk8.4 \
-		$prefix/lib/tk8.4 \
-		$x_libraries/tk8.4 \
-		$PWD/../tk8.4/library \
-		/usr/src/local/tk8.4/library \
-		/usr/local/lib/tk \
-		/usr/lib/tk \
-		$x_libraries/tk"
-	for dir in $places; do
-		if test -r $dir/tk.tcl; then
-			V_LIBRARY_TK=$dir
-			break
-		fi
-	done
-	if test "$V_LIBRARY_TK" = FAIL; then
-		echo "can't find tk/tk.tcl"
-		exit 1
-	fi
+    if test -d "${TK_BIN_DIR}/Headers" ; then
+        # Darwin / MacOS X
+
+        if test ! -f "${TK_BIN_DIR}/PrivateHeaders/tkInt.h" ; then
+            { { echo "$as_me:$LINENO: error: ${TK_BIN_DIR}/PrivateHeaders/tkInt.h not found.
+Use --with-tk= option to indicate location of tkConfig.sh file for a Tk
+which comes with the PrivateHeaders folder." >&5
+echo "$as_me: error: ${TK_BIN_DIR}/PrivateHeaders/tkInt.h not found.
+Use --with-tk= option to indicate location of tkConfig.sh file for a Tk
+which comes with the PrivateHeaders folder." >&2;}
+   { (exit 1); exit 1; }; }
+        fi
+
+        V_INCLUDE_TK="-I${TK_BIN_DIR}/Headers -I${TK_BIN_DIR}/PrivateHeaders"
+        V_LIBRARY_TK=${TK_BIN_DIR}/Resources/Scripts
+
+    else
+        V_INCLUDE_TK=$TK_INCLUDE_SPEC
+
+        V_LIBRARY_TK=FAIL
+        TK_PACKAGE_PATH=`echo $TCL_PACKAGE_PATH | sed 's/tcl/tk/g'`
+        TK_PACKAGE_PATH="$TK_PACKAGE_PATH $TCL_PACKAGE_PATH"
+        for dir in $TK_PACKAGE_PATH; do
+            if test -r "${dir}/tk.tcl" ; then
+                V_LIBRARY_TK=$dir
+                break
+            elif test -r "${dir}/tk${TK_VERSION}/tk.tcl" ; then
+                V_LIBRARY_TK="${dir}/tk${TK_VERSION}"
+                break
+            fi
+        done
+    fi
+
+    if test $V_LIBRARY_TK = FAIL ; then
+        echo "can't find tk.tcl in ${TK_PACKAGE_PATH}"
+        exit 1
+    fi
+    V_LIB_TK=$TK_LIB_SPEC
 fi
-if test -r $V_LIBRARY_TK/optionMenu.tcl ; then
-	V_TKDOSNAMES='$(LIBRARY_TK)/optionMenu.tcl $(LIBRARY_TK)/scrollbar.tcl'
-	V_NEED_DL=""
-else
-	V_TKDOSNAMES='$(LIBRARY_TK)/optMenu.tcl $(LIBRARY_TK)/scrlbar.tcl'
-	V_NEED_DL=YES
+
+V_INCLUDE_X11=$TK_XINCLUDES
+V_LIB_X11=$TK_XLIBSW
+
+# if using X11 shared memory add -lXext if not already supplied
+if test $V_SHM = "-DUSE_SHM" -a "$aquatcl" != yes -a "$mingw" != "yes"; then
+    echo $TK_XLIBSW | grep "\-lXext" > /dev/null 2>&1
+    if test $? -ne 0 ; then
+        V_LIB_X11="$V_LIB_X11 -lXext"
+    fi
 fi
 
 
@@ -4568,6 +4257,8 @@
 
 
 
+
+
 #XXX
 V_STATIC="-static"
 V_LIB_GRABBER=""
@@ -6483,12 +6174,12 @@
         V_STATIC=""
         V_BROKEN_OBJ=
         V_DEFINE="$V_DEFINE -DHAVE_IPV6 -DHAVE_FAST_INT"
-	V_LIB="$V_LIB -framework Carbon -framework QuickTime -lssl -lcrypto"
+        V_LIB="$V_LIB -framework Carbon -framework QuickTime"
         if test "$target_cpu" = powerpc; then
             V_CCOPT="-O2 $ppc_tune"
         fi
         OPSYS=macosx
-	;;
+        ;;
 esac
 
 case "$target" in
@@ -7401,15 +7092,33 @@
 s, at ac_ct_CXX@,$ac_ct_CXX,;t t
 s, at CPP@,$CPP,;t t
 s, at EGREP@,$EGREP,;t t
-s, at V_INCLUDE_X11@,$V_INCLUDE_X11,;t t
-s, at V_LIB_X11@,$V_LIB_X11,;t t
+s, at TCL_VERSION@,$TCL_VERSION,;t t
+s, at TCL_PATCH_LEVEL@,$TCL_PATCH_LEVEL,;t t
+s, at TCL_BIN_DIR@,$TCL_BIN_DIR,;t t
+s, at TCL_SRC_DIR@,$TCL_SRC_DIR,;t t
+s, at TCL_LIB_FILE@,$TCL_LIB_FILE,;t t
+s, at TCL_LIB_FLAG@,$TCL_LIB_FLAG,;t t
+s, at TCL_LIB_SPEC@,$TCL_LIB_SPEC,;t t
+s, at TCL_STUB_LIB_FILE@,$TCL_STUB_LIB_FILE,;t t
+s, at TCL_STUB_LIB_FLAG@,$TCL_STUB_LIB_FLAG,;t t
+s, at TCL_STUB_LIB_SPEC@,$TCL_STUB_LIB_SPEC,;t t
+s, at TK_VERSION@,$TK_VERSION,;t t
+s, at TK_BIN_DIR@,$TK_BIN_DIR,;t t
+s, at TK_SRC_DIR@,$TK_SRC_DIR,;t t
+s, at TK_LIB_FILE@,$TK_LIB_FILE,;t t
+s, at TK_LIB_FLAG@,$TK_LIB_FLAG,;t t
+s, at TK_LIB_SPEC@,$TK_LIB_SPEC,;t t
+s, at TK_STUB_LIB_FILE@,$TK_STUB_LIB_FILE,;t t
+s, at TK_STUB_LIB_FLAG@,$TK_STUB_LIB_FLAG,;t t
+s, at TK_STUB_LIB_SPEC@,$TK_STUB_LIB_SPEC,;t t
 s, at V_INCLUDE_TCL@,$V_INCLUDE_TCL,;t t
-s, at V_LIB_TCL@,$V_LIB_TCL,;t t
 s, at V_LIBRARY_TCL@,$V_LIBRARY_TCL,;t t
-s, at V_TKDOSNAMES@,$V_TKDOSNAMES,;t t
+s, at V_LIB_TCL@,$V_LIB_TCL,;t t
 s, at V_INCLUDE_TK@,$V_INCLUDE_TK,;t t
-s, at V_LIB_TK@,$V_LIB_TK,;t t
 s, at V_LIBRARY_TK@,$V_LIBRARY_TK,;t t
+s, at V_LIB_TK@,$V_LIB_TK,;t t
+s, at V_INCLUDE_X11@,$V_INCLUDE_X11,;t t
+s, at V_LIB_X11@,$V_LIB_X11,;t t
 s, at V_LIB_FFMPEG@,$V_LIB_FFMPEG,;t t
 s, at V_LIB_X264@,$V_LIB_X264,;t t
 s, at V_INCLUDE_GRABBER@,$V_INCLUDE_GRABBER,;t t

Modified: vic/branches/mpeg4/configure.in.head
==============================================================================
--- vic/branches/mpeg4/configure.in.head	(original)
+++ vic/branches/mpeg4/configure.in.head	Tue May  6 23:57:51 2008
@@ -91,7 +91,4 @@
 AC_ARG_ENABLE(aquatcl,  --disable-aquatcl	build with aquatcl enabled, aquatcl=no, )
 AC_ARG_ENABLE(aquatk,   --disable-aquatk	build with aquatk enabled, aquatk=no, )
 
-if test "$aquatk" != "yes" -a "$mingw" != "yes"; then
-builtin(include, configure.in.x11)
-fi
 builtin(include, configure.in.tk)

Modified: vic/branches/mpeg4/configure.in.tk
==============================================================================
--- vic/branches/mpeg4/configure.in.tk	(original)
+++ vic/branches/mpeg4/configure.in.tk	Tue May  6 23:57:51 2008
@@ -1,366 +1,147 @@
-dnl autoconf rules to find tcl & tk 
-dnl $Header$ (LBL)
+SC_PATH_TCLCONFIG
+SC_LOAD_TCLCONFIG
 
-AC_ARG_WITH(ucltcl,	--with-ucltcl=path	specify a pathname for UCL's tcl, ucltcl=$withval, ucltcl="")
+AC_MSG_CHECKING([for a compatible version of Tcl])
+if test "${TCL_MAJOR_VERSION}" -gt 8  \
+  -o \( "${TCL_MAJOR_VERSION}" -eq 8 -a "${TCL_MINOR_VERSION}" -ge 4 \); then
+    AC_MSG_RESULT([Tcl ${TCL_VERSION}${TCL_PATCH_LEVEL}])
 
-AC_ARG_WITH(tcl,	--with-tcl=path	specify a pathname for tcl, d=$withval, d="")
-
-if test "$aquatcl" == yes; then
-	echo "Using AquaTCL"
-        V_LIB_TCL="-framework Tcl"
+    if test "$aquatcl" = yes; then
+        echo "Using AquaTCL"
         V_DEFINE="$V_DEFINE -DMAC_OSX_TCL"
-        V_LIBRARY_TCL=/Library/Frameworks/Tcl.framework/Versions/8.4/Resources/Scripts
-        V_INCLUDE_TCL="-I/Library/Frameworks/Tcl.framework/Headers -I/Library/Frameworks/Tcl.framework/PrivateHeaders"
+    fi
+
+elif test "${TCL_VERSION}" == "8.0" ; then
+    if test -f "${TCL_SRC_DIR}/generic/tcl2c.c" ; then
+        AC_MSG_RESULT([UCL Tcl ${TCL_VERSION}${TCL_PATCH_LEVEL}])
+    else
+        AC_MSG_ERROR([Found Tcl 8.0 which is not UCL Tcl 8.0])
+    fi
 
-elif test "$ucltcl" == yes; then
-	if test -z "$tcl"; then 
-		# UCL defaults
-		ucltcl=../tcl-8.0
-	fi
-	if test ! -d "$ucltcl" ; then
-		echo "UCL tcl path: '$ucltcl' is not a directory"
-		exit 1
-	fi
-	V_INCLUDE_TCL="-I$ucltcl/generic"
-	case "$target" in 
-	  *-*-freebsd*)
-		V_LIB_TCL="$ucltcl/unix/libtcl80.a"
-		;;
-	  *)
-		V_LIB_TCL="$ucltcl/unix/libtcl8.0.a"
-		;;
-	esac
-
-	V_LIBRARY_TCL=$ucltcl/library
-	echo "Using UCL's tcl-8.0: $ucltcl"
-		
-elif test "$d" != "" ; then 
-	echo "Not using UCL tcl - You're on your own!"
-	if test ! -d $d ; then 
-		echo "'$d' is not a directory"
-		exit 1
-	fi
-	V_INCLUDE_TCL=-I$d/include
-	if test ! -r $d/include/tcl.h ; then
-		echo "can't find tcl.h in $d/include"
-		exit 1
-	fi
-	places="$d/lib64/libtcl8.4.so \
-		$d/lib64/libtcl8.4.dylib \
-		$d/lib64/libtcl8.4.a \
-		$d/lib64/libtcl.so \
-		$d/lib64/libtcl.dylib \
-		$d/lib64/libtcl.a \
-		$d/lib/libtcl8.4.so \
-		$d/lib/libtcl8.4.dylib \
-		$d/lib/libtcl8.4.a \
-		$d/lib/libtcl.so \
-		$d/lib/libtcl.dylib \
-		$d/lib/libtcl.a"
-	V_LIB_TCL=FAIL
-	for dir in $places; do
-		if test -r $dir ; then
-			V_LIB_TCL=$dir
-			break
-		fi
-	done
-	if test $V_LIB_TCL = FAIL ; then
-		echo "can't find libtcl.a in $d/lib"
-		exit 1
-	fi
-	places="$d/lib64/tcl-8.4 \
-		$d/lib64/tcl8.4 \
-		$d/lib64/tcl \
-		$d/lib/tcl-8.4 \
-		$d/lib/tcl8.4 \
-		$d/lib/tcl"
-	V_LIBRARY_TCL=FAIL
-	for dir in $places; do
-		if test -r $dir/init.tcl ; then
-			V_LIBRARY_TCL=$dir
-			break
-		fi
-	done
-	if test $V_LIBRARY_TCL = FAIL ; then
-		echo "can't find init.tcl in $d/lib/tcl"
-		exit 1
-	fi
 else
-	echo "Not using UCL tcl - You're on your own!"
-	AC_TEST_CPP([#include <tcl.h>], V_INCLUDE_TCL="", V_INCLUDE_TCL=FAIL)
-	if test "$V_INCLUDE_TCL" = FAIL; then
-		echo "checking for tcl.h"
-		places="$PWD/../tcl-8.4 \
-			$PWD/../tcl8.4 \
-			$PWD/../tcl \
-			/usr/local/include/tcl8.4 \
-			/usr/src/local/tcl8.4 \
-			/usr/include/tcl8.4 \
-			/import/tcl/include/tcl8.4 \
-			$prefix/include \
-			$x_includes/tk \
-			$x_includes \
-			/usr/local/include \
-			/usr/contrib/include \
-			/usr/include"
-		for dir in $places; do
-			if test -r $dir/tcl.h ; then
-				V_INCLUDE_TCL=-I$dir
-			        break
-			fi
-		done
-		if test "$V_INCLUDE_TCL" = FAIL; then
-			echo "can't find tcl.h"
-			exit 1
-		fi
-	fi
-	AC_CHECK_LIB(tcl8.4, main, V_LIB_TCL="-ltcl8.4", V_LIB_TCL="FAIL")
-	if test "$V_LIB_TCL" = FAIL; then
-		echo "checking for libtcl.a"
-		places="$PWD/../tcl-8.4/unix \
-                        $PWD/../tcl8.4/unix \
-                        $PWD/../tcl/unix \
-			/usr/local/lib \
-			$prefix/lib \
-			$x_libraries \
-			/usr/contrib/lib \
-			/usr/local/lib \
-			/usr/lib \
-			$PWD/../tcl8.4 \
-			/usr/src/local/tcl8.4 \
-			/import/tcl/lib/tcl8.4"
-		for dir in $places; do
-			if test -r $dir/libtcl8.4.so -o -r $dir/libtcl8.4.dylib -o -r $dir/libtcl8.4.a; then
-				V_LIB_TCL="-L$dir -ltcl8.4"
-				break
-			fi
-			if test -r $dir/libtcl.so -o -r $dir/libtcl.dylib -o -r $dir/libtcl.a; then
-				V_LIB_TCL="-L$dir -ltcl"
-				break
-			fi
-		done
-		if test "$V_LIB_TCL" = FAIL; then
-			echo "can't find libtcl.a"
-			exit 1
-		else
-			if test $solaris ; then
-				V_LIB_TCL="-R$dir $V_LIB_TCL"
-			fi
-		fi
-	fi
-	echo "checking for tcl/init.tcl"
-	V_LIBRARY_TCL=FAIL
-	places="$PWD/../tcl-8.4/library \
-		$PWD/../tcl8.4/library \
-                $PWD/../tcl/library \
-		/System/Library/Frameworks/Tcl.framework/Versions/8.4/Resources/Scripts \
-		/usr/local/lib/tcl8.4 \
-		/usr/contrib/lib/tcl8.4 \
-		/usr/lib/tcl8.4 \
-		/usr/lib/tk/tcl8.4 \
-		/import/tcl/lib/tcl8.4 \
-		$prefix/lib/tcl8.4 \
-		$x_libraries/tcl8.4 \
-		/usr/local/lib/tcl \
-		/usr/lib/tcl \
-		$x_libraries/tcl"
-	for dir in $places; do
-		if test -r $dir/init.tcl; then
-			V_LIBRARY_TCL=$dir
-			break
-		fi
-	done
-	if test "$V_LIBRARY_TCL" = FAIL; then
-		echo "can't find tcl/init.tcl"
-		exit 1
-	fi
+    AC_MSG_ERROR([Tcl $TCL_VERSION, compatible Tcl for VIC not found
+Use --with-tcl= option to indicate location of tclConfig.sh file for Tcl.])
 fi
-AC_SUBST(V_INCLUDE_TCL)
-AC_SUBST(V_LIB_TCL)
-AC_SUBST(V_LIBRARY_TCL)
 
-AC_ARG_WITH(ucltk,	--with-ucltk=path	specify a pathname for UCL's tk, ucltk=$withval, ucltk="")
+SC_PATH_TKCONFIG
+SC_LOAD_TKCONFIG
 
-AC_ARG_WITH(tk,	--with-tk=path	specify a pathname for tk, d=$withval, d="")
+AC_MSG_CHECKING([for a compatible version of Tk])
+if test "${TCL_VERSION}" == "${TK_VERSION}"; then
+    AC_MSG_RESULT([Tk ${TK_VERSION}${TK_PATCH_LEVEL}])
 
-if test "$aquatk" == yes; then
-	echo "Using AquaTk"
-        V_LIB_TK="-framework Tk"
+    if test "$aquatk" = yes; then
+        echo "Using AquaTk"
         V_DEFINE="$V_DEFINE -DMAC_OSX_TK"
-        V_LIBRARY_TK=/Library/Frameworks/Tk.framework/Versions/8.4/Resources/Scripts
-        V_INCLUDE_TK="-I/Library/Frameworks/Tk.framework/Headers -I/Library/Frameworks/Tk.framework/PrivateHeaders"
+    fi
 
-elif test "$ucltk" == yes; then
-	if test -z "$tk"; then 
-		# UCL defaults
-		ucltk=../tk-8.0
-	fi
-	if test ! -d "$ucltk" ; then
-		echo "UCL TK dir: '$ucltk' is not a directory"
-		exit 1
-	fi
-	V_INCLUDE_TK="-I$ucltk/generic"
-
-	case "$target" in 
-	  *-*-freebsd*)
-		V_LIB_TK="$ucltk/unix/libtk80.a"
-		;;
-	  *)
-		V_LIB_TK="$ucltk/unix/libtk8.0.a"
-		;;
-	esac
-	V_LIBRARY_TK=$ucltk/library
-	echo "Using UCL's tk-8.0: $ucltk"
-		
-elif test "$d" != "" ; then 
-	echo "Not using UCL tk - You're on your own!"
-	if test ! -d $d ; then 
-		echo "'$d' is not a directory"
-		exit 1
-	fi
-	V_INCLUDE_TK=-I$d/include
-	if test ! -r $d/include/tk.h ; then
-		echo "can't find tk.h in $d/include"
-		exit 1
-	fi
-	places="$d/lib64/libtk8.4.so \
-		$d/lib64/libtk8.4.a \
-		$d/lib64/libtk.so \
-		$d/lib64/libtk.a \
-		$d/lib/libtk8.4.so \
-		$d/lib/libtk8.4.a \
-		$d/lib/libtk.so \
-		$d/lib/libtk.a"
-	V_LIB_TK=FAIL
-	for dir in $places; do
-		if test -r $dir ; then
-			V_LIB_TK=$dir
-			break
-		fi
-	done
-	if test $V_LIB_TK = FAIL ; then
-		echo "can't find libtk.a in $d/lib"
-		exit 1
-	fi
-	places="$d/lib64/tk8.4 \
-		$d/lib64/tk \
-		$d/lib/tk8.4 \
-		$d/lib/tk"
-	V_LIBRARY_TK=FAIL
-	for dir in $places; do
-		if test -r $dir/tk.tcl ; then
-			V_LIBRARY_TK=$dir
-			break
-		fi
-	done
-	if test $V_LIBRARY_TK = FAIL ; then
-		echo "can't find tk.tcl in $d/lib/tk"
-		exit 1
-	fi
 else
-	echo "Not using UCL tk - You're on your own!"
-	AC_TEST_CPP([#include <tk.h>], V_INCLUDE_TK="", V_INCLUDE_TK=FAIL)
-	if test "$V_INCLUDE_TK" = FAIL; then
-		echo "checking for tk.h"
-		V_INCLUDE_TK=""
-		places="$PWD/../tk8.4/generic \
-	                $PWD/../tk-8.4/generic \
-       		        $PWD/../tk/generic \
-			/usr/local/include \
-			$prefix/include \
-			/usr/contrib/include \
-			/usr/include/tcl \
-			/usr/include\
-			$x_includes/tk \
-			$x_includes \
-			$PWD/../tk8.4 \
-			/usr/src/local/tk8.4 \
-			/usr/include/tcl8.4 \
-			/import/tcl/include/tk8.4"
-		for dir in $places; do
-			if test -r $dir/tk.h ; then
-				V_INCLUDE_TK=-I$dir
-				break
-			fi
-		done
-		if test "$V_INCLUDE_TK" = FAIL; then
-			echo "can't find tk.h"
-			exit 1
-		fi
-	fi
-	AC_CHECK_LIB(tk8.4, main, V_LIB_TK="-ltk8.4", V_LIB_TK="FAIL")
-	if test "$V_LIB_TK" = FAIL; then
-		echo "checking for libtk8.4.a"
-		places="$PWD/../tk-8.4/unix \
-			$PWD/../tk8.4/unix \
-                	$PWD/../tk/unix \
-			/usr/local/lib \
-			/usr/contrib/lib \
-			/usr/lib \
-			/usr/lib/tk \
-			/import/tcl/lib \
-			$PWD/../tk8.4 \
-			/usr/src/local/tk8.4 \
-			$prefix/lib \
-			$x_libraries"
-		for dir in $places; do
-			if test -r $dir/libtk8.4.so -o -r $dir/libtk.dylib -o -r $dir/libtk8.4.a; then
-				V_LIB_TK="-L$dir -ltk8.4"
-				break
-			fi
-			if test -r $dir/libtk.so -o -r $dir/libtk.a; then
-				V_LIB_TK="-L$dir -ltk"
-				break
-			fi
-		done
-		if test "$V_LIB_TK" = FAIL; then	
-			echo "can't find libtk.a"
-			exit 1
-		else
-			if test $solaris ; then
-				V_LIB_TK="-R$dir $V_LIB_TK"
-			fi
-		fi
-	fi
-	echo "checking for tk/tk.tcl"
-	V_LIBRARY_TK=FAIL
-	places="$PWD/../tk-8.4/library \
-		$PWD/../tk8.4/library \
-               	$PWD/../tk/library \
-		/usr/local/lib/tk8.4 \
-		/System/Library/Frameworks/Tk.framework/Versions/8.4/Resources/Scripts \
-		/usr/contrib/lib/tk8.4 \
-		/usr/lib/tk8.4 \
-		/usr/share/tk8.4 \
-		/usr/lib/tk/tk8.4 \
-		/import/tcl/lib/tk8.4 \
-		$prefix/lib/tk8.4 \
-		$x_libraries/tk8.4 \
-		$PWD/../tk8.4/library \
-		/usr/src/local/tk8.4/library \
-		/usr/local/lib/tk \
-		/usr/lib/tk \
-		$x_libraries/tk"
-	for dir in $places; do
-		if test -r $dir/tk.tcl; then
-			V_LIBRARY_TK=$dir
-			break
-		fi
-	done
-	if test "$V_LIBRARY_TK" = FAIL; then
-		echo "can't find tk/tk.tcl"
-		exit 1
-	fi
+    AC_MSG_ERROR([${TCL_BIN_DIR}/tclConfig.sh is for Tcl ${TCL_VERSION}.
+${TK_BIN_DIR}/tkConfig.sh is for Tk ${TK_VERSION}.
+Tk ${TK_VERSION} needs Tcl ${TK_VERSION}
+Use --with-tcl= option to indicate location of tclConfig.sh file for Tcl.
+Use --with-tk= option to indicate location of tkConfig.sh file for Tk.])
 fi
-if test -r $V_LIBRARY_TK/optionMenu.tcl ; then
-	V_TKDOSNAMES='$(LIBRARY_TK)/optionMenu.tcl $(LIBRARY_TK)/scrollbar.tcl'
-	V_NEED_DL=""
+
+if test -f "${TCL_BIN_DIR}/Makefile" ; then
+    # dealing with Tcl source tree
+    V_INCLUDE_TCL="-I${TCL_SRC_DIR}/generic"
+    V_LIBRARY_TCL="${TCL_SRC_DIR}/library"
+    V_LIB_TCL="-L${TCL_SRC_DIR}/unix ${TCL_LIB_FLAG}"
+
 else
-	V_TKDOSNAMES='$(LIBRARY_TK)/optMenu.tcl $(LIBRARY_TK)/scrlbar.tcl'
-	V_NEED_DL=YES
+    # dealing with Tcl system install
+
+    if test -d "${TCL_BIN_DIR}/Headers" ; then
+        # Darwin / MacOS X
+        V_INCLUDE_TCL=-I${TCL_BIN_DIR}/Headers
+        V_LIBRARY_TCL=${TCL_BIN_DIR}/Resources/Scripts
+
+    else
+        V_INCLUDE_TCL=$TCL_INCLUDE_SPEC
+
+        V_LIBRARY_TCL=FAIL
+        for dir in $TCL_PACKAGE_PATH; do
+            if test -r "${dir}/init.tcl" ; then
+                V_LIBRARY_TCL=$dir
+                break
+            elif test -r "${dir}/tcl${TCL_VERSION}/init.tcl" ; then
+                V_LIBRARY_TCL="${dir}/tcl${TCL_VERSION}"
+                break
+            fi
+        done
+        if test $V_LIBRARY_TCL = FAIL ; then
+            echo "can't find init.tcl in ${TCL_PACKAGE_PATH}"
+            exit 1
+        fi
+    fi
+    V_LIB_TCL=$TCL_LIB_SPEC
 fi
-AC_SUBST(V_TKDOSNAMES)
+
+AC_SUBST(V_INCLUDE_TCL)
+AC_SUBST(V_LIBRARY_TCL)
+AC_SUBST(V_LIB_TCL)
+
+
+if test -f "${TK_BIN_DIR}/Makefile" ; then
+    # dealing with Tk source tree
+    V_INCLUDE_TK="-I${TK_SRC_DIR}/generic"
+    V_LIBRARY_TK="${TK_SRC_DIR}/library"
+    V_LIB_TK="-L${TK_SRC_DIR}/unix ${TK_LIB_FLAG}"
+
+else
+    # dealing with Tk system install
+
+    if test -d "${TK_BIN_DIR}/Headers" ; then
+        # Darwin / MacOS X
+
+        if test ! -f "${TK_BIN_DIR}/PrivateHeaders/tkInt.h" ; then
+            AC_MSG_ERROR([${TK_BIN_DIR}/PrivateHeaders/tkInt.h not found.
+Use --with-tk= option to indicate location of tkConfig.sh file for a Tk
+which comes with the PrivateHeaders folder.])
+        fi
+
+        V_INCLUDE_TK="-I${TK_BIN_DIR}/Headers -I${TK_BIN_DIR}/PrivateHeaders"
+        V_LIBRARY_TK=${TK_BIN_DIR}/Resources/Scripts
+
+    else
+        V_INCLUDE_TK=$TK_INCLUDE_SPEC
+
+        V_LIBRARY_TK=FAIL
+        TK_PACKAGE_PATH=`echo $TCL_PACKAGE_PATH | sed 's/tcl/tk/g'`
+        TK_PACKAGE_PATH="$TK_PACKAGE_PATH $TCL_PACKAGE_PATH"
+        for dir in $TK_PACKAGE_PATH; do
+            if test -r "${dir}/tk.tcl" ; then
+                V_LIBRARY_TK=$dir
+                break
+            elif test -r "${dir}/tk${TK_VERSION}/tk.tcl" ; then
+                V_LIBRARY_TK="${dir}/tk${TK_VERSION}"
+                break
+            fi
+        done
+    fi
+
+    if test $V_LIBRARY_TK = FAIL ; then
+        echo "can't find tk.tcl in ${TK_PACKAGE_PATH}"
+        exit 1
+    fi
+    V_LIB_TK=$TK_LIB_SPEC
+fi
+
+V_INCLUDE_X11=$TK_XINCLUDES
+V_LIB_X11=$TK_XLIBSW
+
+# if using X11 shared memory add -lXext if not already supplied
+if test $V_SHM = "-DUSE_SHM" -a "$aquatcl" != yes -a "$mingw" != "yes"; then
+    echo $TK_XLIBSW | grep "\-lXext" > /dev/null 2>&1
+    if test $? -ne 0 ; then
+        V_LIB_X11="$V_LIB_X11 -lXext"
+    fi
+fi
+
 AC_SUBST(V_INCLUDE_TK)
-AC_SUBST(V_LIB_TK)
 AC_SUBST(V_LIBRARY_TK)
+AC_SUBST(V_LIB_TK)
 
+AC_SUBST(V_INCLUDE_X11)
+AC_SUBST(V_LIB_X11)

Added: vic/branches/mpeg4/tcl.m4
==============================================================================
--- (empty file)
+++ vic/branches/mpeg4/tcl.m4	Tue May  6 23:57:51 2008
@@ -0,0 +1,481 @@
+#------------------------------------------------------------------------
+# SC_PATH_TCLCONFIG --
+#
+#	Locate the tclConfig.sh file and perform a sanity check on
+#	the Tcl compile flags
+#
+# Arguments:
+#	none
+#
+# Results:
+#
+#	Adds the following arguments to configure:
+#		--with-tcl=...
+#
+#	Defines the following vars:
+#		TCL_BIN_DIR	Full path to the directory containing
+#				the tclConfig.sh file
+#------------------------------------------------------------------------
+
+AC_DEFUN([SC_PATH_TCLCONFIG], [
+    #
+    # Ok, lets find the tcl configuration
+    # First, look for one uninstalled.
+    # the alternative search directory is invoked by --with-tcl
+    #
+
+    if test x"${no_tcl}" = x ; then
+	# we reset no_tcl in case something fails here
+	no_tcl=true
+	AC_ARG_WITH(tcl,
+	    AC_HELP_STRING([--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
+
+	    # 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/unix/tclConfig.sh" ; then
+			ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
+			break
+		    fi
+		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 ${libdir} 2>/dev/null` \
+			`ls -d ${exec_prefix}/lib 2>/dev/null` \
+			`ls -d ${prefix}/lib 2>/dev/null` \
+			`ls -d /usr/local/lib 2>/dev/null` \
+			`ls -d /usr/contrib/lib 2>/dev/null` \
+			`ls -d /usr/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/unix/tclConfig.sh" ; then
+		    ac_cv_c_tclconfig=`(cd $i/unix; pwd)`
+		    break
+		fi
+		done
+	    fi
+	])
+
+	if test x"${ac_cv_c_tclconfig}" = x ; then
+	    TCL_BIN_DIR="# no Tcl configs found"
+	    AC_MSG_WARN([Can't find Tcl configuration definitions])
+	    exit 0
+	else
+	    no_tcl=
+	    TCL_BIN_DIR=${ac_cv_c_tclconfig}
+	    AC_MSG_RESULT([found ${TCL_BIN_DIR}/tclConfig.sh])
+	fi
+    fi
+])
+
+#------------------------------------------------------------------------
+# SC_PATH_TKCONFIG --
+#
+#	Locate the tkConfig.sh file
+#
+# Arguments:
+#	none
+#
+# Results:
+#
+#	Adds the following arguments to configure:
+#		--with-tk=...
+#
+#	Defines the following vars:
+#		TK_BIN_DIR	Full path to the directory containing
+#				the tkConfig.sh file
+#------------------------------------------------------------------------
+
+AC_DEFUN([SC_PATH_TKCONFIG], [
+    #
+    # Ok, lets find the tk configuration
+    # First, look for one uninstalled.
+    # the alternative search directory is invoked by --with-tk
+    #
+
+    if test x"${no_tk}" = x ; then
+	# we reset no_tk in case something fails here
+	no_tk=true
+	AC_ARG_WITH(tk,
+	    AC_HELP_STRING([--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
+
+	    # 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/unix/tkConfig.sh" ; then
+			ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
+			break
+		    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 ${libdir} 2>/dev/null` \
+			`ls -d ${exec_prefix}/lib 2>/dev/null` \
+			`ls -d ${prefix}/lib 2>/dev/null` \
+			`ls -d /usr/local/lib 2>/dev/null` \
+			`ls -d /usr/contrib/lib 2>/dev/null` \
+			`ls -d /usr/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/unix/tkConfig.sh" ; then
+			ac_cv_c_tkconfig=`(cd $i/unix; pwd)`
+			break
+		    fi
+		done
+	    fi
+	])
+
+	if test x"${ac_cv_c_tkconfig}" = x ; then
+	    TK_BIN_DIR="# no Tk configs found"
+	    AC_MSG_WARN([Can't find Tk configuration definitions])
+	    exit 0
+	else
+	    no_tk=
+	    TK_BIN_DIR=${ac_cv_c_tkconfig}
+	    AC_MSG_RESULT([found ${TK_BIN_DIR}/tkConfig.sh])
+	fi
+    fi
+])
+
+#------------------------------------------------------------------------
+# SC_LOAD_TCLCONFIG --
+#
+#	Load the tclConfig.sh file
+#
+# Arguments:
+#	
+#	Requires the following vars to be set:
+#		TCL_BIN_DIR
+#
+# Results:
+#
+#	Subst the following vars:
+#		TCL_BIN_DIR
+#		TCL_SRC_DIR
+#		TCL_LIB_FILE
+#
+#------------------------------------------------------------------------
+
+AC_DEFUN([SC_LOAD_TCLCONFIG], [
+    AC_MSG_CHECKING([for existence of ${TCL_BIN_DIR}/tclConfig.sh])
+
+    if test -f "${TCL_BIN_DIR}/tclConfig.sh" ; then
+        AC_MSG_RESULT([loading])
+	. "${TCL_BIN_DIR}/tclConfig.sh"
+    else
+        AC_MSG_RESULT([could not find ${TCL_BIN_DIR}/tclConfig.sh])
+    fi
+
+    # eval is required to do the TCL_DBGX substitution
+    eval "TCL_LIB_FILE=\"${TCL_LIB_FILE}\""
+    eval "TCL_STUB_LIB_FILE=\"${TCL_STUB_LIB_FILE}\""
+
+    # If the TCL_BIN_DIR is the build directory (not the install directory),
+    # then set the common variable name to the value of the build variables.
+    # For example, the variable TCL_LIB_SPEC will be set to the value
+    # of TCL_BUILD_LIB_SPEC. An extension should make use of TCL_LIB_SPEC
+    # instead of TCL_BUILD_LIB_SPEC since it will work with both an
+    # installed and uninstalled version of Tcl.
+    if test -f "${TCL_BIN_DIR}/Makefile" ; then
+        TCL_LIB_SPEC=${TCL_BUILD_LIB_SPEC}
+        TCL_STUB_LIB_SPEC=${TCL_BUILD_STUB_LIB_SPEC}
+        TCL_STUB_LIB_PATH=${TCL_BUILD_STUB_LIB_PATH}
+    elif test "`uname -s`" = "Darwin"; then
+	# If Tcl was built as a framework, attempt to use the libraries
+	# from the framework at the given location so that linking works
+	# against Tcl.framework installed in an arbitary location.
+	case ${TCL_DEFS} in
+	    *TCL_FRAMEWORK*)
+		if test -f "${TCL_BIN_DIR}/${TCL_LIB_FILE}"; then
+		    for i in "`cd ${TCL_BIN_DIR}; pwd`" \
+			     "`cd ${TCL_BIN_DIR}/../..; pwd`"; do
+			if test "`basename "$i"`" = "${TCL_LIB_FILE}.framework"; then
+			    TCL_LIB_SPEC="-F`dirname "$i"` -framework ${TCL_LIB_FILE}"
+			    break
+			fi
+		    done
+		fi
+		if test -f "${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}"; then
+		    TCL_STUB_LIB_SPEC="-L${TCL_BIN_DIR} ${TCL_STUB_LIB_FLAG}"
+		    TCL_STUB_LIB_PATH="${TCL_BIN_DIR}/${TCL_STUB_LIB_FILE}"
+		fi
+		;;
+	esac
+    fi
+
+    # eval is required to do the TCL_DBGX substitution
+    eval "TCL_LIB_FLAG=\"${TCL_LIB_FLAG}\""
+    eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
+    eval "TCL_STUB_LIB_FLAG=\"${TCL_STUB_LIB_FLAG}\""
+    eval "TCL_STUB_LIB_SPEC=\"${TCL_STUB_LIB_SPEC}\""
+
+    AC_SUBST(TCL_VERSION)
+    AC_SUBST(TCL_PATCH_LEVEL)
+    AC_SUBST(TCL_BIN_DIR)
+    AC_SUBST(TCL_SRC_DIR)
+
+    AC_SUBST(TCL_LIB_FILE)
+    AC_SUBST(TCL_LIB_FLAG)
+    AC_SUBST(TCL_LIB_SPEC)
+
+    AC_SUBST(TCL_STUB_LIB_FILE)
+    AC_SUBST(TCL_STUB_LIB_FLAG)
+    AC_SUBST(TCL_STUB_LIB_SPEC)
+])
+
+#------------------------------------------------------------------------
+# SC_LOAD_TKCONFIG --
+#
+#	Load the tkConfig.sh file
+#
+# Arguments:
+#	
+#	Requires the following vars to be set:
+#		TK_BIN_DIR
+#
+# Results:
+#
+#	Sets the following vars that should be in tkConfig.sh:
+#		TK_BIN_DIR
+#------------------------------------------------------------------------
+
+AC_DEFUN([SC_LOAD_TKCONFIG], [
+    AC_MSG_CHECKING([for existence of ${TK_BIN_DIR}/tkConfig.sh])
+
+    if test -f "${TK_BIN_DIR}/tkConfig.sh" ; then
+        AC_MSG_RESULT([loading])
+	. "${TK_BIN_DIR}/tkConfig.sh"
+    else
+        AC_MSG_RESULT([could not find ${TK_BIN_DIR}/tkConfig.sh])
+    fi
+
+    # eval is required to do the TK_DBGX substitution
+    eval "TK_LIB_FILE=\"${TK_LIB_FILE}\""
+    eval "TK_STUB_LIB_FILE=\"${TK_STUB_LIB_FILE}\""
+
+    # If the TK_BIN_DIR is the build directory (not the install directory),
+    # then set the common variable name to the value of the build variables.
+    # For example, the variable TK_LIB_SPEC will be set to the value
+    # of TK_BUILD_LIB_SPEC. An extension should make use of TK_LIB_SPEC
+    # instead of TK_BUILD_LIB_SPEC since it will work with both an
+    # installed and uninstalled version of Tcl.
+    if test -f "${TK_BIN_DIR}/Makefile" ; then
+        TK_LIB_SPEC=${TK_BUILD_LIB_SPEC}
+        TK_STUB_LIB_SPEC=${TK_BUILD_STUB_LIB_SPEC}
+        TK_STUB_LIB_PATH=${TK_BUILD_STUB_LIB_PATH}
+    elif test "`uname -s`" = "Darwin"; then
+	# If Tk was built as a framework, attempt to use the libraries
+	# from the framework at the given location so that linking works
+	# against Tk.framework installed in an arbitary location.
+	case ${TK_DEFS} in
+	    *TK_FRAMEWORK*)
+		if test -f "${TK_BIN_DIR}/${TK_LIB_FILE}"; then
+		    for i in "`cd ${TK_BIN_DIR}; pwd`" \
+			     "`cd ${TK_BIN_DIR}/../..; pwd`"; do
+			if test "`basename "$i"`" = "${TK_LIB_FILE}.framework"; then
+			    TK_LIB_SPEC="-F`dirname "$i"` -framework ${TK_LIB_FILE}"
+			    break
+			fi
+		    done
+		fi
+		if test -f "${TK_BIN_DIR}/${TK_STUB_LIB_FILE}"; then
+		    TK_STUB_LIB_SPEC="-L${TK_BIN_DIR} ${TK_STUB_LIB_FLAG}"
+		    TK_STUB_LIB_PATH="${TK_BIN_DIR}/${TK_STUB_LIB_FILE}"
+		fi
+		;;
+	esac
+    fi
+
+    # eval is required to do the TK_DBGX substitution
+    eval "TK_LIB_FLAG=\"${TK_LIB_FLAG}\""
+    eval "TK_LIB_SPEC=\"${TK_LIB_SPEC}\""
+    eval "TK_STUB_LIB_FLAG=\"${TK_STUB_LIB_FLAG}\""
+    eval "TK_STUB_LIB_SPEC=\"${TK_STUB_LIB_SPEC}\""
+
+    AC_SUBST(TK_VERSION)
+    AC_SUBST(TK_BIN_DIR)
+    AC_SUBST(TK_SRC_DIR)
+
+    AC_SUBST(TK_LIB_FILE)
+    AC_SUBST(TK_LIB_FLAG)
+    AC_SUBST(TK_LIB_SPEC)
+
+    AC_SUBST(TK_STUB_LIB_FILE)
+    AC_SUBST(TK_STUB_LIB_FLAG)
+    AC_SUBST(TK_STUB_LIB_SPEC)
+])
+
+#------------------------------------------------------------------------
+# SC_PROG_TCLSH
+#	Locate a tclsh shell installed on the system path. This macro
+#	will only find a Tcl shell that already exists on the system.
+#	It will not find a Tcl shell in the Tcl build directory or
+#	a Tcl shell that has been installed from the Tcl build directory.
+#	If a Tcl shell can't be located on the PATH, then TCLSH_PROG will
+#	be set to "". Extensions should take care not to create Makefile
+#	rules that are run by default and depend on TCLSH_PROG. An
+#	extension can't assume that an executable Tcl shell exists at
+#	build time.
+#
+# Arguments
+#	none
+#
+# Results
+#	Subst's the following values:
+#		TCLSH_PROG
+#------------------------------------------------------------------------
+
+AC_DEFUN([SC_PROG_TCLSH], [
+    AC_MSG_CHECKING([for tclsh])
+    AC_CACHE_VAL(ac_cv_path_tclsh, [
+	search_path=`echo ${PATH} | sed -e 's/:/ /g'`
+	for dir in $search_path ; do
+	    for j in `ls -r $dir/tclsh[[8-9]]* 2> /dev/null` \
+		    `ls -r $dir/tclsh* 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
+	# It is not an error if an installed version of Tcl can't be located.
+	TCLSH_PROG=""
+	AC_MSG_RESULT([No tclsh found on PATH])
+    fi
+    AC_SUBST(TCLSH_PROG)
+])
+
+
+# Local Variables:
+# mode: autoconf
+# End:



More information about the Sumover-dev mailing list