From: hniksic Date: Tue, 16 Sep 2003 12:24:29 +0000 (-0700) Subject: [svn] Added proper IPv6 configure detection. X-Git-Tag: v1.13~1711 X-Git-Url: http://sjero.net/git/?p=wget;a=commitdiff_plain;h=f5c82a64687024ad4ba272c281743b7c1f4950bd [svn] Added proper IPv6 configure detection. By Mauro Tortonesi. --- diff --git a/ChangeLog b/ChangeLog index 3ff23288..ae109dfb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2003-09-16 Mauro Tortonesi + + * configure.in, aclocal.m4: Added proper IPv6 detection. + 2003-09-16 Hrvoje Niksic * Makefile.in (all): Don't build configure.bat by default. diff --git a/aclocal.m4 b/aclocal.m4 index c0e40bdb..d79cae4d 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -86,47 +86,156 @@ else AC_MSG_RESULT(no) fi]) + dnl ************************************************************ -dnl check for working getaddrinfo() -dnl -AC_DEFUN(WGET_CHECK_WORKING_GETADDRINFO,[ - AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[ - AC_TRY_RUN( [ -#include +dnl START OF IPv6 AUTOCONFIGURATION SUPPORT MACROS +dnl ************************************************************ + +AC_DEFUN([TYPE_STRUCT_SOCKADDR_IN6],[ + ds6_have_sockaddr_in6= + AC_CHECK_TYPES([struct sockaddr_in6],[ + ds6_have_sockaddr_in6=yes + ],[ + ds6_have_sockaddr_in6=no + ],[ #include #include +#include + ]) + + if test "X$ds6_have_sockaddr_in6" = "Xyes"; then : + $1 + else : + $2 + fi +]) -int main(void) { - struct addrinfo hints, *ai; - int error; - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - error = getaddrinfo("127.0.0.1", "8080", &hints, &ai); - if (error) { - exit(1); - } - else { - exit(0); - } -} -],[ - ac_cv_working_getaddrinfo="yes" -],[ - ac_cv_working_getaddrinfo="no" -],[ - ac_cv_working_getaddrinfo="yes" -])]) -if test x"$ac_cv_working_getaddrinfo" = xyes; then - AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works]) - AC_DEFINE(ENABLE_IPV6, 1, [Define if you want to enable IPv6 support]) - - IPV6_ENABLED=1 - AC_SUBST(IPV6_ENABLED) -fi +AC_DEFUN([MEMBER_SIN6_SCOPE_ID],[ + AC_REQUIRE([TYPE_STRUCT_SOCKADDR_IN6]) + + ds6_member_sin6_scope_id= + if test "X$ds6_have_sockaddr_in6" = "Xyes"; then + AC_CHECK_MEMBER([struct sockaddr_in6.sin6_scope_id],[ + ds6_member_sin6_scope_id=yes + ],[ + ds6_member_sin6_scope_id=no + ],[ +#include +#include +#include + ]) + fi + + if test "X$ds6_member_sin6_scope_id" = "Xyes"; then + AC_DEFINE([HAVE_SOCKADDR_IN6_SCOPE_ID], 1, + [Define if struct sockaddr_in6 has the sin6_scope_id member]) + $1 + else : + $2 + fi ]) + +AC_DEFUN([PROTO_INET6],[ + AC_CACHE_CHECK([for INET6 protocol support], [ds6_cv_proto_inet6],[ + AC_TRY_CPP([ +#include +#include + +#ifndef PF_INET6 +#error Missing PF_INET6 +#endif +#ifndef AF_INET6 +#error Mlssing AF_INET6 +#endif + ],[ + ds6_cv_proto_inet6=yes + ],[ + ds6_cv_proto_inet6=no + ]) + ]) + + if test "X$ds6_cv_proto_inet6" = "Xyes"; then : + $1 + else : + $2 + fi +]) + + +AC_DEFUN([GETADDRINFO_AI_ADDRCONFIG],[ + AC_CACHE_CHECK([if getaddrinfo supports AI_ADDRCONFIG], + [ds6_cv_gai_ai_addrconfig],[ + AC_TRY_CPP([ +#include + +#ifndef AI_ADDRCONFIG +#error Missing AI_ADDRCONFIG +#endif + ],[ + ds6_cv_gai_ai_addrconfig=yes + ],[ + ds6_cv_gai_ai_addrconfig=no + ]) + ]) + + if test "X$ds6_cv_gai_ai_addrconfig" = "Xyes"; then : + $1 + else : + $2 + fi +]) + + +AC_DEFUN([GETADDRINFO_AI_ALL],[ + AC_CACHE_CHECK([if getaddrinfo supports AI_ALL],[ds6_cv_gai_ai_all],[ + AC_TRY_CPP([ +#include + +#ifndef AI_ALL +#error Missing AI_ALL +#endif + ],[ + ds6_cv_gai_ai_all=yes + ],[ + ds6_cv_gai_ai_all=no + ]) + ]) + + if test "X$ds6_cv_gai_ai_all" = "Xyes"; then : + $1 + else : + $2 + fi +]) + + +AC_DEFUN([GETADDRINFO_AI_V4MAPPED],[ + AC_CACHE_CHECK([if getaddrinfo supports AI_V4MAPPED],[ds6_cv_gai_ai_v4mapped],[ + AC_TRY_CPP([ +#include + +#ifndef AI_V4MAPPED +#error Missing AI_V4MAPPED +#endif + ],[ + ds6_cv_gai_ai_v4mapped=yes + ],[ + ds6_cv_gai_ai_v4mapped=no + ]) + ]) + + if test "X$ds6_cv_gai_ai_v4mapped" = "Xyes"; then : + $1 + else : + $2 + fi +]) + +dnl ************************************************************ +dnl END OF IPv6 AUTOCONFIGURATION SUPPORT MACROS +dnl ************************************************************ # This code originates from Ulrich Drepper's AM_WITH_NLS. diff --git a/configure.in b/configure.in index 55555b27..c1c781b8 100644 --- a/configure.in +++ b/configure.in @@ -453,43 +453,73 @@ dnl whether it's possible to create an AF_INET6 socket and if yes, use dnl IPv6. dnl -AC_MSG_CHECKING([whether to enable ipv6]) +ipv6= +check_for_ipv6=no AC_ARG_ENABLE(ipv6, -AC_HELP_STRING([--enable-ipv6],[Enable ipv6 support]) -AC_HELP_STRING([--disable-ipv6],[Disable ipv6 support]), -[ case "$enableval" in + AC_HELP_STRING([--disable-ipv6],[disable IPv6 support]), + [case "${enable_ipv6}" in no) - AC_MSG_RESULT(no) - ipv6=no - ;; - *) AC_MSG_RESULT(yes) - ipv6=yes - ;; - esac ], - - AC_TRY_RUN([ /* is AF_INET6 available? */ -#include -#include -main() -{ - if (socket(AF_INET6, SOCK_STREAM, 0) < 0) - exit(1); - else - exit(0); -} -], - AC_MSG_RESULT(yes) - ipv6=yes, - AC_MSG_RESULT(no) - ipv6=no, - AC_MSG_RESULT(no) - ipv6=no -)) - -if test x"$ipv6" = xyes; then - WGET_CHECK_WORKING_GETADDRINFO + AC_MSG_NOTICE([Disabling IPv6 at user request]) + ipv6=no + ;; + *) + ipv6=yes + ;; + esac], + [check_for_ipv6=yes] +) + +if test "X$ipv6" = "Xyes" -o "X$check_for_ipv6" = "Xyes"; then + AC_CHECK_FUNC(getaddrinfo,[ + AC_DEFINE([HAVE_GETADDRINFO], 1) + GETADDRINFO_AI_ADDRCONFIG( + AC_DEFINE( + [HAVE_GETADDRINFO_AI_ADDRCONFIG], 1, + [Define if the system headers support the AI_ADDRCONFIG flag.] + ) + ) + GETADDRINFO_AI_V4MAPPED( + AC_DEFINE( + [HAVE_GETADDRINFO_AI_V4MAPPED], 1, + [Define if the system headers support the AI_V4MAPPED flag.] + ) + ) + GETADDRINFO_AI_ALL( + AC_DEFINE( + [HAVE_GETADDRINFO_AI_ALL], 1, + [Define if the system headers support the AI_ALL flag.] + ) + ) + ],[ + AC_MSG_NOTICE([Disabling IPv6 support: your system does not support getaddrinfo(3)]) + ipv6=no + ]) +fi + +if test "X$ipv6" = "Xyes" -o "X$check_for_ipv6" = "Xyes"; then + PROTO_INET6(,[ + AC_MSG_NOTICE([Disabling IPv6 support: your system does not support the PF_INET6 protocol family]) + ipv6=no + ]) fi +if test "X$ipv6" = "Xyes" -o "X$check_for_ipv6" = "Xyes"; then + TYPE_STRUCT_SOCKADDR_IN6([ + ipv6=yes + ],[ + AC_MSG_NOTICE([Disabling IPv6 support: your system does not support 'struct sockaddr_in6']) + ipv6=no + ]) + if test "X$ipv6" = "Xyes"; then + MEMBER_SIN6_SCOPE_ID + fi +fi + +if test "X$ipv6" = "Xyes"; then + AC_DEFINE([ENABLE_IPV6], 1, [Define if IPv6 support is enabled.]) +fi + + dnl dnl Set of available languages. dnl diff --git a/src/config.h.in b/src/config.h.in index 0ee23e38..46807377 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -253,6 +253,21 @@ char *alloca (); /* Define if you have the getaddrinfo function. */ #undef HAVE_GETADDRINFO +/* Define if the system headers support the AI_ADDRCONFIG flag. */ +#undef HAVE_GETADDRINFO_AI_ADDRCONFIG + +/* Define if the system headers support the AI_V4MAPPED flag. */ +#undef HAVE_GETADDRINFO_AI_V4MAPPED + +/* Define if the system headers support the AI_ALL flag. */ +#undef HAVE_GETADDRINFO_AI_ALL + +/* Define if the system supports struct sockaddr_in6 */ +#undef HAVE_HAVE_STRUCT_SOCKADDR_IN6 + +/* Define if struct sockaddr_in6 has the sin6_scope_id member */ +#undef HAVE_SOCKADDR_IN6_SCOPE_ID + /* Define if you want to enable the IPv6 support. */ #undef ENABLE_IPV6