Update m4.
[m6w6/libmemcached] / m4 / ax_libevent.m4
1 # https://github.com/BrianAker/ddm4
2 # ===========================================================================
3 #
4 # SYNOPSIS
5 #
6 # AX_LIBEVENT(), AX_LIBEVENT2()
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_CACHE_CHECK([test for a working libevent], [ax_cv_libevent], [
25 AX_SAVE_FLAGS
26 LIBS="-levent $LIBS"
27 AC_LANG_PUSH([C])
28 AC_RUN_IFELSE([
29 AC_LANG_PROGRAM([
30 #include <sys/types.h>
31 #include <sys/time.h>
32 #include <stdlib.h>
33 #include <event.h>
34 ], [
35 struct event_base *tmp_event= event_init();
36 event_base_free(tmp_event);
37 ])],
38 [ax_cv_libevent=yes],
39 [ax_cv_libevent=no],
40 [AC_MSG_WARN([test program execution failed])])
41 AC_LANG_POP
42 AX_RESTORE_FLAGS
43 ])
44
45 AS_IF([test "x$ax_cv_libevent" = "xyes"],[
46 LIBEVENT_LDFLAGS="-levent"
47 AC_SUBST(LIBEVENT_LDFLAGS)
48 AC_DEFINE([HAVE_LIBEVENT],[1],[Define if event_init is present in event.h.])],[
49 AC_DEFINE([HAVE_LIBEVENT],[0],[Define if event_init is present in event.h.])
50 ])
51
52 AM_CONDITIONAL(HAVE_LIBEVENT, test "x$ax_cv_libevent" = "xyes")
53 ])
54
55 AC_DEFUN([AX_LIBEVENT2],[
56 AC_REQUIRE([AX_LIBEVENT])
57 AC_CACHE_CHECK([test for a working libevent version 2], [ax_cv_libevent2], [
58 AX_SAVE_FLAGS
59 LIBS="-levent $LIBS"
60 AC_LANG_PUSH([C])
61 AC_RUN_IFELSE([
62 AC_LANG_PROGRAM([
63 #include <sys/types.h>
64 #include <sys/time.h>
65 #include <stdlib.h>
66 #include <event2/event.h>
67 #include <event2/http.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