]> granicus.if.org Git - apache/commitdiff
Fix MPM event/libserf build problems: If libserf was installed during build,
authorStefan Fritsch <sf@apache.org>
Sun, 13 Jun 2010 17:50:54 +0000 (17:50 +0000)
committerStefan Fritsch <sf@apache.org>
Sun, 13 Jun 2010 17:50:54 +0000 (17:50 +0000)
MPM event was picking up the headers but not linking with libserf, causing
unresolved symbol errors.

Now build MPM event with or without serf support depending on --with-serf
being specified or not.

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

acinclude.m4
modules/proxy/config.m4
modules/proxy/mod_serf.h
server/mpm/event/config3.m4
server/mpm/event/event.c

index 6f7fe7466cb8c625e38831a5b1299c2c45464b7f..5976690dd3519e774f57fdfd11352e3460da6740 100644 (file)
@@ -201,7 +201,7 @@ EOF
 ])dnl
 
 dnl
-dnl APACHE_MPM_MODULE(name[, shared[, objects[, config[, path]]]])
+dnl APACHE_MPM_MODULE(name[, shared[, objects[, config[, path[, libs]]]]])
 dnl
 dnl Provide information for building the MPM.  (Enablement is handled using
 dnl --with-mpm/--enable-mpms-shared.)
@@ -211,6 +211,7 @@ dnl shared   -- "shared" to indicate shared module build, empty string otherwise
 dnl objects  -- one or more .lo files to link into the MPM module (default: mpmname.lo)
 dnl config   -- configuration logic to run if the MPM is enabled
 dnl path     -- relative path to MPM (default: server/mpm/mpmname)
