]> granicus.if.org Git - apache/blobdiff - server/mpm/config.m4
properly merge directory configs in mod_include
[apache] / server / mpm / config.m4
index 2e3d53bd3c606579428f1e2e7c3c6c54906ec08b..0b263cbc568598758dc7eb66daefeacaf09e4bb7 100644 (file)
-AC_MSG_CHECKING(which MPM to use)
-AC_ARG_WITH(mpm,
-[  --with-mpm=MPM          Choose the process model for Apache to use.
-                          MPM={dexter,mpmt_beos,mpmt_pthread,prefork,spmt_os2}],[
-  APACHE_MPM=$withval
-],[
-  APACHE_MPM=mpmt_pthread
-  case "`uname -sr`" in
-    "BeOS"*)
-      APACHE_MPM=mpmt_beos;;
-    "OS/2"*)
-      APACHE_MPM=spmt_os2;;
-  esac 
-])
-AC_MSG_RESULT($APACHE_MPM)
+dnl common platform checks needed by MPMs, methods for MPMs to state
+dnl their support for the platform, functions to query MPM properties
 
-apache_cv_mpm=$APACHE_MPM
-       
-if test "$apache_cv_mpm" = "mpmt_pthread" -o "$apache_cv_mpm" = "dexter"; then
-  PTHREADS_CHECK
-  AC_MSG_CHECKING([for which threading library to use])
-  AC_MSG_RESULT($threads_result)
+APR_CHECK_APR_DEFINE(APR_HAS_THREADS)
 
-  if test "$apache_threads_working" = "no"; then
-    AC_MSG_RESULT(The currently selected MPM requires pthreads which your system seems to lack)
-    AC_MSG_CHECKING(checking for replacement)
-    AC_MSG_RESULT(prefork selected)
-    apache_cv_mpm=prefork
-  fi
-fi
+have_threaded_sig_graceful=yes
+case $host in
+    *-linux-*)
+        case `uname -r` in
+          2.0* )
+            dnl Threaded MPM's are not supported on Linux 2.0
+            dnl as on 2.0 the linuxthreads library uses SIGUSR1
+            dnl and SIGUSR2 internally
+            have_threaded_sig_graceful=no
+          ;;
+        esac
+    ;;
+esac
 
-APACHE_CHECK_SIGWAIT_ONE_ARG
-APACHE_CHECK_SHM_RW
+dnl See if APR supports APR_POLLSET_THREADSAFE.
+dnl XXX This hack tests for the underlying functions used by APR when it supports
+dnl XXX APR_POLLSET_THREADSAFE, and duplicates APR's Darwin version check.
+dnl A run-time check for
+dnl     apr_pollset_create(,,APR_POLLSET_THREADSAFE) == APR_SUCCESS
+dnl would be great but an in-tree apr (srclib/apr) hasn't been built yet.
 
-APACHE_FAST_OUTPUT(modules/mpm/Makefile)
-MPM_NAME=$apache_cv_mpm
-MPM_DIR=modules/mpm/$MPM_NAME
-MPM_LIB=$MPM_DIR/lib${MPM_NAME}.la
+AC_CACHE_CHECK([whether APR supports thread-safe pollsets], [ac_cv_have_threadsafe_pollset], [
+    case $host in
+        *-apple-darwin[[1-9]].*)
+            APR_SETIFNULL(ac_cv_func_kqueue, [no])
+            ;;
+    esac
+    AC_CHECK_FUNCS(kqueue port_create epoll_create)
+    if test "$ac_cv_func_kqueue$ac_cv_func_port_create$ac_cv_func_epoll_create" != "nonono"; then
+        ac_cv_have_threadsafe_pollset=yes
+    else
+        ac_cv_have_threadsafe_pollset=no
+    fi
+])
 
-APACHE_SUBST(MPM_NAME)
-MODLIST="$MODLIST mpm_${MPM_NAME}"
+dnl See if this is a forking platform w.r.t. MPMs
+case $host in
+    *mingw32* | *os2-emx*)
+        forking_mpms_supported=no
+        ;;
+    *)
+        forking_mpms_supported=yes
+        ;;
+esac
 
-dnl All the unix MPMs use shared memory; save a little duplication
-AC_DEFUN(APACHE_MPM_CHECK_SHMEM, [
-    AC_CHECK_FUNCS(shmget)
-    AC_FUNC_MMAP
-    
-    AC_MSG_CHECKING(which shared memory mechanism to use)
-    if test "$ac_cv_func_shmget" = "yes" ; then
-        AC_DEFINE(USE_SHMGET_SCOREBOARD,,
-            [Define if MPMs should use shmget to implement their shared memory])
-        AC_MSG_RESULT(shmget)
-    elif test "$ac_cv_func_mmap" = "yes" ; then
-        AC_DEFINE(USE_MMAP_SCOREBOARD,,
-            [Define if MPMs should use mmap to implement their shared memory])
-        AC_MSG_RESULT(mmap)
+dnl APACHE_MPM_SUPPORTED(name, supports-shared, is_threaded)
+AC_DEFUN(APACHE_MPM_SUPPORTED,[
+    if test "$2" = "yes"; then
+        eval "ap_supported_mpm_$1=shared"
+        ap_supported_shared_mpms="$ap_supported_shared_mpms $1 "
     else
-        AC_MSG_ERROR(No known shared memory system)
+        eval "ap_supported_mpm_$1=static"
     fi
-])
+    if test "$3" = "yes"; then
+        eval "ap_threaded_mpm_$1=yes"
+    fi
+])dnl
+
+dnl APACHE_MPM_ENABLED(name)
+AC_DEFUN(APACHE_MPM_ENABLED,[
+    if ap_mpm_is_enabled $1; then
+        :
+    else
+        eval "ap_enabled_mpm_$1=yes"
+        ap_enabled_mpms="$ap_enabled_mpms $1 "
+    fi
+])dnl
 
-dnl Check for pthreads and attempt to support it
-AC_DEFUN(APACHE_MPM_PTHREAD, [
+ap_mpm_is_supported ()
+{
+    eval "tmp=\$ap_supported_mpm_$1"
+    if test -z "$tmp"; then
+        return 1
+    else
+        return 0
+    fi
+}
 
-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
+ap_mpm_supports_shared ()
+{
+    eval "tmp=\$ap_supported_mpm_$1"
+    if test "$tmp" = "shared"; then
+        return 0
+    else
+        return 1
+    fi
+}
 
-    AC_CHECK_HEADER(pthread.h, [ ],[
-        AC_MSG_ERROR(This MPM requires pthreads. Try --with-mpm=prefork.)
-    ])
-    AC_CHECK_FUNC(pthread_create, [ ],[
-        AC_MSG_ERROR(Can't compile pthread code.)
-    ])
+ap_mpm_is_threaded ()
+{
+    if test "$mpm_build" = "shared" -a ac_cv_define_APR_HAS_THREADS = "yes"; then
+        return 0
+    fi
 
-    dnl User threads libraries need pthread.h included everywhere
-    AC_DEFINE(PTHREAD_EVERYWHERE,,
-        [Define if all code should have #include <pthread.h>])
-])
+    for mpm in $ap_enabled_mpms; do
+        eval "tmp=\$ap_threaded_mpm_$mpm"
+        if test "$tmp" = "yes"; then
+            return 0
+        fi
+    done
+    return 1
+}
+
+ap_mpm_is_enabled ()
+{
+    eval "tmp=\$ap_enabled_mpm_$1"
+    if test "$tmp" = "yes"; then
+        return 0
+    else
+        return 1
+    fi
+}