]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
configure: upgrade to libevent 2.x
authorVincent Bernat <bernat@luffy.cx>
Fri, 27 Jan 2012 11:30:41 +0000 (12:30 +0100)
committerVincent Bernat <bernat@luffy.cx>
Tue, 1 May 2012 09:09:41 +0000 (11:09 +0200)
Also, when linking with a static version of libevent, we enforce the
use of libtool ".la" file instead of ".a" to get appropriate
dependencies automatically and avoid a warning when linking inside a
".la".

README.md
m4/libevent.m4
src/Makefile.am

index 92c11c48aa3f3b316a079fd487c92e769b7b52e0..2805f05236b28c3195dbddfd1a7cef3952d3bb3f 100644 (file)
--- a/README.md
+++ b/README.md
@@ -28,28 +28,24 @@ To compile lldpd, use the following:
     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
 
index 9e691db61b44caca7c50664f1ae866faa8893cc7..acfe1eb8400b4734168fd739eea301f656ea0728 100644 (file)
@@ -3,34 +3,39 @@
 #
 
 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
@@ -41,26 +46,32 @@ AC_DEFUN([lldp_CHECK_LIBEVENT], [
      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"
 ])
index a6875f8d6c35edc254a081317c44fef06543f527..a82a5f4541e0bb0f1f29fbe34a52462e489ee1b7 100644 (file)
@@ -13,7 +13,7 @@ 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
-liblldpd_la_CFLAGS = @NETSNMP_CFLAGS@
+liblldpd_la_CFLAGS += @NETSNMP_CFLAGS@
 liblldpd_la_LIBADD += @NETSNMP_LIBS@
 endif