]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - config-scripts/cups-threads.m4
Load cups into easysw/current.
[thirdparty/cups.git] / config-scripts / cups-threads.m4
index 788ce838ce9e1cfe9ecd251004f3350d666d5ebd..639eb741437fbb74f04b6f947371a3c2e44aa49a 100644 (file)
@@ -25,26 +25,32 @@ dnl
 AC_ARG_ENABLE(threads, [  --enable-threads        enable multi-threading support])
 
 have_pthread=no
+PTHREAD_FLAGS=""
 
 if test "x$enable_threads" != xno; then
        AC_CHECK_HEADER(pthread.h, AC_DEFINE(HAVE_PTHREAD_H))
-       AC_CHECK_LIB(pthread, pthread_create)
 
-       if test "x$ac_cv_lib_pthread_pthread_create" = xyes -a x$ac_cv_header_pthread_h = xyes; then
-               have_pthread=yes
-       else
-               dnl *BSD uses -pthread option...
-               AC_MSG_CHECKING([for pthread_create using -pthread])
-               SAVELIBS="$LIBS"
-               LIBS="-pthread $LIBS"
-               AC_TRY_LINK([#include <pthread.h>],
-                       [pthread_create(0, 0, 0, 0);],
-                       have_pthread=yes,
-                       LIBS="$SAVELIBS")
-               AC_MSG_RESULT([$have_pthread])
+       if test x$ac_cv_header_pthread_h = xyes; then
+               dnl Check various threading options for the platforms we support
+               for flag in -lpthreads -lpthread -pthread; do
+                       AC_MSG_CHECKING([for pthread_create using $flag])
+                       SAVELIBS="$LIBS"
+                       LIBS="$flag $LIBS"
+                       AC_TRY_LINK([#include <pthread.h>],
+                               [pthread_create(0, 0, 0, 0);],
+                               have_pthread=yes,
+                               LIBS="$SAVELIBS")
+                       AC_MSG_RESULT([$have_pthread])
+
+                       if test $have_pthread = yes; then
+                               PTHREAD_FLAGS="-D_THREAD_SAFE -D_REENTRANT"
+                               break
+                       fi
+               done
        fi
 fi
 
+AC_SUBST(PTHREAD_FLAGS)
 
 dnl
 dnl End of "$Id$".