1 AC_DEFUN_ONCE(AC_LIBREPLACE_NETWORK_CHECKS,
3 echo "LIBREPLACE_NETWORK_CHECKS: START"
5 AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h)
6 AC_CHECK_HEADERS(netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
8 dnl we need to check that net/if.h really can be used, to cope with hpux
9 dnl where including it always fails
10 AC_CACHE_CHECK([for usable net/if.h],libreplace_cv_USABLE_NET_IF_H,[
11 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
14 # include <sys/socket.h>
17 int main(void) {return 0;}])],
18 [libreplace_cv_USABLE_NET_IF_H=yes],
19 [libreplace_cv_USABLE_NET_IF_H=no]
22 if test x"$libreplace_cv_USABLE_NET_IF_H" = x"yes";then
23 AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h)
26 AC_HAVE_TYPE([socklen_t],[#include <sys/socket.h>])
27 AC_HAVE_TYPE([sa_family_t],[#include <sys/socket.h>])
28 AC_HAVE_TYPE([struct addrinfo], [#include <netdb.h>])
29 AC_HAVE_TYPE([struct sockaddr], [#include <sys/socket.h>])
30 AC_HAVE_TYPE([struct sockaddr_storage], [
31 #include <sys/socket.h>
32 #include <sys/types.h>
33 #include <netinet/in.h>
35 AC_HAVE_TYPE([struct sockaddr_in6], [
36 #include <sys/socket.h>
37 #include <sys/types.h>
38 #include <netinet/in.h>
41 if test x"$ac_cv_type_struct_sockaddr_storage" = x"yes"; then
42 AC_CHECK_MEMBER(struct sockaddr_storage.ss_family,
43 AC_DEFINE(HAVE_SS_FAMILY, 1, [Defined if struct sockaddr_storage has ss_family field]),,
45 #include <sys/socket.h>
46 #include <sys/types.h>
47 #include <netinet/in.h>
50 if test x"$ac_cv_member_struct_sockaddr_storage_ss_family" != x"yes"; then
51 AC_CHECK_MEMBER(struct sockaddr_storage.__ss_family,
52 AC_DEFINE(HAVE___SS_FAMILY, 1, [Defined if struct sockaddr_storage has __ss_family field]),,
54 #include <sys/socket.h>
55 #include <sys/types.h>
56 #include <netinet/in.h>
61 dnl The following test is roughl taken from the cvs sources.
63 dnl If we can't find connect, try looking in -lsocket, -lnsl, and -linet.
64 dnl The Irix 5 libc.so has connect and gethostbyname, but Irix 5 also has
65 dnl libsocket.so which has a bad implementation of gethostbyname (it
66 dnl only looks in /etc/hosts), so we only look for -lsocket if we need
68 AC_CHECK_FUNCS(connect)
69 if test x"$ac_cv_func_connect" = x"no"; then
70 AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, connect)
71 AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, connect)
72 AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, connect)
73 AC_CHECK_LIB_EXT(inet, LIBREPLACE_NETWORK_LIBS, connect)
74 dnl We can't just call AC_CHECK_FUNCS(connect) here,
75 dnl because the value has been cached.
76 if test x"$ac_cv_lib_ext_nsl_s_connect" = x"yes" ||
77 test x"$ac_cv_lib_ext_nsl_connect" = x"yes" ||
78 test x"$ac_cv_lib_ext_socket_connect" = x"yes" ||
79 test x"$ac_cv_lib_ext_inet_connect" = x"yes"
81 AC_DEFINE(HAVE_CONNECT,1,[Whether the system has connect()])
85 AC_CHECK_FUNCS(gethostbyname)
86 if test x"$ac_cv_func_gethostbyname" = x"no"; then
87 AC_CHECK_LIB_EXT(nsl_s, LIBREPLACE_NETWORK_LIBS, gethostbyname)
88 AC_CHECK_LIB_EXT(nsl, LIBREPLACE_NETWORK_LIBS, gethostbyname)
89 AC_CHECK_LIB_EXT(socket, LIBREPLACE_NETWORK_LIBS, gethostbyname)
90 dnl We can't just call AC_CHECK_FUNCS(gethostbyname) here,
91 dnl because the value has been cached.
92 if test x"$ac_cv_lib_ext_nsl_s_gethostbyname" = x"yes" ||
93 test x"$ac_cv_lib_ext_nsl_gethostbyname" = x"yes" ||
94 test x"$ac_cv_lib_ext_socket_gethostbyname" = x"yes"
96 AC_DEFINE(HAVE_GETHOSTBYNAME,1,
97 [Whether the system has gethostbyname()])
101 m4_include(inet_ntop.m4)
102 m4_include(inet_pton.m4)
103 m4_include(inet_aton.m4)
104 m4_include(inet_ntoa.m4)
105 m4_include(getaddrinfo.m4)
106 m4_include(getifaddrs.m4)
107 m4_include(socketpair.m4)
109 echo "LIBREPLACE_NETWORK_CHECKS: END"
110 ]) dnl end AC_LIBREPLACE_NETWORK_CHECKS