]> sjero.net Git - wget/commitdiff
[svn] Added proper IPv6 configure detection.
authorhniksic <devnull@localhost>
Tue, 16 Sep 2003 12:24:29 +0000 (05:24 -0700)
committerhniksic <devnull@localhost>
Tue, 16 Sep 2003 12:24:29 +0000 (05:24 -0700)
By Mauro Tortonesi.

ChangeLog
aclocal.m4
configure.in
src/config.h.in

index 3ff23288b2d7e897ffd6ee739b8fd2125ca11215..ae109dfb03971f20d13b1992e5fa7a3fe44f900b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2003-09-16  Mauro Tortonesi <mauro@deepspace6.net>
+
+       * configure.in, aclocal.m4: Added proper IPv6 detection.
+
 2003-09-16  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * Makefile.in (all): Don't build configure.bat by default.
index c0e40bdb01ae919deb20cb9403c0b4a4d20c8625..d79cae4d3589a91abab3d6abbda896a5ad2a9406 100644 (file)
@@ -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 <netdb.h>
+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 <sys/types.h>
 #include <sys/socket.h>
+#include <netinet/in.h>
+  ])
+
+  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 <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+    ])
+  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 <sys/types.h>
+#include <sys/socket.h>
+
+#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 <netdb.h>
+
+#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 <netdb.h>
+
+#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 <netdb.h>
+
+#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 ************************************************************
 \f
 # This code originates from Ulrich Drepper's AM_WITH_NLS.
 
index 55555b27cd19af11a95bb79ed68ff722aa9ddea9..c1c781b8ca3c405dcfa0f4412a57f3471d6f548f 100644 (file)
@@ -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 <sys/types.h>
-#include <sys/socket.h>
-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
index 0ee23e38b37cc902a09ff7ba46c11e85167721db..46807377f80bf9001778c1c83b6feb4d35ee77a7 100644 (file)
@@ -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