]>
Commit | Line | Data |
---|---|---|
8beb9a73 VB |
1 | # |
2 | # lldp_CHECK_LIBEVENT | |
3 | # | |
4 | ||
5 | AC_DEFUN([lldp_CHECK_LIBEVENT], [ | |
f829effd VB |
6 | # Do we require embedded libevent? |
7 | AC_ARG_WITH([embedded-libevent], | |
8 | AS_HELP_STRING( | |
9 | [--with-embedded-libevent], | |
696f7f6f VB |
10 | [Use embedded libevent @<:@default=auto@:>@] |
11 | ), [], [with_embedded_libevent=auto]) | |
f829effd VB |
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], [ | |
4c1a8c61 VB |
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 | ], [ | |
696f7f6f VB |
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 | |
4c1a8c61 VB |
36 | ]) |
37 | CFLAGS="$_save_CFLAGS" | |
38 | LIBS="$_save_LIBS" | |
f829effd | 39 | ], [ |
696f7f6f VB |
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 | |
f829effd VB |
47 | ]) |
48 | fi | |
4c1a8c61 VB |
49 | |
50 | if test x"$LIBEVENT_EMBEDDED" != x; then | |
51 | unset LIBEVENT_LIBS | |
e5c94652 | 52 | LIBEVENT_CFLAGS="-I\$(top_srcdir)/libevent/include -I\$(top_builddir)/libevent/include" |
e5c94652 | 53 | LIBEVENT_LDFLAGS="\$(top_builddir)/libevent/libevent.la" |
4c1a8c61 | 54 | fi |
1daca827 | 55 | |
a0694903 VB |
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" | |
eb779d02 | 66 | libevent_configure_args="$libevent_configure_args CFLAGS=-Wno-deprecated-declarations" |
a0694903 VB |
67 | lldp_CONFIG_SUBDIRS([libevent], [$libevent_configure_args]) |
68 | ||
4c1a8c61 | 69 | AM_CONDITIONAL([LIBEVENT_EMBEDDED], [test x"$LIBEVENT_EMBEDDED" != x]) |
75b15cd9 VB |
70 | AC_SUBST([LIBEVENT_LIBS]) |
71 | AC_SUBST([LIBEVENT_CFLAGS]) | |
e5c94652 | 72 | AC_SUBST([LIBEVENT_LDFLAGS]) |
8beb9a73 | 73 | ]) |