[vlc-devel] [PATCH] Add detection of POSIX threads via cc -pthread

Brad brad at comstyle.com
Mon Oct 17 12:58:47 CEST 2011


The following diff adds detection of POSIX threads linking via
cc -pthread. This corrects the POSIX threads flag used for OpenBSD.


diff --git a/configure.ac b/configure.ac
index 212d9fd..5a0a210 100644
--- a/configure.ac
+++ b/configure.ac
@@ -194,9 +194,9 @@ case "${host_os}" in
     ;;
   *bsd*)
     SYS="${host_os}"
-    CFLAGS_save="${CFLAGS_save} -pthread"; CFLAGS="${CFLAGS_save}"
     case "${host_os}" in
       freebsd*)
+        CFLAGS_save="${CFLAGS_save} -pthread"; CFLAGS="${CFLAGS_save}"
         CPPFLAGS_save="${CPPFLAGS_save} -I/usr/local/include"
         CPPFLAGS="${CPPFLAGS_save}"
         LDFLAGS_save="${LDFLAGS_save} -L/usr/local/lib"
@@ -721,6 +721,20 @@ if test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"; then
   dnl Check for pthreads - borrowed from XMMS
   THREAD_LIB=error
   if test "${THREAD_LIB}" = "error"; then
+    AC_MSG_CHECKING(for pthread_create in -pthread)
+    save_LDFLAGS="${LDFLAGS}"
+    LDFLAGS="${LDFLAGS} -pthread"
+    AC_LINK_IFELSE(
+      [AC_LANG_PROGRAM(
+        [[#include <pthread.h>
+        pthread_t thr;]],
+        [pthread_create(&thr, NULL, NULL, NULL);])],
+      [THREAD_LIB="-pthread"
+       AC_MSG_RESULT(yes)],
+       [AC_MSG_RESULT(no)])
+    LDFLAGS="${save_LDFLAGS}"
+  fi
+  if test "${THREAD_LIB}" = "error"; then
     AC_CHECK_LIB(pthread,main,THREAD_LIB="-lpthread")
   fi
   if test "${THREAD_LIB}" = "error"; then

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.




More information about the vlc-devel mailing list