Index: Makefile.in
===================================================================
RCS file: /cvsroot/tcl/sampleextension/Makefile.in,v
retrieving revision 1.58
diff -u -r1.58 Makefile.in
--- Makefile.in	25 Jul 2005 07:12:14 -0000	1.58
+++ Makefile.in	26 Jul 2005 03:41:29 -0000
@@ -137,18 +137,11 @@
 		  TCLLIBPATH="$(TCLLIBPATH)"
 #		  TK_LIBRARY=`@CYGPATH@ $(TK_SRC_DIR)/library`
 
-# SYSTEM_TCLSH is a version of Tcl that is already installed
-# on the system. It is used to regenerate a pkgIndex.tcl
-# if needed. Note that is never going to be the same as the
-# version of tclsh in the Tcl build dir.
+TCLSH_PROG	= @TCLSH_PROG@
+TCLSH	= $(TCLSH_ENV) $(TCLSH_PROG)
 
-SYSTEM_TCLSH	= @TCLSH_PROG@
-
-BUILD_TCLSH_PROG	= @BUILD_TCLSH@
-BUILD_TCLSH	= $(TCLSH_ENV) $(BUILD_TCLSH_PROG)
-
-#BUILD_WISH_PROG	= @BUILD_WISH@
-#BUILD_WISH	= $(TCLSH_ENV) $(BUILD_WISH_PROG)
+#WISH_PROG	= @WISH_PROG@
+#WISH	= $(TCLSH_ENV) $(WISH_PROG)
 
 
 SHARED_BUILD	= @SHARED_BUILD@
@@ -244,13 +237,13 @@
 	done
 
 test: binaries libraries
-	$(BUILD_TCLSH) `@CYGPATH@ $(srcdir)/tests/all.tcl` $(TESTFLAGS)
+	$(TCLSH) `@CYGPATH@ $(srcdir)/tests/all.tcl` $(TESTFLAGS)
 
 shell: binaries libraries
-	@$(BUILD_TCLSH) $(SCRIPT)
+	@$(TCLSH) $(SCRIPT)
 
 gdb:
-	$(TCLSH_ENV) gdb $(BUILD_TCLSH_PROG) $(SCRIPT)
+	$(TCLSH_ENV) gdb $(TCLSH_PROG) $(SCRIPT)
 
 depend:
 
@@ -295,22 +288,6 @@
 	$(COMPILE) -c `@CYGPATH@ $<` -o $@
 
 #========================================================================
-# Create the pkgIndex.tcl file.
-# It is usually easiest to let Tcl do this for you with pkg_mkIndex, but
-# you may find that you need to customize the package.  If so, either
-# modify the -hand version, or create a pkgIndex.tcl.in file and have
-# the configure script output the pkgIndex.tcl by editing configure.in.
-#========================================================================
-
-pkgIndex.tcl: $(PKG_LIB_FILE)
-	( echo pkg_mkIndex . $(PKG_LIB_FILE) \; exit; ) | $(SYSTEM_TCLSH)
-
-pkgIndex.tcl-hand:
-	(echo 'package ifneeded $(PACKAGE_NAME) $(PACKAGE_VERSION) \
-	    [list load [file join $$dir $(PKG_LIB_FILE)]]'\
-	) > pkgIndex.tcl
-
-#========================================================================
 # Distribution creation
 # You may need to tweak this target to make it work correctly.
 #========================================================================
Index: configure.in
===================================================================
RCS file: /cvsroot/tcl/sampleextension/configure.in,v
retrieving revision 1.42
diff -u -r1.42 configure.in
--- configure.in	25 Jul 2005 07:12:16 -0000	1.42
+++ configure.in	26 Jul 2005 03:41:29 -0000
@@ -168,19 +168,14 @@
 TEA_MAKE_LIB
 
 #--------------------------------------------------------------------
-# Determine the name of the tclsh and wish executables in the
-# Tcl and Tk build directories and subst into the Makefile.
-# Find tclsh so that we can run pkg_mkIndex to generate the pkgIndex.tcl
-# file during the install process.  Don't run the TCLSH_PROG through
-# ${CYGPATH} because it's being used directly by make.
-# Require that we use a tclsh shell version 8.2 or later since earlier
-# versions have bugs in the pkg_mkIndex routine.
-# Add WISH as well if this is a Tk extension.
+# Determine the name of the tclsh and/or wish executables in the
+# Tcl and Tk build directories or the location they were installed
+# into. These paths are used to support running test cases only,
+# the Makefile should not be making use of these paths to generate
+# a pkgIndex.tcl file or anything else at extension build time.
 #--------------------------------------------------------------------
 
-TEA_BUILD_TCLSH
 TEA_PROG_TCLSH
