libreplace: split out network checks into a AC_LIBREPLACE_NETWORK_CHECKS macro
[Samba.git] / source / lib / replace / libreplace_network.m4
blob7702702799da796ef3717ee589f53a2cb4529092
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([
12                 AC_INCLUDES_DEFAULT
13                 #if HAVE_SYS_SOCKET_H
14                 # include <sys/socket.h>
15                 #endif
16                 #include <net/if.h>
17                 int main(void) {return 0;}])],
18                 [libreplace_cv_USABLE_NET_IF_H=yes],
19                 [libreplace_cv_USABLE_NET_IF_H=no]
20         )
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]),,
44                 [
45 #include <sys/socket.h>
46 #include <sys/types.h>
47 #include <netinet/in.h>
48                 ])
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]),,
53                 [
54 #include <sys/socket.h>
55 #include <sys/types.h>
56 #include <netinet/in.h>
57                 ])
61 m4_include(socket.m4)
62 m4_include(inet_ntop.m4)
63 m4_include(inet_pton.m4)
64 m4_include(inet_aton.m4)
65 m4_include(inet_ntoa.m4)
66 m4_include(getaddrinfo.m4)
67 m4_include(getifaddrs.m4)
68 m4_include(socketpair.m4)
70 echo "LIBREPLACE_NETWORK_CHECKS: END"
71 ]) dnl end AC_LIBREPLACE_NETWORK_CHECKS