1214478Srpaulodnl @(#) $Header: /tcpdump/master/tcpdump/configure.in,v 1.204 2008-11-18 07:39:20 guy Exp $ (LBL)
217680Spstdnl
339297Sfennerdnl Copyright (c) 1994, 1995, 1996, 1997
417680Spstdnl	The Regents of the University of California.  All rights reserved.
517680Spstdnl
617680Spstdnl Process this file with autoconf to produce a configure script.
717680Spstdnl
817680Spst
9214478Srpaulo#
10214478Srpaulo# See
11214478Srpaulo#
12214478Srpaulo#	http://ftp.gnu.org/gnu/config/README
13214478Srpaulo#
14214478Srpaulo# for the URLs to use to fetch new versions of config.guess and
15214478Srpaulo# config.sub.
16214478Srpaulo#
17214478Srpaulo
18214478SrpauloAC_REVISION($Revision: 1.204 $)
19127668SbmsAC_PREREQ(2.50)
2017680SpstAC_INIT(tcpdump.c)
2117680Spst
2298524SfennerAC_CANONICAL_HOST
2317680Spst
24214478SrpauloAC_LBL_C_INIT_BEFORE_CC(V_CCOPT, V_INCLS)
25214478SrpauloAC_PROG_CC
2617680SpstAC_LBL_C_INIT(V_CCOPT, V_INCLS)
27111726SfennerAC_LBL_C_INLINE
2875115SfennerAC_C___ATTRIBUTE__
29214478Srpauloif test "$ac_cv___attribute__" = "yes"; then
30214478Srpaulo	AC_C___ATTRIBUTE___FORMAT_FUNCTION_POINTER
31214478Srpaulofi
32235530SdelphijAC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h netdnet/dnetdb.h)
33172683SmlaierAC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
34172683Smlaier#include <sys/socket.h>
35172683Smlaier#include <net/if.h>])
36190207Srpauloif test "$ac_cv_header_net_pfvar_h" = yes; then
37172683Smlaier	LOCALSRC="print-pflog.c $LOCALSRC"
38172683Smlaierfi
39127668SbmsAC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
40127668Sbms#include <sys/socket.h>])
41146773Ssamif test "$ac_cv_header_netinet_if_ether_h" != yes; then
42146773Ssam	#
43146773Ssam	# The simple test didn't work.
44146773Ssam	# Do we need to include <net/if.h> first?
45146773Ssam	# Unset ac_cv_header_netinet_if_ether_h so we don't
46146773Ssam	# treat the previous failure as a cached value and
47146773Ssam	# suppress the next test.
48146773Ssam	#
49146773Ssam	AC_MSG_NOTICE([Rechecking with some additional includes])
50146773Ssam	unset ac_cv_header_netinet_if_ether_h
51146773Ssam	AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
52146773Ssam#include <sys/socket.h>
53146773Ssam#include <netinet/in.h>
54146773Ssamstruct mbuf;
55146773Ssamstruct rtentry;
56146773Ssam#include <net/if.h>])
57146773Ssamfi
58146773Ssam
5917680SpstAC_HEADER_TIME
6017680Spst
6198524Sfennercase "$host_os" in
6239297Sfenner
63235530Sdelphijdarwin*)
64235530Sdelphij	AC_ARG_ENABLE(universal,
65235530Sdelphij	AC_HELP_STRING([--disable-universal],[don't build universal on OS X]))
66235530Sdelphij	if test "$enable_universal" != "no"; then
67235530Sdelphij		case "$host_os" in
68235530Sdelphij
69235530Sdelphij		darwin9.*)
70235530Sdelphij			#
71235530Sdelphij			# Leopard.  Build for x86 and 32-bit PowerPC, with
72235530Sdelphij			# x86 first.  (That's what Apple does.)
73235530Sdelphij			#
74235530Sdelphij			V_CCOPT="$V_CCOPT -arch i386 -arch ppc"
75235530Sdelphij			LDFLAGS="$LDFLAGS -arch i386 -arch ppc"
76235530Sdelphij			;;
77235530Sdelphij
78235530Sdelphij		darwin10.*)
79235530Sdelphij			#
80235530Sdelphij			# Snow Leopard.  Build for x86-64 and x86, with
81235530Sdelphij			# x86-64 first.  (That's what Apple does.)
82235530Sdelphij			#
83235530Sdelphij			V_CCOPT="$V_CCOPT -arch x86_64 -arch i386"
84235530Sdelphij			LDFLAGS="$LDFLAGS -arch x86_64 -arch i386"
85235530Sdelphij			;;
86235530Sdelphij		esac
87235530Sdelphij	fi
88235530Sdelphij	;;
89235530Sdelphij
9039297Sfennerlinux*)
9139297Sfenner	AC_MSG_CHECKING(Linux kernel version)
9275115Sfenner 	if test "$cross_compiling" = yes; then
9375115Sfenner 		AC_CACHE_VAL(ac_cv_linux_vers,
9475115Sfenner 		    ac_cv_linux_vers=unknown)
9575115Sfenner 	else
9675115Sfenner 		AC_CACHE_VAL(ac_cv_linux_vers,
9775115Sfenner 		    ac_cv_linux_vers=`uname -r 2>&1 | \
9875115Sfenner 			sed -n -e '$s/.* //' -e '$s/\..*//p'`)
9975115Sfenner 	fi
10039297Sfenner	AC_MSG_RESULT($ac_cv_linux_vers)
10175115Sfenner 	if test $ac_cv_linux_vers = unknown ; then
10275115Sfenner 		AC_MSG_ERROR(cannot determine linux version when cross-compiling)
10375115Sfenner 	fi
10439297Sfenner	if test $ac_cv_linux_vers -lt 2 ; then
10539297Sfenner		AC_MSG_ERROR(version 2 or higher required; see the INSTALL doc for more info)
10639297Sfenner	fi
10739297Sfenner	;;
10839297Sfenner
10939297Sfenner*)
11039297Sfenner	;;
11139297Sfenneresac
11239297Sfenner
11356893Sfenner
114214478SrpauloAC_ARG_WITH(smi,
115214478Srpaulo[  --with-smi              link with libsmi (allows to load MIBs on the fly to decode SNMP packets. [default=yes]
116214478Srpaulo  --without-smi           don't link with libsmi],,
117214478Srpaulo   with_smi=yes)
118214478Srpaulo
119214478Srpauloif test "x$with_smi" != "xno" ; then
12056893SfennerAC_CHECK_HEADERS(smi.h)
12175115SfennerAC_CHECK_LIB(smi, smiInit)
12298524Sfennerif test "$ac_cv_header_smi_h" = yes -a "$ac_cv_lib_smi_smiInit" = yes
12398524Sfennerthen
12456893SfennerAC_MSG_CHECKING([whether to enable libsmi])
12556893Sfenner        AC_TRY_RUN([ /* libsmi available check */
12656893Sfenner#include <smi.h>
12756893Sfennermain()
12856893Sfenner{
12975115Sfenner  int current, revision, age, n;
13075115Sfenner  const int required = 2;
13156893Sfenner  if (smiInit("")) 
13256893Sfenner    exit(1);
13375115Sfenner  if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
13475115Sfenner    exit(2);
13575115Sfenner  n = sscanf(smi_library_version, "%d:%d:%d", &current, &revision, &age);
13675115Sfenner  if (n != 3)
13775115Sfenner    exit(3);
13875115Sfenner  if (required < current - age || required > current)
13975115Sfenner    exit(4);
14075115Sfenner  exit(0);
14156893Sfenner}
14256893Sfenner],
14356893Sfenner[ AC_MSG_RESULT(yes)
14456893Sfenner  AC_DEFINE(LIBSMI)
14556893Sfenner  libsmi=yes],
14698524Sfennerdnl autoconf documentation says that $? contains the exit value.
14798524Sfennerdnl reality is that it does not.  We leave this in just in case
14898524Sfennerdnl autoconf ever comes back to match the documentation.
14998524Sfenner[ case $? in
15098524Sfenner  1) AC_MSG_RESULT(no - smiInit failed) ;;
15198524Sfenner  2) AC_MSG_RESULT(no - header/library version mismatch) ;;
15298524Sfenner  3) AC_MSG_RESULT(no - can't determine library version) ;;
15398524Sfenner  4) AC_MSG_RESULT(no - too old) ;;
15498524Sfenner  *) AC_MSG_RESULT(no) ;;
15598524Sfenner  esac
15675115Sfenner  libsmi=no],
15775115Sfenner[ AC_MSG_RESULT(not when cross-compiling)
15856893Sfenner  libsmi=no]
15956893Sfenner)
16098524Sfennerfi
161214478Srpaulofi
16256893Sfenner
16398524SfennerAC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer])
16498524SfennerAC_ARG_ENABLE(smb,
16598524Sfenner[  --enable-smb            enable possibly-buggy SMB printer [default=yes]
16698524Sfenner  --disable-smb           disable possibly-buggy SMB printer],,
16798524Sfenner   enableval=yes)
16898524Sfennercase "$enableval" in
16998524Sfenneryes)	AC_MSG_RESULT(yes)
17098524Sfenner	AC_WARN([The SMB printer may have exploitable buffer overflows!!!])
17198524Sfenner	AC_DEFINE(TCPDUMP_DO_SMB)
17298524Sfenner	LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
17398524Sfenner	;;
17498524Sfenner*)	AC_MSG_RESULT(no)
17598524Sfenner	;;
17698524Sfenneresac
17756893Sfenner
178146773SsamAC_ARG_WITH(user, [  --with-user=USERNAME    drop privileges by default to USERNAME])
179146773SsamAC_MSG_CHECKING([whether to drop root privileges by default])
180146773Ssamif test ! -z "$with_user" ; then
181146773Ssam        AC_DEFINE_UNQUOTED(WITH_USER, "$withval")
182146773Ssam       AC_MSG_RESULT(to \"$withval\")
183146773Ssamelse
184146773Ssam       AC_MSG_RESULT(no)
185146773Ssamfi
186146773Ssam
187146773SsamAC_ARG_WITH(chroot, [  --with-chroot=DIRECTORY when dropping privileges, chroot to DIRECTORY])
188146773SsamAC_MSG_CHECKING([whether to chroot])
189214478Srpauloif test ! -z "$with_chroot" && test "$with_chroot" != "no" ; then
190146773Ssam        AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval")
191146773Ssam       AC_MSG_RESULT(to \"$withval\")
192146773Ssamelse
193146773Ssam       AC_MSG_RESULT(no)
194146773Ssamfi
195146773Ssam
19656893SfennerAC_MSG_CHECKING([whether to enable ipv6])
19756893SfennerAC_ARG_ENABLE(ipv6,
19856893Sfenner[  --enable-ipv6           enable ipv6 (with ipv4) support
19956893Sfenner  --disable-ipv6          disable ipv6 support],
20056893Sfenner[ case "$enableval" in
20156893Sfenneryes)   AC_MSG_RESULT(yes)
202235530Sdelphij       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"
20356893Sfenner       AC_DEFINE(INET6)
20456893Sfenner       ipv6=yes
20556893Sfenner       ;;
20656893Sfenner*)
20756893Sfenner       AC_MSG_RESULT(no)
20856893Sfenner       ipv6=no
20956893Sfenner       ;;
21056893Sfenner  esac ],
21156893Sfenner
21256893Sfenner  AC_TRY_RUN([ /* AF_INET6 available check */
21356893Sfenner#include <sys/types.h>
21456893Sfenner#include <sys/socket.h>
21556893Sfennermain()
21656893Sfenner{
21756893Sfenner if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
21856893Sfenner   exit(1);
21956893Sfenner else
22056893Sfenner   exit(0);
22156893Sfenner}
22256893Sfenner],
22356893Sfenner[ AC_MSG_RESULT(yes)
224235530Sdelphij  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"
22556893Sfenner  AC_DEFINE(INET6)
22656893Sfenner  ipv6=yes],
22756893Sfenner[ AC_MSG_RESULT(no)
22856893Sfenner  ipv6=no],
22956893Sfenner[ AC_MSG_RESULT(no)
23056893Sfenner  ipv6=no]
23156893Sfenner))
23256893Sfenner
23356893Sfenneripv6type=unknown
23456893Sfenneripv6lib=none
23556893Sfenneripv6trylibc=no
23656893Sfenner
23756893Sfennerif test "$ipv6" = "yes"; then
23856893Sfenner	AC_MSG_CHECKING([ipv6 stack type])
23956893Sfenner	for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do
24056893Sfenner		case $i in
24156893Sfenner		inria)
24256893Sfenner			dnl http://www.kame.net/
243127668Sbms			AC_EGREP_CPP(yes,
244127668Sbms[#include <netinet/in.h>
24556893Sfenner#ifdef IPV6_INRIA_VERSION
24656893Sfenneryes
24756893Sfenner#endif],
24856893Sfenner				[ipv6type=$i;
24956893Sfenner				CFLAGS="-DINET6 $CFLAGS"])
25056893Sfenner			;;
25156893Sfenner		kame)
25256893Sfenner			dnl http://www.kame.net/
253127668Sbms			AC_EGREP_CPP(yes,
254127668Sbms[#include <netinet/in.h>
25556893Sfenner#ifdef __KAME__
25656893Sfenneryes
25756893Sfenner#endif],
25856893Sfenner				[ipv6type=$i;
25956893Sfenner				ipv6lib=inet6;
26056893Sfenner				ipv6libdir=/usr/local/v6/lib;
26156893Sfenner				ipv6trylibc=yes;
26256893Sfenner				CFLAGS="-DINET6 $CFLAGS"])
26356893Sfenner			;;
26456893Sfenner		linux-glibc)
26556893Sfenner			dnl http://www.v6.linux.or.jp/
266127668Sbms			AC_EGREP_CPP(yes,
267127668Sbms[#include <features.h>
26856893Sfenner#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
26956893Sfenneryes
27056893Sfenner#endif],
27156893Sfenner				[ipv6type=$i;
27256893Sfenner				CFLAGS="-DINET6 $CFLAGS"])
27356893Sfenner			;;
27456893Sfenner		linux-libinet6)
27556893Sfenner			dnl http://www.v6.linux.or.jp/
276127668Sbms			dnl
277127668Sbms			dnl This also matches Solaris 8 and Tru64 UNIX 5.1,
278127668Sbms			dnl and possibly other versions of those OSes
279127668Sbms			dnl
28056893Sfenner			if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then
28156893Sfenner				ipv6type=$i
28256893Sfenner				ipv6lib=inet6
28356893Sfenner				ipv6libdir=/usr/inet6/lib
28456893Sfenner				ipv6trylibc=yes;
28556893Sfenner				CFLAGS="-DINET6 -I/usr/inet6/include $CFLAGS"
28656893Sfenner			fi
28756893Sfenner			;;
28856893Sfenner		toshiba)
289127668Sbms			AC_EGREP_CPP(yes,
290127668Sbms[#include <sys/param.h>
29156893Sfenner#ifdef _TOSHIBA_INET6
29256893Sfenneryes
29356893Sfenner#endif],
29456893Sfenner				[ipv6type=$i;
29556893Sfenner				ipv6lib=inet6;
29656893Sfenner				ipv6libdir=/usr/local/v6/lib;
29756893Sfenner				CFLAGS="-DINET6 $CFLAGS"])
29856893Sfenner			;;
29956893Sfenner		v6d)
300127668Sbms			AC_EGREP_CPP(yes,
301127668Sbms[#include </usr/local/v6/include/sys/v6config.h>
30256893Sfenner#ifdef __V6D__
30356893Sfenneryes
30456893Sfenner#endif],
30556893Sfenner				[ipv6type=$i;
30656893Sfenner				ipv6lib=v6;
30756893Sfenner				ipv6libdir=/usr/local/v6/lib;
30856893Sfenner				CFLAGS="-I/usr/local/v6/include $CFLAGS"])
30956893Sfenner			;;
31056893Sfenner		zeta)
311127668Sbms			AC_EGREP_CPP(yes,
312127668Sbms[#include <sys/param.h>
31356893Sfenner#ifdef _ZETA_MINAMI_INET6
31456893Sfenneryes
31556893Sfenner#endif],
31656893Sfenner				[ipv6type=$i;
31756893Sfenner				ipv6lib=inet6;
31856893Sfenner				ipv6libdir=/usr/local/v6/lib;
31956893Sfenner				CFLAGS="-DINET6 $CFLAGS"])
32056893Sfenner			;;
32156893Sfenner		esac
32256893Sfenner		if test "$ipv6type" != "unknown"; then
32356893Sfenner			break
32456893Sfenner		fi
32556893Sfenner	done
32656893Sfenner	AC_MSG_RESULT($ipv6type)
32756893Sfennerfi
32856893Sfenner
32956893Sfennerif test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
33056893Sfenner	if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
33156893Sfenner		LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
33256893Sfenner		echo "You have $ipv6lib library, using it"
33356893Sfenner	else
33456893Sfenner		if test "$ipv6trylibc" = "yes"; then
33556893Sfenner			echo "You do not have $ipv6lib library, using libc"
33656893Sfenner		else
33756893Sfenner			echo 'Fatal: no $ipv6lib library found.  cannot continue.'
33856893Sfenner			echo "You need to fetch lib$ipv6lib.a from appropriate"
33956893Sfenner			echo 'ipv6 kit and compile beforehand.'
34056893Sfenner			exit 1
34156893Sfenner		fi
34256893Sfenner	fi
34356893Sfennerfi
34456893Sfenner
34556893Sfenner
34656893Sfennerif test "$ipv6" = "yes"; then
347127668Sbms	#
348127668Sbms	# XXX - on Tru64 UNIX 5.1, there is no "getaddrinfo()"
349127668Sbms	# function in libc; there are "ngetaddrinfo()" and
350127668Sbms	# "ogetaddrinfo()" functions, and <netdb.h> #defines
351127668Sbms	# "getaddrinfo" to be either "ngetaddrinfo" or
352127668Sbms	# "ogetaddrinfo", depending on whether _SOCKADDR_LEN
353127668Sbms	# or _XOPEN_SOURCE_EXTENDED are defined or not.
354127668Sbms	#
355127668Sbms	# So this test doesn't work on Tru64 5.1, and possibly
356127668Sbms	# on other 5.x releases.  This causes the configure
357127668Sbms	# script to become confused, and results in libpcap
358127668Sbms	# being unbuildable.
359127668Sbms	#
36075115Sfenner	AC_SEARCH_LIBS(getaddrinfo, socket, [dnl
36156893Sfenner	AC_MSG_CHECKING(getaddrinfo bug)
362127668Sbms	AC_CACHE_VAL(td_cv_buggygetaddrinfo, [AC_TRY_RUN([
36356893Sfenner#include <sys/types.h>
36456893Sfenner#include <netdb.h>
36556893Sfenner#include <string.h>
36656893Sfenner#include <sys/socket.h>
36756893Sfenner#include <netinet/in.h>
36856893Sfenner
36956893Sfennermain()
37056893Sfenner{
37156893Sfenner  int passive, gaierr, inet4 = 0, inet6 = 0;
37256893Sfenner  struct addrinfo hints, *ai, *aitop;
37356893Sfenner  char straddr[INET6_ADDRSTRLEN], strport[16];
37456893Sfenner
37556893Sfenner  for (passive = 0; passive <= 1; passive++) {
37656893Sfenner    memset(&hints, 0, sizeof(hints));
37756893Sfenner    hints.ai_family = AF_UNSPEC;
37856893Sfenner    hints.ai_flags = passive ? AI_PASSIVE : 0;
37956893Sfenner    hints.ai_socktype = SOCK_STREAM;
380127668Sbms    hints.ai_protocol = IPPROTO_TCP;
38156893Sfenner    if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
38256893Sfenner      (void)gai_strerror(gaierr);
38356893Sfenner      goto bad;
38456893Sfenner    }
38556893Sfenner    for (ai = aitop; ai; ai = ai->ai_next) {
38656893Sfenner      if (ai->ai_addr == NULL ||
38756893Sfenner          ai->ai_addrlen == 0 ||
38856893Sfenner          getnameinfo(ai->ai_addr, ai->ai_addrlen,
38956893Sfenner                      straddr, sizeof(straddr), strport, sizeof(strport),
39056893Sfenner                      NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
39156893Sfenner        goto bad;
39256893Sfenner      }
39356893Sfenner      switch (ai->ai_family) {
39456893Sfenner      case AF_INET:
39556893Sfenner        if (strcmp(strport, "54321") != 0) {
39656893Sfenner          goto bad;
39756893Sfenner        }
39856893Sfenner        if (passive) {
39956893Sfenner          if (strcmp(straddr, "0.0.0.0") != 0) {
40056893Sfenner            goto bad;
40156893Sfenner          }
40256893Sfenner        } else {
40356893Sfenner          if (strcmp(straddr, "127.0.0.1") != 0) {
40456893Sfenner            goto bad;
40556893Sfenner          }
40656893Sfenner        }
40756893Sfenner        inet4++;
40856893Sfenner        break;
40956893Sfenner      case AF_INET6:
41056893Sfenner        if (strcmp(strport, "54321") != 0) {
41156893Sfenner          goto bad;
41256893Sfenner        }
41356893Sfenner        if (passive) {
41456893Sfenner          if (strcmp(straddr, "::") != 0) {
41556893Sfenner            goto bad;
41656893Sfenner          }
41756893Sfenner        } else {
41856893Sfenner          if (strcmp(straddr, "::1") != 0) {
41956893Sfenner            goto bad;
42056893Sfenner          }
42156893Sfenner        }
42256893Sfenner        inet6++;
42356893Sfenner        break;
42456893Sfenner      case AF_UNSPEC:
42556893Sfenner        goto bad;
42656893Sfenner        break;
42756893Sfenner#ifdef AF_UNIX
42856893Sfenner      case AF_UNIX:
42956893Sfenner#else
43056893Sfenner#ifdef AF_LOCAL
43156893Sfenner      case AF_LOCAL:
43256893Sfenner#endif
43356893Sfenner#endif
43456893Sfenner      default:
43556893Sfenner        /* another family support? */
43656893Sfenner        break;
43756893Sfenner      }
43856893Sfenner    }
43956893Sfenner  }
44056893Sfenner
44156893Sfenner  /* supported family should be 2, unsupported family should be 0 */
44256893Sfenner  if (!(inet4 == 0 || inet4 == 2))
44356893Sfenner    goto bad;
44456893Sfenner  if (!(inet6 == 0 || inet6 == 2))
44556893Sfenner    goto bad;
44656893Sfenner
44756893Sfenner  if (aitop)
44856893Sfenner    freeaddrinfo(aitop);
44956893Sfenner  exit(0);
45056893Sfenner
45156893Sfenner bad:
45256893Sfenner  if (aitop)
45356893Sfenner    freeaddrinfo(aitop);
45456893Sfenner  exit(1);
45556893Sfenner}
45656893Sfenner],
457127668Sbms	td_cv_buggygetaddrinfo=no,
458127668Sbms	td_cv_buggygetaddrinfo=yes,
459127668Sbms	td_cv_buggygetaddrinfo=yes)])
460127668Sbms	if test "$td_cv_buggygetaddrinfo" = no; then
461127668Sbms		AC_MSG_RESULT(good)
462127668Sbms	else
463127668Sbms		AC_MSG_RESULT(buggy)
464127668Sbms	fi
46556893Sfenner
466127668Sbms	if test "$td_cv_buggygetaddrinfo" = "yes"; then
467127668Sbms		#
468127668Sbms		# XXX - it doesn't appear that "ipv6type" can ever be
469127668Sbms		# set to "linux".  Should this be testing for
470127668Sbms		# "linux-glibc", or for that *or* "linux-libinet6"?
471127668Sbms		# If the latter, note that "linux-libinet6" is also
472127668Sbms		# the type given to some non-Linux OSes.
473127668Sbms		#
47456893Sfenner		if test "$ipv6type" != "linux"; then
47556893Sfenner			echo 'Fatal: You must get working getaddrinfo() function.'
47656893Sfenner			echo '       or you can specify "--disable-ipv6"'.
47756893Sfenner			exit 1
47856893Sfenner		else
47956893Sfenner			echo 'Warning: getaddrinfo() implementation on your system seems be buggy.'
480127668Sbms			echo '         Better upgrade your system library to newest version'
48156893Sfenner			echo '         of GNU C library (aka glibc).'
48256893Sfenner		fi
48356893Sfenner	fi
484127668Sbms	])
485214478Srpaulo	AC_REPLACE_FUNCS(getnameinfo)
48656893Sfennerfi
48756893Sfenner
488127668SbmsAC_CACHE_CHECK([for dnet_htoa declaration in netdnet/dnetdb.h],
489127668Sbms[td_cv_decl_netdnet_dnetdb_h_dnet_htoa],
490127668Sbms[AC_EGREP_HEADER(dnet_htoa, netdnet/dnetdb.h,
491127668Sbms	td_cv_decl_netdnet_dnetdb_h_dnet_htoa=yes,
492127668Sbms	td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no)])
493127668Sbmsif test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then
494127668Sbms	AC_DEFINE(HAVE_NETDNET_DNETDB_H_DNET_HTOA)
49556893Sfennerfi
49656893Sfenner
49756893Sfennerdnl
49856893Sfennerdnl Checks for addrinfo structure
49956893SfennerAC_STRUCT_ADDRINFO(ac_cv_addrinfo)
50056893Sfennerif test "$ac_cv_addrinfo" = no; then
50156893Sfenner	missing_includes=yes
50256893Sfennerfi
50356893Sfenner
50456893Sfennerdnl
50556893Sfennerdnl Checks for NI_MAXSERV
50656893SfennerAC_NI_MAXSERV(ac_cv_maxserv)
50756893Sfennerif test "$ac_cv_maxserv" = no; then
50856893Sfenner	missing_includes=yes
50956893Sfennerfi
51056893Sfenner
51156893Sfennerdnl
51256893Sfennerdnl Checks for NI_NAMEREQD
51356893SfennerAC_NI_NAMEREQD(ac_cv_namereqd)
51456893Sfennerif test "$ac_cv_namereqd" = no; then
51556893Sfenner	missing_includes=yes
51656893Sfennerfi
51756893Sfenner
51856893Sfennerdnl
51956893Sfennerdnl Checks for sockaddr_storage structure
52056893SfennerAC_STRUCT_SA_STORAGE(ac_cv_sa_storage)
52156893Sfennerif test "$ac_cv_sa_storage" = no; then
52256893Sfenner	missing_includes=yes
52356893Sfennerfi
52456893Sfenner
525127668SbmsAC_REPLACE_FUNCS(vfprintf strcasecmp strlcat strlcpy strdup strsep)
526235530SdelphijAC_CHECK_FUNCS(fork vfork strftime)
527146773SsamAC_CHECK_FUNCS(setlinebuf alarm)
52817680Spst
52975115Sfennerneedsnprintf=no
53075115SfennerAC_CHECK_FUNCS(vsnprintf snprintf,,
53175115Sfenner	[needsnprintf=yes])
53275115Sfennerif test $needsnprintf = yes; then
533146773Ssam	AC_LIBOBJ(snprintf)
53475115Sfennerfi
53575115Sfenner
53698524SfennerAC_LBL_TYPE_SIGNAL
53726180Sfenner
538127668SbmsAC_SEARCH_LIBS(dnet_htoa, dnet, AC_DEFINE(HAVE_DNET_HTOA))
53998524Sfenner
54098524SfennerAC_CHECK_LIB(rpc, main)		dnl It's unclear why we might need -lrpc
54198524Sfenner
542146773Ssamdnl Some platforms may need -lnsl for getrpcbynumber.
543146773SsamAC_SEARCH_LIBS(getrpcbynumber, nsl, AC_DEFINE(HAVE_GETRPCBYNUMBER))
54498524Sfenner
54575115Sfennerdnl AC_CHECK_LIB(z, uncompress)
54675115Sfennerdnl AC_CHECK_HEADERS(zlib.h)
54717680Spst
54817680SpstAC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
54917680Spst
550127668Sbms#
551127668Sbms# Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
552127668Sbms# libraries (e.g., "-lsocket -lnsl" on Solaris).
553127668Sbms#
554127668Sbms# We don't use AC_REPLACE_FUNCS because that uses AC_CHECK_FUNCS which
555127668Sbms# use AC_CHECK_FUNC which doesn't let us specify the right #includes
556127668Sbms# to make this work on BSD/OS 4.x.  BSD/OS 4.x ships with the BIND8
557127668Sbms# resolver, and the way it defines inet_{ntop,pton} is rather strange;
558127668Sbms# it does not ship with a libc symbol "inet_ntop()", it ships with
559127668Sbms# "_inet_ntop()", and has a #define macro in one of the system headers
560127668Sbms# to rename it.
561127668Sbms#
562127668Sbmsdnl AC_TRY_COMPILE(inet_ntop inet_pton inet_aton)
563127668SbmsAC_MSG_CHECKING(for inet_ntop)
564127668SbmsAC_TRY_LINK([#include <sys/types.h>
565127668Sbms#include <sys/socket.h>
566127668Sbms#include <netinet/in.h>
567127668Sbms#include <arpa/inet.h>], [char src[4], dst[128];
568127668Sbmsinet_ntop(AF_INET, src, dst, sizeof(dst));],
569127668Sbms	[AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
570146773Ssam	AC_LIBOBJ(inet_ntop)])
571127668SbmsAC_MSG_CHECKING(for inet_pton)
572127668SbmsAC_TRY_LINK([#include <sys/types.h>
573127668Sbms#include <sys/socket.h>
574127668Sbms#include <netinet/in.h>
575127668Sbms#include <arpa/inet.h>], [char src[128], dst[4];
576127668Sbmsinet_pton(AF_INET, src, dst);],
577127668Sbms	[AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
578146773Ssam	AC_LIBOBJ(inet_pton)])
579127668SbmsAC_MSG_CHECKING(for inet_aton)
580127668SbmsAC_TRY_LINK([#include <sys/types.h>
581127668Sbms#include <netinet/in.h>
582127668Sbms#include <arpa/inet.h>], [char src[128];
583127668Sbmsstruct in_addr dst;
584127668Sbmsinet_aton(src, &dst);],
585127668Sbms	[AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)
586146773Ssam	AC_LIBOBJ(inet_aton)])
587127668Sbms
588146773Ssam#
589146773Ssam# Check for these after AC_LBL_LIBPCAP, for the same reason.
590146773Ssam#
591146773Ssam# You are in a twisty little maze of UN*Xes, all different.
592146773Ssam# Some might not have ether_ntohost().
593146773Ssam# Some might have it, but not declare it in any header file.
594146773Ssam# Some might have it, but declare it in <netinet/if_ether.h>.
595146773Ssam# Some might have it, but declare it in <netinet/ether.h>
596146773Ssam# (And some might have it but document it as something declared in
597146773Ssam# <netinet/ethernet.h>, although <netinet/if_ether.h> appears to work.)
598146773Ssam#
599146773Ssam# Before you is a C compiler.
600146773Ssam#
601146773SsamAC_CHECK_FUNCS(ether_ntohost, [
602146773Ssam    AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [
603146773Ssam	AC_TRY_RUN([
604146773Ssam		#include <netdb.h>
605146773Ssam		#include <sys/types.h>
606146773Ssam		#include <sys/param.h>
607146773Ssam		#include <sys/socket.h>
608146773Ssam
609146773Ssam		int
610146773Ssam		main(int argc, char **argv)
611146773Ssam		{
612146773Ssam			u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff };
613146773Ssam			char name[MAXHOSTNAMELEN];
614146773Ssam
615146773Ssam			ether_ntohost(name, (struct ether_addr *)ea);
616146773Ssam			exit(0);
617146773Ssam		}
618146773Ssam	], [ac_cv_buggy_ether_ntohost=no],
619146773Ssam	   [ac_cv_buggy_ether_ntohost=yes],
620146773Ssam	   [ac_cv_buggy_ether_ntohost="not while cross-compiling"])])
621146773Ssam    if test "$ac_cv_buggy_ether_ntohost" = "no"; then
622146773Ssam	AC_DEFINE(USE_ETHER_NTOHOST)
623146773Ssam    fi
624146773Ssam])
625146773Ssamif test "$ac_cv_func_ether_ntohost" = yes -a \
626146773Ssam    "$ac_cv_buggy_ether_ntohost" = "no"; then
627146773Ssam	#
628146773Ssam	# OK, we have ether_ntohost().  Do we have <netinet/if_ether.h>?
629146773Ssam	#
630146773Ssam	if test "$ac_cv_header_netinet_if_ether_h" = yes; then
631146773Ssam		#
632146773Ssam		# Yes.  Does it declare ether_ntohost()?
633146773Ssam		#
634147899Ssam		AC_CHECK_DECL(ether_ntohost,
635146773Ssam		    [
636146773Ssam			AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST,,
637146773Ssam			    [Define to 1 if netinet/if_ether.h declares `ether_ntohost'])
638146773Ssam		    ],,
639146773Ssam		    [
640146773Ssam#include <sys/types.h>
641146773Ssam#include <sys/socket.h>
642146773Ssam#include <netinet/in.h>
643147899Ssam#include <arpa/inet.h>
644146773Ssamstruct mbuf;
645146773Ssamstruct rtentry;
646146773Ssam#include <net/if.h>
647146773Ssam#include <netinet/if_ether.h>
648146773Ssam		    ])
649146773Ssam	fi
650146773Ssam	#
651146773Ssam	# Did that succeed?
652146773Ssam	#
653146773Ssam	if test "$ac_cv_have_decl_ether_ntohost" != yes; then
654146773Ssam		#
655146773Ssam		# No, how about <netinet/ether.h>, as on Linux?
656146773Ssam		#
657146773Ssam		AC_CHECK_HEADERS(netinet/ether.h)
658146773Ssam		if test "$ac_cv_header_netinet_ether_h" = yes; then
659146773Ssam			#
660146773Ssam			# We have it - does it declare ether_ntohost()?
661146773Ssam			# Unset ac_cv_have_decl_ether_ntohost so we don't
662146773Ssam			# treat the previous failure as a cached value and
663146773Ssam			# suppress the next test.
664146773Ssam			#
665146773Ssam			unset ac_cv_have_decl_ether_ntohost
666147899Ssam			AC_CHECK_DECL(ether_ntohost,
667146773Ssam			    [
668146773Ssam				AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,,
669146773Ssam				    [Define to 1 if netinet/ether.h declares `ether_ntohost'])
670146773Ssam			    ],,
671146773Ssam			    [
672146773Ssam#include <netinet/ether.h>
673146773Ssam			    ])
674146773Ssam		fi
675146773Ssam	fi
676147899Ssam	#
677147899Ssam	# Is ether_ntohost() declared?
678147899Ssam	#
679147899Ssam	if test "$ac_cv_have_decl_ether_ntohost" != yes; then
680147899Ssam		#
681147899Ssam		# No, we'll have to declare it ourselves.
682147899Ssam		# Do we have "struct ether_addr"?
683147899Ssam		#
684147899Ssam		AC_CHECK_TYPES(struct ether_addr,,,
685147899Ssam		    [
686147899Ssam#include <sys/types.h>
687147899Ssam#include <sys/socket.h>
688147899Ssam#include <netinet/in.h>
689147899Ssam#include <arpa/inet.h>
690147899Ssamstruct mbuf;
691147899Ssamstruct rtentry;
692147899Ssam#include <net/if.h>
693147899Ssam#include <netinet/if_ether.h>
694147899Ssam		    ])
695147899Ssam		AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 0,
696147899Ssam		    [Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
697147899Ssamdon't.])
698147899Ssam	else
699147899Ssam		AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 1,
700147899Ssam		    [Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
701147899Ssamdon't.])
702147899Ssam	fi
703146773Ssamfi
704146773Ssam
705190207Srpaulo# libdlpi is needed for Solaris 11 and later.
706190207SrpauloAC_CHECK_LIB(dlpi, dlpi_walk, LIBS="$LIBS -ldlpi" LDFLAGS="-L/lib $LDFLAGS", ,-L/lib)
707190207Srpaulo
708127668Sbmsdnl portability macros for getaddrinfo/getnameinfo
709127668Sbmsdnl
710127668Sbmsdnl Check for sa_len
711127668SbmsAC_CHECK_SA_LEN(ac_cv_sockaddr_has_sa_len)
712127668Sbmsif test "$ac_cv_sockaddr_has_sa_len" = no; then
713127668Sbms	missing_includes=yes
714127668Sbmsfi
715127668Sbms
716190207Srpaulo#
717190207Srpaulo# Do we have the new open API?  Check for pcap_create, and assume that,
718235530Sdelphij# if we do, we also have pcap_activate() and the other new routines
719235530Sdelphij# introduced in libpcap 1.0.0.
720235530Sdelphij#
721190207SrpauloAC_CHECK_FUNCS(pcap_create)
722235530Sdelphijif test $ac_cv_func_pcap_create = "yes" ; then
723235530Sdelphij	#
724235530Sdelphij	# OK, do we have pcap_set_tstamp_type?  If so, assume we have
725235530Sdelphij	# pcap_list_tstamp_types and pcap_free_tstamp_types as well.
726235530Sdelphij	#
727235530Sdelphij	AC_CHECK_FUNCS(pcap_set_tstamp_type)
728235530Sdelphijfi
729190207Srpaulo
730127668SbmsAC_CHECK_FUNCS(pcap_findalldevs pcap_dump_flush pcap_lib_version)
731127668Sbmsif test $ac_cv_func_pcap_findalldevs = "yes" ; then
732146773Ssamdnl Check for Mac OS X, which may ship pcap.h from 0.6 but libpcap may
733127668Sbmsdnl be 0.8; this means that lib has pcap_findalldevs but header doesn't
734127668Sbmsdnl have pcap_if_t.
735241235Sdelphij    savedcppflags="$CPPFLAGS"
736190207Srpaulo    CPPFLAGS="$CPPFLAGS $V_INCLS"
737127668Sbms    AC_CHECK_TYPES(pcap_if_t, , , [#include <pcap.h>])
738190207Srpaulo    CPPFLAGS="$savedcppflags"
739127668Sbmsfi
740146773Ssam
741127668Sbmsif test $ac_cv_func_pcap_lib_version = "no" ; then
742127668Sbms    AC_MSG_CHECKING(whether pcap_version is defined by libpcap)
743127668Sbms    AC_TRY_LINK([],
744127668Sbms       [
745127668Sbms	extern char pcap_version[];
746127668Sbms
747146773Ssam	return (int)pcap_version;
748127668Sbms       ],
749127668Sbms       ac_lbl_cv_pcap_version_defined=yes,
750127668Sbms       ac_lbl_cv_pcap_version_defined=no)
751127668Sbms    if test "$ac_lbl_cv_pcap_version_defined" = yes ; then
752127668Sbms    	AC_MSG_RESULT(yes)
753127668Sbms	AC_DEFINE(HAVE_PCAP_VERSION)
754127668Sbms    else
755127668Sbms	AC_MSG_RESULT(no)
756127668Sbms    fi
757127668Sbmsfi
758127668SbmsAC_MSG_CHECKING(whether pcap_debug is defined by libpcap)
759127668SbmsAC_TRY_LINK([],
760127668Sbms   [
761127668Sbms	extern int pcap_debug;
762127668Sbms
763127668Sbms	return pcap_debug;
764127668Sbms   ],
765127668Sbms   ac_lbl_cv_pcap_debug_defined=yes,
766127668Sbms   ac_lbl_cv_pcap_debug_defined=no)
767127668Sbmsif test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
768127668Sbms	AC_MSG_RESULT(yes)
769127668Sbms	AC_DEFINE(HAVE_PCAP_DEBUG)
770127668Sbmselse
771127668Sbms	AC_MSG_RESULT(no)
772127668Sbms	#
773127668Sbms	# OK, what about "yydebug"?
774127668Sbms	#
775127668Sbms	AC_MSG_CHECKING(whether yydebug is defined by libpcap)
776127668Sbms	AC_TRY_LINK([],
777127668Sbms	   [
778127668Sbms		extern int yydebug;
779127668Sbms
780127668Sbms		return yydebug;
781127668Sbms	   ],
782127668Sbms	   ac_lbl_cv_yydebug_defined=yes,
783127668Sbms	   ac_lbl_cv_yydebug_defined=no)
784127668Sbms	if test "$ac_lbl_cv_yydebug_defined" = yes ; then
785127668Sbms		AC_MSG_RESULT(yes)
786127668Sbms		AC_DEFINE(HAVE_YYDEBUG)
787127668Sbms	else
788127668Sbms		AC_MSG_RESULT(no)
789127668Sbms	fi
790127668Sbmsfi
79175115SfennerAC_REPLACE_FUNCS(bpf_dump)	dnl moved to libpcap in 0.6
79275115Sfenner
79317680SpstV_GROUP=0
79439297Sfennerif test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then
79539297Sfenner	V_GROUP=wheel
79639297Sfennerfi
797214478Srpaulo#
798214478Srpaulo# Assume V7/BSD convention for man pages (file formats in section 5,
799214478Srpaulo# miscellaneous info in section 7).
800214478Srpaulo#
801214478SrpauloMAN_FILE_FORMATS=5
802214478SrpauloMAN_MISC_INFO=7
80398524Sfennercase "$host_os" in
80417680Spst
80517680Spstaix*)
80617680Spst	dnl Workaround to enable certain features
807235530Sdelphij	AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
80817680Spst	;;
80917680Spst
810214478Srpaulohpux*)
811214478Srpaulo	#
812214478Srpaulo	# Use System V conventions for man pages.
813214478Srpaulo	#
814214478Srpaulo	MAN_FILE_FORMATS=4
815214478Srpaulo	MAN_MISC_INFO=5
816214478Srpaulo	;;
817214478Srpaulo
81817680Spstirix*)
81917680Spst	V_GROUP=sys
820214478Srpaulo
821214478Srpaulo	#
822214478Srpaulo	# Use System V conventions for man pages.
823214478Srpaulo	#
824214478Srpaulo	MAN_FILE_FORMATS=4
825214478Srpaulo	MAN_MISC_INFO=5
82617680Spst	;;
82717680Spst
82817680Spstosf*)
82917680Spst	V_GROUP=system
830214478Srpaulo
831214478Srpaulo	#
832214478Srpaulo	# Use System V conventions for man pages.
833214478Srpaulo	#
834214478Srpaulo	MAN_FILE_FORMATS=4
835214478Srpaulo	MAN_MISC_INFO=5
83617680Spst	;;
83717680Spst
83817680Spstsolaris*)
83917680Spst	V_GROUP=sys
840214478Srpaulo
841214478Srpaulo	#
842214478Srpaulo	# Use System V conventions for man pages.
843214478Srpaulo	#
844214478Srpaulo	MAN_FILE_FORMATS=4
845214478Srpaulo	MAN_MISC_INFO=5
84617680Spst	;;
84717680Spstesac
84817680Spst
84917680Spstif test -f /dev/bpf0 ; then
85017680Spst	V_GROUP=bpf
85117680Spstfi
85217680Spst
853147899SsamAC_CHECK_HEADERS(sys/bitypes.h)
85417680Spst
855147899SsamAC_CHECK_TYPE([int8_t], ,
856147899Ssam	[AC_DEFINE([int8_t], [signed char],
857214478Srpaulo	[Define to `signed char' if int8_t not defined.])],
858214478Srpaulo	[AC_INCLUDES_DEFAULT
859214478Srpaulo#ifdef HAVE_SYS_BITYPES_H
860214478Srpaulo#include <sys/bitypes.h>
861214478Srpaulo#endif])
862147899SsamAC_CHECK_TYPE([u_int8_t], ,
863147899Ssam	[AC_DEFINE([u_int8_t], [unsigned char],
864147899Ssam	[Define to `unsigned char' if u_int8_t not defined.])],
865147899Ssam	[AC_INCLUDES_DEFAULT
866147899Ssam#ifdef HAVE_SYS_BITYPES_H
867147899Ssam#include <sys/bitypes.h>
868147899Ssam#endif])
869147899SsamAC_CHECK_TYPE([int16_t], ,
870147899Ssam	[AC_DEFINE([int16_t], [short],
871214478Srpaulo	[Define to `short' if int16_t not defined.])]
872214478Srpaulo	[AC_INCLUDES_DEFAULT
873214478Srpaulo#ifdef HAVE_SYS_BITYPES_H
874214478Srpaulo#include <sys/bitypes.h>
875214478Srpaulo#endif])
876147899SsamAC_CHECK_TYPE([u_int16_t], ,
877147899Ssam	[AC_DEFINE([u_int16_t], [unsigned short],
878147899Ssam	[Define to `unsigned short' if u_int16_t not defined.])],
879147899Ssam	[AC_INCLUDES_DEFAULT
880147899Ssam#ifdef HAVE_SYS_BITYPES_H
881147899Ssam#include <sys/bitypes.h>
882147899Ssam#endif])
883147899SsamAC_CHECK_TYPE([int32_t], ,
884147899Ssam	[AC_DEFINE([int32_t], [int],
885214478Srpaulo	[Define to `int' if int32_t not defined.])],
886214478Srpaulo	[AC_INCLUDES_DEFAULT
887214478Srpaulo#ifdef HAVE_SYS_BITYPES_H
888214478Srpaulo#include <sys/bitypes.h>
889214478Srpaulo#endif])
890147899SsamAC_CHECK_TYPE([u_int32_t], ,
891147899Ssam	[AC_DEFINE([u_int32_t], [unsigned int],
892147899Ssam	[Define to `unsigned int' if u_int32_t not defined.])],
893147899Ssam	[AC_INCLUDES_DEFAULT
894147899Ssam#ifdef HAVE_SYS_BITYPES_H
895147899Ssam#include <sys/bitypes.h>
896147899Ssam#endif])
897147899SsamAC_CHECK_TYPE([int64_t], ,
898147899Ssam	[AC_DEFINE([int64_t], [long long],
899214478Srpaulo	[Define to `long long' if int64_t not defined.])],
900214478Srpaulo	[AC_INCLUDES_DEFAULT
901214478Srpaulo#ifdef HAVE_SYS_BITYPES_H
902214478Srpaulo#include <sys/bitypes.h>
903214478Srpaulo#endif])
904147899SsamAC_CHECK_TYPE([u_int64_t], ,
905147899Ssam	[AC_DEFINE([u_int64_t], [unsigned long long],
906147899Ssam	[Define to `unsigned long long' if u_int64_t not defined.])],
907147899Ssam	[AC_INCLUDES_DEFAULT
908147899Ssam#ifdef HAVE_SYS_BITYPES_H
909147899Ssam#include <sys/bitypes.h>
910147899Ssam#endif])
911147899Ssam
912146773Ssam#
913146773Ssam# We can't just check for <inttypes.h> - some systems have one that
914146773Ssam# doesn't define all the PRI[doxu]64 macros.
915146773Ssam#
916146773SsamAC_CHECK_HEADERS(inttypes.h,
917146773Ssam  [
918146773Ssam    #
919146773Ssam    # OK, we have inttypes.h, but does it define those macros?
920146773Ssam    #
921146773Ssam    AC_MSG_CHECKING([[whether inttypes.h defines the PRI[doxu]64 macros]])
922146773Ssam    AC_COMPILE_IFELSE(
923146773Ssam      [
924146773Ssam	AC_LANG_SOURCE(
925146773Ssam	  [[
926146773Ssam	    #include <inttypes.h>
927146773Ssam	    #include <stdio.h>
928146773Ssam	    #include <sys/types.h>
929147899Ssam	    #ifdef HAVE_SYS_BITYPES_H
930147899Ssam	    #include <sys/bitypes.h>
931147899Ssam	    #endif
932146773Ssam
933146773Ssam	    main()
934146773Ssam	    {
935146773Ssam	      printf("%" PRId64 "\n", (u_int64_t)1);
936146773Ssam	      printf("%" PRIo64 "\n", (u_int64_t)1);
937146773Ssam	      printf("%" PRIx64 "\n", (u_int64_t)1);
938146773Ssam	      printf("%" PRIu64 "\n", (u_int64_t)1);
939146773Ssam	    }
940146773Ssam	  ]])
941146773Ssam      ],
942146773Ssam      [
943146773Ssam	AC_MSG_RESULT(yes)
944146773Ssam	ac_lbl_inttypes_h_defines_formats=yes
945146773Ssam      ],
946146773Ssam      [
947146773Ssam	AC_MSG_RESULT(no)
948146773Ssam	ac_lbl_inttypes_h_defines_formats=no
949146773Ssam      ])
950146773Ssam  ],
951146773Ssam  [
952146773Ssam    #
953146773Ssam    # We don't have inttypes.h, so it obviously can't define those
954146773Ssam    # macros.
955146773Ssam    #
956146773Ssam    ac_lbl_inttypes_h_defines_formats=no
957146773Ssam  ])
958147899Ssamif test "$ac_lbl_inttypes_h_defines_formats" = no; then
959147899Ssam  AC_LBL_CHECK_64BIT_FORMAT(l,
960146773Ssam    [
961147899Ssam      AC_LBL_CHECK_64BIT_FORMAT(ll,
962147899Ssam        [
963147899Ssam          AC_LBL_CHECK_64BIT_FORMAT(L,
964146773Ssam	    [
965147899Ssam	      AC_LBL_CHECK_64BIT_FORMAT(q,
966147899Ssam	        [
967147899Ssam	          AC_MSG_ERROR([neither %llx nor %Lx nor %qx worked on a 64-bit integer])
968147899Ssam	        ])
969146773Ssam	    ])
970146773Ssam	])
971146773Ssam    ])
972146773Ssamfi
973146773Ssam
974235530Sdelphij#
975235530Sdelphij# Check for some headers introduced in later versions of libpcap
976235530Sdelphij# and used by some printers.
977235530Sdelphij#
978235530Sdelphij# Those headers use the {u_}intN_t types, so we must do this after
979235530Sdelphij# we check for what's needed to get them defined.
980235530Sdelphij#
981235530Sdelphijsavedcppflags="$CPPFLAGS"
982235530SdelphijCPPFLAGS="$CPPFLAGS $V_INCLS"
983235530SdelphijAC_CHECK_HEADERS(pcap/bluetooth.h,,,[#include <tcpdump-stdinc.h>])
984235530SdelphijAC_CHECK_HEADERS(pcap/usb.h,,,[#include <tcpdump-stdinc.h>])
985235530SdelphijCPPFLAGS="$savedcppflags"
986235530Sdelphij
987190207SrpauloAC_PROG_RANLIB
988190207Srpaulo
98917680SpstAC_LBL_DEVEL(V_CCOPT)
99017680Spst
99117680SpstAC_LBL_SOCKADDR_SA_LEN
99217680Spst
99317680SpstAC_LBL_UNALIGNED_ACCESS
99417680Spst
99556893SfennerAC_VAR_H_ERRNO
99656893Sfenner
997251158Sdelphij# Check for OpenSSL libcrypto
998251158SdelphijAC_MSG_CHECKING(whether to use OpenSSL libcrypto)
999190207Srpaulo# Specify location for both includes and libraries.
1000251158Sdelphijwant_libcrypto=ifavailable
1001190207SrpauloAC_ARG_WITH(crypto,
1002251158Sdelphij    AS_HELP_STRING([--with-crypto],
1003251158Sdelphij		   [use OpenSSL libcrypto @<:@default=yes, if available@:>@]),
1004190207Srpaulo[
1005190207Srpaulo	if test $withval = no
1006190207Srpaulo	then
1007190207Srpaulo		want_libcrypto=no
1008190207Srpaulo		AC_MSG_RESULT(no)
1009190207Srpaulo	elif test $withval = yes
1010190207Srpaulo	then
1011190207Srpaulo		want_libcrypto=yes
1012190207Srpaulo		AC_MSG_RESULT(yes)
1013190207Srpaulo	fi
1014190207Srpaulo],[
1015127668Sbms	#
1016190207Srpaulo	# Use libcrypto if it's present, otherwise don't.
1017127668Sbms	#
1018190207Srpaulo	want_libcrypto=ifavailable
1019190207Srpaulo	AC_MSG_RESULT([yes, if available])
1020190207Srpaulo])
1021190207Srpauloif test "$want_libcrypto" != "no"; then
1022251158Sdelphij	AC_CHECK_LIB(crypto, DES_cbc_encrypt)
1023251158Sdelphij	AC_CHECK_HEADERS(openssl/evp.h)
102439297Sfennerfi
102539297Sfenner
1026146773Ssamdnl
1027146773Ssamdnl set additional include path if necessary
1028146773Ssamif test "$missing_includes" = "yes"; then
1029235530Sdelphij	CPPFLAGS="$CPPFLAGS -I$srcdir/missing"
1030235530Sdelphij	V_INCLS="$V_INCLS -I$srcdir/missing"
1031146773Ssamfi
1032146773Ssam
103317680SpstAC_SUBST(V_CCOPT)
1034127668SbmsAC_SUBST(V_DEFS)
103517680SpstAC_SUBST(V_GROUP)
103617680SpstAC_SUBST(V_INCLS)
103717680SpstAC_SUBST(V_PCAPDEP)
103856893SfennerAC_SUBST(LOCALSRC)
1039214478SrpauloAC_SUBST(MAN_FILE_FORMATS)
1040214478SrpauloAC_SUBST(MAN_MISC_INFO)
104117680Spst
104217680SpstAC_PROG_INSTALL
104317680Spst
104456893SfennerAC_CONFIG_HEADER(config.h)
104556893Sfenner
104675115SfennerAC_OUTPUT_COMMANDS([if test -f .devel; then
104775115Sfenner	echo timestamp > stamp-h
104875115Sfenner	cat Makefile-devel-adds >> Makefile
104975115Sfenner	make depend
105075115Sfennerfi])
1051214478SrpauloAC_OUTPUT(Makefile tcpdump.1)
105217680Spstexit 0
1053