dnl dnl Configure ext/net dnl This file is included by the toplevel configure.ac dnl # ext/net ------------------------------------------------- dnl dnl process --enable-ipv6 dnl dnl We assume --enable-ipv6=yes by default. dnl we'll check if they are really available later anyway. dnl Use --enable-ipv6=no if you explicitly turn it off. dnl AC_ARG_ENABLE(ipv6, AS_HELP_STRING([--enable-ipv6], [enable IPv6 support]), [ AS_CASE([$enableval], [no], [enable_ipv6=no], [enable_ipv6=yes]) ], [enable_ipv6=yes]) dnl dnl Checks availability of ipv6 support dnl AS_IF([test $enable_ipv6 = yes], [ AC_CACHE_CHECK([for IPv6], ac_cv_ipv6, [ AS_CASE(["$target"], [*mingw*], AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [@%:@include @%:@include ], [ socket(AF_INET6, SOCK_STREAM, 0); ])], [ac_cv_ipv6=yes], [ac_cv_ipv6=no]), AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [@%:@ifdef HAVE_SYS_TYPES_H @%:@include @%:@endif @%:@include ], [ socket(AF_INET6, SOCK_STREAM, 0); ])], [ac_cv_ipv6=yes], [ac_cv_ipv6=no]) ) ]) AS_IF([test "$ac_cv_ipv6" = yes], [ AC_DEFINE(HAVE_IPV6,1,[Define if you have IPv6 support]) ]) ]) dnl dnl Check to see if the system provides sockaddr_storage dnl AS_CASE(["$target"], [*mingw*], [AC_CHECK_TYPES([struct sockaddr_storage],,,[@%:@include ])], [AC_CHECK_TYPES([struct sockaddr_storage],,,[@%:@include ])]) dnl dnl Check if net/if.h and struct ifreq dnl AC_CHECK_HEADERS(net/if.h,,,[ @%:@ifdef HAVE_SYS_TYPES_H @%:@include @%:@endif @%:@include ]) AC_CHECK_TYPES([struct ifreq],,,[ @%:@ifdef HAVE_SYS_TYPES_H @%:@include @%:@endif @%:@include @%:@ifdef HAVE_NET_IF_H @%:@include @%:@endif ]) dnl dnl Checks if sturct ifreq has ifr_ifindex and/or ifr_index field dnl AC_CHECK_MEMBERS([struct ifreq.ifr_ifindex, struct ifreq.ifr_index, struct ifreq.ifr_netmask],,,[ @%:@ifdef HAVE_SYS_TYPES_H @%:@include @%:@endif @%:@include @%:@ifdef HAVE_NET_IF_H @%:@include @%:@endif ]) dnl dnl Checks if sockaddr_in and sockaddr_in6 has *_len field dnl AC_CHECK_MEMBERS([struct sockaddr_un.sun_len],,,[ @%:@ifdef HAVE_SYS_TYPES_H @%:@include @%:@endif @%:@include ]) AC_CHECK_MEMBERS([struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len],,,[ @%:@ifdef HAVE_SYS_TYPES_H @%:@include @%:@endif @%:@include ]) dnl dnl Check for some extra libraries dnl AC_SEARCH_LIBS(shutdown, socket) AC_SEARCH_LIBS(gethostbyname_r, nsl) dnl Check for reentrant version synopsis of netdb functions. dnl The calling synopsis of netdb functions like gethostbyname_r differ dnl among platforms. dnl dnl NB: The newer NetBSD has getprotobyname_r, getprotobynumber_r, dnl getservbyname_r, and getservbyport_r for its internal use, but it's dnl not supposed to be public. configure happens to find these, so for dnl the time being, we specifically disable checks for these functions dnl on netbsd. (2004/5/31) dnl AS_CASE(["$target"], [*-*-netbsd*], [ac_cv_func_gethostbyname_r=no], [AC_CHECK_FUNC(gethostbyname_r)]) AS_IF([test $ac_cv_func_gethostbyname_r = 'yes'], [ AC_CACHE_CHECK(number of arguments for gethostbyname_r, ac_cv_func_gethostbyname_r_nargs, [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include ], [ char *n; struct hostent *h, *r; char buf[4096]; int len=4096; int err; (void)gethostbyname_r(n, h, buf, len, &r, &err); ])], [ac_cv_func_gethostbyname_r_nargs=6], [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include ], [ char *n; struct hostent *h; char buf[4096]; int len=4096; int err; (void)gethostbyname_r(n, h, buf, len, &err); ])], [ac_cv_func_gethostbyname_r_nargs=5], [ ac_cv_func_gethostbyname_r=no])])]) ]) AS_IF([test $ac_cv_func_gethostbyname_r != no], [ AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NUMARGS, $ac_cv_func_gethostbyname_r_nargs, [Define number of args gethostbyname_r takes]) ]) dnl Kludge: DragonFly BSD's gethostbyaddr_r is broken AS_CASE(["$target"], [*-*-dragonfly*|*-*-netbsd*], [ac_cv_func_gethostbyaddr_r='no'], [AC_CHECK_FUNC(gethostbyaddr_r)]) AS_IF([test $ac_cv_func_gethostbyaddr_r = 'yes'], [ AC_CACHE_CHECK(number of arguments for gethostbyaddr_r, ac_cv_func_gethostbyaddr_r_nargs, [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include ], [ char *n; int addrlen, type; struct hostent *h, *r; char buf[4096]; int len=4096; int err; (void)gethostbyaddr_r(n, addrlen, type, h, buf, len, &r, &err); ])], [ac_cv_func_gethostbyaddr_r_nargs=8], [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include ], [ char *n; int addrlen, type; struct hostent *h; char buf[4096]; int len=4096; int err; (void)gethostbyaddr_r(n, addrlen, type, h, buf, len, &err); ])], [ac_cv_func_gethostbyaddr_r_nargs=7], [ ac_cv_func_gethostbyaddr_r=no])])]) ]) AS_IF([test $ac_cv_func_gethostbyaddr_r != no], [ AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NUMARGS, $ac_cv_func_gethostbyaddr_r_nargs, [Define number of args gethostbyaddr_r takes]) ]) dnl exclude netbsd. see the comment above. AS_CASE(["$target"], [*-*-netbsd*], [ac_cv_func_getprotobyname_r=no], [AC_CHECK_FUNC(getprotobyname_r)]) AS_IF([test $ac_cv_func_getprotobyname_r = 'yes'], [ AC_CACHE_CHECK(number of arguments for getprotobyname_r, ac_cv_func_getprotobyname_r_nargs, [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include ], [ char *n; struct protoent *h, *r; char buf[4096]; int len=4096; (void)getprotobyname_r(n, h, buf, len, &r); ])], [ac_cv_func_getprotobyname_r_nargs=5], [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include ], [ char *n; struct protoent *h; char buf[4096]; int len=4096; (void)getprotobyname_r(n, h, buf, len); ])], [ac_cv_func_getprotobyname_r_nargs=4], [ ac_cv_func_getprotobyname_r=no])])]) ]) AS_IF([test $ac_cv_func_getprotobyname_r != no], [ AC_DEFINE_UNQUOTED(GETPROTOBYNAME_R_NUMARGS, $ac_cv_func_getprotobyname_r_nargs, [Define number of args getprotobyname_r takes]) ]) dnl exclude netbsd. see the comment above. AS_CASE(["$target"], [*-*-netbsd*], [ac_cv_func_getprotobynumber_r=no], [AC_CHECK_FUNC(getprotobynumber_r)]) AS_IF([test $ac_cv_func_getprotobynumber_r = 'yes'], [ AC_CACHE_CHECK(number of arguments for getprotobynumber_r, ac_cv_func_getprotobynumber_r_nargs, [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include ], [ int n; struct protoent *h, *r; char buf[4096]; int len=4096; (void)getprotobynumber_r(n, h, buf, len, &r); ])], [ac_cv_func_getprotobynumber_r_nargs=5], [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include ], [ int n; struct protoent *h; char buf[4096]; int len=4096; (void)getprotobynumber_r(n, h, buf, len); ])], [ac_cv_func_getprotobynumber_r_nargs=4], [ ac_cv_func_getprotobynumber_r=no])])]) ]) AS_IF([test $ac_cv_func_getprotobynumber_r != no], [ AC_DEFINE_UNQUOTED(GETPROTOBYNUMBER_R_NUMARGS, $ac_cv_func_getprotobynumber_r_nargs, [Define number of args getprotobynumber_r takes]) ]) dnl exclude netbsd. see the comment above. AS_CASE(["$target"], [*-*-netbsd*], [ac_cv_func_getservbyname_r=no], [AC_CHECK_FUNC(getservbyname_r)]) AC_CHECK_FUNC(getservbyname_r) AS_IF([test $ac_cv_func_getservbyname_r = 'yes'], [ AC_CACHE_CHECK(number of arguments for getservbyname_r, ac_cv_func_getservbyname_r_nargs, [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include ], [ char *n, *p; struct servent *h, *r; char buf[4096]; int len=4096; (void)getservbyname_r(n, p, h, buf, len, &r); ])], [ac_cv_func_getservbyname_r_nargs=6], [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include ], [ char *n, *p; struct servent *h; char buf[4096]; int len=4096; (void)getservbyname_r(n, p, h, buf, len); ])], [ac_cv_func_getservbyname_r_nargs=5], [ ac_cv_func_getservbyname_r=no])])]) ]) AS_IF([test $ac_cv_func_getservbyname_r != no], [ AC_DEFINE_UNQUOTED(GETSERVBYNAME_R_NUMARGS, $ac_cv_func_getservbyname_r_nargs, [Define number of args getservbyname_r takes]) ]) dnl exclude netbsd. see the comment above. AS_CASE(["$target"], [*-*-netbsd*], [ac_cv_func_getservbyport_r=no], [AC_CHECK_FUNC(getservbyport_r)]) AS_IF([test $ac_cv_func_getservbyport_r = 'yes'], [ AC_CACHE_CHECK(number of arguments for getservbyport_r, ac_cv_func_getservbyport_r_nargs, [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include ], [ int n; char *p; struct servent *h, *r; char buf[4096]; int len=4096; (void)getservbyport_r(n, p, h, buf, len, &r); ])], [ac_cv_func_getservbyport_r_nargs=6], [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include ], [ int n; char *p; struct servent *h; char buf[4096]; int len=4096; (void)getservbyport_r(n, p, h, buf, len); ])], [ac_cv_func_getservbyport_r_nargs=5], [ ac_cv_func_getservbyport_r=no])])]) ]) AS_IF([test $ac_cv_func_getservbyport_r != no], [ AC_DEFINE_UNQUOTED(GETSERVBYPORT_R_NUMARGS, $ac_cv_func_getservbyport_r_nargs, [Define number of args getservbyport_r takes]) ]) dnl Check for socklen_t dnl Windows/MinGW is special and we know the answer, so we just don't dnl bother checking it. AS_CASE(["$target"], [*mingw*], [LIBS="$LIBS -lws2_32" EXT_LIBS="$EXT_LIBS -lws2_32"], [AX_TYPE_SOCKLEN_T]) dnl Local variables: dnl mode: autoconf dnl end: