--- /dev/null
+diff -up tcl8.5.7/../library/auto.tcl.old tcl8.5.7/library/auto.tcl
+--- tcl8.5.7/../library/auto.tcl.old 2006-11-03 01:34:52.000000000 +0100
++++ tcl8.5.7/../library/auto.tcl 2009-05-18 10:28:16.337102378 +0200
+@@ -85,6 +85,13 @@ proc tcl_findLibrary {basename version p
+ lappend dirs $value
+ }
+
++ # 2a. As a sibling of Tcl's script directory
++ if {[catch {
++ ::tcl::pkgconfig get scriptdir,runtime
++ } value] == 0} {
++ lappend dirs [file join [file dirname $value] $basename$version]
++ }
++
+ # 3. Relative to auto_path directories. This checks relative to the
+ # Tcl library as well as allowing loading of libraries added to the
+ # auto_path that is not relative to the core library or binary paths.
+diff -up tcl8.5.7/../library/init.tcl.old tcl8.5.7/library/init.tcl
+--- tcl8.5.7/../library/init.tcl.old 2009-04-10 18:54:51.000000000 +0200
++++ tcl8.5.7/../library/init.tcl 2009-05-18 10:25:25.904853164 +0200
+@@ -48,16 +48,11 @@ if {![info exists auto_path]} {
+ }
+ namespace eval tcl {
+ variable Dir
+- foreach Dir [list $::tcl_library [file dirname $::tcl_library]] {
++ foreach Dir [list $::tcl_library] {
+ if {$Dir ni $::auto_path} {
+ lappend ::auto_path $Dir
+ }
+ }
+- set Dir [file join [file dirname [file dirname \
+- [info nameofexecutable]]] lib]
+- if {$Dir ni $::auto_path} {
+- lappend ::auto_path $Dir
+- }
+ catch {
+ foreach Dir $::tcl_pkgPath {
+ if {$Dir ni $::auto_path} {
+diff -up tcl8.5.7/../unix/configure.in.old tcl8.5.7/unix/configure.in
+--- tcl8.5.7/../unix/configure.in.old 2009-04-15 21:30:05.000000000 +0200
++++ tcl8.5.7/../unix/configure.in 2009-05-18 10:21:30.987855050 +0200
+@@ -833,9 +833,9 @@ if test "$FRAMEWORK_BUILD" = "1" ; then
+ test -z "$TCL_MODULE_PATH" && \
+ TCL_MODULE_PATH="~/Library/Tcl /Library/Tcl /System/Library/Tcl"
+ elif test "$prefix/lib" != "$libdir"; then
+- TCL_PACKAGE_PATH="${libdir} ${prefix}/lib ${TCL_PACKAGE_PATH}"
++ TCL_PACKAGE_PATH="${libdir}/tcl8.5 ${prefix}/share/tcl8.5 ${TCL_PACKAGE_PATH}"
+ else
+- TCL_PACKAGE_PATH="${prefix}/lib ${TCL_PACKAGE_PATH}"
++ TCL_PACKAGE_PATH="${libdir}/tcl8.5 ${prefix}/share/tcl8.5 ${TCL_PACKAGE_PATH}"
+ fi
+
+ #--------------------------------------------------------------------
--- /dev/null
+--- tcl8.5.0/../unix/tcl.m4.conf 2007-12-20 10:48:05.000000000 +0100
++++ tcl8.5.0/../unix/tcl.m4 2007-12-20 10:48:52.000000000 +0100
+@@ -1427,12 +1427,12 @@ dnl AC_CHECK_TOOL(AR, ar)
+ # get rid of the warnings.
+ #CFLAGS_OPTIMIZE="${CFLAGS_OPTIMIZE} -D__NO_STRING_INLINES -D__NO_MATH_INLINES"
+
+- SHLIB_LD='${CC} -shared ${CFLAGS} ${LDFLAGS}'
++ SHLIB_LD='${CC} -shared ${CFLAGS} ${LDFLAGS} -fPIC -Wl,-soname,${@}'
+ DL_OBJS="tclLoadDl.o"
+ DL_LIBS="-ldl"
+ LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
+ AS_IF([test $doRpath = yes], [
+- CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'])
++ CC_SEARCH_FLAGS=''])
+ LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
+ AS_IF([test "`uname -m`" = "alpha"], [CFLAGS="$CFLAGS -mieee"])
+ AS_IF([test $do64bit = yes], [
+@@ -1464,7 +1464,7 @@ dnl AC_CHECK_TOOL(AR, ar)
+ SHLIB_LD_LIBS='${LIBS}'
+ SHLIB_SUFFIX=".so"
+
+- SHLIB_LD='${CC} -shared'
++ SHLIB_LD='${CC} ${CFLAGS} -shared -fPIC'
+ DL_OBJS=""
+ DL_LIBS="-ldl"
+ LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
--- /dev/null
+diff -up tcl8.5.7/../unix/Makefile.in.old tcl8.5.7/unix/Makefile.in
+--- tcl8.5.7/../unix//Makefile.in.old 2009-04-15 21:30:05.000000000 +0200
++++ tcl8.5.7/../unix/Makefile.in 2009-07-16 08:27:32.758444459 +0200
+@@ -569,7 +569,7 @@ objs: ${OBJS}
+
+
+ tclsh: ${TCLSH_OBJS} ${TCL_LIB_FILE}
+- ${CC} ${CFLAGS} ${LDFLAGS} ${TCLSH_OBJS} @TCL_BUILD_LIB_SPEC@ ${LIBS} @EXTRA_TCLSH_LIBS@ \
++ ${CC} ${CFLAGS} ${LDFLAGS} -fPIC ${TCLSH_OBJS} @TCL_BUILD_LIB_SPEC@ ${LIBS} @EXTRA_TCLSH_LIBS@ \
+ ${CC_SEARCH_FLAGS} -o tclsh
+
+ # Resetting the LIB_RUNTIME_DIR below is required so that the generated
--- /dev/null
+
+PKG_TOOLCHAIN_DEPS += acl attr gcc glibc
+
+include ../../core/tcl/tcl.nm
+
+DIR_APP = $(DIR_SRC)/tcl$(PKG_VER)/unix
+
+define STAGE_BUILD
+ cd $(DIR_APP) && \
+ ./configure \
+ --prefix=$(TOOLS_DIR) \
+ --disable-nls \
+ --enable-shared
+
+ cd $(DIR_APP) && autoconf
+ cd $(DIR_APP) && make $(PARALLELISMFLAGS)
+endef
+
+define STAGE_TEST
+ cd $(DIR_APP) && make test
+endef
+
+define STAGE_INSTALL
+ cd $(DIR_APP) && make install
+endef
+