changeset 30226:051ed487f38b

Ensure correct syntax when sys/select.h is replaced but sys/socket.h is not.
author Bruno Haible <bruno@clisp.org>
date Sun, 28 Sep 2008 17:41:17 +0200
parents 35bef5339516
children b636c4338efc
files ChangeLog m4/sys_select_h.m4 m4/sys_socket_h.m4
diffstat 3 files changed, 33 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Sep 28 17:02:37 2008 +0200
+++ b/ChangeLog	Sun Sep 28 17:41:17 2008 +0200
@@ -1,3 +1,10 @@
+2008-09-28  Bruno Haible  <bruno@clisp.org>
+
+	* m4/sys_socket_h.m4 (gl_PREREQ_SYS_H_WINSOCK2): New macro, extracted
+	from gl_HEADER_SYS_SOCKET.
+	(gl_HEADER_SYS_SOCKET): Invoke it.
+	* m4/sys_select_h.m4 (gl_HEADER_SYS_SELECT): Likewise.
+
 2008-09-28  Bruno Haible  <bruno@clisp.org>
 
 	* doc/posix-headers/sys_select.texi: Mention 'struct timeval' problem.
--- a/m4/sys_select_h.m4	Sun Sep 28 17:02:37 2008 +0200
+++ b/m4/sys_select_h.m4	Sun Sep 28 17:41:17 2008 +0200
@@ -1,4 +1,4 @@
-# sys_select_h.m4 serial 4
+# sys_select_h.m4 serial 5
 dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -25,6 +25,7 @@
       HAVE_SYS_SELECT_H=0
     fi
     AC_SUBST([HAVE_SYS_SELECT_H])
+    gl_PREREQ_SYS_H_WINSOCK2
   fi
   AC_SUBST([SYS_SELECT_H])
   if test x$ac_cv_header_winsock2_h = xyes; then
--- a/m4/sys_socket_h.m4	Sun Sep 28 17:02:37 2008 +0200
+++ b/m4/sys_socket_h.m4	Sun Sep 28 17:41:17 2008 +0200
@@ -1,4 +1,4 @@
-# sys_socket_h.m4 serial 6
+# sys_socket_h.m4 serial 7
 dnl Copyright (C) 2005-2008 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -44,7 +44,6 @@
     gl_CHECK_NEXT_HEADERS([sys/socket.h])
     if test $ac_cv_header_sys_socket_h = yes; then
       HAVE_SYS_SOCKET_H=1
-      HAVE_WINSOCK2_H=0
       HAVE_WS2TCPIP_H=0
     else
       HAVE_SYS_SOCKET_H=0
@@ -52,24 +51,40 @@
       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])
-      if test $ac_cv_header_winsock2_h = yes; then
-        HAVE_WINSOCK2_H=1
-      else
-        HAVE_WINSOCK2_H=0
-      fi
+      AC_CHECK_HEADERS([ws2tcpip.h])
       if test $ac_cv_header_ws2tcpip_h = yes; then
         HAVE_WS2TCPIP_H=1
       else
         HAVE_WS2TCPIP_H=0
       fi
     fi
+    gl_PREREQ_SYS_H_WINSOCK2
     if test x$ac_cv_header_winsock2_h = xyes; then
       AC_LIBOBJ(winsock)
     fi
     AC_SUBST([HAVE_SYS_SOCKET_H])
-    AC_SUBST([HAVE_WINSOCK2_H])
     AC_SUBST([HAVE_WS2TCPIP_H])
   fi
   AC_SUBST([SYS_SOCKET_H])
 ])
+
+# Common prerequisites of of the <sys/socket.h> replacement and of the
+# <sys/select.h> replacement.
+# Sets and substitutes HAVE_WINSOCK2_H.
+AC_DEFUN([gl_PREREQ_SYS_H_WINSOCK2],
+[
+  AC_CHECK_HEADERS_ONCE([sys/socket.h])
+  if test $ac_cv_header_sys_socket_h != yes; then
+    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])
+  fi
+  if test "$ac_cv_header_winsock2_h" = yes; then
+    HAVE_WINSOCK2_H=1
+  else
+    HAVE_WINSOCK2_H=0
+  fi
+  AC_SUBST([HAVE_WINSOCK2_H])
+])