blob: 9d5c52552c8539e77fb05f23298dab36ebd1a9a3 [file] [log] [blame]
Marc Slemko85ca7a12007-01-17 08:32:16 +00001dnl @synopsis AX_EVENT([MINIMUM-VERSION])
2dnl
3dnl Test for the libevent libraries of a particular version (or newer)
4dnl
5dnl If no path to the installed event library is given the macro
6dnl searchs under /usr, /usr/local, and /opt, and evaluates the
7dnl $EVENT_ROOT environment variable.
8dnl
9dnl This macro calls:
10dnl
11dnl AC_SUBST(EVENT_CPPFLAGS) / AC_SUBST(EVENT_LDFLAGS)
12dnl
13dnl And sets:
14dnl
15dnl HAVE_EVENT
16dnl
17dnl @category InstalledPackages
18dnl @category Cxx
19dnl @author Marc Kwiatkowski <marc@facebook.com>
20dnl @version 2006-06-15
21dnl @license AllPermissive
22
23AC_DEFUN([AX_EVENT_BASE],
24[
25AC_ARG_WITH([event],
26 AS_HELP_STRING([--with-event@<:@=DIR@:>@], [use event (default is yes) - it is possible to specify an alternate root directory for event]),
27 [
28 if test "$withval" = "no"; then
29 want_event="no"
30 elif test "$withval" = "yes"; then
31 want_event="yes"
32 ac_event_path=""
33 else
34 want_event="yes"
35 ac_event_path="$withval"
36 fi
37 ],
38 [want_event="yes"])
39
40if test "x$want_event" = "xyes"; then
41 event_lib_version_req=ifelse([$1], ,1.2.0,$1)
42 event_lib_version_req_shorten=`expr $event_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
43 event_lib_version_req_major=`expr $event_lib_version_req : '\([[0-9]]*\)'`
44 event_lib_version_req_minor=`expr $event_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
45 event_lib_version_req_sub_minor=`expr $event_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
46 if test "x$event_lib_version_req_sub_minor" = "x" ; then
47 event_lib_version_req_sub_minor="0"
48 fi
49 WANT_EVENT_VERSION=`expr $event_lib_version_req_major \* 10000 \+ $event_lib_version_req_minor \* 100 \+ $event_lib_version_req_sub_minor`
50 WANT_EVENT_MAJOR_VERSION=$event_lib_version_req_major
51 WANT_EVENT_MINOR_VERSION=$event_lib_version_req_minor
52 AC_MSG_CHECKING(for eventlib >= $event_lib_version_req)
53 succeeded=no
54
55 if test "$ac_event_path" != "" && test -f "$ac_event_path/include/event.h"; then
56 ac_event_include_path=$ac_event_path/include
57 EVENT_CPPFLAGS="-I$ac_event_include_path"
58 EVENT_LDFLAGS="-L$ac_event_path/lib -levent"
59 succeeded=yes
60 else
61 for ac_event_path_tmp in /usr /usr/local /opt ; do
62 if test -f "$ac_event_path_tmp/include/event.h"; then
63 ac_event_include_path=$ac_event_path_tmp/include
64 EVENT_CPPFLAGS="-I$ac_event_include_path"
65 EVENT_LDFLAGS="-L$ac_event_path_tmp/lib -levent"
66 succeeded=yes
67 break;
68 fi
69 done
70 fi
71
72 if test "$succeeded" != "yes" ; then
Mark Sleeba354562007-04-03 07:31:51 +000073 AC_MSG_ERROR([[We could not detect the event libraries (version $event_lib_version_req_shorten or higher). If you have a staged event library (still not installed) please specify \$EVENT_ROOT in your environment and do not give a PATH to --with-event option. If you are sure you have event installed, then check your version number looking in <event.h>. See http://www.monkey.org/~provos/libevent/ for more documentation.]])
Marc Slemko85ca7a12007-01-17 08:32:16 +000074 else
75 AC_SUBST(EVENT_CPPFLAGS)
76 AC_SUBST(EVENT_LDFLAGS)
77 AC_DEFINE(HAVE_EVENT,,[define if the EVENT library is available])
78 fi
79
80 CPPFLAGS="$CPPFLAGS_SAVED"
81 LDFLAGS="$LDFLAGS_SAVED"
82fi
83
84])