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
+
+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
+ make
+
+ # Compile lldpd with static linking
+ cd ..
+ ./configure --with-libevent=libevent-1.4.13-stable/usr/local/lib/libevent.a
+ make
+ sudo make install
+
If it complains about a missing agent/struct.h, your installation of
Net-SNMP is incomplete. The easiest way to fix this is to provide an
empty struct.h:
lldp_CHECK_SNMP
fi
+# XML
AC_ARG_WITH([xml],
AC_HELP_STRING(
[--with-xml],
lldp_CHECK_XML2
fi
+# Libevent
+lldp_ARG_WITH([libevent], [Location of libevent directory (or libevent.a)], [])
+lldp_CHECK_LIBEVENT([$with_libevent])
+
# Privsep settings
lldp_ARG_WITH([privsep-user], [Which user to use for privilege separation], [_lldpd])
lldp_ARG_WITH([privsep-group], [Which group to use for privilege separation], [_lldpd])
--- /dev/null
+#
+# lldp_CHECK_LIBEVENT
+#
+
+AC_DEFUN([lldp_CHECK_LIBEVENT], [
+ LIBEVENT_URL=http://www.monkey.org/~provos/libevent/
+
+ AC_MSG_CHECKING([how to compile with libevent])
+ _save_LIBS="$LIBS"
+ _save_CFLAGS="$CFLAGS"
+ if test x"$1" = x -o x"$1" = x"yes"; then
+ # Nothing specified, use default location
+ LIBEVENT_LIBS="-levent"
+ else
+ if test -d "$1"; then
+ # Directory, dynamic linking
+ if test -d "$1/lib"; then
+ LIBEVENT_LIBS="-L$1/lib -levent"
+ else
+ LIBEVENT_LIBS="-L$1 -levent"
+ fi
+ if test -d "$1/include"; then
+ LIBEVENT_CFLAGS="-I$1/include"
+ else
+ LIBEVENT_CFLAGS="-I$1"
+ fi
+ else if test -f "$1"; then
+ # Static linking is a bit difficult, we need to "guess dependencies"
+ LIBEVENT_LIBS="$1 -lrt"
+ dir=`AS_DIRNAME(["$1"])`
+ for includedir in "$dir/include" "$dir/../include" "$dir"; do
+ if test -d "$includedir"; then
+ LIBEVENT_CFLAGS="-I$includedir"
+ break
+ fi
+ done
+ else
+ AC_MSG_RESULT(failed)
+ AC_MSG_ERROR([*** non-existant directory ($1) specified for libevent!])
+ fi
+ fi
+ fi
+
+ # Can I compile and link it?
+ LIBS="$LIBS $LIBEVENT_LIBS"
+ CFLAGS="$LIBEVENT_CFLAGS $CFLAGS"
+ AC_TRY_LINK([
+@%:@include <sys/time.h>
+@%:@include <sys/types.h>
+@%:@include <event.h>], [ event_init(); ],
+ [ 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"])
+ else
+ AC_MSG_RESULT([failed with "$LIBEVENT_LIBS $LIBEVENT_CFLAGS"])
+ AC_MSG_ERROR([
+*** libevent is required. Grab it from $LIBEVENT_URL
+*** or install libevent-dev package])
+ fi
+
+ LIBS="$_save_LIBS"
+ CFLAGS="$_save_CFLAGS"
+])
## Convenience library for lldpd and tests
liblldpd_la_SOURCES = frame.h frame.c lldpd.c lldp.c cdp.c sonmp.c edp.c \
interfaces.c client.c priv.c privsep_fdpass.c dmi.c ctl-server.c
-liblldpd_la_LIBADD = libcommon.la
+liblldpd_la_CFLAGS = @LIBEVENT_CFLAGS@
+liblldpd_la_LIBADD = libcommon.la @LIBEVENT_LIBS@
# Add SNMP support if needed
if USE_SNMP
liblldpd_la_SOURCES += agent.c agent_priv.c agent.h