$OpenBSD: patch-configure_in,v 1.6 2004/05/12 22:27:24 brad Exp $
--- configure.in.orig	2003-03-29 17:25:17.000000000 -0500
+++ configure.in	2004-04-19 21:37:54.000000000 -0400
@@ -827,14 +827,28 @@ then
 	Linux*) LDSHARED='$(CC) -shared';;
 	dgux*) LDSHARED="ld -G";;
 	BSD/OS*/4*) LDSHARED="gcc -shared";;
-	OpenBSD*|FreeBSD*)
+	FreeBSD*)
 		if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
 		then
 			LDSHARED="cc -shared ${LDFLAGS}"
 		else
 			LDSHARED="ld -Bshareable ${LDFLAGS}"
 		fi;;
-	NetBSD*) LDSHARED="cc -shared ${LDFLAGS}";;
+	OpenBSD*)
+		if [[ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]]
+		then
+			LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
+		else
+			case `uname -r` in
+			[[01]].* | 2.[[0-7]] | 2.[[0-7]].*)
+			   LDSHARED="ld -Bshareable ${LDFLAGS}"
+			   ;;
+			*)
+			   LDSHARED='$(CC) -shared $(CCSHARED) ${LDFLAGS}'
+			   ;;
+			esac
+		fi;;
+	NetBSD*) LDSHARED="${CC} -shared ${LDFLAGS}";;
 	OpenUNIX*|UnixWare*)
 		if test "$GCC" = "yes"
 		then LDSHARED="$(CC) -shared"
@@ -1083,8 +1097,8 @@ yes
     # on HP/UX, pthread.h renames pthread_create to a different symbol name.
     # So we really have to include pthread.h, and then link.
     _libs=$LIBS
-    LIBS="$LIBS -lpthread"
-    AC_MSG_CHECKING([for pthread_create in -lpthread])
+    LIBS="$LIBS -pthread"
+    AC_MSG_CHECKING([for pthread_create in -pthread])
     AC_TRY_LINK([#include <pthread.h>
 
 void * start_routine (void *arg) { exit (0); }], [
@@ -1102,7 +1116,7 @@ pthread_create (NULL, NULL, start_routin
     LIBOBJS="$LIBOBJS thread.o"],[
     AC_CHECK_LIB(pthreads, pthread_create, [AC_DEFINE(WITH_THREAD)
     posix_threads=yes
-    LIBS="$LIBS -lpthreads"
+    LIBS="$LIBS -pthreads"
     LIBOBJS="$LIBOBJS thread.o"], [
     AC_CHECK_LIB(c_r, pthread_create, [AC_DEFINE(WITH_THREAD)
     posix_threads=yes
@@ -1114,7 +1128,7 @@ pthread_create (NULL, NULL, start_routin
     LIBOBJS="$LIBOBJS thread.o"], [
     AC_CHECK_LIB(pthread, __pthread_create_system, [AC_DEFINE(WITH_THREAD)
     posix_threads=yes
-    LIBS="$LIBS -lpthread"
+    LIBS="$LIBS -pthread"
     LIBOBJS="$LIBOBJS thread.o"], [
     AC_CHECK_LIB(cma, pthread_create, [AC_DEFINE(WITH_THREAD)
     posix_threads=yes
