| 1 |
dnl |
| 2 |
dnl Configure ext/net |
| 3 |
dnl This file is included by the toplevel configure.ac |
| 4 |
dnl |
| 5 |
|
| 6 |
# ext/net ------------------------------------------------- |
| 7 |
|
| 8 |
dnl |
| 9 |
dnl process --enable-ipv6 |
| 10 |
dnl |
| 11 |
dnl We assume --enable-ipv6=yes by default. |
| 12 |
dnl we'll check if they are really available later anyway. |
| 13 |
dnl Use --enable-ipv6=no if you explicitly turn it off. |
| 14 |
dnl |
| 15 |
AC_ARG_ENABLE(ipv6, |
| 16 |
AS_HELP_STRING([--enable-ipv6], [enable IPv6 support]), |
| 17 |
[ |
| 18 |
AS_CASE([$enableval], |
| 19 |
[no], [enable_ipv6=no], |
| 20 |
[enable_ipv6=yes]) |
| 21 |
], [enable_ipv6=yes]) |
| 22 |
|
| 23 |
dnl |
| 24 |
dnl Checks availability of ipv6 support |
| 25 |
dnl |
| 26 |
AS_IF([test $enable_ipv6 = yes], [ |
| 27 |
AC_CACHE_CHECK([for IPv6], ac_cv_ipv6, [ |
| 28 |
AS_CASE(["$target"], |
| 29 |
[*mingw*], AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
| 30 |
[@%:@include <winsock2.h> |
| 31 |
@%:@include <ws2tcpip.h>], [ |
| 32 |
socket(AF_INET6, SOCK_STREAM, 0); |
| 33 |
])], [ac_cv_ipv6=yes], [ac_cv_ipv6=no]), |
| 34 |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
| 35 |
[@%:@ifdef HAVE_SYS_TYPES_H |
| 36 |
@%:@include <sys/types.h> |
| 37 |
@%:@endif |
| 38 |
@%:@include <sys/socket.h>], [ |
| 39 |
socket(AF_INET6, SOCK_STREAM, 0); |
| 40 |
])], [ac_cv_ipv6=yes], [ac_cv_ipv6=no]) |
| 41 |
) |
| 42 |
]) |
| 43 |
AS_IF([test "$ac_cv_ipv6" = yes], [ |
| 44 |
AC_DEFINE(HAVE_IPV6,1,[Define if you have IPv6 support]) |
| 45 |
]) |
| 46 |
]) |
| 47 |
|
| 48 |
dnl |
| 49 |
dnl Check to see if the system provides sockaddr_storage |
| 50 |
dnl |
| 51 |
AS_CASE(["$target"], |
| 52 |
[*mingw*], [AC_CHECK_TYPES([struct sockaddr_storage],,,[@%:@include <windows.h>])], |
| 53 |
[AC_CHECK_TYPES([struct sockaddr_storage],,,[@%:@include <sys/socket.h>])]) |
| 54 |
|
| 55 |
dnl |
| 56 |
dnl Check if net/if.h and struct ifreq |
| 57 |
dnl |
| 58 |
AC_CHECK_HEADERS(net/if.h,,,[ |
| 59 |
@%:@ifdef HAVE_SYS_TYPES_H |
| 60 |
@%:@include <sys/types.h> |
| 61 |
@%:@endif |
| 62 |
@%:@include <sys/socket.h> |
| 63 |
]) |
| 64 |
AC_CHECK_TYPES([struct ifreq],,,[ |
| 65 |
@%:@ifdef HAVE_SYS_TYPES_H |
| 66 |
@%:@include <sys/types.h> |
| 67 |
@%:@endif |
| 68 |
@%:@include <sys/socket.h> |
| 69 |
@%:@ifdef HAVE_NET_IF_H |
| 70 |
@%:@include <net/if.h> |
| 71 |
@%:@endif |
| 72 |
]) |
| 73 |
|
| 74 |
dnl |
| 75 |
dnl Checks if sturct ifreq has ifr_ifindex and/or ifr_index field |
| 76 |
dnl |
| 77 |
AC_CHECK_MEMBERS([struct ifreq.ifr_ifindex, |
| 78 |
struct ifreq.ifr_index, |
| 79 |
struct ifreq.ifr_netmask],,,[ |
| 80 |
@%:@ifdef HAVE_SYS_TYPES_H |
| 81 |
@%:@include <sys/types.h> |
| 82 |
@%:@endif |
| 83 |
@%:@include <sys/socket.h> |
| 84 |
@%:@ifdef HAVE_NET_IF_H |
| 85 |
@%:@include <net/if.h> |
| 86 |
@%:@endif |
| 87 |
]) |
| 88 |
|
| 89 |
dnl |
| 90 |
dnl Checks if sockaddr_in and sockaddr_in6 has *_len field |
| 91 |
dnl |
| 92 |
AC_CHECK_MEMBERS([struct sockaddr_un.sun_len],,,[ |
| 93 |
@%:@ifdef HAVE_SYS_TYPES_H |
| 94 |
@%:@include <sys/types.h> |
| 95 |
@%:@endif |
| 96 |
@%:@include <sys/un.h> |
| 97 |
]) |
| 98 |
AC_CHECK_MEMBERS([struct sockaddr_in.sin_len, |
| 99 |
struct sockaddr_in6.sin6_len],,,[ |
| 100 |
@%:@ifdef HAVE_SYS_TYPES_H |
| 101 |
@%:@include <sys/types.h> |
| 102 |
@%:@endif |
| 103 |
@%:@include <netinet/in.h> |
| 104 |
]) |
| 105 |
|
| 106 |
dnl |
| 107 |
dnl Check for some extra libraries |
| 108 |
dnl |
| 109 |
AC_SEARCH_LIBS(shutdown, socket) |
| 110 |
AC_SEARCH_LIBS(gethostbyname_r, nsl) |
| 111 |
|
| 112 |
dnl Check for reentrant version synopsis of netdb functions. |
| 113 |
dnl The calling synopsis of netdb functions like gethostbyname_r differ |
| 114 |
dnl among platforms. |
| 115 |
dnl |
| 116 |
dnl NB: The newer NetBSD has getprotobyname_r, getprotobynumber_r, |
| 117 |
dnl getservbyname_r, and getservbyport_r for its internal use, but it's |
| 118 |
dnl not supposed to be public. configure happens to find these, so for |
| 119 |
dnl the time being, we specifically disable checks for these functions |
| 120 |
dnl on netbsd. (2004/5/31) |
| 121 |
dnl |
| 122 |
AS_CASE(["$target"], |
| 123 |
[*-*-netbsd*], [ac_cv_func_gethostbyname_r=no], |
| 124 |
[AC_CHECK_FUNC(gethostbyname_r)]) |
| 125 |
|
| 126 |
AS_IF([test $ac_cv_func_gethostbyname_r = 'yes'], [ |
| 127 |
AC_CACHE_CHECK(number of arguments for gethostbyname_r, |
| 128 |
ac_cv_func_gethostbyname_r_nargs, [ |
| 129 |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <netdb.h>], [ |
| 130 |
char *n; struct hostent *h, *r; char buf[4096]; int len=4096; int err; |
| 131 |
(void)gethostbyname_r(n, h, buf, len, &r, &err); |
| 132 |
])], [ac_cv_func_gethostbyname_r_nargs=6], [ |
| 133 |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <netdb.h>], [ |
| 134 |
char *n; struct hostent *h; char buf[4096]; int len=4096; int err; |
| 135 |
(void)gethostbyname_r(n, h, buf, len, &err); |
| 136 |
])], [ac_cv_func_gethostbyname_r_nargs=5], [ |
| 137 |
ac_cv_func_gethostbyname_r=no])])]) |
| 138 |
]) |
| 139 |
|
| 140 |
AS_IF([test $ac_cv_func_gethostbyname_r != no], [ |
| 141 |
AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NUMARGS, $ac_cv_func_gethostbyname_r_nargs, [Define number of args gethostbyname_r takes]) |
| 142 |
]) |
| 143 |
|
| 144 |
dnl Kludge: DragonFly BSD's gethostbyaddr_r is broken |
| 145 |
AS_CASE(["$target"], |
| 146 |
[*-*-dragonfly*|*-*-netbsd*], [ac_cv_func_gethostbyaddr_r='no'], |
| 147 |
[AC_CHECK_FUNC(gethostbyaddr_r)]) |
| 148 |
|
| 149 |
AS_IF([test $ac_cv_func_gethostbyaddr_r = 'yes'], [ |
| 150 |
AC_CACHE_CHECK(number of arguments for gethostbyaddr_r, |
| 151 |
ac_cv_func_gethostbyaddr_r_nargs, [ |
| 152 |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <netdb.h>], [ |
| 153 |
char *n; int addrlen, type; struct hostent *h, *r; char buf[4096]; int len=4096; int err; |
| 154 |
(void)gethostbyaddr_r(n, addrlen, type, h, buf, len, &r, &err); |
| 155 |
])], [ac_cv_func_gethostbyaddr_r_nargs=8], [ |
| 156 |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <netdb.h>], [ |
| 157 |
char *n; int addrlen, type; struct hostent *h; char buf[4096]; int len=4096; int err; |
| 158 |
(void)gethostbyaddr_r(n, addrlen, type, h, buf, len, &err); |
| 159 |
])], [ac_cv_func_gethostbyaddr_r_nargs=7], [ |
| 160 |
ac_cv_func_gethostbyaddr_r=no])])]) |
| 161 |
]) |
| 162 |
|
| 163 |
AS_IF([test $ac_cv_func_gethostbyaddr_r != no], [ |
| 164 |
AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NUMARGS, $ac_cv_func_gethostbyaddr_r_nargs, [Define number of args gethostbyaddr_r takes]) |
| 165 |
]) |
| 166 |
|
| 167 |
dnl exclude netbsd. see the comment above. |
| 168 |
AS_CASE(["$target"], |
| 169 |
[*-*-netbsd*], [ac_cv_func_getprotobyname_r=no], |
| 170 |
[AC_CHECK_FUNC(getprotobyname_r)]) |
| 171 |
|
| 172 |
AS_IF([test $ac_cv_func_getprotobyname_r = 'yes'], [ |
| 173 |
AC_CACHE_CHECK(number of arguments for getprotobyname_r, |
| 174 |
ac_cv_func_getprotobyname_r_nargs, [ |
| 175 |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <netdb.h>], [ |
| 176 |
char *n; struct protoent *h, *r; char buf[4096]; int len=4096; |
| 177 |
(void)getprotobyname_r(n, h, buf, len, &r); |
| 178 |
])], [ac_cv_func_getprotobyname_r_nargs=5], [ |
| 179 |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <netdb.h>], [ |
| 180 |
char *n; struct protoent *h; char buf[4096]; int len=4096; |
| 181 |
(void)getprotobyname_r(n, h, buf, len); |
| 182 |
])], [ac_cv_func_getprotobyname_r_nargs=4], [ |
| 183 |
ac_cv_func_getprotobyname_r=no])])]) |
| 184 |
]) |
| 185 |
|
| 186 |
AS_IF([test $ac_cv_func_getprotobyname_r != no], [ |
| 187 |
AC_DEFINE_UNQUOTED(GETPROTOBYNAME_R_NUMARGS, $ac_cv_func_getprotobyname_r_nargs, [Define number of args getprotobyname_r takes]) |
| 188 |
]) |
| 189 |
|
| 190 |
dnl exclude netbsd. see the comment above. |
| 191 |
AS_CASE(["$target"], |
| 192 |
[*-*-netbsd*], [ac_cv_func_getprotobynumber_r=no], |
| 193 |
[AC_CHECK_FUNC(getprotobynumber_r)]) |
| 194 |
|
| 195 |
AS_IF([test $ac_cv_func_getprotobynumber_r = 'yes'], [ |
| 196 |
AC_CACHE_CHECK(number of arguments for getprotobynumber_r, |
| 197 |
ac_cv_func_getprotobynumber_r_nargs, [ |
| 198 |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <netdb.h>], [ |
| 199 |
int n; struct protoent *h, *r; char buf[4096]; int len=4096; |
| 200 |
(void)getprotobynumber_r(n, h, buf, len, &r); |
| 201 |
])], [ac_cv_func_getprotobynumber_r_nargs=5], [ |
| 202 |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <netdb.h>], [ |
| 203 |
int n; struct protoent *h; char buf[4096]; int len=4096; |
| 204 |
(void)getprotobynumber_r(n, h, buf, len); |
| 205 |
])], [ac_cv_func_getprotobynumber_r_nargs=4], [ |
| 206 |
ac_cv_func_getprotobynumber_r=no])])]) |
| 207 |
]) |
| 208 |
|
| 209 |
AS_IF([test $ac_cv_func_getprotobynumber_r != no], [ |
| 210 |
AC_DEFINE_UNQUOTED(GETPROTOBYNUMBER_R_NUMARGS, $ac_cv_func_getprotobynumber_r_nargs, [Define number of args getprotobynumber_r takes]) |
| 211 |
]) |
| 212 |
|
| 213 |
dnl exclude netbsd. see the comment above. |
| 214 |
AS_CASE(["$target"], |
| 215 |
[*-*-netbsd*], [ac_cv_func_getservbyname_r=no], |
| 216 |
[AC_CHECK_FUNC(getservbyname_r)]) |
| 217 |
|
| 218 |
AC_CHECK_FUNC(getservbyname_r) |
| 219 |
AS_IF([test $ac_cv_func_getservbyname_r = 'yes'], [ |
| 220 |
AC_CACHE_CHECK(number of arguments for getservbyname_r, |
| 221 |
ac_cv_func_getservbyname_r_nargs, [ |
| 222 |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <netdb.h>], [ |
| 223 |
char *n, *p; struct servent *h, *r; char buf[4096]; int len=4096; |
| 224 |
(void)getservbyname_r(n, p, h, buf, len, &r); |
| 225 |
])], [ac_cv_func_getservbyname_r_nargs=6], [ |
| 226 |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <netdb.h>], [ |
| 227 |
char *n, *p; struct servent *h; char buf[4096]; int len=4096; |
| 228 |
(void)getservbyname_r(n, p, h, buf, len); |
| 229 |
])], [ac_cv_func_getservbyname_r_nargs=5], [ |
| 230 |
ac_cv_func_getservbyname_r=no])])]) |
| 231 |
]) |
| 232 |
|
| 233 |
AS_IF([test $ac_cv_func_getservbyname_r != no], [ |
| 234 |
AC_DEFINE_UNQUOTED(GETSERVBYNAME_R_NUMARGS, $ac_cv_func_getservbyname_r_nargs, [Define number of args getservbyname_r takes]) |
| 235 |
]) |
| 236 |
|
| 237 |
dnl exclude netbsd. see the comment above. |
| 238 |
AS_CASE(["$target"], |
| 239 |
[*-*-netbsd*], [ac_cv_func_getservbyport_r=no], |
| 240 |
[AC_CHECK_FUNC(getservbyport_r)]) |
| 241 |
|
| 242 |
AS_IF([test $ac_cv_func_getservbyport_r = 'yes'], [ |
| 243 |
AC_CACHE_CHECK(number of arguments for getservbyport_r, |
| 244 |
ac_cv_func_getservbyport_r_nargs, [ |
| 245 |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <netdb.h>], [ |
| 246 |
int n; char *p; struct servent *h, *r; char buf[4096]; int len=4096; |
| 247 |
(void)getservbyport_r(n, p, h, buf, len, &r); |
| 248 |
])], [ac_cv_func_getservbyport_r_nargs=6], [ |
| 249 |
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@include <netdb.h>], [ |
| 250 |
int n; char *p; struct servent *h; char buf[4096]; int len=4096; |
| 251 |
(void)getservbyport_r(n, p, h, buf, len); |
| 252 |
])], [ac_cv_func_getservbyport_r_nargs=5], [ |
| 253 |
ac_cv_func_getservbyport_r=no])])]) |
| 254 |
]) |
| 255 |
|
| 256 |
AS_IF([test $ac_cv_func_getservbyport_r != no], [ |
| 257 |
AC_DEFINE_UNQUOTED(GETSERVBYPORT_R_NUMARGS, $ac_cv_func_getservbyport_r_nargs, [Define number of args getservbyport_r takes]) |
| 258 |
]) |
| 259 |
|
| 260 |
dnl Check for socklen_t |
| 261 |
dnl Windows/MinGW is special and we know the answer, so we just don't |
| 262 |
dnl bother checking it. |
| 263 |
AS_CASE(["$target"], |
| 264 |
[*mingw*], [LIBS="$LIBS -lws2_32" |
| 265 |
EXT_LIBS="$EXT_LIBS -lws2_32"], |
| 266 |
[AX_TYPE_SOCKLEN_T]) |
| 267 |
|
| 268 |
dnl Local variables: |
| 269 |
dnl mode: autoconf |
| 270 |
dnl end: |