Source
xxxxxxxxxx
1
+
# ARES_CHECK_CONFIG ([DEFAULT-ACTION])
2
+
# ----------------------------------------------------------
3
+
#
4
+
# Checks for c-ares.
5
+
#
6
+
# This macro #defines HAVE_ARES_H if required header files are
7
+
# found, and sets @ARES_LDFLAGS@ and @ARES_CFLAGS@ to the necessary
8
+
# values.
9
+
#
10
+
# This macro is distributed in the hope that it will be useful,
11
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
+
14
+
AC_DEFUN([ARES_TRY_LINK],
15
+
[
16
+
found_ares=$1
17
+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
18
+
#include <ares.h>
19
+
#include "string.h"
20
+
]], [[
21
+
struct ares_channeldata *channel;
22
+
struct ares_addrinfo_hints hints;
23
+
24
+
ares_library_init(ARES_LIB_INIT_ALL);
25
+
ares_getaddrinfo(channel, "localhost", NULL, &hints, NULL, NULL);
26
+
]])],[found_ares="yes"],[])
27
+
])dnl
28
+
29
+
AC_DEFUN([ARES_CHECK_CONFIG],
30
+
[
31
+
want_ares="no"
32
+
AC_ARG_WITH([ares],[
33
+
If you want to use c-ares library:
34
+
AS_HELP_STRING([--with-ares@<:@=ARG@:>@], [use c-ares library @<:@default=no@:>@,])],
35
+
[
36
+
if test "x$withval" = "xyes"; then
37
+
want_ares="yes"
38
+
fi
39
+
]
40
+
)
41
+
42
+
AC_ARG_WITH([ares-include],
43
+
AS_HELP_STRING([--with-ares-include=DIR],
44
+
[use c-ares include headers from given path.]
45
+
),
46
+
[
47
+
ARES_CFLAGS="-I$withval"
48
+
_ares_dir_set="yes"
49
+
want_ares="yes"
50
+
]
51
+
)
52
+
53
+
AC_ARG_WITH([ares-lib],
54
+
AS_HELP_STRING([--with-ares-lib=DIR],
55
+
[use c-ares libraries from given path.]
56
+
),
57
+
[
58
+
ARES_LDFLAGS="-L$withval"
59
+
_ares_dir_set="yes"
60
+
want_ares="yes"
61
+
]
62
+
)
63
+
64
+
if test "x$want_ares" != "xno"; then
65
+
AC_MSG_CHECKING(for ares support)
66
+
67
+
ARES_LIBS="-lcares"
68
+
69
+
if test -n "$_ares_dir_set" -o -f /usr/include/ares.h; then
70
+
found_ares="yes"
71
+
elif test -f /usr/local/include/ares.h; then
72
+
ARES_CFLAGS="-I/usr/local/include"
73
+
ARES_LDFLAGS="-L/usr/local/lib"
74
+
found_ares="yes"
75
+
elif test -f /usr/pkg/include/ares.h; then
76
+
ARES_CFLAGS="-I/usr/pkg/include"
77
+
ARES_LDFLAGS="-L/usr/pkg/lib"
78
+
found_ares="yes"
79
+
else
80
+
found_ares="no"
81
+
AC_MSG_RESULT(no)
82
+
fi
83
+
84
+
if test "x$found_ares" = "xyes"; then
85
+
am_save_CFLAGS="$CFLAGS"
86
+
am_save_LDFLAGS="$LDFLAGS"
87
+
am_save_LIBS="$LIBS"
88
+
89
+
CFLAGS="$CFLAGS $ARES_CFLAGS"
90
+
LDFLAGS="$LDFLAGS $ARES_LDFLAGS"
91
+
LIBS="$LIBS $ARES_LIBS"
92
+
93
+
ARES_TRY_LINK([no])
94
+
AC_CHECK_FUNCS([ares_reinit])
95
+
96
+
CFLAGS="$am_save_CFLAGS"
97
+
LDFLAGS="$am_save_LDFLAGS"
98
+
LIBS="$am_save_LIBS"
99
+
fi
100
+
101
+
if test "x$found_ares" = "xyes"; then
102
+
AC_DEFINE([HAVE_ARES], 1, [Define to 1 if you have the 'c-ares' library (-lcares)])
103
+
AC_MSG_RESULT(yes)
104
+
else
105
+
ARES_CFLAGS=""
106
+
ARES_LDFLAGS=""
107
+
ARES_LIBS=""
108
+
fi
109
+
110
+
AC_SUBST(ARES_CFLAGS)
111
+
AC_SUBST(ARES_LDFLAGS)
112
+
AC_SUBST(ARES_LIBS)
113
+
fi
114
+
])dnl