Update m4
[m6w6/libmemcached] / m4 / ax_libevent.m4
1 # https://github.com/BrianAker/ddm4
2 # ===========================================================================
3 #
4 # SYNOPSIS
5 #
6 # AX_LIBEVENT(), AX_LIBEVENT2(), AX_LIBEVENT2_EVHTTP()
7 #
8 # DESCRIPTION
9 #
10 # libevent library
11 #
12 # LICENSE
13 #
14 # Copyright (c) 2012 Brian Aker <brian@tangent.org>
15 #
16 # Copying and distribution of this file, with or without modification, are
17 # permitted in any medium without royalty provided the copyright notice
18 # and this notice are preserved. This file is offered as-is, without any
19 # warranty.
20
21 #serial 2
22
23 AC_DEFUN([AX_LIBEVENT],
24 [AC_PREREQ([2.63])dnl
25 AC_CACHE_CHECK([test for a working libevent], [ax_cv_libevent], [
26 AX_SAVE_FLAGS
27 LIBS="-levent $LIBS"
28 AC_LANG_PUSH([C])
29 AC_RUN_IFELSE([
30 AC_LANG_PROGRAM([
31 #include <sys/types.h>
32 #include <sys/time.h>
33 #include <stdlib.h>
34 #include <event.h>
35 ], [
36 struct event_base *tmp_event= event_init();
37 event_base_free(tmp_event);
38 ])],
39 [ax_cv_libevent=yes],
40 [ax_cv_libevent=no],
41 [AC_MSG_WARN([test program execution failed])])
42 AC_LANG_POP
43 AX_RESTORE_FLAGS
44 ])
45
46 AS_IF([test "x$ax_cv_libevent" = "xyes"],[
47 LIBEVENT_LDFLAGS="-levent"
48 AC_SUBST(LIBEVENT_LDFLAGS)
49 AC_DEFINE([HAVE_LIBEVENT],[1],[Define if event_init is present in event.h.])],[
50 AC_DEFINE([HAVE_LIBEVENT],[0],[Define if event_init is present in event.h.])
51 ])
52
53 AM_CONDITIONAL(HAVE_LIBEVENT, test "x$ax_cv_libevent" = "xyes")
54 ])
55
56 AC_DEFUN([AX_LIBEVENT2],[
57 AC_REQUIRE([AX_LIBEVENT])
58 AC_CACHE_CHECK([test for a working libevent version 2], [ax_cv_libevent2], [
59 AX_SAVE_FLAGS
60 LIBS="-levent $LIBS"
61 AC_LANG_PUSH([C])
62 AC_RUN_IFELSE([
63 AC_LANG_PROGRAM([
64 #include <sys/types.h>
65 #include <sys/time.h>
66 #include <stdlib.h>
67 #include <event2/event.h>
68 ],[
69 struct event_base *tmp_event= event_init();
70 event_base_free(tmp_event);
71 ])],
72 [ax_cv_libevent2=yes],
73 [ax_cv_libevent2=no],
74 [AC_MSG_WARN([test program execution failed])])
75 AC_LANG_POP
76 AX_RESTORE_FLAGS
77 ])
78
79 AS_IF([test "x$ax_cv_libevent2" = "xyes"],[
80 LIBEVENT2_LDFLAGS="-levent"
81 AC_SUBST(LIBEVENT2_LDFLAGS)
82 AC_DEFINE([HAVE_LIBEVENT2],[1],[Define if event_init is present in event2/event.h.])],[
83 AC_DEFINE([HAVE_LIBEVENT2],[0],[Define if event_init is present in event2/event.h.])
84 ])
85
86 AM_CONDITIONAL(HAVE_LIBEVENT2, test "x$ax_cv_libevent2" = "xyes")
87 ])
88
89 AC_DEFUN([AX_LIBEVENT2_EVHTTP],[
90 AC_REQUIRE([AX_LIBEVENT2])
91 AC_CACHE_CHECK([test for a working libevent2 evhttp interface], [ax_cv_libevent2_evhttp], [
92 AX_SAVE_FLAGS
93 LIBS="-levent $LIBS"
94 AC_LANG_PUSH([C])
95 AC_RUN_IFELSE([
96 AC_LANG_PROGRAM([
97 #include <sys/types.h>
98 #include <sys/time.h>
99 #include <stdlib.h>
100 #include <event2/event.h>
101 #include <event2/http.h>
102 ],[
103 struct event_base *libbase= event_base_new();
104 struct evhttp *libsrvr= evhttp_new(libbase);
105 ])],
106 [ax_cv_libevent2_evhttp=yes],
107 [ax_cv_libevent2_evhttp=no],
108 [AC_MSG_WARN([test program execution failed])])
109 AC_LANG_POP
110 AX_RESTORE_FLAGS
111 ])
112
113 AS_IF([test "x$ax_cv_libevent2_evhttp" = "xyes"],[
114 LIBEVENT2_LDFLAGS="-levent"
115 AC_SUBST(LIBEVENT2_LDFLAGS)
116 AC_DEFINE([HAVE_LIBEVENT2],[1],[Define if event_init is present in event2/event.h.])],[
117 AC_DEFINE([HAVE_LIBEVENT2],[0],[Define if event_init is present in event2/event.h.])
118 ])
119
120 AM_CONDITIONAL(HAVE_LIBEVENT2_EVHTTP, test "x$ax_cv_libevent2_evhttp" = "xyes")
121 ])