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.m488
1 files changed, 88 insertions, 0 deletions
diff --git a/gl/m4/getaddrinfo.m4 b/gl/m4/getaddrinfo.m4
new file mode 100644
index 00000000..db285d94
--- /dev/null
+++ b/gl/m4/getaddrinfo.m4
@@ -0,0 +1,88 @@
1# getaddrinfo.m4 serial 11
2dnl Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_GETADDRINFO],
8[
9 AC_MSG_NOTICE([checking how to do getaddrinfo, freeaddrinfo and getnameinfo])
10
11 AC_SEARCH_LIBS(getaddrinfo, [nsl socket])
12 AC_CHECK_FUNCS(getaddrinfo,, [
13 AC_CACHE_CHECK(for getaddrinfo in ws2tcpip.h and -lws2_32,
14 gl_cv_w32_getaddrinfo, [
15 gl_cv_w32_getaddrinfo=no
16 am_save_LIBS="$LIBS"
17 LIBS="$LIBS -lws2_32"
18 AC_TRY_LINK([
19#ifdef HAVE_WS2TCPIP_H
20#include <ws2tcpip.h>
21#endif
22], [getaddrinfo(0, 0, 0, 0);], gl_cv_w32_getaddrinfo=yes)
23 LIBS="$am_save_LIBS"])
24 if test "$gl_cv_w32_getaddrinfo" = "yes"; then
25 LIBS="$LIBS -lws2_32"
26 else
27 AC_LIBOBJ(getaddrinfo)
28 fi
29 ])
30
31 AC_REPLACE_FUNCS(gai_strerror)
32 gl_PREREQ_GETADDRINFO
33])
34
35# Prerequisites of lib/getaddrinfo.h and lib/getaddrinfo.c.
36AC_DEFUN([gl_PREREQ_GETADDRINFO], [
37 AC_SEARCH_LIBS(gethostbyname, [inet nsl])
38 AC_SEARCH_LIBS(getservbyname, [inet nsl socket xnet])
39 AC_CHECK_FUNCS(gethostbyname,, [
40 AC_CACHE_CHECK(for gethostbyname in winsock2.h and -lws2_32,
41 gl_cv_w32_gethostbyname, [
42 gl_cv_w32_gethostbyname=no
43 am_save_LIBS="$LIBS"
44 LIBS="$LIBS -lws2_32"
45 AC_TRY_LINK([
46#ifdef HAVE_WINSOCK2_H
47#include <winsock2.h>
48#endif
49], [gethostbyname(0);], gl_cv_w32_gethostbyname=yes)
50 LIBS="$am_save_LIBS"])
51 if test "$gl_cv_w32_gethostbyname" = "yes"; then
52 LIBS="$LIBS -lws2_32"
53 fi
54 ])
55 AC_REQUIRE([AC_C_RESTRICT])
56 AC_REQUIRE([gl_SOCKET_FAMILIES])
57 AC_REQUIRE([gl_HEADER_SYS_SOCKET])
58 AC_REQUIRE([AC_C_INLINE])
59 AC_REQUIRE([AC_GNU_SOURCE])
60 AC_CHECK_HEADERS_ONCE(netinet/in.h netdb.h)
61 AC_CHECK_DECLS([getaddrinfo, freeaddrinfo, gai_strerror, getnameinfo],,,[
62 /* sys/types.h is not needed according to POSIX, but the
63 sys/socket.h in i386-unknown-freebsd4.10 and
64 powerpc-apple-darwin5.5 required it. */
65#include <sys/types.h>
66#ifdef HAVE_SYS_SOCKET_H
67#include <sys/socket.h>
68#endif
69#ifdef HAVE_NETDB_H
70#include <netdb.h>
71#endif
72#ifdef HAVE_WS2TCPIP_H
73#include <ws2tcpip.h>
74#endif
75])
76 AC_CHECK_TYPES([struct addrinfo],,,[
77#include <sys/types.h>
78#ifdef HAVE_SYS_SOCKET_H
79#include <sys/socket.h>
80#endif
81#ifdef HAVE_NETDB_H
82#include <netdb.h>
83#endif
84#ifdef HAVE_WS2TCPIP_H
85#include <ws2tcpip.h>
86#endif
87])
88])