diff -urN sample/Makefile.in sapling/Makefile.in
--- sample/Makefile.in	Wed Oct 24 02:07:36 2007
+++ sapling/Makefile.in	Sun May 11 12:44:29 2008
@@ -88,6 +88,7 @@
 top_builddir	= .
 
 INSTALL		= @INSTALL@
+INSTALL_LIBRARY	= @INSTALL_LIBRARY@
 INSTALL_PROGRAM	= @INSTALL_PROGRAM@
 INSTALL_DATA	= @INSTALL_DATA@
 INSTALL_SCRIPT	= @INSTALL_SCRIPT@
@@ -280,7 +281,7 @@
 # As necessary, add $(srcdir):$(srcdir)/compat:....
 #========================================================================
 
-VPATH = $(srcdir):$(srcdir)/generic:$(srcdir)/unix:$(srcdir)/win
+VPATH = @PKG_VPATH@
 
 .c.@OBJEXT@:
 	$(COMPILE) -c `@CYGPATH@ $<` -o $@
@@ -362,8 +363,8 @@
 	@mkdir -p $(DESTDIR)$(pkglibdir)
 	@list='$(lib_BINARIES)'; for p in $$list; do \
 	  if test -f $$p; then \
-	    echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(pkglibdir)/$$p"; \
-	    $(INSTALL_PROGRAM) $$p $(DESTDIR)$(pkglibdir)/$$p; \
+	    echo " $(INSTALL_LIBRARY) $$p $(DESTDIR)$(pkglibdir)/$$p"; \
+	    $(INSTALL_LIBRARY) $$p $(DESTDIR)$(pkglibdir)/$$p; \
 	    stub=`echo $$p|sed -e "s/.*\(stub\).*/\1/"`; \
 	    if test "x$$stub" = "xstub"; then \
 		echo " $(RANLIB_STUB) $(DESTDIR)$(pkglibdir)/$$p"; \
diff -urN sample/pkgIndex.tcl.in sapling/pkgIndex.tcl.in
--- sample/pkgIndex.tcl.in	Tue Nov 29 19:10:48 2005
+++ sapling/pkgIndex.tcl.in	Thu May  8 19:02:29 2008
@@ -1,5 +1,5 @@
 #
 # Tcl package index file
 #
-package ifneeded Tclsha1 @PACKAGE_VERSION@ \
+package ifneeded @PACKAGE_NAME@ @PACKAGE_VERSION@ \
     [list load [file join $dir @PKG_LIB_FILE@] @PACKAGE_NAME@]
diff -urN sample/tclconfig/tcl.m4 sapling/tclconfig/tcl.m4
--- sample/tclconfig/tcl.m4	Fri Mar 28 03:14:52 2008
+++ sapling/tclconfig/tcl.m4	Sun May 11 13:07:19 2008
@@ -15,7 +15,7 @@
 
 dnl TEA extensions pass us the version of TEA they think they
 dnl are compatible with (must be set in TEA_INIT below)
-dnl TEA_VERSION="3.6"
+dnl TEA_VERSION="3.7"
 
 # Possible values for key variables defined:
 #
@@ -91,7 +91,8 @@
 			../../../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
+			`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
@@ -101,7 +102,8 @@
 
 	    # 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` \
+		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` \
@@ -116,7 +118,8 @@
 	    # TEA specific: on Windows, check in common installation locations
 	    if test "${TEA_PLATFORM}" = "windows" \
 		-a x"${ac_cv_c_tclconfig}" = x ; then
-		for i in `ls -d C:/Tcl/lib 2>/dev/null` \
+		for i in \
+			`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
@@ -128,12 +131,16 @@
 
 	    # 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` \
