Additional m4 updates.
[m6w6/libmemcached] / m4 / pandora_have_libevent.m4
1 dnl Copyright (C) 2009 Sun Microsystems, Inc.
2 dnl This file is free software; Sun Microsystems, Inc.
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
5
6 #--------------------------------------------------------------------
7 # Check for libevent
8 #--------------------------------------------------------------------
9
10
11 AC_DEFUN([_PANDORA_SEARCH_LIBEVENT],[
12 AC_REQUIRE([AC_LIB_PREFIX])
13
14 AC_LIB_HAVE_LINKFLAGS(event,,
15 [
16 #include <sys/types.h>
17 #include <sys/time.h>
18 #include <stdlib.h>
19 #include <event.h>
20 ],[
21 struct bufferevent bev;
22 bufferevent_settimeout(&bev, 1, 1);
23 event_init();
24 event_loop(EVLOOP_ONCE);
25 ])
26
27 AM_CONDITIONAL(HAVE_LIBEVENT, [test "x${ac_cv_libevent}" = "xyes"])
28
29 AS_IF([test "x${ac_cv_libevent}" = "xyes"],[
30 save_LIBS="${LIBS}"
31 LIBS="${LIBS} ${LTLIBEVENT}"
32 AC_CHECK_FUNCS(event_base_new)
33 AC_CHECK_FUNCS(event_base_free)
34 AC_CHECK_FUNCS(event_base_get_method)
35 LIBS="$save_LIBS"
36 ])
37 ])
38
39 AC_DEFUN([_PANDORA_HAVE_LIBEVENT],[
40
41 AC_ARG_ENABLE([libevent],
42 [AS_HELP_STRING([--disable-libevent],
43 [Build with libevent support @<:@default=on@:>@])],
44 [ac_enable_libevent="$enableval"],
45 [ac_enable_libevent="yes"])
46
47 _PANDORA_SEARCH_LIBEVENT
48 ])
49
50
51 AC_DEFUN([PANDORA_HAVE_LIBEVENT],[
52 AC_REQUIRE([_PANDORA_HAVE_LIBEVENT])
53 ])
54
55 AC_DEFUN([_PANDORA_REQUIRE_LIBEVENT],[
56 ac_enable_libevent="yes"
57 _PANDORA_SEARCH_LIBEVENT
58
59 AS_IF([test x$ac_cv_libevent = xno],[
60 AC_MSG_ERROR([libevent is required for ${PACKAGE}. On Debian this can be found in libevent-dev. On RedHat this can be found in libevent-devel.])
61 ])
62 ])
63
64 AC_DEFUN([PANDORA_REQUIRE_LIBEVENT],[
65 AC_REQUIRE([_PANDORA_REQUIRE_LIBEVENT])
66 ])