make
sudo make install
-You need libevent that you can grab from
-http://www.monkey.org/~provos/libevent/ or install from your package
-system (libevent-dev for Debian/Ubuntu and libevent-devel for
-Redhat/Fedora/CentOS/SuSE).
-
-You can also compile libevent statically:
-
- ./configure --with-libevent=/usr/lib/libevent.a
+You need libevent that you can grab from http://libevent.org or
+install from your package system (libevent-dev for Debian/Ubuntu and
+libevent-devel for Redhat/Fedora/CentOS/SuSE).
If your system does not have libevent, here is a quick howto to
download it and compile it statically into lldpd:
# Grab and compile libevent
- wget http://www.monkey.org/~provos/libevent-1.4.13-stable.tar.gz
- tar zxvf libevent-1.4.13-stable.tar.gz
- cd libevent-1.4.13-stable
- ./configure
+ wget https://github.com/downloads/libevent/libevent/libevent-2.0.16-stable.tar.gz
+ tar zxvf libevent-2.0.16-stable.tar.gz
+ cd libevent-2.0.16-stable
+ ./configure --prefix=$PWD/usr/local --enable-static --disable-shared
make
+ make install
# Compile lldpd with static linking
cd ..
- ./configure --with-libevent=libevent-1.4.13-stable/usr/local/lib/libevent.a
+ ./configure --with-libevent=libevent-2.0.16-stable/usr/local/lib/libevent.la
make
sudo make install
#
AC_DEFUN([lldp_CHECK_LIBEVENT], [
- LIBEVENT_URL=http://www.monkey.org/~provos/libevent/
-
- AC_MSG_CHECKING([how to compile with libevent])
+ LIBEVENT_URL=http://libevent.org/
_save_LIBS="$LIBS"
_save_CFLAGS="$CFLAGS"
+ _save_CC="$CC"
+
+ # First, try with pkg-config
+ PKG_CHECK_MODULES([LIBEVENT], [libevent >= 2.0.5], [], [:])
+
+ AC_MSG_CHECKING([how to compile with libevent])
if test x"$1" = x -o x"$1" = x"yes"; then
- # Nothing specified, use default location
- LIBEVENT_LIBS="-levent"
+ # Nothing specified, use default location from pkg-config
+ :
else
+ # Black magic....
if test -d "$1"; then
+ libevent_dir=`readlink -f "$1"`
# Directory, dynamic linking
- if test -d "$1/lib"; then
- LIBEVENT_LIBS="-L$1/lib -levent"
+ if test -d "${libevent_dir}/lib"; then
+ LIBEVENT_LIBS="-L${libevent_dir}/lib -levent"
else
- LIBEVENT_LIBS="-L$1 -levent"
+ LIBEVENT_LIBS="-L${libevent_dir} -levent"
fi
- if test -d "$1/include"; then
- LIBEVENT_CFLAGS="-I$1/include"
+ if test -d "${libevent_dir}/include"; then
+ LIBEVENT_CFLAGS="-I${libevent_dir}/include"
else
- LIBEVENT_CFLAGS="-I$1"
+ LIBEVENT_CFLAGS="-I${libevent_dir}"
fi
else if test -f "$1"; then
- # Static linking is a bit difficult, we need to "guess dependencies"
- LIBEVENT_LIBS="$1 -lrt"
+ LIBEVENT_LIBS=`readlink -f "$1"`
dir=`AS_DIRNAME(["$1"])`
for includedir in "$dir/include" "$dir/../include" "$dir"; do
if test -d "$includedir"; then
- LIBEVENT_CFLAGS="-I$includedir"
+ LIBEVENT_CFLAGS=-I`readlink -f "$includedir"`
break
fi
done
fi
fi
- # Can I compile and link it?
+ # Can I compile and link it? We need to use libtool
LIBS="$LIBS $LIBEVENT_LIBS"
CFLAGS="$LIBEVENT_CFLAGS $CFLAGS"
+ CC="${SHELL-/bin/sh} libtool link $CC"
AC_TRY_LINK([
@%:@include <sys/time.h>
@%:@include <sys/types.h>
-@%:@include <event.h>], [ event_init(); ],
+@%:@include <event2/event.h>], [ event_base_new(); ],
[ libevent_linked=yes ], [ libevent_linked=no ])
if test x"$libevent_linked" = x"yes"; then
AC_SUBST([LIBEVENT_LIBS])
AC_SUBST([LIBEVENT_CFLAGS])
- AC_MSG_RESULT([ok with "$LIBEVENT_LIBS $LIBEVENT_CFLAGS"])
+ AC_MSG_RESULT([ok with $LIBEVENT_LIBS $LIBEVENT_CFLAGS])
else
- AC_MSG_RESULT([failed with "$LIBEVENT_LIBS $LIBEVENT_CFLAGS"])
+ if test x"$LIBEVENT_LIBS" = x; then
+ AC_MSG_RESULT([no libevent])
+ else
+ AC_MSG_RESULT([failed with $LIBEVENT_LIBS $LIBEVENT_CFLAGS])
+ fi
AC_MSG_ERROR([
-*** libevent is required. Grab it from $LIBEVENT_URL
+*** libevent 2.x is required. Grab it from $LIBEVENT_URL
*** or install libevent-dev package])
fi
+ CC="$_save_CC"
LIBS="$_save_LIBS"
CFLAGS="$_save_CFLAGS"
])