]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
configure: enable compilation of a libevent archive
authorVincent Bernat <bernat@luffy.cx>
Tue, 1 May 2012 13:28:41 +0000 (15:28 +0200)
committerVincent Bernat <bernat@luffy.cx>
Tue, 1 May 2012 14:04:24 +0000 (16:04 +0200)
README.md has been updated for those instructions. We still rely on
libtool to make this work. Unfortunately, the generated libtool comes
too late: we can't use it...

README.md
configure.ac
m4/libevent.m4
src/Makefile.am
tests/Makefile.am

index 2805f05236b28c3195dbddfd1a7cef3952d3bb3f..caf0bdaeebc2f82102b00bb752ca7419acb950e4 100644 (file)
--- a/README.md
+++ b/README.md
@@ -36,16 +36,8 @@ 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 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-2.0.16-stable/usr/local/lib/libevent.la
+    wget https://github.com/downloads/libevent/libevent/libevent-2.0.18-stable.tar.gz
+    ./configure --with-libevent=libevent-2.0.18-stable.tar.gz
     make
     sudo make install
 
index 9f0af928ec51ec71ebbfd7446a8fd148c5f7b576..a1a627a6c99553fa1b283bb74062b71e1a6598b2 100644 (file)
@@ -222,7 +222,7 @@ if test x"$with_xml" = x"yes"; then
 fi
 
 # Libevent
-lldp_ARG_WITH([libevent], [Location of libevent directory (or libevent.a)], [])
+lldp_ARG_WITH([libevent], [Location of libevent directory, la or archive], [])
 lldp_CHECK_LIBEVENT([$with_libevent])
 
 # Privsep settings
index d802afb448c003113319e0c6c15f962c8fb91504..29b104c28221896fb6ff55562afcfacea8bae53e 100644 (file)
@@ -31,17 +31,58 @@ AC_DEFUN([lldp_CHECK_LIBEVENT], [
            LIBEVENT_CFLAGS="-I${libevent_dir}"
         fi
      else if test -f "$1"; then
-        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`readlink -f "$includedir"`
-               break
-            fi
-        done
+        case "$1" in
+            *.la)
+                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`readlink -f "$includedir"`
+                        break
+                    fi
+                done
+                ;;
+            *.tar.gz)
+                # This won't work for cross compilation. Dunno how to handle this.
+                AC_MSG_RESULT([from archive $1])
+                AC_MSG_CHECKING([compilation of libevent in $1])
+                {
+                    dir=`(umask 077 && mktemp -d "\`pwd\`/libeventXXXXXX") 2>/dev/null` &&
+                    test -d "$dir"
+                } || {
+                    AC_MSG_RESULT([failed to create temporary directory])
+                    AC_MSG_ERROR([*** unable to compile libevent])
+                }
+                gunzip -c "$1" | tar -C $dir -xf -
+                (exec >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD &&
+                    cd $dir/libevent* &&
+                    ./configure \
+                        --disable-libevent-regress \
+                        --disable-thread-support \
+                        --prefix=$dir/build --enable-static --disable-shared &&
+                    make &&
+                    make install) || {
+                    AC_MSG_RESULT([failed to compile libevent])
+                    AC_MSG_ERROR([*** unable to compile libevent])
+                }
+                LIBEVENT_LIBS=`readlink -f $dir/build/lib/libevent.la`
+                levdir=`AS_DIRNAME(["$LIBEVENT_LIBS"])`
+                test -d "$levdir/../include" || {
+                    AC_MSG_RESULT([failed to locate static libevent.la])
+                    AC_MSG_ERROR([*** unable to compile libevent])
+                }
+                LIBEVENT_CFLAGS=-I`readlink -f "$levdir/../include"`
+                AC_MSG_RESULT([successful!])
+                AC_MSG_CHECKING([how to use this fresh new libevent])
+                ;;
+            *)
+                AC_MSG_RESULT(failed)
+                AC_MSG_ERROR([*** dunno what to do with $1])
+                ;;
+        esac
      else
         AC_MSG_RESULT(failed)
-        AC_MSG_ERROR([*** non-existant directory ($1) specified for libevent!])
+        AC_MSG_ERROR([*** non-existant directory/file/archive ($1) specified for libevent!])
      fi
      fi
   fi
index 637331e443e603150235e4a4b58dcccfc72f46b5..4d3a63159362fe4a4022267a5935721979d7340a 100644 (file)
@@ -19,7 +19,7 @@ endif
 
 ## lldpd
 lldpd_SOURCES = main.c
-lldpd_LDADD = liblldpd.la
+lldpd_LDADD = liblldpd.la @LIBEVENT_LIBS@
 
 ## lldpctl
 lldpctl_SOURCES = lldpctl.h lldpctl.c display.c writer.h text_writer.c kv_writer.c
index b498ad732814f1833d7c09f2d2179c7e9ac9d6de..f1135a9b3c7fa60993df92aca646576d8f98620d 100644 (file)
@@ -26,7 +26,7 @@ check_ifaddrs_SOURCES = check_ifaddrs.c \
        $(top_srcdir)/src/getifaddrs.c
 
 AM_CFLAGS = @CHECK_CFLAGS@
-LDADD = $(top_builddir)/src/liblldpd.la @CHECK_LIBS@
+LDADD = $(top_builddir)/src/liblldpd.la @CHECK_LIBS@ @LIBEVENT_LIBS@
 
 if USE_SNMP
 TESTS += check_snmp