--- configure.orig	Fri Mar 28 14:46:36 2008
+++ configure	Fri May  9 14:27:39 2008
@@ -3536,6 +3536,7 @@
 # Threads support - this auto-enables if Tcl was compiled threaded
 #------------------------------------------------------------------------
 
+TCL_SRC_DIR=${prefix}/include/tcl${TCLVERSION}
 
     # Check whether --enable-threads or --disable-threads was given.
 if test "${enable_threads+set}" = set; then
@@ -5811,7 +5812,7 @@
 	    UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
 	    TCL_LIB_VERSIONS_OK=nodots
 	    ;;
-	NetBSD-*|FreeBSD-*)
+	NetBSD-*|FreeBSD-*|MidnightBSD-*)
 	    # FreeBSD 3.* and greater have ELF.
 	    # NetBSD 2.* has ELF and can use 'cc -shared' to build shared libs
 	    SHLIB_CFLAGS="-fPIC"
@@ -5820,7 +5821,7 @@
 	    SHLIB_SUFFIX=".so"
 	    DL_OBJS="tclLoadDl.o"
 	    DL_LIBS=""
-	    LDFLAGS="$LDFLAGS -export-dynamic"
+	    LDFLAGS=""
 	    if test $doRpath = yes; then
 
 		CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
@@ -5831,16 +5832,16 @@
 
 		# The -pthread needs to go in the CFLAGS, not LIBS
 		LIBS=`echo $LIBS | sed s/-pthread//`
-		CFLAGS="$CFLAGS -pthread"
-	    	LDFLAGS="$LDFLAGS -pthread"
+		CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+	    	LDFLAGS="$LDFLAGS $PTHREAD_LIBS"
 
 fi
 
 	    case $system in
-	    FreeBSD-3.*)
+	    FreeBSD-*|MidnightBSD-*)
 	    	# FreeBSD-3 doesn't handle version numbers with dots.
 	    	UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
-	    	SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so'
+	    	SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.1'
 	    	TCL_LIB_VERSIONS_OK=nodots
 		;;
 	    esac
@@ -6830,7 +6831,7 @@
 	    AIX-*) ;;
 	    BSD/OS*) ;;
 	    IRIX*) ;;
-	    NetBSD-*|FreeBSD-*) ;;
+	    NetBSD-*|FreeBSD-*|MidnightBSD-*) ;;
 	    Darwin-*) ;;
 	    SCO_SV-3.2*) ;;
 	    *) SHLIB_CFLAGS="-fPIC" ;;
@@ -9575,7 +9576,7 @@
 fi
 rm -f conftest.err conftest.$ac_ext
 	else
-	    if test ! -r $x_includes/X11/Intrinsic.h; then
+	    if test ! -r $x_includes/X11/Xlib.h; then
 		not_really_there="yes"
 	    fi
 	fi
@@ -9590,7 +9591,7 @@
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <X11/Intrinsic.h>
+#include <X11/Xlib.h>
 _ACEOF
 if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
@@ -9621,7 +9622,7 @@
 	if test "$found_xincludes" = "no"; then
 	    dirs="/usr/unsupported/include /usr/local/include /usr/X386/include /usr/X11R6/include /usr/X11R5/include /usr/include/X11R5 /usr/include/X11R4 /usr/openwin/include /usr/X11/include /usr/sww/include"
 	    for i in $dirs ; do
-		if test -r $i/X11/Intrinsic.h; then
+		if test -r $i/X11/Xlib.h; then
 		    echo "$as_me:$LINENO: result: $i" >&5
 echo "${ECHO_T}$i" >&6
 		    XINCLUDES=" -I$i"
