From: Vincent Bernat Date: Tue, 1 May 2012 13:28:41 +0000 (+0200) Subject: configure: enable compilation of a libevent archive X-Git-Tag: 0.6.0~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b4cd8459dcba76d8f6c482fc4793bb386cac61a;p=thirdparty%2Flldpd.git configure: enable compilation of a libevent archive 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... --- diff --git a/README.md b/README.md index 2805f052..caf0bdae 100644 --- 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 diff --git a/configure.ac b/configure.ac index 9f0af928..a1a627a6 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/m4/libevent.m4 b/m4/libevent.m4 index d802afb4..29b104c2 100644 --- a/m4/libevent.m4 +++ b/m4/libevent.m4 @@ -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 diff --git a/src/Makefile.am b/src/Makefile.am index 637331e4..4d3a6315 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 diff --git a/tests/Makefile.am b/tests/Makefile.am index b498ad73..f1135a9b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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