1 # getaddrinfo.m4 serial 11
2 dnl Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_GETADDRINFO],
9 AC_MSG_NOTICE([checking how to do getaddrinfo, freeaddrinfo and getnameinfo])
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
19 #ifdef HAVE_WS2TCPIP_H
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
27 AC_LIBOBJ(getaddrinfo)
31 AC_REPLACE_FUNCS(gai_strerror)
35 # Prerequisites of lib/getaddrinfo.h and lib/getaddrinfo.c.
36 AC_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
46 #ifdef HAVE_WINSOCK2_H
49 ], [gethostbyname(0);], gl_cv_w32_gethostbyname=yes)
50 LIBS="$am_save_LIBS"])
51 if test "$gl_cv_w32_gethostbyname" = "yes"; then
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>
72 #ifdef HAVE_WS2TCPIP_H
76 AC_CHECK_TYPES([struct addrinfo],,,[
77 #include <sys/types.h>
78 #ifdef HAVE_SYS_SOCKET_H
79 #include <sys/socket.h>
84 #ifdef HAVE_WS2TCPIP_H