-#TEA_BUILD_WISH
 #TEA_PROG_WISH
 
 #--------------------------------------------------------------------
Index: tclconfig/tcl.m4
===================================================================
RCS file: /cvsroot/tcl/tclconfig/tcl.m4,v
retrieving revision 1.70
diff -u -r1.70 tcl.m4
--- tclconfig/tcl.m4	25 Jul 2005 02:38:43 -0000	1.70
+++ tclconfig/tcl.m4	26 Jul 2005 03:41:30 -0000
@@ -3562,15 +3562,14 @@
 
 #------------------------------------------------------------------------
 # TEA_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.
+#	Determine the fully qualified path name of the tclsh executable
+#	in the Tcl build directory or the tclsh installed in a bin
+#	directory. This macro will correctly determine the name
+#	of the tclsh executable even if tclsh has not yet been
+#	built in the build directory. The tclsh found is always
+#	associated with a tclConfig.sh file. This tclsh should be used
+#	only for running extension test cases. It should never be
+#	or generation of files (like pkgIndex.tcl) at build time.
 #
 # Arguments
 #	none
@@ -3581,76 +3580,37 @@
 #------------------------------------------------------------------------
 
 AC_DEFUN(TEA_PROG_TCLSH, [
-    # Allow the user to provide this setting in the env
-    if test "x${TCLSH_PROG}" = "x" ; then
-	AC_MSG_CHECKING([for tclsh])
-
-	AC_CACHE_VAL(ac_cv_path_tclsh, [
-	search_path=`echo ${PATH} | sed -e 's/:/ /g'`
-	for dir in $search_path ; do
-	    for j in `ls -r $dir/tclsh[[8-9]]*${EXEEXT} 2> /dev/null` \
-		    `ls -r $dir/tclsh*${EXEEXT} 2> /dev/null` ; do
-		if test x"$ac_cv_path_tclsh" = x ; then
-		    if test -f "$j" ; then
-			ac_cv_path_tclsh=$j
-			break
-		    fi
-		fi
-	    done
-	done
-	])
-
-	if test -f "$ac_cv_path_tclsh" ; then
-	    TCLSH_PROG="$ac_cv_path_tclsh"
-	    AC_MSG_RESULT($TCLSH_PROG)
-	else
-	    # 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
-    fi
-    AC_SUBST(TCLSH_PROG)
-])
-
-#------------------------------------------------------------------------
-# TEA_BUILD_TCLSH
-#	Determine the fully qualified path name of the tclsh executable
-#	in the Tcl build directory. This macro will correctly determine
-#	the name of the tclsh executable even if tclsh has not yet
-#	been built in the build directory. The build tclsh must be used
-#	when running tests from an extension build directory. It is not
-#	correct to use the TCLSH_PROG in cases like this.
-#
-# Arguments
-#	none
-#
-# Results
-#	Subst's the following values:
-#		BUILD_TCLSH
-#------------------------------------------------------------------------
-
-AC_DEFUN(TEA_BUILD_TCLSH, [
-    AC_MSG_CHECKING([for tclsh in Tcl build directory])
-    if test "$TEA_PLATFORM" = "windows"; then
-        BUILD_TCLSH=${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}
+    AC_MSG_CHECKING([for tclsh])
+    if test -f "$TCL_BIN_DIR/Makefile" ; then
+        # tclConfig.sh is in Tcl build directory
+        if test "$TEA_PLATFORM" = "windows"; then
+            TCLSH_PROG=${TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}
+        else
+            TCLSH_PROG=${TCL_BIN_DIR}/tclsh
+        fi
     else
-        BUILD_TCLSH=${TCL_BIN_DIR}/tclsh
+        # tclConfig.sh is in $INSTALL/lib directory
+        REAL_TCL_BIN_DIR=`cd ${TCL_BIN_DIR}/../bin/;pwd`
+        if test "$TEA_PLATFORM" = "windows"; then
+            TCLSH_PROG=${REAL_TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}${TCL_DBGX}${EXEEXT}
+        else
+            TCLSH_PROG=${REAL_TCL_BIN_DIR}/tclsh${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}${TCL_DBGX}
+        fi
     fi
-    AC_MSG_RESULT($BUILD_TCLSH)
-    AC_SUBST(BUILD_TCLSH)
+    AC_MSG_RESULT($TCLSH_PROG)
+    AC_SUBST(TCLSH_PROG)
 ])
 
 #------------------------------------------------------------------------
 # TEA_PROG_WISH
