Index: Makefile.in
==================================================================
--- Makefile.in
+++ Makefile.in
@@ -10,11 +10,11 @@
 # All rights reserved.
 #
 # See the file "license.terms" for information on usage and redistribution
 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 #
-# RCS: @(#) $Id: Makefile.in,v 1.25 2007/06/22 21:19:12 hobbs2 Exp $
+# RCS: @(#) $Id: Makefile.in,v 1.26 2008/03/18 00:40:37 hobbs2 Exp $
 
 
 #========================================================================
 # Enumerate the names of the source files included in this package.
 # This will be used when a dist target is added to the Makefile.
@@ -262,12 +262,12 @@
 pkgIndex.tcl-auto:
 	( echo pkg_mkIndex . $(PKG_LIB_FILE) \; exit; ) | $(TCLSH)
 
 pkgIndex.tcl:
 	(echo 'package ifneeded $(PACKAGE_NAME) $(PACKAGE_VERSION) \
-	    "[list load [file join $$dir $(PKG_LIB_FILE)]] ; \
-	     [list source [file join $$dir tls.tcl]]"'\
+	    "[list source [file join $$dir tls.tcl]] ; \
+	     [list tls::initlib $$dir $(PKG_LIB_FILE)]"'\
 	) > pkgIndex.tcl
 
 #========================================================================
 # End of user-definable section
 #========================================================================

Index: tls.tcl
==================================================================
--- tls.tcl
+++ tls.tcl
@@ -1,9 +1,9 @@
 #
 # Copyright (C) 1997-2000 Matt Newman <matt@novadigm.com> 
 #
-# $Header: /home/rkeene/tmp/cvs2fossil/../tcltls/tls/tls/tls.tcl,v 1.8 2007/02/28 23:33:41 patthoyts Exp $
+# $Header: /home/rkeene/tmp/cvs2fossil/../tcltls/tls/tls/tls.tcl,v 1.9 2008/03/18 00:40:37 hobbs2 Exp $
 #
 namespace eval tls {
     variable logcmd tclLog
     variable debug 0
  
@@ -18,10 +18,26 @@
     variable socketCmd
     if {![info exists socketCmd]} {
         set socketCmd [info command ::socket]
     }
 }
+
+proc tls::initlib {dir dll} {
+    # Package index cd's into the package directory for loading.
+    # Irrelevant to unixoids, but for Windows this enables the OS to find
+    # the dependent DLL's in the CWD, where they may be.
+    set cwd [pwd]
+    catch {cd $dir}
+    set res [catch {load [file join $dir $dll]} err]
+    catch {cd $cwd}
+    if {$res} {
+	namespace delete tls
+	return -code $res $err
+    }
+    rename tls::initlib {}
+}
+
 #
 # Backwards compatibility, also used to set the default
 # context options
 #
 proc tls::init {args} {