summaryrefslogtreecommitdiffstats
path: root/gl/m4/getaddrinfo.m4
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@aei.ca>2009-01-15 04:22:57 -0500
committerThomas Guyot-Sionnest <dermoth@aei.ca>2009-01-15 05:19:08 -0500
commit71cdb52799220f8d9052643baf1d3e9836a9c755 (patch)
tree27aee97a35d9ab51f0d8f64a46690bd41a5f8c1b /gl/m4/getaddrinfo.m4
parentf7afa46586645e50498d8b2d0c67884f014dc3a4 (diff)
downloadmonitoring-plugins-71cdb52799220f8d9052643baf1d3e9836a9c755.tar.gz
Sync with gnulib
Diffstat (limited to 'gl/m4/getaddrinfo.m4')
-rw-r--r--gl/m4/getaddrinfo.m496
1 files changed, 66 insertions, 30 deletions
diff --git a/gl/m4/getaddrinfo.m4 b/gl/m4/getaddrinfo.m4
index 5d36c195..40886719 100644
--- a/gl/m4/getaddrinfo.m4
+++ b/gl/m4/getaddrinfo.m4
@@ -1,5 +1,5 @@
1# getaddrinfo.m4 serial 15 1# getaddrinfo.m4 serial 20
2dnl Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc. 2dnl Copyright (C) 2004-2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -7,11 +7,23 @@ dnl with or without modifications, as long as this notice is preserved.
7AC_DEFUN([gl_GETADDRINFO], 7AC_DEFUN([gl_GETADDRINFO],
8[ 8[
9 AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H 9 AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
10 AC_REQUIRE([gl_HEADER_NETDB])dnl for HAVE_NETDB_H
10 AC_MSG_NOTICE([checking how to do getaddrinfo, freeaddrinfo and getnameinfo]) 11 AC_MSG_NOTICE([checking how to do getaddrinfo, freeaddrinfo and getnameinfo])
12 GETADDRINFO_LIB=
13 gai_saved_LIBS="$LIBS"
11 14
12 AC_CHECK_HEADERS_ONCE(netdb.h) 15 dnl Where is getaddrinfo()?
16 dnl - On Solaris, it is in libsocket.
17 dnl - On Haiku, it is in libnetwork.
18 dnl - On BeOS, it is in libnet.
19 dnl - On native Windows, it is in ws2_32.dll.
20 dnl - Otherwise it is in libc.
21 AC_SEARCH_LIBS([getaddrinfo], [socket network net],
22 [if test "$ac_cv_search_getaddrinfo" != "none required"; then
23 GETADDRINFO_LIB="$ac_cv_search_getaddrinfo"
24 fi])
25 LIBS="$gai_saved_LIBS $GETADDRINFO_LIB"
13 26
14 AC_SEARCH_LIBS(getaddrinfo, [nsl socket])
15 AC_CACHE_CHECK([for getaddrinfo], [gl_cv_func_getaddrinfo], [ 27 AC_CACHE_CHECK([for getaddrinfo], [gl_cv_func_getaddrinfo], [
16 AC_TRY_LINK([ 28 AC_TRY_LINK([
17#include <sys/types.h> 29#include <sys/types.h>
@@ -26,7 +38,7 @@ AC_DEFUN([gl_GETADDRINFO],
26 [gl_cv_func_getaddrinfo=yes], 38 [gl_cv_func_getaddrinfo=yes],
27 [gl_cv_func_getaddrinfo=no])]) 39 [gl_cv_func_getaddrinfo=no])])
28 if test $gl_cv_func_getaddrinfo = no; then 40 if test $gl_cv_func_getaddrinfo = no; then
29 AC_CACHE_CHECK(for getaddrinfo in ws2tcpip.h and -lws2_32, 41 AC_CACHE_CHECK([for getaddrinfo in ws2tcpip.h and -lws2_32],
30 gl_cv_w32_getaddrinfo, [ 42 gl_cv_w32_getaddrinfo, [
31 gl_cv_w32_getaddrinfo=no 43 gl_cv_w32_getaddrinfo=no
32 am_save_LIBS="$LIBS" 44 am_save_LIBS="$LIBS"
@@ -37,11 +49,13 @@ AC_DEFUN([gl_GETADDRINFO],
37#endif 49#endif
38#include <stddef.h> 50#include <stddef.h>
39], [getaddrinfo(NULL, NULL, NULL, NULL);], gl_cv_w32_getaddrinfo=yes) 51], [getaddrinfo(NULL, NULL, NULL, NULL);], gl_cv_w32_getaddrinfo=yes)
40 LIBS="$am_save_LIBS"]) 52 LIBS="$am_save_LIBS"
53 ])
41 if test "$gl_cv_w32_getaddrinfo" = "yes"; then 54 if test "$gl_cv_w32_getaddrinfo" = "yes"; then
42 LIBS="$LIBS -lws2_32" 55 GETADDRINFO_LIB="-lws2_32"
56 LIBS="$gai_saved_LIBS $GETADDRINFO_LIB"
43 else 57 else
44 AC_LIBOBJ(getaddrinfo) 58 AC_LIBOBJ([getaddrinfo])
45 fi 59 fi
46 fi 60 fi
47 61
@@ -66,40 +80,34 @@ AC_DEFUN([gl_GETADDRINFO],
66 [gl_cv_func_gai_strerror=yes], 80 [gl_cv_func_gai_strerror=yes],
67 [gl_cv_func_gai_strerror=no])]) 81 [gl_cv_func_gai_strerror=no])])
68 if test $gl_cv_func_gai_strerror = no; then 82 if test $gl_cv_func_gai_strerror = no; then
69 AC_LIBOBJ(gai_strerror) 83 AC_LIBOBJ([gai_strerror])
70 fi 84 fi
71 85
86 LIBS="$gai_saved_LIBS"
87
72 gl_PREREQ_GETADDRINFO 88 gl_PREREQ_GETADDRINFO
89
90 AC_SUBST([GETADDRINFO_LIB])
73]) 91])
74 92
75# Prerequisites of lib/getaddrinfo.h and lib/getaddrinfo.c. 93# Prerequisites of lib/netdb.in.h and lib/getaddrinfo.c.
76AC_DEFUN([gl_PREREQ_GETADDRINFO], [ 94AC_DEFUN([gl_PREREQ_GETADDRINFO], [
95 AC_REQUIRE([gl_NETDB_H_DEFAULTS])
77 AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H 96 AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
78 AC_SEARCH_LIBS(gethostbyname, [inet nsl]) 97 AC_REQUIRE([gl_HOSTENT]) dnl for HOSTENT_LIB
79 AC_SEARCH_LIBS(getservbyname, [inet nsl socket xnet]) 98 AC_REQUIRE([gl_SERVENT]) dnl for SERVENT_LIB
80 AC_CHECK_FUNCS(gethostbyname,, [
81 AC_CACHE_CHECK(for gethostbyname in winsock2.h and -lws2_32,
82 gl_cv_w32_gethostbyname, [
83 gl_cv_w32_gethostbyname=no
84 am_save_LIBS="$LIBS"
85 LIBS="$LIBS -lws2_32"
86 AC_TRY_LINK([
87#ifdef HAVE_WINSOCK2_H
88#include <winsock2.h>
89#endif
90#include <stddef.h>
91], [gethostbyname(NULL);], gl_cv_w32_gethostbyname=yes)
92 LIBS="$am_save_LIBS"])
93 if test "$gl_cv_w32_gethostbyname" = "yes"; then
94 LIBS="$LIBS -lws2_32"
95 fi
96 ])
97 AC_REQUIRE([AC_C_RESTRICT]) 99 AC_REQUIRE([AC_C_RESTRICT])
98 AC_REQUIRE([gl_SOCKET_FAMILIES]) 100 AC_REQUIRE([gl_SOCKET_FAMILIES])
99 AC_REQUIRE([gl_HEADER_SYS_SOCKET]) 101 AC_REQUIRE([gl_HEADER_SYS_SOCKET])
100 AC_REQUIRE([AC_C_INLINE]) 102 AC_REQUIRE([AC_C_INLINE])
101 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) 103 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
102 AC_CHECK_HEADERS_ONCE(netinet/in.h netdb.h) 104
105 dnl Including sys/socket.h is wrong for Windows, but Windows does not
106 dnl have sa_len so the result is correct anyway.
107 AC_CHECK_MEMBERS([struct sockaddr.sa_len], , , [#include <sys/socket.h>])
108
109 AC_CHECK_HEADERS_ONCE([netinet/in.h])
110
103 AC_CHECK_DECLS([getaddrinfo, freeaddrinfo, gai_strerror, getnameinfo],,,[ 111 AC_CHECK_DECLS([getaddrinfo, freeaddrinfo, gai_strerror, getnameinfo],,,[
104 /* sys/types.h is not needed according to POSIX, but the 112 /* sys/types.h is not needed according to POSIX, but the
105 sys/socket.h in i386-unknown-freebsd4.10 and 113 sys/socket.h in i386-unknown-freebsd4.10 and
@@ -115,6 +123,19 @@ AC_DEFUN([gl_PREREQ_GETADDRINFO], [
115#include <ws2tcpip.h> 123#include <ws2tcpip.h>
116#endif 124#endif
117]) 125])
126 if test $ac_cv_have_decl_getaddrinfo = no; then
127 HAVE_DECL_GETADDRINFO=0
128 fi
129 if test $ac_cv_have_decl_freeaddrinfo = no; then
130 HAVE_DECL_FREEADDRINFO=0
131 fi
132 if test $ac_cv_have_decl_gai_strerror = no; then
133 HAVE_DECL_GAI_STRERROR=0
134 fi
135 if test $ac_cv_have_decl_getnameinfo = no; then
136 HAVE_DECL_GETNAMEINFO=0
137 fi
138
118 AC_CHECK_TYPES([struct addrinfo],,,[ 139 AC_CHECK_TYPES([struct addrinfo],,,[
119#include <sys/types.h> 140#include <sys/types.h>
120#ifdef HAVE_SYS_SOCKET_H 141#ifdef HAVE_SYS_SOCKET_H
@@ -127,4 +148,19 @@ AC_DEFUN([gl_PREREQ_GETADDRINFO], [
127#include <ws2tcpip.h> 148#include <ws2tcpip.h>
128#endif 149#endif
129]) 150])
151 if test $ac_cv_type_struct_addrinfo = no; then
152 HAVE_STRUCT_ADDRINFO=0
153 fi
154
155 dnl Append $HOSTENT_LIB to GETADDRINFO_LIB, avoiding gratuitous duplicates.
156 case " $GETADDRINFO_LIB " in
157 *" $HOSTENT_LIB "*) ;;
158 *) GETADDRINFO_LIB="$GETADDRINFO_LIB $HOSTENT_LIB" ;;
159 esac
160
161 dnl Append $SERVENT_LIB to GETADDRINFO_LIB, avoiding gratuitous duplicates.
162 case " $GETADDRINFO_LIB " in
163 *" $SERVENT_LIB "*) ;;
164 *) GETADDRINFO_LIB="$GETADDRINFO_LIB $SERVENT_LIB" ;;
165 esac
130]) 166])