+		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` \
+			`ls -dr ${exec_prefix}/lib/tcl[[8-9]].[[0-9]] 2>/dev/null` \
+			`ls -dr ${prefix}/lib/tcl[[8-9]].[[0-9]] 2>/dev/null` \
+			`ls -dr /usr/local/lib/tcl[[8-9]].[[0-9]] 2>/dev/null` \
 			; do
 		    if test -f "$i/tclConfig.sh" ; then
 			ac_cv_c_tclconfig=`(cd $i; pwd)`
@@ -148,7 +155,8 @@
 			${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
+			`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
@@ -234,7 +242,8 @@
 			../../../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
+			`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
@@ -244,7 +253,8 @@
 
 	    # 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` \
+		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` \
@@ -258,12 +268,16 @@
 
 	    # 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` \
+		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` \
+			`ls -dr ${exec_prefix}/lib/tk[[8-9]].[[0-9]] 2>/dev/null` \
+			`ls -dr ${prefix}/lib/tk[[8-9]].[[0-9]] 2>/dev/null` \
+			`ls -dr /usr/local/lib/tk[[8-9]].[[0-9]] 2>/dev/null` \
 			; do
 		    if test -f "$i/tkConfig.sh" ; then
 			ac_cv_c_tkconfig=`(cd $i; pwd)`
@@ -275,7 +289,8 @@
 	    # TEA specific: on Windows, check in common installation locations
 	    if test "${TEA_PLATFORM}" = "windows" \
 		-a x"${ac_cv_c_tkconfig}" = x ; then
-		for i in `ls -d C:/Tcl/lib 2>/dev/null` \
+		for i in \
+			`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
@@ -291,7 +306,8 @@
 			${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
+			`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
@@ -358,12 +374,14 @@
     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.
+	# against Tcl.framework installed in an arbitrary 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
+		    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
@@ -447,12 +465,14 @@
     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.
+	# against Tk.framework installed in an arbitrary 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
+		    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
@@ -520,7 +540,7 @@
 #	none
 #
 # Results
-#	Subst's the following values:
+#	Substs the following values:
 #		TCLSH_PROG
 #------------------------------------------------------------------------
 
@@ -570,7 +590,7 @@
 #	none
 #
 # Results
-#	Subst's the following values:
+#	Substs the following values:
 #		WISH_PROG
 #------------------------------------------------------------------------
 
@@ -2312,7 +2332,7 @@
 #	Supply substitutes for missing POSIX header files.  Special
 #	notes:
 #	    - stdlib.h doesn't define strtol, strtoul, or
-#	      strtod insome versions of SunOS
+#	      strtod in some versions of SunOS
 #	    - some versions of string.h don't declare procedures such
 #	      as strstr
 #
@@ -2679,7 +2699,7 @@
 #	
 # Results:
 #
-#	Subst's the following var:
+#	Substs the following var:
 #		TCL_LIBS
 #		MATH_LIBS
 #
@@ -2970,9 +2990,39 @@
     AC_SUBST(PKG_INCLUDES)
     AC_SUBST(PKG_LIBS)
     AC_SUBST(PKG_CFLAGS)
+
+    PKG_VPATH='$(srcdir):$(srcdir)/generic'
+    TEA_VPATH="$srcdir $srcdir/generic"
+    AC_SUBST(PKG_VPATH)
 ])
 
 #------------------------------------------------------------------------
+# TEA_ADD_VPATH_DIR --
+#
+#	Specify one or more source "vpath" dirs.  Users should check for
+#	the right platform before adding to their list.
+#
+#	This should be called before any calls to TEA_ADD_SOURCES or
+#	TEA_ADD_STUB_SOURCES to ensure that the sources are found.
+#
+# Arguments:
+#	one or more directory names
+#
+# Results:
+#
+#	Defines and substs the following vars:
+#		PKG_VPATH
+#------------------------------------------------------------------------
+AC_DEFUN([TEA_ADD_VPATH_DIR], [
+    vars="$@"
+    for i in $vars; do
+	PKG_VPATH="$PKG_VPATH:\$(srcdir)/$i"
+	TEA_VPATH="$TEA_VPATH ${srcdir}/$i"
+    done
+    AC_SUBST(PKG_VPATH)
+])
+
+#------------------------------------------------------------------------
 # TEA_ADD_SOURCES --
 #
 #	Specify one or more source files.  Users should check for
@@ -2999,12 +3049,16 @@
 		PKG_OBJECTS="$PKG_OBJECTS $i"
 		;;
 	    *)
-		# check for existence - allows for generic/win/unix VPATH
-		# To add more dirs here (like 'src'), you have to update VPATH
-		# in Makefile.in as well
-		if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \
-		    -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \
-		    ; then
+		# check for existence
+		# allows for generic/win/unix/other VPATH
+		found='no'
+		for j in $TEA_VPATH ; do
+		    if test -f $j/$i ; then
+			found='yes'
+			break
+		    fi
+		done
+		if test ${found} == 'no' ; then
 		    AC_MSG_ERROR([could not find source file '$i'])
 		fi
 		PKG_SOURCES="$PKG_SOURCES $i"
@@ -3044,10 +3098,16 @@
 AC_DEFUN([TEA_ADD_STUB_SOURCES], [
     vars="$@"
     for i in $vars; do
-	# check for existence - allows for generic/win/unix VPATH
-	if test ! -f "${srcdir}/$i" -a ! -f "${srcdir}/generic/$i" \
-	    -a ! -f "${srcdir}/win/$i" -a ! -f "${srcdir}/unix/$i" \
-	    ; then
+	# check for existence
+	# allows for generic/win/unix/other VPATH
+	found='no'
+	for j in $TEA_VPATH ; do
+	    if test -f $j/$i ; then
+		found='yes'
+		break
+	    fi
+	done
+	if test ${found} == 'no' ; then
 	    AC_MSG_ERROR([could not find stub source file '$i'])
 	fi
 	PKG_STUB_SOURCES="$PKG_STUB_SOURCES $i"
@@ -3250,6 +3310,8 @@
     AC_PROG_CPP
 
     AC_PROG_INSTALL
+    INSTALL_LIBRARY="${INSTALL_PROGRAM}"
+    AC_SUBST(INSTALL_LIBRARY)
 
     #--------------------------------------------------------------------
     # Checks to see if the make program sets the $MAKE variable.
@@ -3461,7 +3523,8 @@
 	    `ls -dr /usr/lib/$1[[0-9]]*.lib 2>/dev/null ` \
 	    `ls -dr /usr/lib/lib$1[[0-9]]* 2>/dev/null ` \
 	    `ls -dr /usr/local/lib/$1[[0-9]]*.lib 2>/dev/null ` \
-	    `ls -dr /usr/local/lib/lib$1[[0-9]]* 2>/dev/null ` ; do
+	    `ls -dr /usr/local/lib/lib$1[[0-9]]* 2>/dev/null ` \
+	    ; do
 	if test -f "$i" ; then
 	    tea_lib_name_dir=`dirname $i`
 	    $1_LIB_NAME=`basename $i`
@@ -3787,6 +3850,10 @@
 		`ls -d ${TCL_BIN_DIR}/../include 2>/dev/null`"
 	    if test "${TEA_PLATFORM}" != "windows" -o "$GCC" = "yes"; then
 		list="$list /usr/local/include /usr/include"
+		if test x"${TK_INCLUDE_SPEC}" != x ; then
+		    d=`echo "${TK_INCLUDE_SPEC}" | sed -e 's/^-I//'`
+		    list="$list `ls -d ${d} 2>/dev/null`"
+		fi
 	    fi
 	    for i in $list ; do
 		if test -f "$i/tk.h" ; then
@@ -3913,7 +3980,8 @@
 
 	    # check in a few common install locations
 	    if test x"${ac_cv_c_$1config}" = x ; then
-		for i in `ls -d ${libdir} 2>/dev/null` \
+		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` \
