diff options
Diffstat (limited to 'gl/m4/sys_socket_h.m4')
-rw-r--r-- | gl/m4/sys_socket_h.m4 | 90 |
1 files changed, 78 insertions, 12 deletions
diff --git a/gl/m4/sys_socket_h.m4 b/gl/m4/sys_socket_h.m4 index d9659c2..85a0ace 100644 --- a/gl/m4/sys_socket_h.m4 +++ b/gl/m4/sys_socket_h.m4 | |||
@@ -1,5 +1,5 @@ | |||
1 | # sys_socket_h.m4 serial 4 | 1 | # sys_socket_h.m4 serial 12 |
2 | dnl Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2005-2008 Free Software Foundation, Inc. |
3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
@@ -8,22 +8,43 @@ dnl From Simon Josefsson. | |||
8 | 8 | ||
9 | AC_DEFUN([gl_HEADER_SYS_SOCKET], | 9 | AC_DEFUN([gl_HEADER_SYS_SOCKET], |
10 | [ | 10 | [ |
11 | AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS]) | ||
12 | AC_REQUIRE([AC_C_INLINE]) | ||
13 | |||
11 | AC_CACHE_CHECK([whether <sys/socket.h> is self-contained], | 14 | AC_CACHE_CHECK([whether <sys/socket.h> is self-contained], |
12 | [gl_cv_header_sys_socket_h_selfcontained], | 15 | [gl_cv_header_sys_socket_h_selfcontained], |
13 | [ | 16 | [ |
14 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/socket.h>], [])], | 17 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/socket.h>]], [[]])], |
15 | [gl_cv_header_sys_socket_h_selfcontained=yes], | 18 | [gl_cv_header_sys_socket_h_selfcontained=yes], |
16 | [gl_cv_header_sys_socket_h_selfcontained=no]) | 19 | [gl_cv_header_sys_socket_h_selfcontained=no]) |
17 | ]) | 20 | ]) |
18 | if test $gl_cv_header_sys_socket_h_selfcontained = yes; then | 21 | if test $gl_cv_header_sys_socket_h_selfcontained = yes; then |
19 | SYS_SOCKET_H='' | 22 | SYS_SOCKET_H='' |
23 | dnl If the shutdown function exists, <sys/socket.h> should define | ||
24 | dnl SHUT_RD, SHUT_WR, SHUT_RDWR. | ||
25 | AC_CHECK_FUNCS([shutdown]) | ||
26 | if test $ac_cv_func_shutdown = yes; then | ||
27 | AC_CACHE_CHECK([whether <sys/socket.h> defines the SHUT_* macros], | ||
28 | [gl_cv_header_sys_socket_h_shut], | ||
29 | [ | ||
30 | AC_COMPILE_IFELSE( | ||
31 | [AC_LANG_PROGRAM([[#include <sys/socket.h>]], | ||
32 | [[int a[] = { SHUT_RD, SHUT_WR, SHUT_RDWR };]])], | ||
33 | [gl_cv_header_sys_socket_h_shut=yes], | ||
34 | [gl_cv_header_sys_socket_h_shut=no]) | ||
35 | ]) | ||
36 | if test $gl_cv_header_sys_socket_h_shut = no; then | ||
37 | SYS_SOCKET_H='sys/socket.h' | ||
38 | fi | ||
39 | fi | ||
20 | else | 40 | else |
21 | SYS_SOCKET_H='sys/socket.h' | 41 | SYS_SOCKET_H='sys/socket.h' |
22 | 42 | fi | |
43 | if test -n "$SYS_SOCKET_H"; then | ||
44 | dnl Check prerequisites of the <sys/socket.h> replacement. | ||
23 | gl_CHECK_NEXT_HEADERS([sys/socket.h]) | 45 | gl_CHECK_NEXT_HEADERS([sys/socket.h]) |
24 | if test $ac_cv_header_sys_socket_h = yes; then | 46 | if test $ac_cv_header_sys_socket_h = yes; then |
25 | HAVE_SYS_SOCKET_H=1 | 47 | HAVE_SYS_SOCKET_H=1 |
26 | HAVE_WINSOCK2_H=0 | ||
27 | HAVE_WS2TCPIP_H=0 | 48 | HAVE_WS2TCPIP_H=0 |
28 | else | 49 | else |
29 | HAVE_SYS_SOCKET_H=0 | 50 | HAVE_SYS_SOCKET_H=0 |
@@ -31,21 +52,66 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET], | |||
31 | dnl the check for those headers unconditional; yet cygwin reports | 52 | dnl the check for those headers unconditional; yet cygwin reports |
32 | dnl that the headers are present but cannot be compiled (since on | 53 | dnl that the headers are present but cannot be compiled (since on |
33 | dnl cygwin, all socket information should come from sys/socket.h). | 54 | dnl cygwin, all socket information should come from sys/socket.h). |
34 | AC_CHECK_HEADERS([winsock2.h ws2tcpip.h]) | 55 | AC_CHECK_HEADERS([ws2tcpip.h]) |
35 | if test $ac_cv_header_winsock2_h = yes; then | ||
36 | HAVE_WINSOCK2_H=1 | ||
37 | else | ||
38 | HAVE_WINSOCK2_H=0 | ||
39 | fi | ||
40 | if test $ac_cv_header_ws2tcpip_h = yes; then | 56 | if test $ac_cv_header_ws2tcpip_h = yes; then |
41 | HAVE_WS2TCPIP_H=1 | 57 | HAVE_WS2TCPIP_H=1 |
42 | else | 58 | else |
43 | HAVE_WS2TCPIP_H=0 | 59 | HAVE_WS2TCPIP_H=0 |
44 | fi | 60 | fi |
45 | fi | 61 | fi |
62 | gl_PREREQ_SYS_H_WINSOCK2 | ||
46 | AC_SUBST([HAVE_SYS_SOCKET_H]) | 63 | AC_SUBST([HAVE_SYS_SOCKET_H]) |
47 | AC_SUBST([HAVE_WINSOCK2_H]) | ||
48 | AC_SUBST([HAVE_WS2TCPIP_H]) | 64 | AC_SUBST([HAVE_WS2TCPIP_H]) |
49 | fi | 65 | fi |
50 | AC_SUBST([SYS_SOCKET_H]) | 66 | AC_SUBST([SYS_SOCKET_H]) |
51 | ]) | 67 | ]) |
68 | |||
69 | # Common prerequisites of of the <sys/socket.h> replacement and of the | ||
70 | # <sys/select.h> replacement. | ||
71 | # Sets and substitutes HAVE_WINSOCK2_H. | ||
72 | AC_DEFUN([gl_PREREQ_SYS_H_WINSOCK2], | ||
73 | [ | ||
74 | m4_ifdef([gl_UNISTD_H_DEFAULTS], [AC_REQUIRE([gl_UNISTD_H_DEFAULTS])]) | ||
75 | m4_ifdef([gl_SYS_IOCTL_H_DEFAULTS], [AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS])]) | ||
76 | AC_CHECK_HEADERS_ONCE([sys/socket.h]) | ||
77 | if test $ac_cv_header_sys_socket_h != yes; then | ||
78 | dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make | ||
79 | dnl the check for those headers unconditional; yet cygwin reports | ||
80 | dnl that the headers are present but cannot be compiled (since on | ||
81 | dnl cygwin, all socket information should come from sys/socket.h). | ||
82 | AC_CHECK_HEADERS([winsock2.h]) | ||
83 | fi | ||
84 | if test "$ac_cv_header_winsock2_h" = yes; then | ||
85 | HAVE_WINSOCK2_H=1 | ||
86 | UNISTD_H_HAVE_WINSOCK2_H=1 | ||
87 | SYS_IOCTL_H_HAVE_WINSOCK2_H=1 | ||
88 | else | ||
89 | HAVE_WINSOCK2_H=0 | ||
90 | fi | ||
91 | AC_SUBST([HAVE_WINSOCK2_H]) | ||
92 | ]) | ||
93 | |||
94 | AC_DEFUN([gl_SYS_SOCKET_MODULE_INDICATOR], | ||
95 | [ | ||
96 | dnl Use AC_REQUIRE here, so that the default settings are expanded once only. | ||
97 | AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS]) | ||
98 | GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 | ||
99 | ]) | ||
100 | |||
101 | AC_DEFUN([gl_SYS_SOCKET_H_DEFAULTS], | ||
102 | [ | ||
103 | GNULIB_SOCKET=0; AC_SUBST([GNULIB_SOCKET]) | ||
104 | GNULIB_CONNECT=0; AC_SUBST([GNULIB_CONNECT]) | ||
105 | GNULIB_ACCEPT=0; AC_SUBST([GNULIB_ACCEPT]) | ||
106 | GNULIB_BIND=0; AC_SUBST([GNULIB_BIND]) | ||
107 | GNULIB_GETPEERNAME=0; AC_SUBST([GNULIB_GETPEERNAME]) | ||
108 | GNULIB_GETSOCKNAME=0; AC_SUBST([GNULIB_GETSOCKNAME]) | ||
109 | GNULIB_GETSOCKOPT=0; AC_SUBST([GNULIB_GETSOCKOPT]) | ||
110 | GNULIB_LISTEN=0; AC_SUBST([GNULIB_LISTEN]) | ||
111 | GNULIB_RECV=0; AC_SUBST([GNULIB_RECV]) | ||
112 | GNULIB_SEND=0; AC_SUBST([GNULIB_SEND]) | ||
113 | GNULIB_RECVFROM=0; AC_SUBST([GNULIB_RECVFROM]) | ||
114 | GNULIB_SENDTO=0; AC_SUBST([GNULIB_SENDTO]) | ||
115 | GNULIB_SETSOCKOPT=0; AC_SUBST([GNULIB_SETSOCKOPT]) | ||
116 | GNULIB_SHUTDOWN=0; AC_SUBST([GNULIB_SHUTDOWN]) | ||
117 | ]) | ||