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