summaryrefslogtreecommitdiff
path: root/m4/cares-functions.m4
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2009-06-17 12:52:46 +0000
committerYang Tse <yangsita@gmail.com>2009-06-17 12:52:46 +0000
commitd96073913339cb935c5e2f767188b6747ce4387b (patch)
treec42d73f0725ed00187f03235323b832e9dda5d2a /m4/cares-functions.m4
parenta741386bec28b19b544e7732a69af3b40e8c8272 (diff)
downloadc-ares-d96073913339cb935c5e2f767188b6747ce4387b.tar.gz
c-ares-d96073913339cb935c5e2f767188b6747ce4387b.tar.bz2
c-ares-d96073913339cb935c5e2f767188b6747ce4387b.zip
check for socket() and closesocket() as it is done for other functions
Diffstat (limited to 'm4/cares-functions.m4')
-rw-r--r--m4/cares-functions.m4215
1 files changed, 214 insertions, 1 deletions
diff --git a/m4/cares-functions.m4 b/m4/cares-functions.m4
index 10bbdbe..40545d9 100644
--- a/m4/cares-functions.m4
+++ b/m4/cares-functions.m4
@@ -16,7 +16,7 @@
#***************************************************************************
# File version for 'aclocal' use. Keep it a single number.
-# serial 29
+# serial 30
dnl CARES_INCLUDES_ARPA_INET
@@ -91,6 +91,27 @@ cares_includes_netdb="\
])
+dnl CARES_INCLUDES_SOCKET
+dnl -------------------------------------------------
+dnl Set up variable with list of headers that must be
+dnl included when socket.h is to be included.
+
+AC_DEFUN([CARES_INCLUDES_SOCKET], [
+cares_includes_socket="\
+/* includes start */
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SOCKET_H
+# include <socket.h>
+#endif
+/* includes end */"
+ AC_CHECK_HEADERS(
+ sys/types.h socket.h,
+ [], [], [$cares_includes_socket])
+])
+
+
dnl CARES_INCLUDES_STDLIB
dnl -------------------------------------------------
dnl Set up variable with list of headers that must be
@@ -319,6 +340,100 @@ cares_preprocess_callconv="\
])
+dnl CARES_CHECK_FUNC_CLOSESOCKET
+dnl -------------------------------------------------
+dnl Verify if closesocket is available, prototyped, and
+dnl can be compiled. If all of these are true, and
+dnl usage has not been previously disallowed with
+dnl shell variable cares_disallow_closesocket, then
+dnl HAVE_CLOSESOCKET will be defined.
+
+AC_DEFUN([CARES_CHECK_FUNC_CLOSESOCKET], [
+ AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
+ AC_REQUIRE([CARES_INCLUDES_SOCKET])dnl
+ #
+ tst_links_closesocket="unknown"
+ tst_proto_closesocket="unknown"
+ tst_compi_closesocket="unknown"
+ tst_allow_closesocket="unknown"
+ #
+ AC_MSG_CHECKING([if closesocket can be linked])
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([[
+ $cares_includes_winsock2
+ $cares_includes_socket
+ ]],[[
+ if(0 != closesocket(0))
+ return 1;
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_links_closesocket="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_links_closesocket="no"
+ ])
+ #
+ if test "$tst_links_closesocket" = "yes"; then
+ AC_MSG_CHECKING([if closesocket is prototyped])
+ AC_EGREP_CPP([closesocket],[
+ $cares_includes_winsock2
+ $cares_includes_socket
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_proto_closesocket="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_proto_closesocket="no"
+ ])
+ fi
+ #
+ if test "$tst_proto_closesocket" = "yes"; then
+ AC_MSG_CHECKING([if closesocket is compilable])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ $cares_includes_winsock2
+ $cares_includes_socket
+ ]],[[
+ if(0 != closesocket(0))
+ return 1;
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_compi_closesocket="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_compi_closesocket="no"
+ ])
+ fi
+ #
+ if test "$tst_compi_closesocket" = "yes"; then
+ AC_MSG_CHECKING([if closesocket usage allowed])
+ if test "x$cares_disallow_closesocket" != "xyes"; then
+ AC_MSG_RESULT([yes])
+ tst_allow_closesocket="yes"
+ else
+ AC_MSG_RESULT([no])
+ tst_allow_closesocket="no"
+ fi
+ fi
+ #
+ AC_MSG_CHECKING([if closesocket might be used])
+ if test "$tst_links_closesocket" = "yes" &&
+ test "$tst_proto_closesocket" = "yes" &&
+ test "$tst_compi_closesocket" = "yes" &&
+ test "$tst_allow_closesocket" = "yes"; then
+ AC_MSG_RESULT([yes])
+ AC_DEFINE_UNQUOTED(HAVE_CLOSESOCKET, 1,
+ [Define to 1 if you have the closesocket function.])
+ ac_cv_func_closesocket="yes"
+ else
+ AC_MSG_RESULT([no])
+ ac_cv_func_closesocket="no"
+ fi
+])
+
+
dnl CARES_CHECK_FUNC_FCNTL
dnl -------------------------------------------------
dnl Verify if fcntl is available, prototyped, and
@@ -2074,6 +2189,104 @@ AC_DEFUN([CARES_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK], [
])
+dnl CARES_CHECK_FUNC_SOCKET
+dnl -------------------------------------------------
+dnl Verify if socket is available, prototyped, and
+dnl can be compiled. If all of these are true, and
+dnl usage has not been previously disallowed with
+dnl shell variable cares_disallow_socket, then
+dnl HAVE_SOCKET will be defined.
+
+AC_DEFUN([CARES_CHECK_FUNC_SOCKET], [
+ AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
+ AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
+ AC_REQUIRE([CARES_INCLUDES_SOCKET])dnl
+ #
+ tst_links_socket="unknown"
+ tst_proto_socket="unknown"
+ tst_compi_socket="unknown"
+ tst_allow_socket="unknown"
+ #
+ AC_MSG_CHECKING([if socket can be linked])
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([[
+ $cares_includes_winsock2
+ $cares_includes_sys_socket
+ $cares_includes_socket
+ ]],[[
+ if(0 != socket(0, 0, 0))
+ return 1;
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_links_socket="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_links_socket="no"
+ ])
+ #
+ if test "$tst_links_socket" = "yes"; then
+ AC_MSG_CHECKING([if socket is prototyped])
+ AC_EGREP_CPP([socket],[
+ $cares_includes_winsock2
+ $cares_includes_sys_socket
+ $cares_includes_socket
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_proto_socket="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_proto_socket="no"
+ ])
+ fi
+ #
+ if test "$tst_proto_socket" = "yes"; then
+ AC_MSG_CHECKING([if socket is compilable])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ $cares_includes_winsock2
+ $cares_includes_sys_socket
+ $cares_includes_socket
+ ]],[[
+ if(0 != socket(0, 0, 0))
+ return 1;
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_compi_socket="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_compi_socket="no"
+ ])
+ fi
+ #
+ if test "$tst_compi_socket" = "yes"; then
+ AC_MSG_CHECKING([if socket usage allowed])
+ if test "x$cares_disallow_socket" != "xyes"; then
+ AC_MSG_RESULT([yes])
+ tst_allow_socket="yes"
+ else
+ AC_MSG_RESULT([no])
+ tst_allow_socket="no"
+ fi
+ fi
+ #
+ AC_MSG_CHECKING([if socket might be used])
+ if test "$tst_links_socket" = "yes" &&
+ test "$tst_proto_socket" = "yes" &&
+ test "$tst_compi_socket" = "yes" &&
+ test "$tst_allow_socket" = "yes"; then
+ AC_MSG_RESULT([yes])
+ AC_DEFINE_UNQUOTED(HAVE_SOCKET, 1,
+ [Define to 1 if you have the socket function.])
+ ac_cv_func_socket="yes"
+ else
+ AC_MSG_RESULT([no])
+ ac_cv_func_socket="no"
+ fi
+])
+
+
dnl CARES_CHECK_FUNC_STRCASECMP
dnl -------------------------------------------------
dnl Verify if strcasecmp is available, prototyped, and