use ares_inet_{ntop,pton}; parse AAAA answers
[m6w6/ext-ares] / config.m4
1 dnl $Id$
2 dnl config.m4 for extension ares
3
4 PHP_ARG_WITH(ares, [enable asynchronous resolver support],
5 [ --with-ares Include asynchronous resolver support])
6
7 if test "$PHP_ARES" != "no"; then
8 PHP_ARES_DIR=
9 AC_MSG_CHECKING(for ares.h)
10 for i in "$PHP_ARES" /usr/local /usr; do
11 if test -r "$i/include/ares.h"; then
12 PHP_ARES_DIR=$i
13 AC_MSG_RESULT(found in $i)
14 break;
15 fi
16 done
17 if test -z "$PHP_ARES_DIR"; then
18 AC_MSG_ERROR(could not find ares.h)
19 fi
20
21 PHP_ARES_LIB=
22 PHP_ARES_LIBADD=
23 PHP_CHECK_LIBRARY(cares, ares_init, [
24 PHP_ARES_LIB=cares
25 ], [
26 PHP_CHECK_LIBRARY(ares, ares_init, [
27 PHP_ARES_LIB=ares
28 ], [
29 PHP_CHECK_LIBRARY(cares, ares_init, [
30 PHP_ARES_LIB=cares
31 PHP_ARES_LIBADD=rt
32 ], [
33 PHP_CHECK_LIBRARY(ares, ares_init, [
34 PHP_ARES_LIB=ares
35 PHP_ARES_LIBADD=rt
36 ], [
37 PHP_AREES_LIB=unknown
38 ], [
39 -lrt -L$PHP_ARES_DIR/$PHP_LIBDIR
40 ])
41 ], [
42 -lrt -L$PHP_ARES_DIR/$PHP_LIBDIR
43 ])
44 ], [
45 -L$PHP_ARES_DIR/$PHP_LIBDIR
46 ]
47 )
48 ], [
49 -L$PHP_ARES_DIR/$PHP_LIBDIR
50 ]
51 )
52 AC_MSG_CHECKING(for libares/libcares)
53 AC_MSG_RESULT($PHP_ARES_LIB)
54
55 if test "x$PHP_ARES_LIBADD" != "x"; then
56 PHP_ADD_LIBRARY(PHP_ARES_LIBADD, 1, ARES_SHARED_LIBADD)
57 dnl for later use
58 PHP_ARES_LIBADD="-l$PHP_ARES_LIBADD"
59 fi
60
61 if test $PHP_ARES_LIB = "unknown"; then
62 AC_MSG_ERROR(could neither find libares nor libcares)
63 elif test $PHP_ARES_LIB = "cares"; then
64 AC_DEFINE([PHP_ARES_CARES], [1], [ ])
65 AC_DEFINE_UNQUOTED([PHP_ARES_LIBNAME], "c-ares (CURL)", [ ])
66 AC_DEFINE([PHP_ARES_EXPAND_LEN_TYPE], [long], [ ])
67 else
68 AC_DEFINE_UNQUOTED([PHP_ARES_LIBNAME], "ares (MIT)", [ ])
69 AC_DEFINE([PHP_ARES_EXPAND_LEN_TYPE], [int], [ ])
70 AC_DEFINE([HAVE_OLD_ARES_STRERROR], [1], [ ])
71 fi
72
73 PHP_CHECK_LIBRARY($PHP_ARES_LIB, ares_cancel,
74 [AC_DEFINE([HAVE_ARES_CANCEL], [1], [ ])], [ ],
75 [$PHP_ARES_LIBADD -L$PHP_ARES_DIR/$PHP_LIBDIR]
76 )
77 PHP_CHECK_LIBRARY($PHP_ARES_LIB, ares_getnameinfo,
78 [AC_DEFINE([HAVE_ARES_GETNAMEINFO], [1], [ ])], [ ],
79 [$PHP_ARES_LIBADD -L$PHP_ARES_DIR/$PHP_LIBDIR]
80 )
81 PHP_CHECK_LIBRARY($PHP_ARES_LIB, ares_getsock,
82 [AC_DEFINE([HAVE_ARES_GETSOCK], [1], [ ])], [ ],
83 [$PHP_ARES_LIBADD -L$PHP_ARES_DIR/$PHP_LIBDIR]
84 )
85 PHP_CHECK_LIBRARY($PHP_ARES_LIB, ares_version,
86 [AC_DEFINE([HAVE_ARES_VERSION], [1], [ ])], [ ],
87 [$PHP_ARES_LIBADD -L$PHP_ARES_DIR/$PHP_LIBDIR]
88 )
89 PHP_CHECK_LIBRARY($PHP_ARES_LIB, ares_library_init,
90 [AC_DEFINE([HAVE_ARES_LIBRARY_INIT], [1], [ ])], [ ],
91 [$PHP_ARES_LIBADD -L$PHP_ARES_DIR/$PHP_LIBDIR]
92 )
93 PHP_CHECK_LIBRARY($PHP_ARES_LIB, ares_library_cleanup,
94 [AC_DEFINE([HAVE_ARES_LIBRARY_CLEANUP], [1], [ ])], [ ],
95 [$PHP_ARES_LIBADD -L$PHP_ARES_DIR/$PHP_LIBDIR]
96 )
97 PHP_CHECK_LIBRARY($PHP_ARES_LIB, ares_set_local_dev,
98 [AC_DEFINE([HAVE_ARES_SET_LOCAL_DEV], [1], [ ])], [ ],
99 [$PHP_ARES_LIBADD -L$PHP_ARES_DIR/$PHP_LIBDIR]
100 )
101 PHP_CHECK_LIBRARY($PHP_ARES_LIB, ares_set_local_ip4,
102 [AC_DEFINE([HAVE_ARES_SET_LOCAL_IP4], [1], [ ])], [ ],
103 [$PHP_ARES_LIBADD -L$PHP_ARES_DIR/$PHP_LIBDIR]
104 )
105 PHP_CHECK_LIBRARY($PHP_ARES_LIB, ares_set_local_ip6,
106 [AC_DEFINE([HAVE_ARES_SET_LOCAL_IP6], [1], [ ])], [ ],
107 [$PHP_ARES_LIBADD -L$PHP_ARES_DIR/$PHP_LIBDIR]
108 )
109 PHP_CHECK_LIBRARY($PHP_ARES_LIB, ares_inet_ntop,
110 [AC_DEFINE([HAVE_ARES_INET_NTOP], [1], [ ])], [ ],
111 [$PHP_ARES_LIBADD -L$PHP_ARES_DIR/$PHP_LIBDIR]
112 )
113 PHP_CHECK_LIBRARY($PHP_ARES_LIB, ares_inet_pton,
114 [AC_DEFINE([HAVE_ARES_INET_NTOP], [1], [ ])], [ ],
115 [$PHP_ARES_LIBADD -L$PHP_ARES_DIR/$PHP_LIBDIR]
116 )
117
118 dnl ##########
119 dnl check new c-ares callback API
120 dnl ##########
121 save_LIBS=$LIBS
122 save_CFLAGS=$CFLAGS
123 LIBS="-L$PHP_ARES_DIR/$PHP_LIBDIR -l$PHP_ARES_LIB $PHP_ARES_LIBADD"
124 CFLAGS="-I$PHP_ARES_DIR/include -Werror"
125
126 AC_MSG_CHECKING(for new c-ares callback API)
127 AC_TRY_COMPILE(
128 [#include <ares.h>
129 ], [
130 ares_search(0, 0, 0, 0, (void (*)(void *, int, int, unsigned char *, int)) 0, 0);
131 ], [
132 AC_MSG_RESULT(yes)
133 AC_DEFINE([PHP_ARES_NEW_CALLBACK_API], [1], [ ])
134 ], [
135 AC_MSG_RESULT(no)
136 AC_DEFINE([PHP_ARES_NEW_CALLBACK_API], [0], [ ])
137 ]
138 )
139
140 LIBS=$save_LIBS
141 CFLAGS=$save_CFLAGS
142
143 AC_CHECK_HEADERS([netdb.h unistd.h arpa/inet.h arpa/nameser.h arpa/nameser_compat.h])
144
145 PHP_ADD_INCLUDE($PHP_ARES_DIR/include)
146 PHP_ADD_LIBRARY_WITH_PATH($PHP_ARES_LIB, $PHP_ARES_DIR/$PHP_LIBDIR, ARES_SHARED_LIBADD)
147
148 PHP_SUBST(ARES_SHARED_LIBADD)
149 PHP_NEW_EXTENSION(ares, php_ares.c, $ext_shared)
150 fi