+AC_DEFINE([HAVE_MD5], 1, [Define if we're compiling support for MD5.])
+
+dnl **********************************************************************
+dnl Checks for IPv6
+dnl **********************************************************************
+
+dnl
+dnl We test for IPv6 by checking, in turn, for availability of
+dnl getaddrinfo, presence of the INET6 address/protocol family, and
+dnl the existence of struct sockaddr_in6. If any of them is missing,
+dnl IPv6 is disabled, and the code reverts to old-style gethostbyname.
+dnl
+dnl If --enable-ipv6 is explicitly specified on the configure command
+dnl line, we check for IPv6 and abort if not found. If --disable-ipv6
+dnl is specified, we disable IPv6 and don't check for it. The default
+dnl is to autodetect IPv6 and use it where available.
+dnl
+
+AC_ARG_ENABLE(ipv6,
+ AC_HELP_STRING([--disable-ipv6],[disable IPv6 support]),
+ [case "${enable_ipv6}" in
+ no)
+ AC_MSG_NOTICE([disabling IPv6 at user request])
+ dnl Disable IPv6 checking
+ ipv6=no
+ ;;
+ yes)
+ dnl IPv6 explicitly enabled: force its use (abort if unavailable).
+ ipv6=yes
+ force_ipv6=yes
+ ;;
+ auto)
+ dnl Auto-detect IPv6, i.e. check for IPv6, but don't force it.
+ ipv6=yes
+ ;;
+ *)
+ AC_MSG_ERROR([Invalid --enable-ipv6 argument \`$enable_ipv6'])
+ ;;
+ esac
+ ], [
+ dnl If nothing is specified, assume auto-detection.
+ ipv6=yes
+ ]
+)
+
+if test "X$ipv6" = "Xyes"; then
+ AC_CHECK_FUNCS(getaddrinfo, [], [
+ AC_MSG_NOTICE([Disabling IPv6 support: your system does not support getaddrinfo(3)])
+ ipv6=no
+ ])
+fi
+
+if test "X$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"; then
+ TYPE_STRUCT_SOCKADDR_IN6([],[
+ AC_MSG_NOTICE([Disabling IPv6 support: your system does not support \`struct sockaddr_in6'])
+ ipv6=no
+ ])
+ if test "X$ipv6" = "Xyes"; then
+ WGET_STRUCT_SOCKADDR_STORAGE
+ MEMBER_SIN6_SCOPE_ID
+ fi
+fi
+
+if test "X$ipv6" = "Xyes"; then
+ AC_DEFINE([ENABLE_IPV6], 1, [Define if IPv6 support is enabled.])
+ AC_MSG_NOTICE([Enabling support for IPv6.])
+elif test "x$force_ipv6" = "xyes"; then
+ AC_MSG_ERROR([IPv6 support requested but not found; aborting])
+fi
+