X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-ares;a=blobdiff_plain;f=config.m4;h=1b96e73f4b561bedae8cfb5b19c92e7fbc9ccdfb;hp=2acb051eaee8f21d4f1fde38ac1177a7bb7ea10d;hb=d7101dab193ff93425126756a861f3b1c7c6d5e8;hpb=3790230026996d266f0dfc62e4e50c0a5320a2a7 diff --git a/config.m4 b/config.m4 index 2acb051..1b96e73 100644 --- a/config.m4 +++ b/config.m4 @@ -3,8 +3,6 @@ dnl config.m4 for extension ares PHP_ARG_WITH(ares, for asynchronous resolver support, [ --with-ares Include asynchronous resolver support]) -PHP_ARG_WITH(ares-lib, type of ares library (cares), -[ --with-ares-lib MIT/ares or CURL/cares], "cares", "cares") if test "$PHP_ARES" != "no"; then PHP_ARES_DIR= @@ -20,28 +18,35 @@ if test "$PHP_ARES" != "no"; then AC_MSG_ERROR(could not find ares.h) fi - case "$PHP_ARES_LIB" in - MIT* [)] - PHP_ARES_LIB=ares - ;; - ares [)] - ;; - CURL* [)] + PHP_ADD_LIBRARY(rt, ARES_SHARED_LIBADD) + PHP_ARES_LIB= + PHP_CHECK_LIBRARY(cares, ares_init, [ PHP_ARES_LIB=cares - ;; - cares [)] - ;; - * [)] - PHP_ARES_LIB=cares - ;; - esac + ], [ + PHP_CHECK_LIBRARY(ares, ares_init, [ + PHP_ARES_LIB=ares + ], [ + PHP_ARES_LIB=unknown + ], [ + -L$PHP_ARES_DIR/$PHP_LIBDIR + ] + ) + ], [ + -L$PHP_ARES_DIR/$PHP_LIBDIR + ] + ) + AC_MSG_CHECKING(for libares/libcares) + AC_MSG_RESULT($PHP_ARES_LIB) - if test $PHP_ARES_LIB = "cares"; then + if test $PHP_ARES_LIB = "unknown"; then + AC_MSG_ERROR(could neither find libares nor libcares) + elif test $PHP_ARES_LIB = "cares"; then AC_DEFINE_UNQUOTED([PHP_ARES_LIBNAME], "c-ares (CURL)", [ ]) AC_DEFINE([PHP_ARES_EXPAND_LEN_TYPE], [long], [ ]) else AC_DEFINE_UNQUOTED([PHP_ARES_LIBNAME], "ares (MIT)", [ ]) AC_DEFINE([PHP_ARES_EXPAND_LEN_TYPE], [int], [ ]) + AC_DEFINE([HAVE_OLD_ARES_STRERROR], [1], [ ]) fi PHP_CHECK_LIBRARY($PHP_ARES_LIB, ares_cancel, @@ -52,14 +57,6 @@ if test "$PHP_ARES" != "no"; then [AC_DEFINE([HAVE_ARES_GETNAMEINFO], [1], [ ])], [ ], [-L$PHP_ARES_DIR/$PHP_LIBDIR] ) - PHP_CHECK_LIBRARY($PHP_ARES_LIB, ares_expand_string, - [AC_DEFINE([HAVE_ARES_EXPAND_STRING], [1], [ ])], [ ], - [-L$PHP_ARES_DIR/$PHP_LIBDIR] - ) - PHP_CHECK_LIBRARY($PHP_ARES_LIB, ares_parse_aaaa_reply, - [AC_DEFINE([HAVE_ARES_PARSE_AAAA_REPLY], [1], [ ])], [ ], - [-L$PHP_ARES_DIR/$PHP_LIBDIR] - ) PHP_CHECK_LIBRARY($PHP_ARES_LIB, ares_getsock, [AC_DEFINE([HAVE_ARES_GETSOCK], [1], [ ])], [ ], [-L$PHP_ARES_DIR/$PHP_LIBDIR] @@ -69,9 +66,36 @@ if test "$PHP_ARES" != "no"; then [-L$PHP_ARES_DIR/$PHP_LIBDIR] ) + + dnl check new c-ares API + + save_LIBS=$LIBS + save_CFLAGS=$CFLAGS + LIBS="-L $PHP_ARES_DIR/$PHP_LIBDIR -l $PHP_ARES_LIB" + CFLAGS="-I$PHP_ARES_DIR/include -pedantic-errors" + + AC_MSG_CHECKING(for new c-ares callback API) + AC_TRY_COMPILE( + [#include + ], [ + ares_search(0, 0, 0, 0, (void (*)(void *, int, int, unsigned char *, int)) 0, 0); + ], [ + AC_MSG_RESULT(yes) + AC_DEFINE([PHP_ARES_NEW_CALLBACK_API], [1], [ ]) + ], [ + AC_MSG_RESULT(no) + AC_DEFINE([PHP_ARES_NEW_CALLBACK_API], [0], [ ]) + ] + ) + + LIBS=$save_LIBS + CFLAGS=$save_CFLAGS + AC_CHECK_HEADERS([netdb.h unistd.h arpa/inet.h arpa/nameser.h]) + PHP_ADD_INCLUDE($PHP_ARES_DIR/include) PHP_ADD_LIBRARY_WITH_PATH($PHP_ARES_LIB, $PHP_ARES_DIR/$PHP_LIBDIR, ARES_SHARED_LIBADD) + PHP_SUBST(ARES_SHARED_LIBADD) PHP_NEW_EXTENSION(ares, ares.c, $ext_shared) fi