* sys_socket_h.m4 (gl_HEADER_SYS_SOCKET): Don't attempt using
authorSimon Josefsson <simon@josefsson.org>
Thu, 16 Feb 2006 09:48:07 +0000 (09:48 +0000)
committerSimon Josefsson <simon@josefsson.org>
Thu, 16 Feb 2006 09:48:07 +0000 (09:48 +0000)
winsock2.h or ws2tcpip.h when sys/socket.h is present. Fixes
'present but cannot compile' warnings on cygwin.
* socklen.m4 (gl_TYPE_SOCKLEN_T): Use gl_HEADER_SYS_SOCKET.  Don't
use ws2tcpip.h if sys/socket.h works.
* getaddrinfo.m4 (gl_PREREQ_GETADDRINFO): Use gl_HEADER_SYS_SOCKET.
(gl_GETADDRINFO): Don't use ws2tcpip.h when sys/socket.h is present.

m4/ChangeLog
m4/getaddrinfo.m4
m4/socklen.m4
m4/sys_socket_h.m4

index 0c784d4..d3c7d53 100644 (file)
@@ -1,3 +1,13 @@
+2006-02-15  Eric Blake  <ebb9@byu.net>
+
+       * sys_socket_h.m4 (gl_HEADER_SYS_SOCKET): Don't attempt using
+       winsock2.h or ws2tcpip.h when sys/socket.h is present. Fixes
+       'present but cannot compile' warnings on cygwin.
+       * socklen.m4 (gl_TYPE_SOCKLEN_T): Use gl_HEADER_SYS_SOCKET.  Don't
+       use ws2tcpip.h if sys/socket.h works.
+       * getaddrinfo.m4 (gl_PREREQ_GETADDRINFO): Use gl_HEADER_SYS_SOCKET.
+       (gl_GETADDRINFO): Don't use ws2tcpip.h when sys/socket.h is present.
+
 2006-02-14  Jim Meyering  <jim@meyering.net>
 
        Sync from coreutils.
