2005-10-01 Simon Josefsson <jas@extundo.com>
[pspp] / m4 / getaddrinfo.m4
1 # getaddrinfo.m4 serial 6
2 dnl Copyright (C) 2004, 2005 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.
6
7 AC_DEFUN([gl_GETADDRINFO],
8 [
9   AC_SEARCH_LIBS(getaddrinfo, [nsl socket])
10   AC_SEARCH_LIBS(gethostbyname, [inet nsl])
11   AC_SEARCH_LIBS(getservbyname, [inet nsl socket xnet])
12   AC_REPLACE_FUNCS(getaddrinfo gai_strerror)
13   gl_PREREQ_GETADDRINFO
14 ])
15
16 # Prerequisites of lib/getaddrinfo.h and lib/getaddrinfo.c.
17 AC_DEFUN([gl_PREREQ_GETADDRINFO], [
18   AC_REQUIRE([gl_C_RESTRICT])
19   AC_REQUIRE([gl_SOCKET_FAMILIES])
20   AC_REQUIRE([AC_C_INLINE])
21   AC_REQUIRE([AC_GNU_SOURCE])
22   AC_CHECK_HEADERS_ONCE(sys/socket.h netdb.h sys/types.h netinet/in.h)
23   AC_CHECK_DECLS([getaddrinfo, freeaddrinfo, gai_strerror],,,[
24 #ifdef HAVE_SYS_SOCKET_H
25 # include <sys/socket.h>
26 #endif
27 #ifdef HAVE_NETDB_H
28 # include <netdb.h>
29 #endif
30 ])
31   AC_CHECK_TYPES([struct addrinfo],,,[
32 #ifdef HAVE_SYS_SOCKET_H
33 # include <sys/socket.h>
34 #endif
35 #ifdef HAVE_NETDB_H
36 # include <netdb.h>
37 #endif
38 ])
39 ])