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