1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
#
# lldp_CHECK_LIBEVENT
#
AC_DEFUN([lldp_CHECK_LIBEVENT], [
# Do we require embedded libevent?
AC_ARG_WITH([embedded-libevent],
AS_HELP_STRING(
[--with-embedded-libevent],
[Use embedded libevent @<:@default=auto@:>@]
), [], [with_embedded_libevent=auto])
AS_IF([test x"$with_embedded_libevent" = x"yes"], [
LIBEVENT_EMBEDDED=1
], [
# If not forced, check first with pkg-config
PKG_CHECK_MODULES([libevent], [libevent >= 2.0.5], [
# Check if we have a working libevent
AC_MSG_CHECKING([if system libevent works as expected])
_save_CFLAGS="$CFLAGS"
_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $libevent_CFLAGS"
LIBS="$LIBS $libevent_LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
@%:@include <sys/time.h>
@%:@include <sys/types.h>
@%:@include <event2/event.h>]], [[ struct event_base *base = event_base_new(); event_new(base, -1, 0, NULL, NULL); ]])],[
AC_MSG_RESULT([yes])
],[
AS_IF([test x"$with_embedded_libevent" = x"auto"], [
AC_MSG_RESULT([no, using shipped libevent])
LIBEVENT_EMBEDDED=1
], [
AC_MSG_ERROR([*** unusable system libevent])
])
])
CFLAGS="$_save_CFLAGS"
LIBS="$_save_LIBS"
], [
# No appropriate version, let's use the shipped copy if possible
AS_IF([test x"$with_embedded_libevent" = x"auto"], [
AC_MSG_NOTICE([using shipped libevent])
LIBEVENT_EMBEDDED=1
], [
AC_MSG_ERROR([*** libevent not found])
])
])
])
AS_IF([test x"$LIBEVENT_EMBEDDED" != x], [
unset libevent_LIBS
libevent_CFLAGS="-I\$(top_srcdir)/libevent/include -I\$(top_builddir)/libevent/include"
libevent_LDFLAGS="\$(top_builddir)/libevent/libevent.la"
])
# Call ./configure in libevent. Need it for make dist...
libevent_configure_args="$libevent_configure_args --disable-libevent-regress"
libevent_configure_args="$libevent_configure_args --disable-thread-support"
libevent_configure_args="$libevent_configure_args --disable-openssl"
libevent_configure_args="$libevent_configure_args --disable-malloc-replacement"
libevent_configure_args="$libevent_configure_args --disable-debug-mode"
libevent_configure_args="$libevent_configure_args --enable-function-sections"
libevent_configure_args="$libevent_configure_args --disable-shared"
libevent_configure_args="$libevent_configure_args --with-pic"
libevent_configure_args="$libevent_configure_args --enable-static"
lldp_CONFIG_SUBDIRS([libevent], [$libevent_configure_args])
AM_CONDITIONAL([LIBEVENT_EMBEDDED], [test x"$LIBEVENT_EMBEDDED" != x])
AC_SUBST([libevent_LIBS])
AC_SUBST([libevent_CFLAGS])
AC_SUBST([libevent_LDFLAGS])
])
|