$OpenBSD: patch-ltmain_sh,v 1.2 2004/08/13 08:09:23 pvalchev Exp $
--- ltmain.sh.orig	Tue Feb  3 14:58:07 2004
+++ ltmain.sh	Fri Aug 13 00:25:53 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//'`
@@ -2403,7 +2430,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"
@@ -3337,7 +3364,7 @@ EOF
 	      if test -n "$a_deplib" ; then
 		libname=`eval \\$echo \"$libname_spec\"`
 		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
-		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+		  potential_libs=`ls $i/$libname[.-]* $i/${libname}_pic.a 2>/dev/null`
 		  for potent_lib in $potential_libs; do
 		    potlib="$potent_lib" # see symlink-check above in file_magic test
 		    if eval $echo \"$potent_lib\" 2>/dev/null \
