From 02a513a41a3a8aaf7a28bbb86db4eafaf63045ff Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Mon, 5 May 2014 16:07:04 +0000
Subject: import patch from previous version


diff --git a/tests/env.test b/tests/env.test
index ee13b7f..db8f1ce 100644
--- a/tests/env.test
+++ b/tests/env.test
@@ -85,7 +85,7 @@ set printenvScript [makeFile {
 	TCL_LIBRARY PATH LD_LIBRARY_PATH LIBPATH PURE_PROG_NAME DISPLAY
 	SHLIB_PATH SYSTEMDRIVE SYSTEMROOT DYLD_LIBRARY_PATH DYLD_FRAMEWORK_PATH
 	DYLD_NEW_LOCAL_SHARED_REGIONS DYLD_NO_FIX_PREBINDING
-	__CF_USER_TEXT_ENCODING SECURITYSESSIONID LANG WINDIR TERM
+	__CF_USER_TEXT_ENCODING SECURITYSESSIONID LANG WINDIR TERM LIBRARY_PATH
 	CommonProgramFiles ProgramFiles CommonProgramW6432 ProgramW6432
     } {
 	lrem names $name
@@ -117,7 +117,7 @@ foreach name [array names env] {
 	TCL_LIBRARY PATH LD_LIBRARY_PATH LIBPATH DISPLAY SHLIB_PATH
 	SYSTEMDRIVE SYSTEMROOT DYLD_LIBRARY_PATH DYLD_FRAMEWORK_PATH
 	DYLD_NEW_LOCAL_SHARED_REGIONS DYLD_NO_FIX_PREBINDING
-	SECURITYSESSIONID LANG WINDIR TERM
+	SECURITYSESSIONID LANG WINDIR TERM LIBRARY_PATH
 	CONNOMPROGRAMFILES PROGRAMFILES COMMONPROGRAMW6432 PROGRAMW6432
     }} {
 	unset env($name)
diff --git a/unix/tcl.m4 b/unix/tcl.m4
index f484989..def649b 100644
--- a/unix/tcl.m4
+++ b/unix/tcl.m4
@@ -652,7 +652,13 @@ AC_DEFUN([SC_ENABLE_THREADS], [
 	    # The space is needed
 	    THREADS_LIBS=" -lpthread"
 	else
-	    AC_CHECK_LIB(pthreads, pthread_mutex_init,
+	    AC_CHECK_LIB(root, pthread_mutex_init,
+		tcl_ok=yes, tcl_ok=no)
+		if test "$tcl_ok" = "yes"; then
+		# The space is needed
+		THREAD_LIBS=" "
+		else
+		AC_CHECK_LIB(pthreads, pthread_mutex_init,
 		tcl_ok=yes, tcl_ok=no)
 	    if test "$tcl_ok" = "yes"; then
 		# The space is needed
@@ -671,6 +677,7 @@ AC_DEFUN([SC_ENABLE_THREADS], [
 			AC_MSG_WARN([Don't know how to find pthread lib on your system - you must disable thread support or edit the LIBS in the Makefile...])
 		    fi
 		fi
+		fi
 	    fi
 	fi
 
@@ -1284,6 +1291,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
 	    SHLIB_LD='${CC} -shared ${CFLAGS} ${LDFLAGS}'
 	    DL_OBJS="tclLoadDl.o"
 	    DL_LIBS="-lroot"
+	    LD_LIBRARY_PATH_VAR="LIBRARY_PATH"
 	    AC_CHECK_LIB(network, inet_ntoa, [LIBS="$LIBS -lnetwork"])
 	    ;;
 	HP-UX-*.11.*)
-- 
1.8.3.4

