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