]> git.ipfire.org Git - thirdparty/lldpd.git/blob - m4/libevent.m4
Update changelog, travis and packaging for libevent
[thirdparty/lldpd.git] / m4 / libevent.m4
1 #
2 # lldp_CHECK_LIBEVENT
3 #
4
5 AC_DEFUN([lldp_CHECK_LIBEVENT], [
6 LIBEVENT_URL=http://libevent.org/
7 _save_LIBS="$LIBS"
8 _save_CFLAGS="$CFLAGS"
9 _save_CC="$CC"
10
11 # First, try with pkg-config
12 PKG_CHECK_MODULES([LIBEVENT], [libevent >= 1.4.3], [], [:])
13
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
17 :
18 else
19 # Black magic....
20 if test -d "$1"; then
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"
25 else
26 LIBEVENT_LIBS="-L${libevent_dir} -levent"
27 fi
28 if test -d "${libevent_dir}/include"; then
29 LIBEVENT_CFLAGS="-I${libevent_dir}/include"
30 else
31 LIBEVENT_CFLAGS="-I${libevent_dir}"
32 fi
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"`
39 break
40 fi
41 done
42 else
43 AC_MSG_RESULT(failed)
44 AC_MSG_ERROR([*** non-existant directory ($1) specified for libevent!])
45 fi
46 fi
47 fi
48
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"
53 AC_TRY_LINK([
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 ])
58
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])
63 else
64 if test x"$LIBEVENT_LIBS" = x; then
65 AC_MSG_RESULT([no libevent])
66 else
67 AC_MSG_RESULT([failed with $LIBEVENT_LIBS $LIBEVENT_CFLAGS])
68 fi
69 AC_MSG_ERROR([
70 *** libevent 2.x is required. Grab it from $LIBEVENT_URL
71 *** or install libevent-dev package])
72 fi
73
74 CC="$_save_CC"
75 LIBS="$_save_LIBS"
76 CFLAGS="$_save_CFLAGS"
77 ])