$OpenBSD: patch-aconfigure_ac,v 1.2 2010/05/03 14:30:19 dcoppa Exp $

use -pthread instead of -lpthread
fix memory alignment detection on sparc64
fix header detection when using external libgsm on OpenBSD

--- aconfigure.ac.orig	Sat May  1 18:15:27 2010
+++ aconfigure.ac	Sat May  1 18:23:28 2010
@@ -48,7 +48,23 @@ case $target in 
 	;;
 esac
 
-AC_CHECK_LIB(pthread,pthread_create)
+AC_CHECK_HEADER(pthread.h, have_pthread_h=yes)
+if test "X$have_pthread_h" = "Xyes" ; then
+    save_LDFLAGS="$LDFLAGS";
+    LDFLAGS="$LDFLAGS -pthread"
+    AC_LINK_IFELSE(
+      [AC_LANG_PROGRAM(
+        [[#include <pthread.h>
+        pthread_t thr;]],
+        [pthread_create(&thr, NULL, NULL, NULL);])],
+      [ac_cv_support_pthreads=yes],
+      [LDFLAGS="$save_LDFLAGS"])
+    if test "X$ac_cv_support_pthreads" != "Xyes" ; then
+      AC_CHECK_LIB(pthread, pthread_create,
+        LIBS="-lpthread $LIBS")
+    fi
+fi
+
 AC_CHECK_LIB(wsock32,puts)
 AC_CHECK_LIB(ws2_32,puts)
 AC_CHECK_LIB(ole32,puts)
@@ -67,7 +83,7 @@ dnl Memory alignment detection
 dnl
 AC_MSG_CHECKING([memory alignment])
 case $target in
-    ia64-* | x86_64-* )
+    ia64-* | x86_64-* | sparc64-* )
 	AC_DEFINE(PJ_POOL_ALIGNMENT, 8)
 	AC_MSG_RESULT([8 bytes])
 	;;
@@ -410,7 +426,7 @@ AC_ARG_WITH(external-gsm,
 	if test "x$with_external_gsm" != "xno"; then
 		# Test GSM library installation
 		AC_MSG_CHECKING([if external GSM devkit is installed])
-		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gsm/gsm.h>
+		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gsm.h>
 						                   ]],
 						                   [gsm_create(); ])
 						  ],
