From f1281718cfb8a9e92bcc3d03961424043f281735 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Sat, 11 Apr 2020 14:33:00 -0400
Subject: import patch from previous version


diff --git a/tests/env.test b/tests/env.test
index 036c7a2..ab8fe59 100644
--- a/tests/env.test
+++ b/tests/env.test
@@ -101,7 +101,7 @@ variable keep {
     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 MSYSTEM
-    __CF_USER_TEXT_ENCODING SECURITYSESSIONID LANG WINDIR TERM
+    __CF_USER_TEXT_ENCODING SECURITYSESSIONID LANG WINDIR TERM LIBRARY_PATH
     CommonProgramFiles ProgramFiles CommonProgramW6432 ProgramW6432
 }
 
diff --git a/unix/tcl.m4 b/unix/tcl.m4
index 27b7540..1091ee0 100644
--- a/unix/tcl.m4
+++ b/unix/tcl.m4
@@ -628,7 +628,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
@@ -647,6 +653,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
 
@@ -1238,6 +1245,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
 	    SHLIB_LD='${CC} ${CFLAGS} ${LDFLAGS} -shared'
 	    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.*)
-- 
2.30.0

