]> git.ipfire.org Git - thirdparty/lldpd.git/blob - m4/libevent.m4
build: bump actions/download-artifact from 3 to 4
[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_LINK_IFELSE([AC_LANG_PROGRAM([[
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 AC_MSG_RESULT([yes])
28 ],[
29 if test x"$with_embedded_libevent" = x"auto"; then
30 AC_MSG_RESULT([no, using shipped libevent])
31 LIBEVENT_EMBEDDED=1
32 else
33 AC_MSG_ERROR([*** unusable system libevent])
34 fi
35 ])
36 CFLAGS="$_save_CFLAGS"
37 LIBS="$_save_LIBS"
38 ], [
39 # No appropriate version, let's use the shipped copy if possible
40 if test x"$with_embedded_libevent" = x"auto"; then
41 AC_MSG_NOTICE([using shipped libevent])
42 LIBEVENT_EMBEDDED=1
43 else
44 AC_MSG_ERROR([*** libevent not found])
45 fi
46 ])
47 fi
48
49 if test x"$LIBEVENT_EMBEDDED" != x; then
50 unset libevent_LIBS
51 libevent_CFLAGS="-I\$(top_srcdir)/libevent/include -I\$(top_builddir)/libevent/include"
52 libevent_LDFLAGS="\$(top_builddir)/libevent/libevent.la"
53 fi
54
55 # Call ./configure in libevent. Need it for make dist...
56 libevent_configure_args="$libevent_configure_args --disable-libevent-regress"
57 libevent_configure_args="$libevent_configure_args --disable-thread-support"
58 libevent_configure_args="$libevent_configure_args --disable-openssl"
59 libevent_configure_args="$libevent_configure_args --disable-malloc-replacement"
60 libevent_configure_args="$libevent_configure_args --disable-debug-mode"
61 libevent_configure_args="$libevent_configure_args --enable-function-sections"
62 libevent_configure_args="$libevent_configure_args --disable-shared"
63 libevent_configure_args="$libevent_configure_args --with-pic"
64 libevent_configure_args="$libevent_configure_args --enable-static"
65 lldp_CONFIG_SUBDIRS([libevent], [$libevent_configure_args])
66
67 AM_CONDITIONAL([LIBEVENT_EMBEDDED], [test x"$LIBEVENT_EMBEDDED" != x])
68 AC_SUBST([libevent_LIBS])
69 AC_SUBST([libevent_CFLAGS])
70 AC_SUBST([libevent_LDFLAGS])
71 ])