File: libevent.m4

package info (click to toggle)
remctl 3.18-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,612 kB
  • sloc: ansic: 19,504; sh: 5,386; perl: 1,778; java: 740; makefile: 715; xml: 502; python: 430
file content (103 lines) | stat: -rw-r--r-- 4,531 bytes parent folder | download | duplicates (3)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
dnl Find the compiler and linker flags for libevent.
dnl
dnl Finds the compiler and linker flags for linking with the libevent library.
dnl Provides the --with-libevent, --with-libevent-lib, and
dnl --with-libevent-include configure options to specify non-standard paths to
dnl the libevent libraries or header files.
dnl
dnl Provides the macro RRA_LIB_EVENT and sets the substitution variables
dnl LIBEVENT_CPPFLAGS, LIBEVENT_LDFLAGS, and LIBEVENT_LIBS.  Also provides
dnl RRA_LIB_EVENT_SWITCH to set CPPFLAGS, LDFLAGS, and LIBS to include the
dnl libevent library, saving the current values first, and
dnl RRA_LIB_EVENT_RESTORE to restore those settings to before the last
dnl RRA_LIB_EVENT_SWITCH.  Defines HAVE_LIBEVENT and sets rra_use_LIBEVENT to
dnl true.
dnl
dnl Provides the RRA_LIB_EVENT_OPTIONAL macro, which should be used if
dnl libevent support is optional.  This macro will still always set the
dnl substitution variables, but they'll be empty if libevent is not found or
dnl if --without-libevent is given.  Defines HAVE_LIBEVENT and sets
dnl rra_use_LIBEVENT to true if libevent is found and --without-libevent is
dnl not given.
dnl
dnl Also provides RRA_INCLUDES_EVENT, which are the headers to include when
dnl probing the libevent library properties.  This assumes that
dnl AC_CHECK_HEADERS([event2/event.h]) has been called.
dnl
dnl Depends on the lib-helper.m4 framework and the Autoconf macros that come
dnl with pkg-config.
dnl
dnl The canonical version of this file is maintained in the rra-c-util
dnl package, available at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
dnl
dnl Written by Russ Allbery <eagle@eyrie.org>
dnl Copyright 2022 Russ Allbery <eagle@eyrie.org>
dnl Copyright 2014
dnl     The Board of Trustees of the Leland Stanford Junior University
dnl
dnl This file is free software; the authors give unlimited permission to copy
dnl and/or distribute it, with or without modifications, as long as this
dnl notice is preserved.
dnl
dnl SPDX-License-Identifier: FSFULLR

dnl Headers to include when probing for libevent declarations.
AC_DEFUN([RRA_INCLUDES_EVENT], [[
#if HAVE_EVENT2_EVENT_H
# include <event2/buffer.h>
# include <event2/bufferevent.h>
# include <event2/event.h>
#else
# include <event.h>
#endif
]])

dnl Save the current CPPFLAGS, LDFLAGS, and LIBS settings and switch to
dnl versions that include the libevent flags.  Used as a wrapper, with
dnl RRA_LIB_LIBEVENT_RESTORE, around tests.
AC_DEFUN([RRA_LIB_EVENT_SWITCH], [RRA_LIB_HELPER_SWITCH([LIBEVENT])])

dnl Restore CPPFLAGS, LDFLAGS, and LIBS to their previous values before
dnl RRA_LIB_LIBEVENT_SWITCH was called.
AC_DEFUN([RRA_LIB_EVENT_RESTORE], [RRA_LIB_HELPER_RESTORE([LIBEVENT])])

dnl Checks if libevent is present.  The single argument, if "true", says to
dnl fail if the libevent library could not be found.  Prefer probing with
dnl pkg-config if available and the --with flags were not given.  Failing
dnl that, prefer linking with libevent_core over libevent.  (This means that
dnl callers will need to add the non-core libraries if desired.)
AC_DEFUN([_RRA_LIB_EVENT_INTERNAL],
[AC_REQUIRE([RRA_ENABLE_REDUCED_DEPENDS])
 RRA_LIB_HELPER_PATHS([LIBEVENT])
 AS_IF([test x"$LIBEVENT_CPPFLAGS" = x && test x"$LIBEVENT_LDFLAGS" = x],
    [PKG_CHECK_EXISTS([libevent],
        [PKG_CHECK_MODULES([LIBEVENT], [libevent])
         LIBEVENT_CPPFLAGS="$LIBEVENT_CFLAGS"])])
 AS_IF([test x"$LIBEVENT_LIBS" = x],
    [RRA_LIB_EVENT_SWITCH
     LIBS=
     AC_SEARCH_LIBS([event_base_free], [event_core event],
        [LIBEVENT_LIBS="$LIBS"],
        [AS_IF([test x"$1" = xtrue],
            [AC_MSG_ERROR([cannot find usable libevent library])])])
     RRA_LIB_EVENT_RESTORE])])

dnl The main macro for packages with mandatory libevent support.
AC_DEFUN([RRA_LIB_EVENT],
[RRA_LIB_HELPER_VAR_INIT([LIBEVENT])
 RRA_LIB_HELPER_WITH([libevent], [libevent], [LIBEVENT])
 _RRA_LIB_EVENT_INTERNAL([true])
 rra_use_LIBEVENT=true
 AC_DEFINE([HAVE_LIBEVENT], 1, [Define if libevent is available.])])

dnl The main macro for packages with optional libevent support.
AC_DEFUN([RRA_LIB_EVENT_OPTIONAL],
[RRA_LIB_HELPER_VAR_INIT([LIBEVENT])
 RRA_LIB_HELPER_WITH_OPTIONAL([libevent], [libevent], [LIBEVENT])
 AS_IF([test x"$rra_use_LIBEVENT" != xfalse],
    [AS_IF([test x"$rra_use_LIBEVENT" = xtrue],
        [_RRA_LIB_EVENT_INTERNAL([true])],
        [_RRA_LIB_EVENT_INTERNAL([false])])])
 AS_IF([test x"$LIBEVENT_LIBS" != x],
    [rra_use_LIBEVENT=true
     AC_DEFINE([HAVE_LIBEVENT], 1, [Define if libevent is available.])])])