$OpenBSD: patch-ltmain_sh,v 1.2 2004/12/04 21:44:34 sturm Exp $
--- ltmain.sh.orig	Mon Jul 19 11:57:44 2004
+++ ltmain.sh	Mon Aug  9 03:09:03 2004
@@ -1354,6 +1354,17 @@ EOF
 
       -o) prev=output ;;
 
+      -pthread)
+	case $host in
+	*-*-openbsd* | *-*-freebsd*)
+	  # These systems use the -pthread flag for pthreads.
+	  deplibs="$deplibs $arg"
+	  continue
+	  ;;
+	esac
+	continue
+	;;
+
       -release)
 	prev=release
 	continue
@@ -1898,6 +1909,22 @@ EOF
 	  esac # linkmode
 	  continue
 	  ;; # -L
+        -pthread)
+	  case $host in
+	  *-*-openbsd* | *-*-freebsd*)
+	    # These systems use the -pthread flag for pthreads.
+	    if test "$linkmode,$pass" = "prog,link"; then
+	      compile_deplibs="$deplib $compile_deplibs"
+	      finalize_deplibs="$deplib $finalize_deplibs"
+	    else
+	      deplibs="$deplib $deplibs"
+	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+	    fi
+	    continue
+	    ;;
+	  esac
+          continue
+	  ;;
 	-R*)
 	  if test "$pass" = link; then
 	    dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
@@ -1918,7 +1945,21 @@ EOF
 	  fi
 	  case $linkmode in
 	  lib)
-	    if test "$deplibs_check_method" != pass_all; then
+	    valid_a_lib=no
+	    case $deplibs_check_method in
+	      match_pattern*)
+	        match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
+		if eval $echo \"$deplib\" 2>/dev/null \
+		    | ${SED} 10q \
+		    | ${EGREP} "$match_pattern_regex" > /dev/null; then
+		  valid_a_lib=yes
+		fi
+		;;
+	      pass_all)
+		valid_a_lib=yes
+		;;
+            esac
+	    if test "$valid_a_lib" != yes; then
 	      $echo
 	      $echo "*** Warning: Trying to link with static lib archive $deplib."
 	      $echo "*** I have the capability to make that library automatically link in when"
@@ -2403,7 +2444,7 @@ EOF
 	    add_dir=
 	    add=
 	    # Finalize command for both is simple: just hardcode it.
-	    if test "$hardcode_direct" = yes; then
+	    if test "$hardcode_direct" = yes && test -f $libdir/$linklib; then
 	      add="$libdir/$linklib"
 	    elif test "$hardcode_minus_L" = yes; then
 	      add_dir="-L$libdir"
