forked from zabbix/zabbix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibevent.m4
112 lines (98 loc) · 2.9 KB
/
libevent.m4
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
104
105
106
107
108
109
110
111
112
# LIBEVENT_CHECK_CONFIG ([DEFAULT-ACTION])
# ----------------------------------------------------------
#
# Checks for libevent. DEFAULT-ACTION is the string yes or no to
# specify whether to default to --with-libevent or --without-libevent.
# If not supplied, DEFAULT-ACTION is no.
#
# This macro #defines HAVE_LIBEVENT if a required header files is
# found, and sets @LIBEVENT_LDFLAGS@ and @LIBEVENT_CFLAGS@ to the necessary
# values.
#
# This macro is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
AC_DEFUN([LIBEVENT_TRY_LINK],
[
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdlib.h>
#include <event.h>
#include <event2/thread.h>
]], [[
evthread_use_pthreads();
event_init();
]])],[found_libevent="yes"],[])
])dnl
AC_DEFUN([LIBEVENT_CHECK_CONFIG],
[
AC_ARG_WITH([libevent],[
If you want to specify libevent installation directories:
AS_HELP_STRING([--with-libevent@<:@=DIR@:>@], [use libevent from given base install directory (DIR), default is to search through a number of common places for the libevent files.])],
[
if test "x$withval" = "xyes"; then
if test -f /usr/local/include/event.h; then withval=/usr/local; else withval=/usr; fi
fi
LIBEVENT_CFLAGS="-I$withval/include"
LIBEVENT_LDFLAGS="-L$withval/lib"
_libevent_dir_set="yes"
]
)
AC_ARG_WITH([libevent-include],
AS_HELP_STRING([--with-libevent-include@<:@=DIR@:>@],
[use libevent include headers from given path.]
),
[
LIBEVENT_CFLAGS="-I$withval"
_libevent_dir_set="yes"
]
)
AC_ARG_WITH([libevent-lib],
AS_HELP_STRING([--with-libevent-lib@<:@=DIR@:>@],
[use libevent libraries from given path.]
),
[
LIBEVENT_LDFLAGS="-L$withval"
_libevent_dir_set="yes"
]
)
AC_MSG_CHECKING(for libevent support)
if test "x$ARCH" = "xopenbsd"; then
LIBEVENT_LIBS="-levent_core -levent_pthreads"
else
LIBEVENT_LIBS="-levent -levent_pthreads"
fi
if test -n "$_libevent_dir_set" -o -f /usr/include/event.h; then
found_libevent="yes"
elif test -f /usr/local/include/event.h; then
LIBEVENT_CFLAGS="-I/usr/local/include"
LIBEVENT_LDFLAGS="-L/usr/local/lib"
found_libevent="yes"
else
found_libevent="no"
AC_MSG_RESULT(no)
fi
if test "x$found_libevent" = "xyes"; then
am_save_CFLAGS="$CFLAGS"
am_save_LDFLAGS="$LDFLAGS"
am_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $LIBEVENT_CFLAGS"
LDFLAGS="$LDFLAGS $LIBEVENT_LDFLAGS"
LIBS="$LIBS $LIBEVENT_LIBS"
found_libevent="no"
LIBEVENT_TRY_LINK([no])
CFLAGS="$am_save_CFLAGS"
LDFLAGS="$am_save_LDFLAGS"
LIBS="$am_save_LIBS"
fi
if test "x$found_libevent" = "xyes"; then
AC_DEFINE([HAVE_LIBEVENT], 1, [Define to 1 if you have the 'libevent' library (-levent)])
AC_MSG_RESULT(yes)
else
LIBEVENT_CFLAGS=""
LIBEVENT_LDFLAGS=""
LIBEVENT_LIBS=""
fi
AC_SUBST(LIBEVENT_CFLAGS)
AC_SUBST(LIBEVENT_LDFLAGS)
AC_SUBST(LIBEVENT_LIBS)
])dnl