Update m4.
[awesomized/libmemcached] / m4 / ax_libevent.m4
index 79999ef761adff0479c20a345d11e064ae055a10..ebe1f2ad4f15efae00fea31a7b04b6b016ed99da 100644 (file)
@@ -3,7 +3,7 @@
 #
 # SYNOPSIS
 #
-#   AX_LIBEVENT()
+#   AX_LIBEVENT(), AX_LIBEVENT2()
 #
 # DESCRIPTION
 #
@@ -18,7 +18,7 @@
 #   and this notice are preserved. This file is offered as-is, without any
 #   warranty.
 
-#serial 1
+#serial 2
  
   AC_DEFUN([AX_LIBEVENT],[
       AC_CACHE_CHECK([test for a working libevent], [ax_cv_libevent], [
         LIBS="-levent $LIBS"
         AC_LANG_PUSH([C])
         AC_RUN_IFELSE([
-          AC_LANG_PROGRAM([#include <event.h>], [
+          AC_LANG_PROGRAM([
+#include <sys/types.h>
+#include <sys/time.h>
+#include <stdlib.h>
+#include <event.h>
+            ], [
             struct event_base *tmp_event= event_init();
             event_base_free(tmp_event);
             ])],
         LIBEVENT_LDFLAGS="-levent"
         AC_SUBST(LIBEVENT_LDFLAGS)
         AC_DEFINE([HAVE_LIBEVENT],[1],[Define if event_init is present in event.h.])],[
-        AC_DEFINE([HAVE_LIBEVENT],[0],[Define if event_init is present in event_init.h.])
+        AC_DEFINE([HAVE_LIBEVENT],[0],[Define if event_init is present in event.h.])
         ])
 
       AM_CONDITIONAL(HAVE_LIBEVENT, test "x$ax_cv_libevent" = "xyes")
       ])
 
+  AC_DEFUN([AX_LIBEVENT2],[
+      AC_REQUIRE([AX_LIBEVENT])
+      AC_CACHE_CHECK([test for a working libevent version 2], [ax_cv_libevent2], [
+        AX_SAVE_FLAGS
+        LIBS="-levent $LIBS"
+        AC_LANG_PUSH([C])
+        AC_RUN_IFELSE([
+          AC_LANG_PROGRAM([
+#include <sys/types.h>
+#include <sys/time.h>
+#include <stdlib.h>
+#include <event2/event.h>
+#include <event2/http.h>
+            ], [
+            struct event_base *tmp_event= event_init();
+            event_base_free(tmp_event);
+            ])],
+          [ax_cv_libevent2=yes],
+          [ax_cv_libevent2=no],
+          [AC_MSG_WARN([test program execution failed])])
+        AC_LANG_POP
+        AX_RESTORE_FLAGS
+        ])
+
+      AS_IF([test "x$ax_cv_libevent2" = "xyes"],[
+        LIBEVENT2_LDFLAGS="-levent"
+        AC_SUBST(LIBEVENT2_LDFLAGS)
+        AC_DEFINE([HAVE_LIBEVENT2],[1],[Define if event_init is present in event2/event.h.])],[
+        AC_DEFINE([HAVE_LIBEVENT2],[0],[Define if event_init is present in event2/event.h.])
+        ])
+
+      AM_CONDITIONAL(HAVE_LIBEVENT2, test "x$ax_cv_libevent2" = "xyes")
+      ])
+