The Android Open Source Project | 2949f58 | 2009-03-03 19:30:46 -0800 | [diff] [blame^] | 1 | dnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.188.2.8 2007/09/12 19:48:50 guy Exp $ (LBL) |
| 2 | dnl |
| 3 | dnl Copyright (c) 1994, 1995, 1996, 1997 |
| 4 | dnl The Regents of the University of California. All rights reserved. |
| 5 | dnl |
| 6 | dnl Process this file with autoconf to produce a configure script. |
| 7 | dnl |
| 8 | |
| 9 | AC_REVISION($Revision: 1.188.2.8 $) |
| 10 | AC_PREREQ(2.50) |
| 11 | AC_INIT(tcpdump.c) |
| 12 | |
| 13 | AC_CANONICAL_HOST |
| 14 | |
| 15 | AC_LBL_C_INIT(V_CCOPT, V_INCLS) |
| 16 | AC_LBL_C_INLINE |
| 17 | AC_C___ATTRIBUTE__ |
| 18 | AC_CHECK_HEADERS(fcntl.h rpc/rpcent.h netdnet/dnetdb.h) |
| 19 | AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h> |
| 20 | #include <sys/socket.h> |
| 21 | #include <net/if.h>]) |
| 22 | if test "$ac_cv_header_net_pfvar_h" == yes; then |
| 23 | LOCALSRC="print-pflog.c $LOCALSRC" |
| 24 | fi |
| 25 | AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h> |
| 26 | #include <sys/socket.h>]) |
| 27 | if test "$ac_cv_header_netinet_if_ether_h" != yes; then |
| 28 | # |
| 29 | # The simple test didn't work. |
| 30 | # Do we need to include <net/if.h> first? |
| 31 | # Unset ac_cv_header_netinet_if_ether_h so we don't |
| 32 | # treat the previous failure as a cached value and |
| 33 | # suppress the next test. |
| 34 | # |
| 35 | AC_MSG_NOTICE([Rechecking with some additional includes]) |
| 36 | unset ac_cv_header_netinet_if_ether_h |
| 37 | AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h> |
| 38 | #include <sys/socket.h> |
| 39 | #include <netinet/in.h> |
| 40 | struct mbuf; |
| 41 | struct rtentry; |
| 42 | #include <net/if.h>]) |
| 43 | fi |
| 44 | |
| 45 | AC_HEADER_TIME |
| 46 | |
| 47 | case "$host_os" in |
| 48 | |
| 49 | linux*) |
| 50 | AC_MSG_CHECKING(Linux kernel version) |
| 51 | if test "$cross_compiling" = yes; then |
| 52 | AC_CACHE_VAL(ac_cv_linux_vers, |
| 53 | ac_cv_linux_vers=unknown) |
| 54 | else |
| 55 | AC_CACHE_VAL(ac_cv_linux_vers, |
| 56 | ac_cv_linux_vers=`uname -r 2>&1 | \ |
| 57 | sed -n -e '$s/.* //' -e '$s/\..*//p'`) |
| 58 | fi |
| 59 | AC_MSG_RESULT($ac_cv_linux_vers) |
| 60 | if test $ac_cv_linux_vers = unknown ; then |
| 61 | AC_MSG_ERROR(cannot determine linux version when cross-compiling) |
| 62 | fi |
| 63 | if test $ac_cv_linux_vers -lt 2 ; then |
| 64 | AC_MSG_ERROR(version 2 or higher required; see the INSTALL doc for more info) |
| 65 | fi |
| 66 | ;; |
| 67 | |
| 68 | *) |
| 69 | ;; |
| 70 | esac |
| 71 | |
| 72 | |
| 73 | AC_CHECK_HEADERS(smi.h) |
| 74 | AC_CHECK_LIB(smi, smiInit) |
| 75 | if test "$ac_cv_header_smi_h" = yes -a "$ac_cv_lib_smi_smiInit" = yes |
| 76 | then |
| 77 | AC_MSG_CHECKING([whether to enable libsmi]) |
| 78 | AC_TRY_RUN([ /* libsmi available check */ |
| 79 | #include <smi.h> |
| 80 | main() |
| 81 | { |
| 82 | int current, revision, age, n; |
| 83 | const int required = 2; |
| 84 | if (smiInit("")) |
| 85 | exit(1); |
| 86 | if (strcmp(SMI_LIBRARY_VERSION, smi_library_version)) |
| 87 | exit(2); |
| 88 | n = sscanf(smi_library_version, "%d:%d:%d", ¤t, &revision, &age); |
| 89 | if (n != 3) |
| 90 | exit(3); |
| 91 | if (required < current - age || required > current) |
| 92 | exit(4); |
| 93 | exit(0); |
| 94 | } |
| 95 | ], |
| 96 | [ AC_MSG_RESULT(yes) |
| 97 | AC_DEFINE(LIBSMI) |
| 98 | libsmi=yes], |
| 99 | dnl autoconf documentation says that $? contains the exit value. |
| 100 | dnl reality is that it does not. We leave this in just in case |
| 101 | dnl autoconf ever comes back to match the documentation. |
| 102 | [ case $? in |
| 103 | 1) AC_MSG_RESULT(no - smiInit failed) ;; |
| 104 | 2) AC_MSG_RESULT(no - header/library version mismatch) ;; |
| 105 | 3) AC_MSG_RESULT(no - can't determine library version) ;; |
| 106 | 4) AC_MSG_RESULT(no - too old) ;; |
| 107 | *) AC_MSG_RESULT(no) ;; |
| 108 | esac |
| 109 | libsmi=no], |
| 110 | [ AC_MSG_RESULT(not when cross-compiling) |
| 111 | libsmi=no] |
| 112 | ) |
| 113 | fi |
| 114 | |
| 115 | AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer]) |
| 116 | AC_ARG_ENABLE(smb, |
| 117 | [ --enable-smb enable possibly-buggy SMB printer [default=yes] |
| 118 | --disable-smb disable possibly-buggy SMB printer],, |
| 119 | enableval=yes) |
| 120 | case "$enableval" in |
| 121 | yes) AC_MSG_RESULT(yes) |
| 122 | AC_WARN([The SMB printer may have exploitable buffer overflows!!!]) |
| 123 | AC_DEFINE(TCPDUMP_DO_SMB) |
| 124 | LOCALSRC="print-smb.c smbutil.c $LOCALSRC" |
| 125 | ;; |
| 126 | *) AC_MSG_RESULT(no) |
| 127 | ;; |
| 128 | esac |
| 129 | |
| 130 | AC_ARG_WITH(user, [ --with-user=USERNAME drop privileges by default to USERNAME]) |
| 131 | AC_MSG_CHECKING([whether to drop root privileges by default]) |
| 132 | if test ! -z "$with_user" ; then |
| 133 | AC_DEFINE_UNQUOTED(WITH_USER, "$withval") |
| 134 | AC_MSG_RESULT(to \"$withval\") |
| 135 | else |
| 136 | AC_MSG_RESULT(no) |
| 137 | fi |
| 138 | |
| 139 | AC_ARG_WITH(chroot, [ --with-chroot=DIRECTORY when dropping privileges, chroot to DIRECTORY]) |
| 140 | AC_MSG_CHECKING([whether to chroot]) |
| 141 | if test ! -z "$with_chroot" ; then |
| 142 | AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval") |
| 143 | AC_MSG_RESULT(to \"$withval\") |
| 144 | else |
| 145 | AC_MSG_RESULT(no) |
| 146 | fi |
| 147 | |
| 148 | AC_MSG_CHECKING([whether to enable ipv6]) |
| 149 | AC_ARG_ENABLE(ipv6, |
| 150 | [ --enable-ipv6 enable ipv6 (with ipv4) support |
| 151 | --disable-ipv6 disable ipv6 support], |
| 152 | [ case "$enableval" in |
| 153 | yes) AC_MSG_RESULT(yes) |
| 154 | LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC" |
| 155 | AC_DEFINE(INET6) |
| 156 | ipv6=yes |
| 157 | ;; |
| 158 | *) |
| 159 | AC_MSG_RESULT(no) |
| 160 | ipv6=no |
| 161 | ;; |
| 162 | esac ], |
| 163 | |
| 164 | AC_TRY_RUN([ /* AF_INET6 available check */ |
| 165 | #include <sys/types.h> |
| 166 | #include <sys/socket.h> |
| 167 | main() |
| 168 | { |
| 169 | if (socket(AF_INET6, SOCK_STREAM, 0) < 0) |
| 170 | exit(1); |
| 171 | else |
| 172 | exit(0); |
| 173 | } |
| 174 | ], |
| 175 | [ AC_MSG_RESULT(yes) |
| 176 | LOCALSRC="print-ip6.c print-ip6opts.c print-mobility.c print-ripng.c print-icmp6.c print-frag6.c print-rt6.c print-ospf6.c print-dhcp6.c $LOCALSRC" |
| 177 | AC_DEFINE(INET6) |
| 178 | ipv6=yes], |
| 179 | [ AC_MSG_RESULT(no) |
| 180 | ipv6=no], |
| 181 | [ AC_MSG_RESULT(no) |
| 182 | ipv6=no] |
| 183 | )) |
| 184 | |
| 185 | ipv6type=unknown |
| 186 | ipv6lib=none |
| 187 | ipv6trylibc=no |
| 188 | |
| 189 | if test "$ipv6" = "yes"; then |
| 190 | AC_MSG_CHECKING([ipv6 stack type]) |
| 191 | for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do |
| 192 | case $i in |
| 193 | inria) |
| 194 | dnl http://www.kame.net/ |
| 195 | AC_EGREP_CPP(yes, |
| 196 | [#include <netinet/in.h> |
| 197 | #ifdef IPV6_INRIA_VERSION |
| 198 | yes |
| 199 | #endif], |
| 200 | [ipv6type=$i; |
| 201 | CFLAGS="-DINET6 $CFLAGS"]) |
| 202 | ;; |
| 203 | kame) |
| 204 | dnl http://www.kame.net/ |
| 205 | AC_EGREP_CPP(yes, |
| 206 | [#include <netinet/in.h> |
| 207 | #ifdef __KAME__ |
| 208 | yes |
| 209 | #endif], |
| 210 | [ipv6type=$i; |
| 211 | ipv6lib=inet6; |
| 212 | ipv6libdir=/usr/local/v6/lib; |
| 213 | ipv6trylibc=yes; |
| 214 | CFLAGS="-DINET6 $CFLAGS"]) |
| 215 | ;; |
| 216 | linux-glibc) |
| 217 | dnl http://www.v6.linux.or.jp/ |
| 218 | AC_EGREP_CPP(yes, |
| 219 | [#include <features.h> |
| 220 | #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 |
| 221 | yes |
| 222 | #endif], |
| 223 | [ipv6type=$i; |
| 224 | CFLAGS="-DINET6 $CFLAGS"]) |
| 225 | ;; |
| 226 | linux-libinet6) |
| 227 | dnl http://www.v6.linux.or.jp/ |
| 228 | dnl |
| 229 | dnl This also matches Solaris 8 and Tru64 UNIX 5.1, |
| 230 | dnl and possibly other versions of those OSes |
| 231 | dnl |
| 232 | if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then |
| 233 | ipv6type=$i |
| 234 | ipv6lib=inet6 |
| 235 | ipv6libdir=/usr/inet6/lib |
| 236 | ipv6trylibc=yes; |
| 237 | CFLAGS="-DINET6 -I/usr/inet6/include $CFLAGS" |
| 238 | fi |
| 239 | ;; |
| 240 | toshiba) |
| 241 | AC_EGREP_CPP(yes, |
| 242 | [#include <sys/param.h> |
| 243 | #ifdef _TOSHIBA_INET6 |
| 244 | yes |
| 245 | #endif], |
| 246 | [ipv6type=$i; |
| 247 | ipv6lib=inet6; |
| 248 | ipv6libdir=/usr/local/v6/lib; |
| 249 | CFLAGS="-DINET6 $CFLAGS"]) |
| 250 | ;; |
| 251 | v6d) |
| 252 | AC_EGREP_CPP(yes, |
| 253 | [#include </usr/local/v6/include/sys/v6config.h> |
| 254 | #ifdef __V6D__ |
| 255 | yes |
| 256 | #endif], |
| 257 | [ipv6type=$i; |
| 258 | ipv6lib=v6; |
| 259 | ipv6libdir=/usr/local/v6/lib; |
| 260 | CFLAGS="-I/usr/local/v6/include $CFLAGS"]) |
| 261 | ;; |
| 262 | zeta) |
| 263 | AC_EGREP_CPP(yes, |
| 264 | [#include <sys/param.h> |
| 265 | #ifdef _ZETA_MINAMI_INET6 |
| 266 | yes |
| 267 | #endif], |
| 268 | [ipv6type=$i; |
| 269 | ipv6lib=inet6; |
| 270 | ipv6libdir=/usr/local/v6/lib; |
| 271 | CFLAGS="-DINET6 $CFLAGS"]) |
| 272 | ;; |
| 273 | esac |
| 274 | if test "$ipv6type" != "unknown"; then |
| 275 | break |
| 276 | fi |
| 277 | done |
| 278 | AC_MSG_RESULT($ipv6type) |
| 279 | fi |
| 280 | |
| 281 | if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then |
| 282 | if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then |
| 283 | LIBS="-L$ipv6libdir -l$ipv6lib $LIBS" |
| 284 | echo "You have $ipv6lib library, using it" |
| 285 | else |
| 286 | if test "$ipv6trylibc" = "yes"; then |
| 287 | echo "You do not have $ipv6lib library, using libc" |
| 288 | else |
| 289 | echo 'Fatal: no $ipv6lib library found. cannot continue.' |
| 290 | echo "You need to fetch lib$ipv6lib.a from appropriate" |
| 291 | echo 'ipv6 kit and compile beforehand.' |
| 292 | exit 1 |
| 293 | fi |
| 294 | fi |
| 295 | fi |
| 296 | |
| 297 | |
| 298 | if test "$ipv6" = "yes"; then |
| 299 | # |
| 300 | # XXX - on Tru64 UNIX 5.1, there is no "getaddrinfo()" |
| 301 | # function in libc; there are "ngetaddrinfo()" and |
| 302 | # "ogetaddrinfo()" functions, and <netdb.h> #defines |
| 303 | # "getaddrinfo" to be either "ngetaddrinfo" or |
| 304 | # "ogetaddrinfo", depending on whether _SOCKADDR_LEN |
| 305 | # or _XOPEN_SOURCE_EXTENDED are defined or not. |
| 306 | # |
| 307 | # So this test doesn't work on Tru64 5.1, and possibly |
| 308 | # on other 5.x releases. This causes the configure |
| 309 | # script to become confused, and results in libpcap |
| 310 | # being unbuildable. |
| 311 | # |
| 312 | AC_SEARCH_LIBS(getaddrinfo, socket, [dnl |
| 313 | AC_MSG_CHECKING(getaddrinfo bug) |
| 314 | AC_CACHE_VAL(td_cv_buggygetaddrinfo, [AC_TRY_RUN([ |
| 315 | #include <sys/types.h> |
| 316 | #include <netdb.h> |
| 317 | #include <string.h> |
| 318 | #include <sys/socket.h> |
| 319 | #include <netinet/in.h> |
| 320 | |
| 321 | main() |
| 322 | { |
| 323 | int passive, gaierr, inet4 = 0, inet6 = 0; |
| 324 | struct addrinfo hints, *ai, *aitop; |
| 325 | char straddr[INET6_ADDRSTRLEN], strport[16]; |
| 326 | |
| 327 | for (passive = 0; passive <= 1; passive++) { |
| 328 | memset(&hints, 0, sizeof(hints)); |
| 329 | hints.ai_family = AF_UNSPEC; |
| 330 | hints.ai_flags = passive ? AI_PASSIVE : 0; |
| 331 | hints.ai_socktype = SOCK_STREAM; |
| 332 | hints.ai_protocol = IPPROTO_TCP; |
| 333 | if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) { |
| 334 | (void)gai_strerror(gaierr); |
| 335 | goto bad; |
| 336 | } |
| 337 | for (ai = aitop; ai; ai = ai->ai_next) { |
| 338 | if (ai->ai_addr == NULL || |
| 339 | ai->ai_addrlen == 0 || |
| 340 | getnameinfo(ai->ai_addr, ai->ai_addrlen, |
| 341 | straddr, sizeof(straddr), strport, sizeof(strport), |
| 342 | NI_NUMERICHOST|NI_NUMERICSERV) != 0) { |
| 343 | goto bad; |
| 344 | } |
| 345 | switch (ai->ai_family) { |
| 346 | case AF_INET: |
| 347 | if (strcmp(strport, "54321") != 0) { |
| 348 | goto bad; |
| 349 | } |
| 350 | if (passive) { |
| 351 | if (strcmp(straddr, "0.0.0.0") != 0) { |
| 352 | goto bad; |
| 353 | } |
| 354 | } else { |
| 355 | if (strcmp(straddr, "127.0.0.1") != 0) { |
| 356 | goto bad; |
| 357 | } |
| 358 | } |
| 359 | inet4++; |
| 360 | break; |
| 361 | case AF_INET6: |
| 362 | if (strcmp(strport, "54321") != 0) { |
| 363 | goto bad; |
| 364 | } |
| 365 | if (passive) { |
| 366 | if (strcmp(straddr, "::") != 0) { |
| 367 | goto bad; |
| 368 | } |
| 369 | } else { |
| 370 | if (strcmp(straddr, "::1") != 0) { |
| 371 | goto bad; |
| 372 | } |
| 373 | } |
| 374 | inet6++; |
| 375 | break; |
| 376 | case AF_UNSPEC: |
| 377 | goto bad; |
| 378 | break; |
| 379 | #ifdef AF_UNIX |
| 380 | case AF_UNIX: |
| 381 | #else |
| 382 | #ifdef AF_LOCAL |
| 383 | case AF_LOCAL: |
| 384 | #endif |
| 385 | #endif |
| 386 | default: |
| 387 | /* another family support? */ |
| 388 | break; |
| 389 | } |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | /* supported family should be 2, unsupported family should be 0 */ |
| 394 | if (!(inet4 == 0 || inet4 == 2)) |
| 395 | goto bad; |
| 396 | if (!(inet6 == 0 || inet6 == 2)) |
| 397 | goto bad; |
| 398 | |
| 399 | if (aitop) |
| 400 | freeaddrinfo(aitop); |
| 401 | exit(0); |
| 402 | |
| 403 | bad: |
| 404 | if (aitop) |
| 405 | freeaddrinfo(aitop); |
| 406 | exit(1); |
| 407 | } |
| 408 | ], |
| 409 | td_cv_buggygetaddrinfo=no, |
| 410 | td_cv_buggygetaddrinfo=yes, |
| 411 | td_cv_buggygetaddrinfo=yes)]) |
| 412 | if test "$td_cv_buggygetaddrinfo" = no; then |
| 413 | AC_MSG_RESULT(good) |
| 414 | else |
| 415 | AC_MSG_RESULT(buggy) |
| 416 | fi |
| 417 | |
| 418 | if test "$td_cv_buggygetaddrinfo" = "yes"; then |
| 419 | # |
| 420 | # XXX - it doesn't appear that "ipv6type" can ever be |
| 421 | # set to "linux". Should this be testing for |
| 422 | # "linux-glibc", or for that *or* "linux-libinet6"? |
| 423 | # If the latter, note that "linux-libinet6" is also |
| 424 | # the type given to some non-Linux OSes. |
| 425 | # |
| 426 | if test "$ipv6type" != "linux"; then |
| 427 | echo 'Fatal: You must get working getaddrinfo() function.' |
| 428 | echo ' or you can specify "--disable-ipv6"'. |
| 429 | exit 1 |
| 430 | else |
| 431 | echo 'Warning: getaddrinfo() implementation on your system seems be buggy.' |
| 432 | echo ' Better upgrade your system library to newest version' |
| 433 | echo ' of GNU C library (aka glibc).' |
| 434 | fi |
| 435 | fi |
| 436 | ]) |
| 437 | AC_REPLACE_FUNCS(getaddrinfo getnameinfo) |
| 438 | fi |
| 439 | |
| 440 | AC_CACHE_CHECK([for dnet_htoa declaration in netdnet/dnetdb.h], |
| 441 | [td_cv_decl_netdnet_dnetdb_h_dnet_htoa], |
| 442 | [AC_EGREP_HEADER(dnet_htoa, netdnet/dnetdb.h, |
| 443 | td_cv_decl_netdnet_dnetdb_h_dnet_htoa=yes, |
| 444 | td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no)]) |
| 445 | if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then |
| 446 | AC_DEFINE(HAVE_NETDNET_DNETDB_H_DNET_HTOA) |
| 447 | fi |
| 448 | |
| 449 | dnl |
| 450 | dnl check sizeof basic types. |
| 451 | dnl They're very likely to be wrong for cross-compiling. |
| 452 | AC_CHECK_SIZEOF(char, 1) |
| 453 | AC_CHECK_SIZEOF(short, 2) |
| 454 | AC_CHECK_SIZEOF(int, 4) |
| 455 | AC_CHECK_SIZEOF(long, 4) |
| 456 | AC_CHECK_SIZEOF(long long, 8) |
| 457 | |
| 458 | dnl |
| 459 | dnl Checks for u_intXX_t |
| 460 | dnl AC_CHECK_BITTYPES(ac_cv_bittypes) |
| 461 | dnl if test "$ac_cv_bittypes" = no; then |
| 462 | dnl missing_includes=yes |
| 463 | dnl fi |
| 464 | |
| 465 | dnl |
| 466 | dnl Checks for addrinfo structure |
| 467 | AC_STRUCT_ADDRINFO(ac_cv_addrinfo) |
| 468 | if test "$ac_cv_addrinfo" = no; then |
| 469 | missing_includes=yes |
| 470 | fi |
| 471 | |
| 472 | dnl |
| 473 | dnl Checks for NI_MAXSERV |
| 474 | AC_NI_MAXSERV(ac_cv_maxserv) |
| 475 | if test "$ac_cv_maxserv" = no; then |
| 476 | missing_includes=yes |
| 477 | fi |
| 478 | |
| 479 | dnl |
| 480 | dnl Checks for NI_NAMEREQD |
| 481 | AC_NI_NAMEREQD(ac_cv_namereqd) |
| 482 | if test "$ac_cv_namereqd" = no; then |
| 483 | missing_includes=yes |
| 484 | fi |
| 485 | |
| 486 | dnl |
| 487 | dnl Checks for sockaddr_storage structure |
| 488 | AC_STRUCT_SA_STORAGE(ac_cv_sa_storage) |
| 489 | if test "$ac_cv_sa_storage" = no; then |
| 490 | missing_includes=yes |
| 491 | fi |
| 492 | |
| 493 | dnl |
| 494 | dnl Checks for IN[6]ADDRSZ |
| 495 | AC_CHECK_ADDRSZ(ac_cv_addrsz) |
| 496 | if test "$ac_cv_addrsz" = no; then |
| 497 | missing_includes=yes |
| 498 | fi |
| 499 | |
| 500 | dnl |
| 501 | dnl Checks for RES_USE_INET6 |
| 502 | AC_CHECK_RES_USE_INET6(ac_cv_res_inet6) |
| 503 | if test "$ac_cv_res_inet6" = no; then |
| 504 | missing_includes=yes |
| 505 | fi |
| 506 | |
| 507 | dnl |
| 508 | dnl Checks for res_state_ext structure |
| 509 | AC_STRUCT_RES_STATE_EXT(ac_cv_res_state_ext) |
| 510 | if test "$ac_cv_res_state_ext" = no; then |
| 511 | missing_includes=yes |
| 512 | fi |
| 513 | |
| 514 | dnl |
| 515 | dnl Checks if res_state structure has nsort member. |
| 516 | AC_STRUCT_RES_STATE(ac_cv_res_state) |
| 517 | |
| 518 | |
| 519 | AC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup strsep) |
| 520 | AC_CHECK_FUNCS(strftime) |
| 521 | AC_CHECK_FUNCS(setlinebuf alarm) |
| 522 | |
| 523 | needsnprintf=no |
| 524 | AC_CHECK_FUNCS(vsnprintf snprintf,, |
| 525 | [needsnprintf=yes]) |
| 526 | if test $needsnprintf = yes; then |
| 527 | AC_LIBOBJ(snprintf) |
| 528 | fi |
| 529 | |
| 530 | AC_LBL_TYPE_SIGNAL |
| 531 | |
| 532 | AC_SEARCH_LIBS(dnet_htoa, dnet, AC_DEFINE(HAVE_DNET_HTOA)) |
| 533 | |
| 534 | AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc |
| 535 | |
| 536 | dnl Some platforms may need -lnsl for getrpcbynumber. |
| 537 | AC_SEARCH_LIBS(getrpcbynumber, nsl, AC_DEFINE(HAVE_GETRPCBYNUMBER)) |
| 538 | |
| 539 | dnl AC_CHECK_LIB(z, uncompress) |
| 540 | dnl AC_CHECK_HEADERS(zlib.h) |
| 541 | |
| 542 | AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS) |
| 543 | |
| 544 | # |
| 545 | # Check for these after AC_LBL_LIBPCAP, so we link with the appropriate |
| 546 | # libraries (e.g., "-lsocket -lnsl" on Solaris). |
| 547 | # |
| 548 | # We don't use AC_REPLACE_FUNCS because that uses AC_CHECK_FUNCS which |
| 549 | # use AC_CHECK_FUNC which doesn't let us specify the right #includes |
| 550 | # to make this work on BSD/OS 4.x. BSD/OS 4.x ships with the BIND8 |
| 551 | # resolver, and the way it defines inet_{ntop,pton} is rather strange; |
| 552 | # it does not ship with a libc symbol "inet_ntop()", it ships with |
| 553 | # "_inet_ntop()", and has a #define macro in one of the system headers |
| 554 | # to rename it. |
| 555 | # |
| 556 | dnl AC_TRY_COMPILE(inet_ntop inet_pton inet_aton) |
| 557 | AC_MSG_CHECKING(for inet_ntop) |
| 558 | AC_TRY_LINK([#include <sys/types.h> |
| 559 | #include <sys/socket.h> |
| 560 | #include <netinet/in.h> |
| 561 | #include <arpa/inet.h>], [char src[4], dst[128]; |
| 562 | inet_ntop(AF_INET, src, dst, sizeof(dst));], |
| 563 | [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no) |
| 564 | AC_LIBOBJ(inet_ntop)]) |
| 565 | AC_MSG_CHECKING(for inet_pton) |
| 566 | AC_TRY_LINK([#include <sys/types.h> |
| 567 | #include <sys/socket.h> |
| 568 | #include <netinet/in.h> |
| 569 | #include <arpa/inet.h>], [char src[128], dst[4]; |
| 570 | inet_pton(AF_INET, src, dst);], |
| 571 | [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no) |
| 572 | AC_LIBOBJ(inet_pton)]) |
| 573 | AC_MSG_CHECKING(for inet_aton) |
| 574 | AC_TRY_LINK([#include <sys/types.h> |
| 575 | #include <netinet/in.h> |
| 576 | #include <arpa/inet.h>], [char src[128]; |
| 577 | struct in_addr dst; |
| 578 | inet_aton(src, &dst);], |
| 579 | [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no) |
| 580 | AC_LIBOBJ(inet_aton)]) |
| 581 | |
| 582 | # |
| 583 | # Check for these after AC_LBL_LIBPCAP, for the same reason. |
| 584 | # |
| 585 | # You are in a twisty little maze of UN*Xes, all different. |
| 586 | # Some might not have ether_ntohost(). |
| 587 | # Some might have it, but not declare it in any header file. |
| 588 | # Some might have it, but declare it in <netinet/if_ether.h>. |
| 589 | # Some might have it, but declare it in <netinet/ether.h> |
| 590 | # (And some might have it but document it as something declared in |
| 591 | # <netinet/ethernet.h>, although <netinet/if_ether.h> appears to work.) |
| 592 | # |
| 593 | # Before you is a C compiler. |
| 594 | # |
| 595 | AC_CHECK_FUNCS(ether_ntohost, [ |
| 596 | AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [ |
| 597 | AC_TRY_RUN([ |
| 598 | #include <netdb.h> |
| 599 | #include <sys/types.h> |
| 600 | #include <sys/param.h> |
| 601 | #include <sys/socket.h> |
| 602 | |
| 603 | int |
| 604 | main(int argc, char **argv) |
| 605 | { |
| 606 | u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff }; |
| 607 | char name[MAXHOSTNAMELEN]; |
| 608 | |
| 609 | ether_ntohost(name, (struct ether_addr *)ea); |
| 610 | exit(0); |
| 611 | } |
| 612 | ], [ac_cv_buggy_ether_ntohost=no], |
| 613 | [ac_cv_buggy_ether_ntohost=yes], |
| 614 | [ac_cv_buggy_ether_ntohost="not while cross-compiling"])]) |
| 615 | if test "$ac_cv_buggy_ether_ntohost" = "no"; then |
| 616 | AC_DEFINE(USE_ETHER_NTOHOST) |
| 617 | fi |
| 618 | ]) |
| 619 | if test "$ac_cv_func_ether_ntohost" = yes -a \ |
| 620 | "$ac_cv_buggy_ether_ntohost" = "no"; then |
| 621 | # |
| 622 | # OK, we have ether_ntohost(). Do we have <netinet/if_ether.h>? |
| 623 | # |
| 624 | if test "$ac_cv_header_netinet_if_ether_h" = yes; then |
| 625 | # |
| 626 | # Yes. Does it declare ether_ntohost()? |
| 627 | # |
| 628 | AC_CHECK_DECL(ether_ntohost, |
| 629 | [ |
| 630 | AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST,, |
| 631 | [Define to 1 if netinet/if_ether.h declares `ether_ntohost']) |
| 632 | ],, |
| 633 | [ |
| 634 | #include <sys/types.h> |
| 635 | #include <sys/socket.h> |
| 636 | #include <netinet/in.h> |
| 637 | #include <arpa/inet.h> |
| 638 | struct mbuf; |
| 639 | struct rtentry; |
| 640 | #include <net/if.h> |
| 641 | #include <netinet/if_ether.h> |
| 642 | ]) |
| 643 | fi |
| 644 | # |
| 645 | # Did that succeed? |
| 646 | # |
| 647 | if test "$ac_cv_have_decl_ether_ntohost" != yes; then |
| 648 | # |
| 649 | # No, how about <netinet/ether.h>, as on Linux? |
| 650 | # |
| 651 | AC_CHECK_HEADERS(netinet/ether.h) |
| 652 | if test "$ac_cv_header_netinet_ether_h" = yes; then |
| 653 | # |
| 654 | # We have it - does it declare ether_ntohost()? |
| 655 | # Unset ac_cv_have_decl_ether_ntohost so we don't |
| 656 | # treat the previous failure as a cached value and |
| 657 | # suppress the next test. |
| 658 | # |
| 659 | unset ac_cv_have_decl_ether_ntohost |
| 660 | AC_CHECK_DECL(ether_ntohost, |
| 661 | [ |
| 662 | AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,, |
| 663 | [Define to 1 if netinet/ether.h declares `ether_ntohost']) |
| 664 | ],, |
| 665 | [ |
| 666 | #include <netinet/ether.h> |
| 667 | ]) |
| 668 | fi |
| 669 | fi |
| 670 | # |
| 671 | # Is ether_ntohost() declared? |
| 672 | # |
| 673 | if test "$ac_cv_have_decl_ether_ntohost" != yes; then |
| 674 | # |
| 675 | # No, we'll have to declare it ourselves. |
| 676 | # Do we have "struct ether_addr"? |
| 677 | # |
| 678 | AC_CHECK_TYPES(struct ether_addr,,, |
| 679 | [ |
| 680 | #include <sys/types.h> |
| 681 | #include <sys/socket.h> |
| 682 | #include <netinet/in.h> |
| 683 | #include <arpa/inet.h> |
| 684 | struct mbuf; |
| 685 | struct rtentry; |
| 686 | #include <net/if.h> |
| 687 | #include <netinet/if_ether.h> |
| 688 | ]) |
| 689 | AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 0, |
| 690 | [Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you |
| 691 | don't.]) |
| 692 | else |
| 693 | AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 1, |
| 694 | [Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you |
| 695 | don't.]) |
| 696 | fi |
| 697 | fi |
| 698 | |
| 699 | dnl portability macros for getaddrinfo/getnameinfo |
| 700 | dnl |
| 701 | dnl Check for sa_len |
| 702 | AC_CHECK_SA_LEN(ac_cv_sockaddr_has_sa_len) |
| 703 | if test "$ac_cv_sockaddr_has_sa_len" = no; then |
| 704 | missing_includes=yes |
| 705 | fi |
| 706 | |
| 707 | AC_CHECK_FUNCS(pcap_findalldevs pcap_dump_flush pcap_lib_version) |
| 708 | if test $ac_cv_func_pcap_findalldevs = "yes" ; then |
| 709 | dnl Check for Mac OS X, which may ship pcap.h from 0.6 but libpcap may |
| 710 | dnl be 0.8; this means that lib has pcap_findalldevs but header doesn't |
| 711 | dnl have pcap_if_t. |
| 712 | savedcflags="$CFLAGS" |
| 713 | CFLAGS="$CFLAGS $V_INCLS" |
| 714 | AC_CHECK_TYPES(pcap_if_t, , , [#include <pcap.h>]) |
| 715 | CFLAGS="$savedcflags" |
| 716 | fi |
| 717 | |
| 718 | if test $ac_cv_func_pcap_lib_version = "no" ; then |
| 719 | AC_MSG_CHECKING(whether pcap_version is defined by libpcap) |
| 720 | AC_TRY_LINK([], |
| 721 | [ |
| 722 | extern char pcap_version[]; |
| 723 | |
| 724 | return (int)pcap_version; |
| 725 | ], |
| 726 | ac_lbl_cv_pcap_version_defined=yes, |
| 727 | ac_lbl_cv_pcap_version_defined=no) |
| 728 | if test "$ac_lbl_cv_pcap_version_defined" = yes ; then |
| 729 | AC_MSG_RESULT(yes) |
| 730 | AC_DEFINE(HAVE_PCAP_VERSION) |
| 731 | else |
| 732 | AC_MSG_RESULT(no) |
| 733 | fi |
| 734 | fi |
| 735 | AC_MSG_CHECKING(whether pcap_debug is defined by libpcap) |
| 736 | AC_TRY_LINK([], |
| 737 | [ |
| 738 | extern int pcap_debug; |
| 739 | |
| 740 | return pcap_debug; |
| 741 | ], |
| 742 | ac_lbl_cv_pcap_debug_defined=yes, |
| 743 | ac_lbl_cv_pcap_debug_defined=no) |
| 744 | if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then |
| 745 | AC_MSG_RESULT(yes) |
| 746 | AC_DEFINE(HAVE_PCAP_DEBUG) |
| 747 | else |
| 748 | AC_MSG_RESULT(no) |
| 749 | # |
| 750 | # OK, what about "yydebug"? |
| 751 | # |
| 752 | AC_MSG_CHECKING(whether yydebug is defined by libpcap) |
| 753 | AC_TRY_LINK([], |
| 754 | [ |
| 755 | extern int yydebug; |
| 756 | |
| 757 | return yydebug; |
| 758 | ], |
| 759 | ac_lbl_cv_yydebug_defined=yes, |
| 760 | ac_lbl_cv_yydebug_defined=no) |
| 761 | if test "$ac_lbl_cv_yydebug_defined" = yes ; then |
| 762 | AC_MSG_RESULT(yes) |
| 763 | AC_DEFINE(HAVE_YYDEBUG) |
| 764 | else |
| 765 | AC_MSG_RESULT(no) |
| 766 | fi |
| 767 | fi |
| 768 | AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6 |
| 769 | |
| 770 | V_GROUP=0 |
| 771 | if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then |
| 772 | V_GROUP=wheel |
| 773 | fi |
| 774 | case "$host_os" in |
| 775 | |
| 776 | aix*) |
| 777 | dnl Workaround to enable certain features |
| 778 | AC_DEFINE(_SUN) |
| 779 | ;; |
| 780 | |
| 781 | irix*) |
| 782 | V_GROUP=sys |
| 783 | ;; |
| 784 | |
| 785 | osf*) |
| 786 | V_GROUP=system |
| 787 | ;; |
| 788 | |
| 789 | solaris*) |
| 790 | V_GROUP=sys |
| 791 | ;; |
| 792 | esac |
| 793 | |
| 794 | if test -f /dev/bpf0 ; then |
| 795 | V_GROUP=bpf |
| 796 | fi |
| 797 | |
| 798 | AC_CHECK_HEADERS(sys/bitypes.h) |
| 799 | |
| 800 | AC_CHECK_TYPE([int8_t], , |
| 801 | [AC_DEFINE([int8_t], [signed char], |
| 802 | [Define to `signed char' if int8_t not defined.])]) |
| 803 | AC_CHECK_TYPE([u_int8_t], , |
| 804 | [AC_DEFINE([u_int8_t], [unsigned char], |
| 805 | [Define to `unsigned char' if u_int8_t not defined.])], |
| 806 | [AC_INCLUDES_DEFAULT |
| 807 | #ifdef HAVE_SYS_BITYPES_H |
| 808 | #include <sys/bitypes.h> |
| 809 | #endif]) |
| 810 | AC_CHECK_TYPE([int16_t], , |
| 811 | [AC_DEFINE([int16_t], [short], |
| 812 | [Define to `short' if int16_t not defined.])]) |
| 813 | AC_CHECK_TYPE([u_int16_t], , |
| 814 | [AC_DEFINE([u_int16_t], [unsigned short], |
| 815 | [Define to `unsigned short' if u_int16_t not defined.])], |
| 816 | [AC_INCLUDES_DEFAULT |
| 817 | #ifdef HAVE_SYS_BITYPES_H |
| 818 | #include <sys/bitypes.h> |
| 819 | #endif]) |
| 820 | AC_CHECK_TYPE([int32_t], , |
| 821 | [AC_DEFINE([int32_t], [int], |
| 822 | [Define to `int' if int32_t not defined.])]) |
| 823 | AC_CHECK_TYPE([u_int32_t], , |
| 824 | [AC_DEFINE([u_int32_t], [unsigned int], |
| 825 | [Define to `unsigned int' if u_int32_t not defined.])], |
| 826 | [AC_INCLUDES_DEFAULT |
| 827 | #ifdef HAVE_SYS_BITYPES_H |
| 828 | #include <sys/bitypes.h> |
| 829 | #endif]) |
| 830 | AC_CHECK_TYPE([int64_t], , |
| 831 | [AC_DEFINE([int64_t], [long long], |
| 832 | [Define to `long long' if int64_t not defined.])]) |
| 833 | AC_CHECK_TYPE([u_int64_t], , |
| 834 | [AC_DEFINE([u_int64_t], [unsigned long long], |
| 835 | [Define to `unsigned long long' if u_int64_t not defined.])], |
| 836 | [AC_INCLUDES_DEFAULT |
| 837 | #ifdef HAVE_SYS_BITYPES_H |
| 838 | #include <sys/bitypes.h> |
| 839 | #endif]) |
| 840 | |
| 841 | # |
| 842 | # We can't just check for <inttypes.h> - some systems have one that |
| 843 | # doesn't define all the PRI[doxu]64 macros. |
| 844 | # |
| 845 | AC_CHECK_HEADERS(inttypes.h, |
| 846 | [ |
| 847 | # |
| 848 | # OK, we have inttypes.h, but does it define those macros? |
| 849 | # |
| 850 | AC_MSG_CHECKING([[whether inttypes.h defines the PRI[doxu]64 macros]]) |
| 851 | AC_COMPILE_IFELSE( |
| 852 | [ |
| 853 | AC_LANG_SOURCE( |
| 854 | [[ |
| 855 | #include <inttypes.h> |
| 856 | #include <stdio.h> |
| 857 | #include <sys/types.h> |
| 858 | #ifdef HAVE_SYS_BITYPES_H |
| 859 | #include <sys/bitypes.h> |
| 860 | #endif |
| 861 | |
| 862 | main() |
| 863 | { |
| 864 | printf("%" PRId64 "\n", (u_int64_t)1); |
| 865 | printf("%" PRIo64 "\n", (u_int64_t)1); |
| 866 | printf("%" PRIx64 "\n", (u_int64_t)1); |
| 867 | printf("%" PRIu64 "\n", (u_int64_t)1); |
| 868 | } |
| 869 | ]]) |
| 870 | ], |
| 871 | [ |
| 872 | AC_MSG_RESULT(yes) |
| 873 | ac_lbl_inttypes_h_defines_formats=yes |
| 874 | ], |
| 875 | [ |
| 876 | AC_MSG_RESULT(no) |
| 877 | ac_lbl_inttypes_h_defines_formats=no |
| 878 | ]) |
| 879 | ], |
| 880 | [ |
| 881 | # |
| 882 | # We don't have inttypes.h, so it obviously can't define those |
| 883 | # macros. |
| 884 | # |
| 885 | ac_lbl_inttypes_h_defines_formats=no |
| 886 | ]) |
| 887 | if test "$ac_lbl_inttypes_h_defines_formats" = no; then |
| 888 | AC_LBL_CHECK_64BIT_FORMAT(l, |
| 889 | [ |
| 890 | AC_LBL_CHECK_64BIT_FORMAT(ll, |
| 891 | [ |
| 892 | AC_LBL_CHECK_64BIT_FORMAT(L, |
| 893 | [ |
| 894 | AC_LBL_CHECK_64BIT_FORMAT(q, |
| 895 | [ |
| 896 | AC_MSG_ERROR([neither %llx nor %Lx nor %qx worked on a 64-bit integer]) |
| 897 | ]) |
| 898 | ]) |
| 899 | ]) |
| 900 | ]) |
| 901 | fi |
| 902 | |
| 903 | AC_LBL_DEVEL(V_CCOPT) |
| 904 | |
| 905 | AC_LBL_SOCKADDR_SA_LEN |
| 906 | |
| 907 | AC_LBL_UNALIGNED_ACCESS |
| 908 | |
| 909 | AC_VAR_H_ERRNO |
| 910 | |
| 911 | AC_ARG_WITH(crypto, [ --without-crypto disable crypto support], |
| 912 | [], [ |
| 913 | AC_MSG_CHECKING(for SSLeay) |
| 914 | ac_cv_ssleay_path=no |
| 915 | incdir=no |
| 916 | |
| 917 | # |
| 918 | # If Xprefix is set in the environment, use that value. |
| 919 | # XXX - this should arguably be done by having --with-crypto take an |
| 920 | # optional argument, and have that argument be used to set Xprefix |
| 921 | # if present. |
| 922 | # |
| 923 | if test -z "$Xprefix"; then |
| 924 | Xprefix=`eval echo $prefix` |
| 925 | fi |
| 926 | |
| 927 | for dir in $Xprefix /usr/${host_alias} /usr /usr/local /usr/local/ssl /usr/pkg; do |
| 928 | # |
| 929 | # XXX - is there a better way to check if a given library is |
| 930 | # in a given directory than checking each of the possible |
| 931 | # shared library suffixes? |
| 932 | # |
| 933 | # Are there any other suffixes we need to look for? Do we have to |
| 934 | # worry about ".so.{version}"? |
| 935 | # |
| 936 | # Or should we just look for "libcrypto.*"? |
| 937 | # |
| 938 | if test -d $dir/lib -a \( -f $dir/lib/libcrypto.a -o \ |
| 939 | -f $dir/lib/libcrypto.so -o \ |
| 940 | -f $dir/lib/libcrypto.sl -o \ |
| 941 | -f $dir/lib/libcrypto.dylib \); then |
| 942 | ac_cv_ssleay_path=$dir |
| 943 | fi |
| 944 | if test -d $dir/include/openssl -a -f $dir/include/openssl/des.h; then |
| 945 | incdir="-I$dir/include" |
| 946 | fi |
| 947 | if test "$ac_cv_ssleay_path" != "no" -a "$incdir" != "no"; then |
| 948 | break; |
| 949 | else |
| 950 | ac_cv_ssleay_path=no |
| 951 | incdir=no |
| 952 | fi |
| 953 | done |
| 954 | AC_MSG_RESULT($ac_cv_ssleay_path) |
| 955 | if test "$ac_cv_ssleay_path" != no; then |
| 956 | V_INCLS="$V_INCLS $incdir" |
| 957 | LDFLAGS="-L$dir/lib $LDFLAGS" |
| 958 | if test -f $ac_cv_ssleay_path/lib/libRSAglue.a; then |
| 959 | LIBS="$LIBS -lRSAglue" |
| 960 | fi |
| 961 | if test -f $ac_cv_ssleay_path/lib/librsaref.a; then |
| 962 | LIBS="$LIBS -lrsaref" |
| 963 | fi |
| 964 | AC_CHECK_LIB(crypto, DES_cbc_encrypt) |
| 965 | |
| 966 | CPPFLAGS="$CPPFLAGS $V_INCLS" |
| 967 | AC_CHECK_HEADERS(openssl/evp.h) |
| 968 | fi |
| 969 | ]) |
| 970 | |
| 971 | dnl |
| 972 | dnl set additional include path if necessary |
| 973 | if test "$missing_includes" = "yes"; then |
| 974 | CPPFLAGS="$CPPFLAGS -I\$(srcdir)/missing" |
| 975 | V_INCLS="$V_INCLS -I\$(srcdir)/missing" |
| 976 | fi |
| 977 | |
| 978 | AC_SUBST(V_CCOPT) |
| 979 | AC_SUBST(V_DEFS) |
| 980 | AC_SUBST(V_GROUP) |
| 981 | AC_SUBST(V_INCLS) |
| 982 | AC_SUBST(V_PCAPDEP) |
| 983 | AC_SUBST(LOCALSRC) |
| 984 | |
| 985 | AC_PROG_INSTALL |
| 986 | |
| 987 | AC_CONFIG_HEADER(config.h) |
| 988 | |
| 989 | AC_OUTPUT_COMMANDS([if test -f .devel; then |
| 990 | echo timestamp > stamp-h |
| 991 | cat Makefile-devel-adds >> Makefile |
| 992 | make depend |
| 993 | fi]) |
| 994 | AC_OUTPUT(Makefile) |
| 995 | exit 0 |