+dnl libs     -- libs needed by this MPM
 dnl
 AC_DEFUN(APACHE_MPM_MODULE,[
     if ap_mpm_is_enabled $1; then
@@ -232,6 +233,7 @@ AC_DEFUN(APACHE_MPM_MODULE,[
         APACHE_FAST_OUTPUT($mpmpath/Makefile)
 
         if test -z "$2"; then
+            APR_ADDTO(AP_LIBS, [$6])
             libname="lib$1.la"
             cat >$mpmpath/modules.mk<<EOF
 $libname: $objects
@@ -246,7 +248,7 @@ EOF
             shobjects=`echo $objects | sed 's/\.lo/.slo/g'`
             cat >$mpmpath/modules.mk<<EOF
 $libname: $shobjects
-       \$(SH_LINK) -rpath \$(libexecdir) -module -avoid-version $objects
+       \$(SH_LINK) -rpath \$(libexecdir) -module -avoid-version $objects $6
 DISTCLEAN_TARGETS = modules.mk
 static =
 shared = $libname
@@ -575,6 +577,48 @@ if test "x$ap_ssltk_configured" = "x"; then
 fi
 ])
 
+dnl
+dnl APACHE_CHECK_SERF
+dnl
+dnl Configure for the detected libserf, giving preference to
+dnl "--with-serf=<path>" if it was specified.
+dnl
+AC_DEFUN([APACHE_CHECK_SERF], [
+  AC_CACHE_CHECK([for libserf], [ac_cv_serf], [
+    ac_cv_serf=no
+    serf_prefix=no
+    SERF_LIBS=""
+    AC_ARG_WITH(serf, APACHE_HELP_STRING([--with-serf=PREFIX],
+                                    [Serf client library]),
+    [
+        if test "$withval" = "yes" ; then
+          serf_prefix=/usr
+        else
+          serf_prefix=$withval
+        fi
+    ])
+
+    if test "$serf_prefix" != "no" ; then
+      save_cppflags="$CPPFLAGS"
+      CPPFLAGS="$CPPFLAGS $APR_INCLUDES $APU_INCLUDES -I$serf_prefix/include/serf-0"
+      AC_CHECK_HEADERS(serf.h,[
+        save_ldflags="$LDFLAGS"
+        LDFLAGS="$LDFLAGS -L$serf_prefix/lib"
+        AC_CHECK_LIB(serf-0, serf_context_create,[ac_cv_serf="yes"])
+        LDFLAGS="$save_ldflags"])
+      CPPFLAGS="$save_cppflags"
+    fi
+  ])
+
+  APACHE_SUBST(SERF_LIBS)
+  if test "$ac_cv_serf" = "yes"; then
+    AC_DEFINE(HAVE_SERF, 1, [Define if libserf is available])
+    APR_SETVAR(SERF_LIBS, [-L$serf_prefix/lib -lserf-0])
+    APR_ADDTO(INCLUDES, [-I$serf_prefix/include/serf-0])
+  fi
+])
+
+
 dnl
 dnl APACHE_EXPORT_ARGUMENTS
 dnl Export (via APACHE_SUBST) the various path-related variables that
index f382dde8ed9b02b5fa27a2d4cb5bdfa320cfda62..ad24349a9c79e65eac3f41297727e7f9d6c4dda4 100644 (file)
@@ -59,37 +59,13 @@ APACHE_MODULE(proxy_fdpass, Apache proxy to Unix Daemon Socket module, $proxy_fd
 APACHE_MODULE(proxy_ajp, Apache proxy AJP module, $proxy_ajp_objs, , $proxy_mods_enable)
 APACHE_MODULE(proxy_balancer, Apache proxy BALANCER module, $proxy_balancer_objs, , $proxy_mods_enable)
 
-
-AC_DEFUN([CHECK_SERF], [
-  serf_found="no"
-  AC_ARG_WITH(serf, APACHE_HELP_STRING([--with-serf=PREFIX],
-                                  [Serf client library]),
-  [
-    if test "$withval" = "yes" ; then
-      AC_MSG_ERROR([--with-serf requires an argument.])
+APACHE_MODULE(serf, [Reverse proxy module using Serf], , , no, [
+    APACHE_CHECK_SERF
+    if test "$ac_cv_serf" = "yes" ; then
+      APR_SETVAR(MOD_SERF_LDADD, [\$(SERF_LIBS)])
     else
-      serf_prefix=$withval
-      save_cppflags="$CPPFLAGS"
-      CPPFLAGS="$CPPFLAGS $APR_INCLUDES $APU_INCLUDES -I$serf_prefix/include/serf-0"
-      AC_CHECK_HEADERS(serf.h,[
-        save_ldflags="$LDFLAGS"
-        LDFLAGS="$LDFLAGS -L$serf_prefix/lib"
-        AC_CHECK_LIB(serf-0, serf_context_create,[serf_found="yes"])
-        LDFLAGS="$save_ldflags"])
-      CPPFLAGS="$save_cppflags"
+      AC_MSG_ERROR("libserf not found")
     fi
-  ])
-
-  if test "$serf_found" = "yes"; then
-    MOD_SERF_LDADD="-L$serf_prefix/lib -lserf-0"
-    APR_ADDTO(INCLUDES, ["-I$serf_prefix/include/serf-0"])
-  else
-    AC_MSG_ERROR(unable to find serf)
-  fi
-])
-
-APACHE_MODULE(serf, [Reverse proxy module using Serf], , , no, [
-    CHECK_SERF
 ])
 
 APR_ADDTO(INCLUDES, [-I\$(top_srcdir)/$modpath_current])
index 2aaaa3dc3bde93d5658653f1b1d87a33d8c44e01..90353ad3052c918a3426ebaec2eb7746cf155834 100644 (file)
 #if !defined(WIN32) && !defined(NETWARE)
 #include "ap_config_auto.h"
 #endif
-#ifdef HAVE_SERF_H
+#ifdef HAVE_SERF
 #include "serf.h"
-#ifndef AP_HAS_SERF
-#define AP_HAS_SERF 1
-#endif
 #endif
 
 #include "ap_provider.h"
index 649d863874670081060422fde0aec03e632e790c..abe66477c645f8c0042d337ef691544dff43824a 100644 (file)
@@ -1,5 +1,11 @@
 dnl ## XXX - Need a more thorough check of the proper flags to use
 
+APACHE_CHECK_SERF
+if test "$ac_cv_serf" = yes ; then
+    APR_SETVAR(MOD_MPM_EVENT_LDADD,[\$(SERF_LIBS)])
+fi
+APACHE_SUBST(MOD_MPM_EVENT_LDADD)
+
 APACHE_MPM_MODULE(event, $enable_mpm_event, event.lo fdqueue.lo pod.lo,[
     AC_CHECK_FUNCS(pthread_kill)
-])
+], , [\$(MOD_MPM_EVENT_LDADD)])
index c7f6b0ec30a9a77624e0f7ff958a1dcea44ab139..371eb6620d24abba70164b9300f001e43fe6a494 100644 (file)
@@ -95,9 +95,9 @@
 #include <signal.h>
 #include <limits.h>             /* for INT_MAX */
 
-#include "mod_serf.h"
 
-#if AP_HAS_SERF
+#if HAVE_SERF
+#include "mod_serf.h"
 #include "serf.h"
 #endif
 
@@ -178,7 +178,7 @@ static struct timeout_head_t timeout_head, keepalive_timeout_head;
 
 static apr_pollset_t *event_pollset;
 
-#if AP_HAS_SERF
+#if HAVE_SERF
 typedef struct {
     apr_pollset_t *pollset;
     apr_pool_t *pool;
@@ -210,7 +210,7 @@ typedef enum
 {
     PT_CSD,
     PT_ACCEPT
-#if AP_HAS_SERF
+#if HAVE_SERF
     , PT_SERF
 #endif
 } poll_type_e;
@@ -796,7 +796,7 @@ static void dummy_signal_handler(int sig)
 }
 
 
-#if AP_HAS_SERF
+#if HAVE_SERF
 static apr_status_t s_socket_add(void *user_baton,
                                  apr_pollfd_t *pfd,
                                  void *serf_baton)
@@ -823,7 +823,7 @@ static apr_status_t s_socket_remove(void *user_baton,
 
 static apr_status_t init_pollset(apr_pool_t *p)
 {
-#if AP_HAS_SERF
+#if HAVE_SERF
     s_baton_t *baton = NULL;
 #endif
     apr_status_t rv;
@@ -868,7 +868,7 @@ static apr_status_t init_pollset(apr_pool_t *p)
         lr->accept_func = ap_unixd_accept;
     }
 
-#if AP_HAS_SERF
+#if HAVE_SERF
     baton = apr_pcalloc(p, sizeof(*baton));
     baton->pollset = event_pollset;
     /* TODO: subpools, threads, reuse, etc.  -- currently use malloc() inside :( */
@@ -1095,7 +1095,7 @@ static void * APR_THREAD_FUNC listener_thread(apr_thread_t * thd, void *dummy)
             apr_thread_mutex_unlock(g_timer_ring_mtx);
         }
 
-#if AP_HAS_SERF
+#if HAVE_SERF
         rc = serf_context_prerun(g_serf);
         if (rc != APR_SUCCESS) {
             /* TOOD: what should do here? ugh. */
@@ -1233,7 +1233,7 @@ static void * APR_THREAD_FUNC listener_thread(apr_thread_t * thd, void *dummy)
                     ap_push_pool(worker_queue_info, ptrans);
                 }
             }               /* if:else on pt->type */
-#if AP_HAS_SERF
+#if HAVE_SERF
             else if (pt->type == PT_SERF) {
                 /* send socket to serf. */
                 /* XXXX: this doesn't require get_worker(&have_idle_worker) */