-#	Locate a wish shell installed on the system path. This macro
-#	will only find a Wish shell that already exists on the system.
-#	It will not find a Wish shell in the Tk build directory or
-#	a Tk shell that has been installed from the Tk build directory.
-#	If a Tk shell can't be located on the PATH, then WISH_PROG will
-#	be set to "". Extensions should take care not to create Makefile
-#	rules that are run by default and depend on WISH_PROG. An
-#	extension can't assume that an executable Tk shell exists at
-#	build time.
+#	Determine the fully qualified path name of the wish executable
+#	in the Tk build directory or the wish installed in a bin
+#	directory. This macro will correctly determine the name
+#	of the wish executable even if wish has not yet been
+#	built in the build directory. The wish found is always
+#	associated with a tkConfig.sh file. This wish should be used
+#	only for running extension test cases. It should never be
+#	or generation of files (like pkgIndex.tcl) at build time.
 #
 # Arguments
 #	none
@@ -3661,63 +3621,25 @@
 #------------------------------------------------------------------------
 
 AC_DEFUN(TEA_PROG_WISH, [
-    # Allow the user to provide this setting in the env
-    if test "x${WISH_PROG}" = "x" ; then
-	AC_MSG_CHECKING([for wish])
-
-	AC_CACHE_VAL(ac_cv_path_wish, [
-	search_path=`echo ${PATH} | sed -e 's/:/ /g'`
-	for dir in $search_path ; do
-	    for j in `ls -r $dir/wish[[8-9]]*${EXEEXT} 2> /dev/null` \
-		    `ls -r $dir/wish*${EXEEXT} 2> /dev/null` ; do
-		if test x"$ac_cv_path_wish" = x ; then
-		    if test -f "$j" ; then
-			ac_cv_path_wish=$j
-			break
-		    fi
-		fi
-	    done
-	done
-	])
-
-	if test -f "$ac_cv_path_wish" ; then
-	    WISH_PROG="$ac_cv_path_wish"
-	    AC_MSG_RESULT($WISH_PROG)
-	else
-	    # It is not an error if an installed version of Tk can't be located.
-	    WISH_PROG=""
-	    AC_MSG_RESULT([No wish found on PATH])
-	fi
-    fi
-    AC_SUBST(WISH_PROG)
-])
-
-#------------------------------------------------------------------------
-# TEA_BUILD_WISH
-#	Determine the fully qualified path name of the wish executable
-#	in the Tk build directory. This macro will correctly determine
-#	the name of the wish executable even if wish has not yet
-#	been built in the build directory. The build wish must be used
-#	when running tests from an extension build directory. It is not
-#	correct to use the WISH_PROG in cases like this.
-#
-# Arguments
-#	none
-#
-# Results
-#	Subst's the following values:
-#		BUILD_WISH
-#------------------------------------------------------------------------
-
-AC_DEFUN(TEA_BUILD_WISH, [
-    AC_MSG_CHECKING([for wish in Tk build directory])
-    if test "$TEA_PLATFORM" = "windows"; then
-        BUILD_WISH=${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${TCL_DBGX}${EXEEXT}
+    AC_MSG_CHECKING([for wish])
+    if test -f "$TK_BIN_DIR/Makefile" ; then
+        # tkConfig.sh is in Tk build directory
+        if test "$TEA_PLATFORM" = "windows"; then
+            WISH_PROG=${TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${TK_DBGX}${EXEEXT}
+        else
+            WISH_PROG=${TK_BIN_DIR}/wish
+        fi
     else
-        BUILD_WISH=${TK_BIN_DIR}/wish
+        # tkConfig.sh is in $INSTALL/lib directory
+        REAL_TK_BIN_DIR=`cd ${TK_BIN_DIR}/../bin/;pwd`
+        if test "$TEA_PLATFORM" = "windows"; then
+            WISH_PROG=${REAL_TK_BIN_DIR}/wish${TK_MAJOR_VERSION}${TK_MINOR_VERSION}${TK_DBGX}${EXEEXT}
+        else
+            WISH_PROG=${REAL_TK_BIN_DIR}/wish${TK_MAJOR_VERSION}.${TK_MINOR_VERSION}${TK_DBGX}
+        fi
     fi
-    AC_MSG_RESULT($BUILD_WISH)
-    AC_SUBST(BUILD_WISH)
+    AC_MSG_RESULT($WISH_PROG)
+    AC_SUBST(WISH_PROG)
 ])
 
 #------------------------------------------------------------------------
@@ -3957,6 +3879,11 @@
     fi
 ])
 
+# FIXME: This macro is ill-conceived. One can't assume that the
+# TCLSH_PROG can be executed at build time when cross compiling.
+# Also, this will not work when TCLSH_PROG is the tclsh in the
+# build directory.
+
 #------------------------------------------------------------------------
 # TEA_PATH_NOSPACE
 #	Ensure that the given path has no spaces.  This is necessary for