index 006cdab..3c6a869 100644 (file)
@@ -1,4 +1,4 @@
-# getaddrinfo.m4 serial 7
+# getaddrinfo.m4 serial 8
 dnl Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -11,19 +11,21 @@ AC_DEFUN([gl_GETADDRINFO],
   AC_SEARCH_LIBS(getaddrinfo, [nsl socket])
   AC_CHECK_FUNCS(getaddrinfo,, [
     AC_CACHE_CHECK(for getaddrinfo in ws2tcpip.h and -lws2_32,
-                   gl_cv_w32_getaddrinfo, [
+                  gl_cv_w32_getaddrinfo, [
       gl_cv_w32_getaddrinfo=no
       am_save_LIBS="$LIBS"
       LIBS="$LIBS -lws2_32"
       AC_TRY_LINK([
+#ifdef HAVE_WS2TCPIP_H
 #define WINVER 0x0501
 #include <ws2tcpip.h>
+#endif
 ], [getaddrinfo(0, 0, 0, 0);], gl_cv_w32_getaddrinfo=yes)
       LIBS="$am_save_LIBS"
       if test "$gl_cv_w32_getaddrinfo" = "yes"; then
-        LIBS="$LIBS -lws2_32"
+       LIBS="$LIBS -lws2_32"
       else
-        AC_LIBOBJ(getaddrinfo)
+       AC_LIBOBJ(getaddrinfo)
       fi
     ])])
 
@@ -37,9 +39,10 @@ AC_DEFUN([gl_PREREQ_GETADDRINFO], [
   AC_SEARCH_LIBS(getservbyname, [inet nsl socket xnet])
   AC_REQUIRE([gl_C_RESTRICT])
   AC_REQUIRE([gl_SOCKET_FAMILIES])
+  AC_REQUIRE([gl_HEADER_SYS_SOCKET])
   AC_REQUIRE([AC_C_INLINE])
   AC_REQUIRE([AC_GNU_SOURCE])
-  AC_CHECK_HEADERS_ONCE(netinet/in.h sys/socket.h netdb.h ws2tcpip.h)
+  AC_CHECK_HEADERS_ONCE(netinet/in.h netdb.h)
   AC_CHECK_DECLS([getaddrinfo, freeaddrinfo, gai_strerror],,,[
   /* sys/types.h is not needed according to POSIX, but the
      sys/socket.h in i386-unknown-freebsd4.10 and
index 01da2b5..5e3765a 100644 (file)
@@ -1,4 +1,4 @@
-# socklen.m4 serial 3
+# socklen.m4 serial 4
 dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -13,40 +13,40 @@ dnl have to test to find something that will work.
 
 dnl On mingw32, socklen_t is in ws2tcpip.h ('int'), so we try to find
 dnl it there first.  That file is included by gnulib's socket_.h, which
-dnl all users of this module should include.
+dnl all users of this module should include.  Cygwin must not include
+dnl ws2tcpip.h.
 AC_DEFUN([gl_TYPE_SOCKLEN_T],
-  [AC_CHECK_HEADERS_ONCE([sys/socket.h ws2tcpip.h])
+  [AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl
    AC_CHECK_TYPE([socklen_t], ,
      [AC_MSG_CHECKING([for socklen_t equivalent])
       AC_CACHE_VAL([gl_cv_gl_cv_socklen_t_equiv],
-        [# Systems have either "struct sockaddr *" or
-         # "void *" as the second argument to getpeername
-         gl_cv_socklen_t_equiv=
-         for arg2 in "struct sockaddr" void; do
+       [# Systems have either "struct sockaddr *" or
+        # "void *" as the second argument to getpeername
+        gl_cv_socklen_t_equiv=
+        for arg2 in "struct sockaddr" void; do
           for t in int size_t "unsigned int" "long int" "unsigned long int"; do
             AC_TRY_COMPILE(
               [#include <sys/types.h>
-                #include <sys/socket.h>
+               #include <sys/socket.h>
 
                int getpeername (int, $arg2 *, $t *);],
-               [$t len;
+              [$t len;
                getpeername (0, 0, &len);],
               [gl_cv_socklen_t_equiv="$t"])
-             test "$gl_cv_socklen_t_equiv" != "" && break
+            test "$gl_cv_socklen_t_equiv" != "" && break
           done
-           test "$gl_cv_socklen_t_equiv" != "" && break
-         done
+          test "$gl_cv_socklen_t_equiv" != "" && break
+        done
       ])
       if test "$gl_cv_socklen_t_equiv" = ""; then
        AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
       fi
       AC_MSG_RESULT([$gl_cv_socklen_t_equiv])
       AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv],
-        [type to use in place of socklen_t if not defined])],
+       [type to use in place of socklen_t if not defined])],
      [#include <sys/types.h>
       #if HAVE_SYS_SOCKET_H
       # include <sys/socket.h>
-      #endif
-      #if HAVE_WS2TCPIP_H
+      #elif HAVE_WS2TCPIP_H
       # include <ws2tcpip.h>
       #endif])])
index 10d042c..d3e45b4 100644 (file)
@@ -1,4 +1,4 @@
-# sys_socket_h.m4 serial 1
+# sys_socket_h.m4 serial 2
 dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,7 +12,11 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
   if test $ac_cv_header_sys_socket_h = yes; then
     SYS_SOCKET_H=''
   else
-    AC_CHECK_HEADERS_ONCE([winsock2.h ws2tcpip.h])
+    dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
+    dnl the check for those headers unconditional; yet cygwin reports
+    dnl that the headers are present but cannot be compiled (since on
+    dnl cygwin, all socket information should come from sys/socket.h).
+    AC_CHECK_HEADERS([winsock2.h ws2tcpip.h])
     SYS_SOCKET_H='sys/socket.h'
   fi
   AC_SUBST(SYS_SOCKET_H)