Imported Upstream version 3.2.0
[debian/amanda] / config / amanda / ipv6.m4
1 #
2 # Checks to see if there's a sockaddr_storage structure
3 #
4 # usage:
5 #
6 #       AMANDA_SOCKADDR_STORAGE
7 #
8 # results:
9 #
10 #       HAVE_SOCKADDR_STORAGE (defined)
11 #
12 AC_DEFUN([AMANDA_SOCKADDR_STORAGE],
13 [
14     AC_CACHE_CHECK([if sockaddr_storage struct exists],
15         ac_cv_has_sockaddr_storage,
16     [
17         AC_TRY_COMPILE([
18 #       include <sys/types.h>
19 #       include <sys/socket.h>],
20         [u_int i = sizeof (struct sockaddr_storage)],
21         ac_cv_has_sockaddr_storage=yes,
22         ac_cv_has_sockaddr_storage=no)
23     ])
24
25     if test $ac_cv_has_sockaddr_storage = yes ; then
26         AC_DEFINE(HAVE_SOCKADDR_STORAGE,1,
27             [struct sockaddr_storage exists])
28     fi
29 ])
30
31 # SYNOPSIS
32 #
33 #   AMANDA_CHECK_IPV6
34 #
35 # DESCRIPTION
36 #
37 #   Determine if this system has basic IPv6 support.  This 
38 #   addresse general availability (defining WORKING_IPV6 if
39 #   there's some amount of compatibility there), as well as
40 #   searching for specific functionality by requiring the other
41 #   macros in this file.
42 #   
43 AC_DEFUN([AMANDA_CHECK_IPV6],
44 [
45     AC_REQUIRE([AMANDA_SOCKADDR_STORAGE])
46
47     WORKING_IPV6=no
48     AC_ARG_WITH(ipv6,
49         AS_HELP_STRING([--with-ipv6],
50                        [enable IPv6 support (default if IPv6 is found)])
51         AS_HELP_STRING([--without-ipv6],
52                        [disable IPv6]),
53         [
54             case "$withval" in
55             y | ye | yes) amanda_with_ipv6=yes;;
56             n | no) amanda_with_ipv6=no;;
57             *)
58                 AC_MSG_ERROR([*** You must not supply an argument to --with-ipv6 option.])
59               ;;
60             esac
61         ], [
62             amanda_with_ipv6=maybe
63         ]
64     )
65
66     if test x"$amanda_with_ipv6" = x"yes" ||
67        test x"$amanda_with_ipv6" = x"maybe" ; then
68         AC_CACHE_CHECK([for working IPv6],
69                        amanda_cv_working_ipv6,
70         [
71             case "$host" in
72                 *-pc-cygwin) amanda_cv_working_ipv6=no;;
73                 *)
74                     AC_RUN_IFELSE([AC_LANG_SOURCE([[
75 #include <sys/types.h>
76 #ifdef HAVE_SYS_SOCKET_H
77 #include <sys/socket.h>
78 #endif
79 #ifdef HAVE_NETINET_IN_H
80 #include <netinet/in.h>
81 #endif
82 #ifdef HAVE_WINSOCK2_H
83 #include <winsock2.h>
84 #endif
85 #include <sys/socket.h>
86 #include <errno.h>
87
88 main()
89 {
90    int aa;
91    aa = socket(AF_INET6, SOCK_STREAM, 0);
92    if (aa > 0) return 0;
93    return aa;
94 }]])],
95     [ amanda_cv_working_ipv6=yes ],
96     [ amanda_cv_working_ipv6=no ],
97     [ amanda_cv_working_ipv6=yes ]
98                 )
99             esac
100         ])
101
102         if test "$amanda_cv_working_ipv6" = yes; then
103             WORKING_IPV6=yes
104             AC_DEFINE(WORKING_IPV6,1,
105                 [This system has functional IPv6 support (kernel and compiler)])
106         else
107             # error out only if the user specifically requested support
108             if test x"$amanda_with_ipv6" = x"yes"; then
109                 AC_MSG_ERROR([IPv6 support was requested, but opening an IPv6 socket failed])
110             fi
111         fi
112     fi
113 ])
114
115 # SYNOPSIS
116 #
117 #   AMANDA_SHOW_IPV6_SUMMARY
118 #
119 # OVERVIEW
120 #
121 #   Show a summary of the settings from this file.
122 #
123 AC_DEFUN([AMANDA_SHOW_IPV6_SUMMARY],
124 [
125     echo "Working IPv6:" $WORKING_IPV6
126 ])