summaryrefslogtreecommitdiffstats
path: root/gl/m4/getaddrinfo.m4
diff options
context:
space:
mode:
Diffstat (limited to 'gl/m4/getaddrinfo.m4')
-rw-r--r--gl/m4/getaddrinfo.m451
1 files changed, 47 insertions, 4 deletions
diff --git a/gl/m4/getaddrinfo.m4 b/gl/m4/getaddrinfo.m4
index 15f09ffb..2931d526 100644
--- a/gl/m4/getaddrinfo.m4
+++ b/gl/m4/getaddrinfo.m4
@@ -1,13 +1,16 @@
1# getaddrinfo.m4 serial 34 1# getaddrinfo.m4
2dnl Copyright (C) 2004-2023 Free Software Foundation, Inc. 2# serial 38
3dnl Copyright (C) 2004-2025 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7dnl This file is offered as-is, without any warranty.
6 8
7AC_DEFUN([gl_GETADDRINFO], 9AC_DEFUN([gl_GETADDRINFO],
8[ 10[
9 AC_REQUIRE([gl_SYS_SOCKET_H])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H 11 AC_REQUIRE([gl_SYS_SOCKET_H])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
10 AC_REQUIRE([gl_NETDB_H])dnl for HAVE_NETDB_H 12 AC_REQUIRE([gl_NETDB_H])dnl for HAVE_NETDB_H
13 AC_REQUIRE([AC_CANONICAL_HOST])
11 GETADDRINFO_LIB= 14 GETADDRINFO_LIB=
12 gai_saved_LIBS="$LIBS" 15 gai_saved_LIBS="$LIBS"
13 16
@@ -41,7 +44,7 @@ AC_DEFUN([gl_GETADDRINFO],
41 AC_CACHE_CHECK([for getaddrinfo in ws2tcpip.h and -lws2_32], 44 AC_CACHE_CHECK([for getaddrinfo in ws2tcpip.h and -lws2_32],
42 gl_cv_w32_getaddrinfo, [ 45 gl_cv_w32_getaddrinfo, [
43 gl_cv_w32_getaddrinfo=no 46 gl_cv_w32_getaddrinfo=no
44 am_save_LIBS="$LIBS" 47 gl_saved_LIBS="$LIBS"
45 LIBS="$LIBS -lws2_32" 48 LIBS="$LIBS -lws2_32"
46 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 49 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
47#ifdef HAVE_WS2TCPIP_H 50#ifdef HAVE_WS2TCPIP_H
@@ -49,7 +52,7 @@ AC_DEFUN([gl_GETADDRINFO],
49#endif 52#endif
50#include <stddef.h> 53#include <stddef.h>
51]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])], [gl_cv_w32_getaddrinfo=yes]) 54]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])], [gl_cv_w32_getaddrinfo=yes])
52 LIBS="$am_save_LIBS" 55 LIBS="$gl_saved_LIBS"
53 ]) 56 ])
54 if test "$gl_cv_w32_getaddrinfo" = "yes"; then 57 if test "$gl_cv_w32_getaddrinfo" = "yes"; then
55 GETADDRINFO_LIB="-lws2_32" 58 GETADDRINFO_LIB="-lws2_32"
@@ -86,6 +89,46 @@ int getaddrinfo (const char *, const char *, const struct addrinfo *, struct add
86 HAVE_GETADDRINFO=0 89 HAVE_GETADDRINFO=0
87 fi 90 fi
88 fi 91 fi
92 if test $HAVE_GETADDRINFO != 0; then
93 AC_CACHE_CHECK([whether getaddrinfo supports AI_NUMERICSERV],
94 [gl_cv_func_getaddrinfo_works],
95 [AC_RUN_IFELSE(
96 [AC_LANG_PROGRAM([[
97#include <sys/types.h>
98#ifdef HAVE_SYS_SOCKET_H
99#include <sys/socket.h>
100#endif
101#ifdef HAVE_NETDB_H
102#include <netdb.h>
103#endif
104#ifdef HAVE_WS2TCPIP_H
105#include <ws2tcpip.h>
106#endif
107#include <stddef.h>
108#include <string.h>
109 ]], [[
110 struct addrinfo hints;
111 struct addrinfo *ai;
112 memset (&hints, 0, sizeof (hints));
113 hints.ai_flags = AI_NUMERICSERV;
114 return getaddrinfo ("www.gnu.org", "http", &hints, &ai) != EAI_NONAME;
115 ]])
116 ],
117 [gl_cv_func_getaddrinfo_works=yes],
118 [gl_cv_func_getaddrinfo_works=no],
119 [case "$host_os" in
120 # Guess no on native Windows.
121 mingw* | windows*) gl_cv_func_getaddrinfo_works="guessing no" ;;
122 # Guess yes otherwise.
123 *) gl_cv_func_getaddrinfo_works="guessing yes" ;;
124 esac
125 ])
126 ])
127 case "$gl_cv_func_getaddrinfo_works" in
128 *yes) ;;
129 *) REPLACE_GETADDRINFO=1 ;;
130 esac
131 fi
89 AC_DEFINE_UNQUOTED([HAVE_GETADDRINFO], [$HAVE_GETADDRINFO], 132 AC_DEFINE_UNQUOTED([HAVE_GETADDRINFO], [$HAVE_GETADDRINFO],
90 [Define to 1 if getaddrinfo exists, or to 0 otherwise.]) 133 [Define to 1 if getaddrinfo exists, or to 0 otherwise.])
91 134