check for freeaddrinfo() at configuration phase

pull/1/head
Yang Tse 16 years ago
parent 0e4d0eda3d
commit c0711bdca9
  1. 1
      configure.ac
  2. 98
      m4/cares-functions.m4

@ -553,6 +553,7 @@ CURL_CHECK_FUNC_RECVFROM
CURL_CHECK_FUNC_SEND CURL_CHECK_FUNC_SEND
CURL_CHECK_MSG_NOSIGNAL CURL_CHECK_MSG_NOSIGNAL
CARES_CHECK_FUNC_FREEADDRINFO
CARES_CHECK_FUNC_GETADDRINFO CARES_CHECK_FUNC_GETADDRINFO
CARES_CHECK_FUNC_GETHOSTNAME CARES_CHECK_FUNC_GETHOSTNAME
CARES_CHECK_FUNC_GETSERVBYPORT_R CARES_CHECK_FUNC_GETSERVBYPORT_R

@ -16,7 +16,7 @@
#*************************************************************************** #***************************************************************************
# File version for 'aclocal' use. Keep it a single number. # File version for 'aclocal' use. Keep it a single number.
# serial 17 # serial 18
dnl CARES_INCLUDES_ARPA_INET dnl CARES_INCLUDES_ARPA_INET
@ -230,6 +230,102 @@ cares_includes_ws2tcpip="\
]) ])
dnl CARES_CHECK_FUNC_FREEADDRINFO
dnl -------------------------------------------------
dnl Verify if freeaddrinfo is available, prototyped,
dnl and can be compiled. If all of these are true,
dnl and usage has not been previously disallowed with
dnl shell variable cares_disallow_freeaddrinfo, then
dnl HAVE_FREEADDRINFO will be defined.
AC_DEFUN([CARES_CHECK_FUNC_FREEADDRINFO], [
AC_REQUIRE([CARES_INCLUDES_WS2TCPIP])dnl
AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
AC_REQUIRE([CARES_INCLUDES_NETDB])dnl
#
tst_links_freeaddrinfo="unknown"
tst_proto_freeaddrinfo="unknown"
tst_compi_freeaddrinfo="unknown"
tst_allow_freeaddrinfo="unknown"
#
AC_MSG_CHECKING([if freeaddrinfo can be linked])
AC_LINK_IFELSE([
AC_LANG_PROGRAM([[
$cares_includes_ws2tcpip
$cares_includes_sys_socket
$cares_includes_netdb
]],[[
freeaddrinfo(0);
]])
],[
AC_MSG_RESULT([yes])
tst_links_freeaddrinfo="yes"
],[
AC_MSG_RESULT([no])
tst_links_freeaddrinfo="no"
])
#
if test "$tst_links_freeaddrinfo" = "yes"; then
AC_MSG_CHECKING([if freeaddrinfo is prototyped])
AC_EGREP_CPP([freeaddrinfo],[
$cares_includes_ws2tcpip
$cares_includes_sys_socket
$cares_includes_netdb
],[
AC_MSG_RESULT([yes])
tst_proto_freeaddrinfo="yes"
],[
AC_MSG_RESULT([no])
tst_proto_freeaddrinfo="no"
])
fi
#
if test "$tst_proto_freeaddrinfo" = "yes"; then
AC_MSG_CHECKING([if freeaddrinfo is compilable])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
$cares_includes_ws2tcpip
$cares_includes_sys_socket
$cares_includes_netdb
]],[[
freeaddrinfo(0);
]])
],[
AC_MSG_RESULT([yes])
tst_compi_freeaddrinfo="yes"
],[
AC_MSG_RESULT([no])
tst_compi_freeaddrinfo="no"
])
fi
#
if test "$tst_compi_freeaddrinfo" = "yes"; then
AC_MSG_CHECKING([if freeaddrinfo usage allowed])
if test "x$cares_disallow_freeaddrinfo" != "xyes"; then
AC_MSG_RESULT([yes])
tst_allow_freeaddrinfo="yes"
else
AC_MSG_RESULT([no])
tst_allow_freeaddrinfo="no"
fi
fi
#
AC_MSG_CHECKING([if freeaddrinfo might be used])
if test "$tst_links_freeaddrinfo" = "yes" &&
test "$tst_proto_freeaddrinfo" = "yes" &&
test "$tst_compi_freeaddrinfo" = "yes" &&
test "$tst_allow_freeaddrinfo" = "yes"; then
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED(HAVE_FREEADDRINFO, 1,
[Define to 1 if you have the freeaddrinfo function.])
ac_cv_func_freeaddrinfo="yes"
else
AC_MSG_RESULT([no])
ac_cv_func_freeaddrinfo="no"
fi
])
dnl CARES_CHECK_FUNC_GETADDRINFO dnl CARES_CHECK_FUNC_GETADDRINFO
dnl ------------------------------------------------- dnl -------------------------------------------------
dnl Verify if getaddrinfo is available, prototyped, can dnl Verify if getaddrinfo is available, prototyped, can

Loading…
Cancel
Save