]> granicus.if.org Git - apache/commitdiff
First stab at logic to determine which threading library to use. This also
authorRyan Bloom <rbb@apache.org>
Thu, 23 Dec 1999 21:01:31 +0000 (21:01 +0000)
committerRyan Bloom <rbb@apache.org>
Thu, 23 Dec 1999 21:01:31 +0000 (21:01 +0000)
gets rid of the hack of always putting -pthread in the CFLAGS variable.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@84363 13f79535-47bb-0310-9956-ffa450edef68

acinclude.m4
configure.in
server/mpm/config.m4

index f45bc2ce1eba7e9455accdfea565e00d692a3989..57c8bf78b9b45bda5b5d83e93308d9a800e45d15 100644 (file)
@@ -95,3 +95,46 @@ AC_DEFUN(APACHE_ONCE,[
   fi
 ])
 
+dnl
+dnl APACHE_CHECK_THREADS()
+dnl
+dnl Determine the best flags for linking against a threading library.
+dnl
+AC_DEFUN(THREAD_TEST, [
+AC_TRY_RUN( [
+#include <pthread.h>
+
+void *thread_routine(void *data) {
+    return data;
+}
+
+int main() {
+    pthread_t thd;
+    int data = 1;
+    return pthread_create(&thd, NULL, thread_routine, &data);
+} ], [ 
+  THREADS_WORKING="yes"
+  ], [
+  THREADS_WORKING="no"
+  ], THREADS_WORKING="no" ) ] )
+
+define(APACHE_CHECK_THREADS, [dnl
+  cflags_orig="$CFLAGS"
+  ldflags_orig="$LDFLAGS"
+  for test_cflag in $1; do
+    for test_ldflag in $2; do
+      CFLAGS="$test_cflag $cflags_orig"
+      LDFLAGS="$test_ldflag $ldflags_orig"
+      THREAD_TEST()
+      if test "$THREADS_WORKING" = "yes"; then
+        break
+      fi
+    done
+    if test "$THREADS_WORKING" = "yes"; then
+      threads_result="Updating CFLAGS and LDFLAGS"
+      break
+    fi
+      threads_result="Threads not found"
+  done
+] )
+        
index 58205e3aa0fa1a870b80678f41675d81e3751422..bdf03dd91071505edd8b7e3a46822ca6e7ff0020 100644 (file)
@@ -73,6 +73,10 @@ AC_TYPE_PID_T
 
 dnl ## Check for library functions
 
+AC_MSG_CHECKING([for which threading library to use])
+APACHE_CHECK_THREADS('' -pthread -D_REENTRANT, '' -lpthread -lc_r)
+AC_MSG_RESULT("$threads_result")
+
 dnl See Comment #Spoon
 
 AC_CHECK_FUNCS( \
index 3af2173aea8d4a4b779d1a035dc7327d6e401e60..7ab84353e07c8d95f18708ed796be1b8b0faafa9 100644 (file)
@@ -46,8 +46,6 @@ AC_DEFUN(APACHE_MPM_PTHREAD, [
 
 dnl XXX - We should be checking for the proper flags to use on a particular 
 dnl platform. This will cover a couple of them, anyway
-    CFLAGS="-pthread $CFLAGS"
-    CXXFLAGS="-pthread $CXXFLAGS"
 
     AC_CHECK_HEADER(pthread.h, [ ],[
         AC_MSG_ERROR(This MPM requires pthreads. Try --with-mpm=prefork.)