5 AC_DEFUN([lldp_CHECK_LIBEVENT], [
6 LIBEVENT_URL=http://libevent.org/
11 # First, try with pkg-config
12 PKG_CHECK_MODULES([LIBEVENT], [libevent >= 1.4.3], [], [:])
14 AC_MSG_CHECKING([how to compile with libevent])
15 if test x"$1" = x -o x"$1" = x"yes"; then
16 # Nothing specified, use default location from pkg-config
21 libevent_dir=`readlink -f "$1"`
22 # Directory, dynamic linking
23 if test -d "${libevent_dir}/lib"; then
24 LIBEVENT_LIBS="-L${libevent_dir}/lib -levent"
26 LIBEVENT_LIBS="-L${libevent_dir} -levent"
28 if test -d "${libevent_dir}/include"; then
29 LIBEVENT_CFLAGS="-I${libevent_dir}/include"
31 LIBEVENT_CFLAGS="-I${libevent_dir}"
33 else if test -f "$1"; then
34 LIBEVENT_LIBS=`readlink -f "$1"`
35 dir=`AS_DIRNAME(["$1"])`
36 for includedir in "$dir/include" "$dir/../include" "$dir"; do
37 if test -d "$includedir"; then
38 LIBEVENT_CFLAGS=-I`readlink -f "$includedir"`
44 AC_MSG_ERROR([*** non-existant directory ($1) specified for libevent!])
49 # Can I compile and link it? We need to use libtool
50 LIBS="$LIBS $LIBEVENT_LIBS"
51 CFLAGS="$LIBEVENT_CFLAGS $CFLAGS"
52 CC="${SHELL-/bin/sh} libtool link $CC"
54 @%:@include <sys/time.h>
55 @%:@include <sys/types.h>
56 @%:@include <event2/event.h>], [ event_base_new(); ],
57 [ libevent_linked=yes ], [ libevent_linked=no ])
59 if test x"$libevent_linked" = x"yes"; then
60 AC_SUBST([LIBEVENT_LIBS])
61 AC_SUBST([LIBEVENT_CFLAGS])
62 AC_MSG_RESULT([ok with $LIBEVENT_LIBS $LIBEVENT_CFLAGS])
64 if test x"$LIBEVENT_LIBS" = x; then
65 AC_MSG_RESULT([no libevent])
67 AC_MSG_RESULT([failed with $LIBEVENT_LIBS $LIBEVENT_CFLAGS])
70 *** libevent 2.x is required. Grab it from $LIBEVENT_URL
71 *** or install libevent-dev package])
76 CFLAGS="$_save_CFLAGS"