## Unit tests wich check
PKG_CHECK_MODULES([CHECK], [check >= 0.9.4], [have_check=yes], [have_check=no])
+# Libevent
+lldp_CHECK_LIBEVENT([$with_libevent])
+
#######################
### Options
lldp_CHECK_XML2
fi
-# Libevent
-lldp_ARG_WITH([libevent], [Location of libevent directory, la or archive], [])
-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])
AM_CONDITIONAL([USE_XML], [test x"$with_xml" = x"yes"])
AC_OUTPUT
+if test x"$LIBEVENT_LDFLAGS" = x; then
+ libevent=system
+else
+ libevent=embedded
+fi
+
cat <<EOF
------------------ Summary ------------------
Prefix.........: $prefix
C Compiler.....: $CC $CFLAGS $CPPFLAGS
Linker.........: $LD $LDFLAGS $LIBS
+ Libevent.......: $libevent
Optional features:
SNMP support...: ${with_snmp-no}
CDP............: $enable_cdp
_save_CFLAGS="$CFLAGS"
# First, try with pkg-config
- PKG_CHECK_MODULES([LIBEVENT], [libevent >= 1.4.3], [], [:])
+ PKG_CHECK_MODULES([LIBEVENT], [libevent >= 2.0.5], [], [
+ # No appropriate version, let's use the shipped copy
+ AC_MSG_NOTICE([using shipped libevent])
+ LIBEVENT_CFLAGS="-I\$(top_srcdir)/libevent/include -I\$(top_builddir)/libevent/include"
+ LIBEVENT_LIBS="\$(top_builddir)/libevent/libevent.la"
+ LIBEVENT_LDFLAGS="\$(top_builddir)/libevent/libevent.la"
+ ])
- AC_MSG_CHECKING([how to compile with libevent])
- if test x"$1" = x -o x"$1" = x"yes"; then
- # Nothing specified, use default location from pkg-config
- LIBS="$LIBS $LIBEVENT_LIBS"
- CFLAGS="$LIBEVENT_CFLAGS $CFLAGS"
- AC_TRY_LINK([
-@%:@include <sys/time.h>
-@%:@include <sys/types.h>
-@%:@include <event2/event.h>], [ event_base_new(); ],
- [ libevent_linked=yes ], [ libevent_linked=no ])
-
- if test x"$libevent_linked" = x"yes"; then
- AC_MSG_RESULT([ok with $LIBEVENT_LIBS $LIBEVENT_CFLAGS])
- else
- 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 2.x is required. Grab it from $LIBEVENT_URL
- *** or install libevent-dev package])
- fi
- LIBS="$_save_LIBS"
- CFLAGS="$_save_CFLAGS"
- else
- # Black magic....
- if test -d "$1"; then
- libevent_dir=`readlink -f "$1"`
- # Directory, dynamic linking
- if test -d "${libevent_dir}/lib"; then
- LIBEVENT_LIBS="-L${libevent_dir}/lib -levent"
- else
- LIBEVENT_LIBS="-L${libevent_dir} -levent"
- fi
- if test -d "${libevent_dir}/include"; then
- LIBEVENT_CFLAGS="-I${libevent_dir}/include"
- else
- LIBEVENT_CFLAGS="-I${libevent_dir}"
- fi
- else if test -f "$1"; then
- 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
- AC_MSG_RESULT([ok with $LIBEVENT_LIBS $LIBEVENT_CFLAGS])
- ;;
- *.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_RESULT(failed)
- AC_MSG_ERROR([*** dunno what to do with $1])
- ;;
- esac
- else
- AC_MSG_RESULT(failed)
- AC_MSG_ERROR([*** non-existant directory/file/archive ($1) specified for libevent!])
- fi
- fi
+ # Override configure arguments
+ ac_configure_args="$ac_configure_args --disable-libevent-regress --disable-thread-support --disable-shared --enable-static"
+ if test x"$LIBEVENT_LDFLAGS" != x; then
+ AC_CONFIG_SUBDIRS([libevent])
fi
-
+ AM_CONDITIONAL([LIBEVENT_EMBEDDED], [test x"$LIBEVENT_LDFLAGS" != x])
AC_SUBST([LIBEVENT_LIBS])
AC_SUBST([LIBEVENT_CFLAGS])
+ AC_SUBST([LIBEVENT_LDFLAGS])
])