xref: /netbsd-src/external/bsd/tcpdump/dist/configure.ac (revision c41df9f6167ea7cd2f761f0a97783c8267cb8847)
14c1a0b88Schristosdnl Copyright (c) 1994, 1995, 1996, 1997
24c1a0b88Schristosdnl	The Regents of the University of California.  All rights reserved.
34c1a0b88Schristosdnl
44c1a0b88Schristosdnl Process this file with autoconf to produce a configure script.
54c1a0b88Schristosdnl
64c1a0b88Schristos
74c1a0b88Schristos#
84c1a0b88Schristos# See
94c1a0b88Schristos#
10d881c474Schristos#	https://ftp.gnu.org/gnu/config/README
114c1a0b88Schristos#
124c1a0b88Schristos# for the URLs to use to fetch new versions of config.guess and
134c1a0b88Schristos# config.sub.
144c1a0b88Schristos#
154c1a0b88Schristos
16*c41df9f6SchristosAC_PREREQ([2.69])
17*c41df9f6SchristosAC_INIT([tcpdump],[m4_esyscmd_s(cat VERSION)])
18d881c474SchristosAC_CONFIG_SRCDIR(tcpdump.c)
194c1a0b88Schristos
204c1a0b88SchristosAC_CANONICAL_HOST
214c1a0b88Schristos
224c1a0b88SchristosAC_LBL_C_INIT_BEFORE_CC(V_INCLS)
23d881c474Schristos#
24d881c474Schristos# Try to enable as many C99 features as we can.
25d881c474Schristos# At minimum, we want C++/C99-style // comments.
26d881c474Schristos#
27d881c474SchristosAC_PROG_CC_C99
28d881c474Schristosif test "$ac_cv_prog_cc_c99" = "no"; then
29d881c474Schristos	AC_MSG_WARN([The C compiler does not support C99; there may be compiler errors])
30d881c474Schristosfi
314c1a0b88SchristosAC_LBL_C_INIT(V_CCOPT, V_INCLS)
324c1a0b88SchristosAC_LBL_C_INLINE
334c1a0b88Schristos
34*c41df9f6SchristosAC_CHECK_HEADERS(rpc/rpc.h rpc/rpcent.h net/if.h)
35*c41df9f6Schristos#
36*c41df9f6Schristos# Get the size of a void *, to know whether this is a 32-bit or 64-bit build.
37*c41df9f6Schristos#
38*c41df9f6SchristosAC_CHECK_SIZEOF([void *])
39*c41df9f6Schristos
40*c41df9f6Schristos#
41*c41df9f6Schristos# Get the size of a time_t, to know whether it's 32-bit or 64-bit.
42*c41df9f6Schristos#
43*c41df9f6SchristosAC_CHECK_SIZEOF([time_t],,[#include <time.h>])
444c1a0b88Schristos
454c1a0b88Schristoscase "$host_os" in
464c1a0b88Schristos
474c1a0b88Schristosdarwin*)
484c1a0b88Schristos	AC_ARG_ENABLE(universal,
49d881c474Schristos	AS_HELP_STRING([--disable-universal],[don't build universal on macOS]))
504c1a0b88Schristos	if test "$enable_universal" != "no"; then
514c1a0b88Schristos		case "$host_os" in
524c1a0b88Schristos
534c1a0b88Schristos		darwin9.*)
544c1a0b88Schristos			#
554c1a0b88Schristos			# Leopard.  Build for x86 and 32-bit PowerPC, with
564c1a0b88Schristos			# x86 first.  (That's what Apple does.)
574c1a0b88Schristos			#
584c1a0b88Schristos			V_CCOPT="$V_CCOPT -arch i386 -arch ppc"
594c1a0b88Schristos			LDFLAGS="$LDFLAGS -arch i386 -arch ppc"
604c1a0b88Schristos			;;
614c1a0b88Schristos
624c1a0b88Schristos		darwin10.*)
634c1a0b88Schristos			#
644c1a0b88Schristos			# Snow Leopard.  Build for x86-64 and x86, with
654c1a0b88Schristos			# x86-64 first.  (That's what Apple does.)
664c1a0b88Schristos			#
674c1a0b88Schristos			V_CCOPT="$V_CCOPT -arch x86_64 -arch i386"
684c1a0b88Schristos			LDFLAGS="$LDFLAGS -arch x86_64 -arch i386"
694c1a0b88Schristos			;;
704c1a0b88Schristos		esac
714c1a0b88Schristos	fi
724c1a0b88Schristos	;;
734c1a0b88Schristosesac
744c1a0b88Schristos
75*c41df9f6Schristos#
76*c41df9f6Schristos# Do we have pkg-config?
77*c41df9f6Schristos#
78*c41df9f6SchristosPKG_PROG_PKG_CONFIG
79*c41df9f6Schristos
80*c41df9f6Schristos#
81*c41df9f6Schristos# Do we have the brew command from Homebrew?
82*c41df9f6Schristos#
83*c41df9f6SchristosAC_PATH_PROG([BREW], [brew])
844c1a0b88Schristos
85d881c474SchristosAC_ARG_WITH([smi],
86d881c474Schristos   [AS_HELP_STRING([--with-smi],
87d881c474Schristos     [link with libsmi (allows to load MIBs on the fly to decode SNMP packets) [default=yes, if available]])],
88d881c474Schristos   [],
89d881c474Schristos   [with_smi=yes])
904c1a0b88Schristos
914c1a0b88Schristosif test "x$with_smi" != "xno" ; then
924c1a0b88Schristos	AC_CHECK_HEADER(smi.h,
934c1a0b88Schristos	[
944c1a0b88Schristos		#
954c1a0b88Schristos		# OK, we found smi.h.  Do we have libsmi with smiInit?
964c1a0b88Schristos		#
974c1a0b88Schristos		AC_CHECK_LIB(smi, smiInit,
984c1a0b88Schristos		[
994c1a0b88Schristos			#
1004c1a0b88Schristos			# OK, we have libsmi with smiInit.  Can we use it?
1014c1a0b88Schristos			#
1024c1a0b88Schristos			AC_MSG_CHECKING([whether to enable libsmi])
1034c1a0b88Schristos			savedlibs="$LIBS"
1044c1a0b88Schristos			LIBS="-lsmi $LIBS"
105*c41df9f6Schristos			AC_RUN_IFELSE([AC_LANG_SOURCE([[
1064c1a0b88Schristos/* libsmi available check */
107d881c474Schristos#include <stdio.h>
108d881c474Schristos#include <stdlib.h>
109d881c474Schristos#include <string.h>
1104c1a0b88Schristos#include <smi.h>
111d881c474Schristosint main()
1124c1a0b88Schristos{
1134c1a0b88Schristos  int current, revision, age, n;
1144c1a0b88Schristos  const int required = 2;
1154c1a0b88Schristos  if (smiInit(""))
1164c1a0b88Schristos    exit(1);
1174c1a0b88Schristos  if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
1184c1a0b88Schristos    exit(2);
1194c1a0b88Schristos  n = sscanf(smi_library_version, "%d:%d:%d", &current, &revision, &age);
1204c1a0b88Schristos  if (n != 3)
1214c1a0b88Schristos    exit(3);
1224c1a0b88Schristos  if (required < current - age || required > current)
1234c1a0b88Schristos    exit(4);
1244c1a0b88Schristos  exit(0);
1254c1a0b88Schristos}
126*c41df9f6Schristos				]])
1274c1a0b88Schristos				],
1284c1a0b88Schristos				[
1294c1a0b88Schristos					AC_MSG_RESULT(yes)
1304c1a0b88Schristos					AC_DEFINE(USE_LIBSMI, 1,
1314c1a0b88Schristos					    [Define if you enable support for libsmi])
1324c1a0b88Schristos				],
1334c1a0b88Schristos				[
1344c1a0b88Schristos					dnl autoconf documentation says that
1354c1a0b88Schristos					dnl $? contains the exit value.
1364c1a0b88Schristos					dnl reality is that it does not.
1374c1a0b88Schristos					dnl We leave this in just in case
1384c1a0b88Schristos					dnl autoconf ever comes back to
1394c1a0b88Schristos					dnl match the documentation.
1404c1a0b88Schristos					case $? in
1414c1a0b88Schristos					  1) AC_MSG_RESULT(no - smiInit failed) ;;
1424c1a0b88Schristos					  2) AC_MSG_RESULT(no - header/library version mismatch) ;;
1434c1a0b88Schristos					  3) AC_MSG_RESULT(no - can't determine library version) ;;
1444c1a0b88Schristos					  4) AC_MSG_RESULT(no - too old) ;;
1454c1a0b88Schristos					  *) AC_MSG_RESULT(no) ;;
1464c1a0b88Schristos					esac
1474c1a0b88Schristos					LIBS="$savedlibs"
1484c1a0b88Schristos				],
1494c1a0b88Schristos				[
1504c1a0b88Schristos					AC_MSG_RESULT(not when cross-compiling)
1514c1a0b88Schristos					LIBS="$savedlibs"
1524c1a0b88Schristos				]
1534c1a0b88Schristos			)
1544c1a0b88Schristos		])
1554c1a0b88Schristos	])
1564c1a0b88Schristosfi
1574c1a0b88Schristos
158*c41df9f6SchristosAC_MSG_CHECKING([whether to enable the instrument functions code])
159*c41df9f6SchristosAC_ARG_ENABLE([instrument-functions],
160*c41df9f6Schristos   [AS_HELP_STRING([--enable-instrument-functions],
161*c41df9f6Schristos     [enable instrument functions code [default=no]])],
162*c41df9f6Schristos   [],
163*c41df9f6Schristos   [enableval=no])
164*c41df9f6Schristoscase "$enableval" in
165*c41df9f6Schristosyes)	AC_MSG_RESULT(yes)
166*c41df9f6Schristos	AC_CHECK_LIB([bfd], [bfd_init],
167*c41df9f6Schristos	    [true],
168*c41df9f6Schristos	    [AC_MSG_ERROR(
169*c41df9f6Schristos	       [--enable-instrument-functions was given, but test for library libbfd failed. Please install the 'binutils-dev' package.])],
170*c41df9f6Schristos	    [])
171*c41df9f6Schristos	AC_DEFINE(ENABLE_INSTRUMENT_FUNCTIONS, 1,
172*c41df9f6Schristos	    [define if you want to build the instrument functions code])
173*c41df9f6Schristos	LOCALSRC="$LOCALSRC instrument-functions.c"
174*c41df9f6Schristos	# Add '-finstrument-functions' instrumentation option to generate
175*c41df9f6Schristos	# instrumentation calls for entry and exit to functions.
176*c41df9f6Schristos	# Try to avoid Address Space Layout Randomization (ALSR).
177*c41df9f6Schristos	CFLAGS="$CFLAGS -O0 -ggdb -finstrument-functions -fno-stack-protector -fno-pic"
178*c41df9f6Schristos	LDFLAGS="$LDFLAGS -O0 -ggdb -fno-stack-protector -no-pie"
179*c41df9f6Schristos	LIBS="$LIBS -lbfd"
180*c41df9f6Schristos	;;
181*c41df9f6Schristos*)	AC_MSG_RESULT(no)
182*c41df9f6Schristos	;;
183*c41df9f6Schristosesac
184*c41df9f6Schristos
1854c1a0b88SchristosAC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer])
186d881c474SchristosAC_ARG_ENABLE([smb],
187d881c474Schristos   [AS_HELP_STRING([--enable-smb],
188d881c474Schristos     [enable possibly-buggy SMB printer [default=no]])],
189d881c474Schristos   [],
190d881c474Schristos   [enableval=no])
1914c1a0b88Schristoscase "$enableval" in
1924c1a0b88Schristosyes)	AC_MSG_RESULT(yes)
1934c1a0b88Schristos	AC_DEFINE(ENABLE_SMB, 1,
1944c1a0b88Schristos	    [define if you want to build the possibly-buggy SMB printer])
1954c1a0b88Schristos	LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
1964c1a0b88Schristos	;;
1974c1a0b88Schristos*)	AC_MSG_RESULT(no)
1984c1a0b88Schristos	;;
1994c1a0b88Schristosesac
2004c1a0b88Schristos
2014c1a0b88SchristosAC_MSG_CHECKING([whether to drop root privileges by default])
202*c41df9f6SchristosAC_ARG_WITH(
203*c41df9f6Schristos	[user],
204*c41df9f6Schristos	[AS_HELP_STRING([--with-user=USERNAME],
205*c41df9f6Schristos		[drop privileges by default to USERNAME]
206*c41df9f6Schristos	)],
207*c41df9f6Schristos	[],
208*c41df9f6Schristos	[withval=no])
209*c41df9f6SchristosAS_CASE(["$withval"],
210*c41df9f6Schristos	[no], [AC_MSG_RESULT(no)],
211*c41df9f6Schristos	[''|yes], [AC_MSG_ERROR([--with-user requires a username])],
212*c41df9f6Schristos	[
2134c1a0b88Schristos		AC_DEFINE_UNQUOTED(WITH_USER, "$withval",
2144c1a0b88Schristos		    [define if should drop privileges by default])
215*c41df9f6Schristos		AC_MSG_RESULT([yes, to user "$withval"])
216*c41df9f6Schristos	]
217*c41df9f6Schristos)
2184c1a0b88Schristos
2194c1a0b88SchristosAC_MSG_CHECKING([whether to chroot])
220*c41df9f6SchristosAC_ARG_WITH(
221*c41df9f6Schristos	[chroot],
222*c41df9f6Schristos	[AS_HELP_STRING([--with-chroot=DIRECTORY],
223*c41df9f6Schristos		[when dropping privileges, chroot to DIRECTORY]
224*c41df9f6Schristos	)],
225*c41df9f6Schristos	[],
226*c41df9f6Schristos	[withval=no]
227*c41df9f6Schristos)
228*c41df9f6SchristosAS_CASE(["$withval"],
229*c41df9f6Schristos	[no], [AC_MSG_RESULT(no)],
230*c41df9f6Schristos	[''|yes], [AC_MSG_ERROR([--with-chroot requires a directory])],
231*c41df9f6Schristos	[
2324c1a0b88Schristos		AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval",
2334c1a0b88Schristos		    [define if should chroot when dropping privileges])
234*c41df9f6Schristos		AC_MSG_RESULT([yes, to directory "$withval"])
235*c41df9f6Schristos	]
236*c41df9f6Schristos)
2374c1a0b88Schristos
2384c1a0b88SchristosAC_ARG_WITH(sandbox-capsicum,
2394c1a0b88Schristos	AS_HELP_STRING([--with-sandbox-capsicum],
2404c1a0b88Schristos		       [use Capsicum security functions @<:@default=yes, if available@:>@]))
2414c1a0b88Schristos#
2424c1a0b88Schristos# Check whether various functions are available.  If any are, set
2434c1a0b88Schristos# ac_lbl_capsicum_function_seen to yes; if any are not, set
2444c1a0b88Schristos# ac_lbl_capsicum_function_not_seen to yes.
2454c1a0b88Schristos#
2464c1a0b88Schristos# We don't check cap_rights_init(), as it's a macro, wrapping another
2474c1a0b88Schristos# function, in at least some versions of FreeBSD, and AC_CHECK_FUNCS()
2484c1a0b88Schristos# doesn't handle that.
2494c1a0b88Schristos#
2504c1a0b88Schristos# All of the ones we check for must be available in order to enable
2514c1a0b88Schristos# capsicum sandboxing.
2524c1a0b88Schristos#
2534c1a0b88Schristos# XXX - do we need to check for all of them, or are there some that, if
2544c1a0b88Schristos# present, imply others are present?
2554c1a0b88Schristos#
256d881c474Schristosif test -z "$with_sandbox_capsicum" || test "$with_sandbox_capsicum" != "no" ; then
257d881c474Schristos	#
258d881c474Schristos	# First, make sure we have the required header.
259d881c474Schristos	#
260d881c474Schristos	AC_CHECK_HEADER(sys/capsicum.h,
261d881c474Schristos	[
262d881c474Schristos		#
263d881c474Schristos		# We do; now make sure we have the required functions.
264d881c474Schristos		#
2654c1a0b88Schristos		AC_CHECK_FUNCS(cap_enter cap_rights_limit cap_ioctls_limit openat,
2664c1a0b88Schristos		    ac_lbl_capsicum_function_seen=yes,
2674c1a0b88Schristos		    ac_lbl_capsicum_function_not_seen=yes)
268d881c474Schristos	])
269d881c474Schristos	AC_CHECK_LIB(casper, cap_init, LIBS="$LIBS -lcasper")
270d881c474Schristos	AC_CHECK_LIB(cap_dns, cap_gethostbyaddr, LIBS="$LIBS -lcap_dns")
2714c1a0b88Schristosfi
2724c1a0b88SchristosAC_MSG_CHECKING([whether to sandbox using capsicum])
2734c1a0b88Schristosif test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then
2744c1a0b88Schristos	AC_DEFINE(HAVE_CAPSICUM, 1, [capsicum support available])
2754c1a0b88Schristos	AC_MSG_RESULT(yes)
2764c1a0b88Schristoselse
2774c1a0b88Schristos	AC_MSG_RESULT(no)
2784c1a0b88Schristosfi
279d881c474SchristosAC_MSG_CHECKING([whether to sandbox using Casper library])
280d881c474Schristosif test "x$ac_cv_lib_casper_cap_init" = "xyes" -a "x$ac_cv_lib_cap_dns_cap_gethostbyaddr" = "xyes"; then
281d881c474Schristos	AC_DEFINE(HAVE_CASPER, 1, [Casper support available])
282d881c474Schristos	AC_MSG_RESULT(yes)
283d881c474Schristoselse
284d881c474Schristos	AC_MSG_RESULT(no)
285d881c474Schristosfi
2864c1a0b88Schristos
2874c1a0b88Schristos#
2884c1a0b88Schristos# We must check this before checking whether to check the OS's IPv6,
2894c1a0b88Schristos# support because, on some platforms (such as SunOS 5.x), the test
2904c1a0b88Schristos# program requires the extra networking libraries.
2914c1a0b88Schristos#
2924c1a0b88SchristosAC_LBL_LIBRARY_NET
2934c1a0b88Schristos
2944c1a0b88Schristos#
2954c1a0b88Schristos# Check whether AF_INET6 and struct in6_addr are defined.
2964c1a0b88Schristos# If they aren't both defined, we don't have sufficient OS
2974c1a0b88Schristos# support for IPv6, so we don't look for IPv6 support libraries,
2984c1a0b88Schristos# and we define AF_INET6 and struct in6_addr ourselves.
2994c1a0b88Schristos#
3004c1a0b88SchristosAC_MSG_CHECKING([whether the operating system supports IPv6])
3014c1a0b88SchristosAC_COMPILE_IFELSE(
3024c1a0b88Schristos    [
3034c1a0b88Schristos      AC_LANG_SOURCE(
3044c1a0b88Schristos	[[
305d881c474Schristos#include <string.h>
3064c1a0b88Schristos/* AF_INET6 available check */
3074c1a0b88Schristos#include <sys/types.h>
308d881c474Schristos#ifdef _WIN32
309d881c474Schristos#include <ws2tcpip.h>
310d881c474Schristos#else
3114c1a0b88Schristos#include <sys/socket.h>
3124c1a0b88Schristos#include <netinet/in.h>
313d881c474Schristos#endif
3144c1a0b88Schristos#ifdef AF_INET6
3154c1a0b88Schristosvoid
3164c1a0b88Schristosfoo(struct in6_addr *addr)
3174c1a0b88Schristos{
3184c1a0b88Schristos memset(addr, 0, sizeof (struct in6_addr));
3194c1a0b88Schristos}
3204c1a0b88Schristos#else
3214c1a0b88Schristos#error "AF_INET6 not defined"
3224c1a0b88Schristos#endif
3234c1a0b88Schristos	]])
3244c1a0b88Schristos    ],
3254c1a0b88Schristos    [
3264c1a0b88Schristos	AC_MSG_RESULT(yes)
3274c1a0b88Schristos	AC_DEFINE(HAVE_OS_IPV6_SUPPORT, 1,
3284c1a0b88Schristos	    [define if the OS provides AF_INET6 and struct in6_addr])
3294c1a0b88Schristos	ipv6=yes
3304c1a0b88Schristos    ],
3314c1a0b88Schristos    [
3324c1a0b88Schristos	AC_MSG_RESULT(no)
3334c1a0b88Schristos	ipv6=no
3344c1a0b88Schristos    ]
3354c1a0b88Schristos)
3364c1a0b88Schristos
3374c1a0b88Schristosipv6type=unknown
3384c1a0b88Schristosipv6lib=none
3394c1a0b88Schristosipv6trylibc=no
3404c1a0b88Schristos
3414c1a0b88Schristosif test "$ipv6" = "yes"; then
3424c1a0b88Schristos	AC_MSG_CHECKING([ipv6 stack type])
3434c1a0b88Schristos	for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do
3444c1a0b88Schristos		case $i in
3454c1a0b88Schristos		inria)
3464c1a0b88Schristos			dnl http://www.kame.net/
3474c1a0b88Schristos			AC_EGREP_CPP(yes,
3484c1a0b88Schristos[#include <netinet/in.h>
3494c1a0b88Schristos#ifdef IPV6_INRIA_VERSION
3504c1a0b88Schristosyes
3514c1a0b88Schristos#endif],
3524c1a0b88Schristos				[ipv6type=$i])
3534c1a0b88Schristos			;;
3544c1a0b88Schristos		kame)
3554c1a0b88Schristos			dnl http://www.kame.net/
3564c1a0b88Schristos			AC_EGREP_CPP(yes,
3574c1a0b88Schristos[#include <netinet/in.h>
3584c1a0b88Schristos#ifdef __KAME__
3594c1a0b88Schristosyes
3604c1a0b88Schristos#endif],
3614c1a0b88Schristos				[ipv6type=$i;
3624c1a0b88Schristos				ipv6lib=inet6;
3634c1a0b88Schristos				ipv6libdir=/usr/local/v6/lib;
3644c1a0b88Schristos				ipv6trylibc=yes])
3654c1a0b88Schristos			;;
3664c1a0b88Schristos		linux-glibc)
3674c1a0b88Schristos			dnl http://www.v6.linux.or.jp/
3684c1a0b88Schristos			AC_EGREP_CPP(yes,
3694c1a0b88Schristos[#include <features.h>
3704c1a0b88Schristos#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
3714c1a0b88Schristosyes
3724c1a0b88Schristos#endif],
3734c1a0b88Schristos				[ipv6type=$i])
3744c1a0b88Schristos			;;
3754c1a0b88Schristos		linux-libinet6)
3764c1a0b88Schristos			dnl http://www.v6.linux.or.jp/
3774c1a0b88Schristos			dnl
3784c1a0b88Schristos			dnl This also matches Solaris 8 and Tru64 UNIX 5.1,
3794c1a0b88Schristos			dnl and possibly other versions of those OSes
3804c1a0b88Schristos			dnl
3814c1a0b88Schristos			if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then
3824c1a0b88Schristos				ipv6type=$i
3834c1a0b88Schristos				ipv6lib=inet6
3844c1a0b88Schristos				ipv6libdir=/usr/inet6/lib
3854c1a0b88Schristos				ipv6trylibc=yes;
3864c1a0b88Schristos				CFLAGS="-I/usr/inet6/include $CFLAGS"
3874c1a0b88Schristos			fi
3884c1a0b88Schristos			;;
3894c1a0b88Schristos		toshiba)
3904c1a0b88Schristos			AC_EGREP_CPP(yes,
3914c1a0b88Schristos[#include <sys/param.h>
3924c1a0b88Schristos#ifdef _TOSHIBA_INET6
3934c1a0b88Schristosyes
3944c1a0b88Schristos#endif],
3954c1a0b88Schristos				[ipv6type=$i;
3964c1a0b88Schristos				ipv6lib=inet6;
3974c1a0b88Schristos				ipv6libdir=/usr/local/v6/lib])
3984c1a0b88Schristos			;;
3994c1a0b88Schristos		v6d)
4004c1a0b88Schristos			AC_EGREP_CPP(yes,
4014c1a0b88Schristos[#include </usr/local/v6/include/sys/v6config.h>
4024c1a0b88Schristos#ifdef __V6D__
4034c1a0b88Schristosyes
4044c1a0b88Schristos#endif],
4054c1a0b88Schristos				[ipv6type=$i;
4064c1a0b88Schristos				ipv6lib=v6;
4074c1a0b88Schristos				ipv6libdir=/usr/local/v6/lib;
4084c1a0b88Schristos				CFLAGS="-I/usr/local/v6/include $CFLAGS"])
4094c1a0b88Schristos			;;
4104c1a0b88Schristos		zeta)
4114c1a0b88Schristos			AC_EGREP_CPP(yes,
4124c1a0b88Schristos[#include <sys/param.h>
4134c1a0b88Schristos#ifdef _ZETA_MINAMI_INET6
4144c1a0b88Schristosyes
4154c1a0b88Schristos#endif],
4164c1a0b88Schristos				[ipv6type=$i;
4174c1a0b88Schristos				ipv6lib=inet6;
4184c1a0b88Schristos				ipv6libdir=/usr/local/v6/lib])
4194c1a0b88Schristos			;;
4204c1a0b88Schristos		esac
4214c1a0b88Schristos		if test "$ipv6type" != "unknown"; then
4224c1a0b88Schristos			break
4234c1a0b88Schristos		fi
4244c1a0b88Schristos	done
4254c1a0b88Schristos	AC_MSG_RESULT($ipv6type)
4264c1a0b88Schristosfi
4274c1a0b88Schristos
4284c1a0b88Schristosif test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
4294c1a0b88Schristos	if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
4304c1a0b88Schristos		LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
4314c1a0b88Schristos		echo "You have $ipv6lib library, using it"
4324c1a0b88Schristos	else
4334c1a0b88Schristos		if test "$ipv6trylibc" = "yes"; then
4344c1a0b88Schristos			echo "You do not have $ipv6lib library, using libc"
4354c1a0b88Schristos		else
4364c1a0b88Schristos			echo 'Fatal: no $ipv6lib library found.  cannot continue.'
4374c1a0b88Schristos			echo "You need to fetch lib$ipv6lib.a from appropriate"
4384c1a0b88Schristos			echo 'ipv6 kit and compile beforehand.'
4394c1a0b88Schristos			exit 1
4404c1a0b88Schristos		fi
4414c1a0b88Schristos	fi
4424c1a0b88Schristosfi
4434c1a0b88Schristos
444d881c474SchristosAC_REPLACE_FUNCS(strlcat strlcpy strdup strsep getservent getopt_long)
445d881c474SchristosAC_CHECK_FUNCS(fork vfork)
446d881c474SchristosAC_CHECK_FUNCS(setlinebuf)
4474c1a0b88Schristos
448d881c474Schristos#
449*c41df9f6Schristos# Make sure we have snprintf(); we require it.
450d881c474Schristos#
451d881c474SchristosAC_CHECK_FUNC(snprintf,,
452d881c474Schristos    AC_MSG_ERROR([snprintf() is required but wasn't found]))
4534c1a0b88Schristos
454d881c474Schristos#
455*c41df9f6Schristos# It became apparent at some point that using a suitable C99 compiler does not
456*c41df9f6Schristos# automatically mean snprintf(3) implementation in the libc supports all the
457*c41df9f6Schristos# modifiers and specifiers used in the project, so let's test that before the
458*c41df9f6Schristos# build, not after.
459d881c474Schristos#
460*c41df9f6Schristos# Testing the sizeof_t length modifier takes making an snprintf() call and
461*c41df9f6Schristos# comparing the actual result with the expected result.  If this fails, it will
462*c41df9f6Schristos# most likely happen at run time, not compile time.
463*c41df9f6Schristos#
464*c41df9f6Schristos# Testing the 64-bit conversion specifiers in addition to that requires the
465*c41df9f6Schristos# <inttypes.h> header to be present and the macros to be defined, so if this
466*c41df9f6Schristos# fails, it will more likely happen at compile time.
467*c41df9f6Schristos#
468*c41df9f6SchristosAC_MSG_CHECKING([whether snprintf is suitable])
469d881c474SchristosAC_RUN_IFELSE(
470d881c474Schristos    [
471d881c474Schristos        AC_LANG_SOURCE([[
472d881c474Schristos#include <stdio.h>
473d881c474Schristos#include <string.h>
474*c41df9f6Schristos#include <inttypes.h>
475*c41df9f6Schristos#include <sys/types.h>
476d881c474Schristos
477d881c474Schristosint main()
478d881c474Schristos{
479d881c474Schristos  char buf[100];
480*c41df9f6Schristos  uint64_t t = (uint64_t)1 << 32;
481*c41df9f6Schristos
482d881c474Schristos  snprintf(buf, sizeof(buf), "%zu", sizeof(buf));
483*c41df9f6Schristos  if (strncmp(buf, "100", sizeof(buf)))
484*c41df9f6Schristos    return 1;
485*c41df9f6Schristos
486*c41df9f6Schristos  snprintf(buf, sizeof(buf), "%zd", -sizeof(buf));
487*c41df9f6Schristos  if (strncmp(buf, "-100", sizeof(buf)))
488*c41df9f6Schristos    return 2;
489*c41df9f6Schristos
490*c41df9f6Schristos  snprintf(buf, sizeof(buf), "%" PRId64, -t);
491*c41df9f6Schristos  if (strncmp(buf, "-4294967296", sizeof(buf)))
492*c41df9f6Schristos    return 3;
493*c41df9f6Schristos
494*c41df9f6Schristos  snprintf(buf, sizeof(buf), "0o%" PRIo64, t);
495*c41df9f6Schristos  if (strncmp(buf, "0o40000000000", sizeof(buf)))
496*c41df9f6Schristos    return 4;
497*c41df9f6Schristos
498*c41df9f6Schristos  snprintf(buf, sizeof(buf), "0x%" PRIx64, t);
499*c41df9f6Schristos  if (strncmp(buf, "0x100000000", sizeof(buf)))
500*c41df9f6Schristos    return 5;
501*c41df9f6Schristos
502*c41df9f6Schristos  snprintf(buf, sizeof(buf), "%" PRIu64, t);
503*c41df9f6Schristos  if (strncmp(buf, "4294967296", sizeof(buf)))
504*c41df9f6Schristos    return 6;
505*c41df9f6Schristos
506*c41df9f6Schristos  return 0;
507d881c474Schristos}
508d881c474Schristos        ]])
509d881c474Schristos    ],
510d881c474Schristos    [
511d881c474Schristos        AC_MSG_RESULT(yes)
512d881c474Schristos    ],
513d881c474Schristos    [
514d881c474Schristos        AC_MSG_RESULT(no)
515*c41df9f6Schristos        AC_MSG_ERROR(
516*c41df9f6Schristos[The snprintf(3) implementation in this libc is not suitable,
517*c41df9f6Schristostcpdump would not work correctly even if it managed to compile.])
518d881c474Schristos    ],
519d881c474Schristos    [
520d881c474Schristos        AC_MSG_RESULT(not while cross-compiling)
521d881c474Schristos    ]
522d881c474Schristos)
5234c1a0b88Schristos
5244c1a0b88SchristosAC_CHECK_LIB(rpc, main)		dnl It's unclear why we might need -lrpc
5254c1a0b88Schristos
5264c1a0b88Schristosdnl Some platforms may need -lnsl for getrpcbynumber.
5274c1a0b88SchristosAC_SEARCH_LIBS(getrpcbynumber, nsl,
5284c1a0b88Schristos    AC_DEFINE(HAVE_GETRPCBYNUMBER, 1, [define if you have getrpcbynumber()]))
5294c1a0b88Schristos
5304c1a0b88SchristosAC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
5314c1a0b88Schristos
5324c1a0b88Schristos#
5334c1a0b88Schristos# Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
5344c1a0b88Schristos# libraries (e.g., "-lsocket -lnsl" on Solaris).
5354c1a0b88Schristos#
5364c1a0b88Schristos# You are in a twisty little maze of UN*Xes, all different.
5374c1a0b88Schristos# Some might not have ether_ntohost().
538d881c474Schristos# Some might have it and declare it in <net/ethernet.h>.
539d881c474Schristos# Some might have it and declare it in <netinet/ether.h>
540d881c474Schristos# Some might have it and declare it in <sys/ethernet.h>.
541d881c474Schristos# Some might have it and declare it in <arpa/inet.h>.
542d881c474Schristos# Some might have it and declare it in <netinet/if_ether.h>.
543d881c474Schristos# Some might have it and not declare it in any header file.
5444c1a0b88Schristos#
5454c1a0b88Schristos# Before you is a C compiler.
5464c1a0b88Schristos#
5474c1a0b88SchristosAC_CHECK_FUNCS(ether_ntohost, [
5484c1a0b88Schristos    AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [
549*c41df9f6Schristos	AC_RUN_IFELSE([AC_LANG_SOURCE([[
5504c1a0b88Schristos		#include <netdb.h>
551d881c474Schristos		#include <netinet/ether.h>
552d881c474Schristos		#include <stdlib.h>
5534c1a0b88Schristos		#include <sys/types.h>
5544c1a0b88Schristos		#include <sys/param.h>
5554c1a0b88Schristos		#include <sys/socket.h>
5564c1a0b88Schristos
5574c1a0b88Schristos		int
5584c1a0b88Schristos		main(int argc, char **argv)
5594c1a0b88Schristos		{
5604c1a0b88Schristos			u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff };
5614c1a0b88Schristos			char name[MAXHOSTNAMELEN];
5624c1a0b88Schristos
5634c1a0b88Schristos			ether_ntohost(name, (struct ether_addr *)ea);
5644c1a0b88Schristos			exit(0);
5654c1a0b88Schristos		}
566*c41df9f6Schristos	]])
5674c1a0b88Schristos	], [ac_cv_buggy_ether_ntohost=no],
5684c1a0b88Schristos	   [ac_cv_buggy_ether_ntohost=yes],
5694c1a0b88Schristos	   [ac_cv_buggy_ether_ntohost="not while cross-compiling"])])
5704c1a0b88Schristos    if test "$ac_cv_buggy_ether_ntohost" = "no"; then
5714c1a0b88Schristos	AC_DEFINE(USE_ETHER_NTOHOST, 1,
5724c1a0b88Schristos	    [define if you have ether_ntohost() and it works])
5734c1a0b88Schristos    fi
5744c1a0b88Schristos])
5754c1a0b88Schristosif test "$ac_cv_func_ether_ntohost" = yes -a \
5764c1a0b88Schristos    "$ac_cv_buggy_ether_ntohost" = "no"; then
5774c1a0b88Schristos	#
578d881c474Schristos	# OK, we have ether_ntohost().  Is it declared in <net/ethernet.h>?
5794c1a0b88Schristos	#
580d881c474Schristos	# This test fails if we don't have <net/ethernet.h> or if we do
581d881c474Schristos	# but it doesn't declare ether_ntohost().
5824c1a0b88Schristos	#
5834c1a0b88Schristos	AC_CHECK_DECL(ether_ntohost,
5844c1a0b88Schristos	    [
585d881c474Schristos		AC_DEFINE(NET_ETHERNET_H_DECLARES_ETHER_NTOHOST,,
586d881c474Schristos		    [Define to 1 if net/ethernet.h declares `ether_ntohost'])
5874c1a0b88Schristos	    ],,
5884c1a0b88Schristos	    [
589d881c474Schristos#include <net/ethernet.h>
5904c1a0b88Schristos	    ])
5914c1a0b88Schristos	#
5924c1a0b88Schristos	# Did that succeed?
5934c1a0b88Schristos	#
5944c1a0b88Schristos	if test "$ac_cv_have_decl_ether_ntohost" != yes; then
5954c1a0b88Schristos		#
5964c1a0b88Schristos		# No, how about <netinet/ether.h>, as on Linux?
5974c1a0b88Schristos		#
598d881c474Schristos		# This test fails if we don't have <netinet/ether.h>
599d881c474Schristos		# or if we do but it doesn't declare ether_ntohost().
6004c1a0b88Schristos		#
6014c1a0b88Schristos		# Unset ac_cv_have_decl_ether_ntohost so we don't
6024c1a0b88Schristos		# treat the previous failure as a cached value and
6034c1a0b88Schristos		# suppress the next test.
6044c1a0b88Schristos		#
6054c1a0b88Schristos		unset ac_cv_have_decl_ether_ntohost
6064c1a0b88Schristos		AC_CHECK_DECL(ether_ntohost,
6074c1a0b88Schristos		    [
608*c41df9f6Schristos			AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,1,
6094c1a0b88Schristos			    [Define to 1 if netinet/ether.h declares `ether_ntohost'])
6104c1a0b88Schristos		    ],,
6114c1a0b88Schristos		    [
6124c1a0b88Schristos#include <netinet/ether.h>
6134c1a0b88Schristos		    ])
6144c1a0b88Schristos	fi
6154c1a0b88Schristos	#
616d881c474Schristos	# Did that succeed?
6174c1a0b88Schristos	#
6184c1a0b88Schristos	if test "$ac_cv_have_decl_ether_ntohost" != yes; then
6194c1a0b88Schristos		#
620d881c474Schristos		# No, how about <sys/ethernet.h>, as on Solaris 10
621d881c474Schristos		# and later?
622d881c474Schristos		#
623d881c474Schristos		# This test fails if we don't have <sys/ethernet.h>
624d881c474Schristos		# or if we do but it doesn't declare ether_ntohost().
625d881c474Schristos		#
626d881c474Schristos		# Unset ac_cv_have_decl_ether_ntohost so we don't
627d881c474Schristos		# treat the previous failure as a cached value and
628d881c474Schristos		# suppress the next test.
629d881c474Schristos		#
630d881c474Schristos		unset ac_cv_have_decl_ether_ntohost
631d881c474Schristos		AC_CHECK_DECL(ether_ntohost,
632d881c474Schristos		    [
633d881c474Schristos			AC_DEFINE(SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST,,
634d881c474Schristos			    [Define to 1 if sys/ethernet.h declares `ether_ntohost'])
635d881c474Schristos		    ],,
636d881c474Schristos		    [
637d881c474Schristos#include <sys/ethernet.h>
638d881c474Schristos		    ])
639d881c474Schristos	fi
640d881c474Schristos	#
641d881c474Schristos	# Did that succeed?
642d881c474Schristos	#
643d881c474Schristos	if test "$ac_cv_have_decl_ether_ntohost" != yes; then
644d881c474Schristos		#
645d881c474Schristos		# No, how about <arpa/inet.h>, as in AIX?
646d881c474Schristos		#
647d881c474Schristos		# This test fails if we don't have <arpa/inet.h>
648d881c474Schristos		# (if we have ether_ntohost(), we should have
649d881c474Schristos		# networking, and if we have networking, we should
650d881c474Schristos		# have <arpa/inet.h>) or if we do but it doesn't
651d881c474Schristos		# declare ether_ntohost().
652d881c474Schristos		#
653d881c474Schristos		# Unset ac_cv_have_decl_ether_ntohost so we don't
654d881c474Schristos		# treat the previous failure as a cached value and
655d881c474Schristos		# suppress the next test.
656d881c474Schristos		#
657d881c474Schristos		unset ac_cv_have_decl_ether_ntohost
658d881c474Schristos		AC_CHECK_DECL(ether_ntohost,
659d881c474Schristos		    [
660d881c474Schristos			AC_DEFINE(ARPA_INET_H_DECLARES_ETHER_NTOHOST,,
661d881c474Schristos			    [Define to 1 if arpa/inet.h declares `ether_ntohost'])
662d881c474Schristos		    ],,
663d881c474Schristos		    [
664d881c474Schristos#include <arpa/inet.h>
665d881c474Schristos		    ])
666d881c474Schristos	fi
667d881c474Schristos	#
668d881c474Schristos	# Did that succeed?
669d881c474Schristos	#
670d881c474Schristos	if test "$ac_cv_have_decl_ether_ntohost" != yes; then
671d881c474Schristos		#
672d881c474Schristos		# No, how about <netinet/if_ether.h>?
673d881c474Schristos		# On some platforms, it requires <net/if.h> and
674d881c474Schristos		# <netinet/in.h>, and we always include it with
675d881c474Schristos		# both of them, so test it with both of them.
676d881c474Schristos		#
677d881c474Schristos		# This test fails if we don't have <netinet/if_ether.h>
678d881c474Schristos		# and the headers we include before it, or if we do but
679d881c474Schristos		# <netinet/if_ether.h> doesn't declare ether_hostton().
680d881c474Schristos		#
681d881c474Schristos		# Unset ac_cv_have_decl_ether_ntohost so we don't
682d881c474Schristos		# treat the previous failure as a cached value and
683d881c474Schristos		# suppress the next test.
684d881c474Schristos		#
685d881c474Schristos		unset ac_cv_have_decl_ether_ntohost
686d881c474Schristos		AC_CHECK_DECL(ether_ntohost,
687d881c474Schristos		    [
688d881c474Schristos			AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST,,
689d881c474Schristos			    [Define to 1 if netinet/if_ether.h declares `ether_ntohost'])
690d881c474Schristos		    ],,
691d881c474Schristos		    [
692d881c474Schristos#include <sys/types.h>
693d881c474Schristos#include <sys/socket.h>
694d881c474Schristos#include <net/if.h>
695d881c474Schristos#include <netinet/in.h>
696d881c474Schristos#include <netinet/if_ether.h>
697d881c474Schristos		    ])
698d881c474Schristos	fi
699d881c474Schristos	#
700d881c474Schristos	# After all that, is ether_ntohost() declared?
701d881c474Schristos	#
702d881c474Schristos	if test "$ac_cv_have_decl_ether_ntohost" = yes; then
703d881c474Schristos		#
704d881c474Schristos		# Yes.
705d881c474Schristos		#
706d881c474Schristos		AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 1,
707d881c474Schristos		    [Define to 1 if you have the declaration of `ether_ntohost'])
708d881c474Schristos	else
709d881c474Schristos		#
7104c1a0b88Schristos		# No, we'll have to declare it ourselves.
711d881c474Schristos		# Do we have "struct ether_addr" if we include
712d881c474Schristos		# <netinet/if_ether.h>?
7134c1a0b88Schristos		#
7144c1a0b88Schristos		AC_CHECK_TYPES(struct ether_addr,,,
7154c1a0b88Schristos		    [
7164c1a0b88Schristos			#include <sys/types.h>
7174c1a0b88Schristos			#include <sys/socket.h>
7184c1a0b88Schristos			#include <net/if.h>
719d881c474Schristos			#include <netinet/in.h>
7204c1a0b88Schristos			#include <netinet/if_ether.h>
7214c1a0b88Schristos		    ])
7224c1a0b88Schristos	fi
7234c1a0b88Schristosfi
7244c1a0b88Schristos
7254c1a0b88Schristosdnl
726d881c474Schristosdnl Check for "pcap_list_datalinks()" and use a substitute version if
727d881c474Schristosdnl it's not present.  If it is present, check for "pcap_free_datalinks()";
728d881c474Schristosdnl if it's not present, we don't replace it for now.  (We could do so
729d881c474Schristosdnl on UN*X, but not on Windows, where hilarity ensues if a program
730d881c474Schristosdnl built with one version of the MSVC support library tries to free
731d881c474Schristosdnl something allocated by a library built with another version of
732d881c474Schristosdnl the MSVC support library.)
7334c1a0b88Schristosdnl
7344c1a0b88SchristosAC_CHECK_FUNC(pcap_list_datalinks,
7354c1a0b88Schristos	[
7364c1a0b88Schristos	    AC_DEFINE(HAVE_PCAP_LIST_DATALINKS, 1,
7374c1a0b88Schristos		[define if libpcap has pcap_list_datalinks()])
7384c1a0b88Schristos	    AC_CHECK_FUNCS(pcap_free_datalinks)
7394c1a0b88Schristos	],
7404c1a0b88Schristos	[
7414c1a0b88Schristos	    AC_LIBOBJ(datalinks)
7424c1a0b88Schristos	])
743d881c474Schristos
744d881c474Schristosdnl
745d881c474Schristosdnl Check for "pcap_datalink_name_to_val()", and use a substitute
746d881c474Schristosdnl version if it's not present.  If it is present, check for
747d881c474Schristosdnl "pcap_datalink_val_to_description()", and if we don't have it,
748d881c474Schristosdnl use a substitute version.
749d881c474Schristosdnl
7504c1a0b88SchristosAC_CHECK_FUNC(pcap_datalink_name_to_val,
7514c1a0b88Schristos	[
7524c1a0b88Schristos	    AC_DEFINE(HAVE_PCAP_DATALINK_NAME_TO_VAL, 1,
7534c1a0b88Schristos		[define if libpcap has pcap_datalink_name_to_val()])
7544c1a0b88Schristos	    AC_CHECK_FUNC(pcap_datalink_val_to_description,
7554c1a0b88Schristos		AC_DEFINE(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION, 1,
7564c1a0b88Schristos		    [define if libpcap has pcap_datalink_val_to_description()]),
7574c1a0b88Schristos		[
7584c1a0b88Schristos		    AC_LIBOBJ(dlnames)
7594c1a0b88Schristos		])
7604c1a0b88Schristos	],
7614c1a0b88Schristos	[
7624c1a0b88Schristos	    AC_LIBOBJ(dlnames)
7634c1a0b88Schristos	])
7644c1a0b88Schristos
7654c1a0b88Schristosdnl
766d881c474Schristosdnl Check for "pcap_set_datalink()"; you can't substitute for it if
767d881c474Schristosdnl it's absent (it has hooks into libpcap), so just define the
768d881c474Schristosdnl HAVE_ value if it's there.
769d881c474Schristosdnl
770d881c474SchristosAC_CHECK_FUNCS(pcap_set_datalink)
771d881c474Schristos
772d881c474Schristosdnl
7734c1a0b88Schristosdnl Check for "pcap_breakloop()"; you can't substitute for it if
7744c1a0b88Schristosdnl it's absent (it has hooks into the live capture routines),
7754c1a0b88Schristosdnl so just define the HAVE_ value if it's there.
7764c1a0b88Schristosdnl
7774c1a0b88SchristosAC_CHECK_FUNCS(pcap_breakloop)
7784c1a0b88Schristos
7794c1a0b88Schristos#
7804c1a0b88Schristos# Do we have the new open API?  Check for pcap_create, and assume that,
7814c1a0b88Schristos# if we do, we also have pcap_activate() and the other new routines
7824c1a0b88Schristos# introduced in libpcap 1.0.0.
7834c1a0b88Schristos#
7844c1a0b88SchristosAC_CHECK_FUNCS(pcap_create)
7854c1a0b88Schristosif test $ac_cv_func_pcap_create = "yes" ; then
7864c1a0b88Schristos	#
7874c1a0b88Schristos	# OK, do we have pcap_set_tstamp_type?  If so, assume we have
7884c1a0b88Schristos	# pcap_list_tstamp_types and pcap_free_tstamp_types as well.
7894c1a0b88Schristos	#
7904c1a0b88Schristos	AC_CHECK_FUNCS(pcap_set_tstamp_type)
7914c1a0b88Schristos	#
7924c1a0b88Schristos	# And do we have pcap_set_tstamp_precision?  If so, we assume
7934c1a0b88Schristos	# we also have pcap_open_offline_with_tstamp_precision.
7944c1a0b88Schristos	#
7954c1a0b88Schristos	AC_CHECK_FUNCS(pcap_set_tstamp_precision)
7964c1a0b88Schristosfi
7974c1a0b88Schristos
7984c1a0b88Schristos#
7994c1a0b88Schristos# Check for a miscellaneous collection of functions which we use
8004c1a0b88Schristos# if we have them.
8014c1a0b88Schristos#
802d881c474SchristosAC_CHECK_FUNCS(pcap_findalldevs)
803d881c474SchristosAC_CHECK_FUNCS(pcap_dump_flush pcap_lib_version)
8044c1a0b88Schristosif test $ac_cv_func_pcap_lib_version = "no" ; then
8054c1a0b88Schristos    AC_MSG_CHECKING(whether pcap_version is defined by libpcap)
806*c41df9f6Schristos    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
8074c1a0b88Schristos	extern char pcap_version[];
8084c1a0b88Schristos
8094c1a0b88Schristos	return (int)pcap_version;
810*c41df9f6Schristos       ]])
8114c1a0b88Schristos       ],
812*c41df9f6Schristos       [ac_lbl_cv_pcap_version_defined=yes],
813*c41df9f6Schristos       [ac_lbl_cv_pcap_version_defined=no])
8144c1a0b88Schristos    if test "$ac_lbl_cv_pcap_version_defined" = yes ; then
8154c1a0b88Schristos	AC_MSG_RESULT(yes)
8164c1a0b88Schristos	AC_DEFINE(HAVE_PCAP_VERSION, 1, [define if libpcap has pcap_version])
8174c1a0b88Schristos    else
8184c1a0b88Schristos	AC_MSG_RESULT(no)
8194c1a0b88Schristos    fi
8204c1a0b88Schristosfi
821d881c474SchristosAC_CHECK_FUNCS(pcap_setdirection pcap_set_immediate_mode pcap_dump_ftell64)
822*c41df9f6Schristos#
823*c41df9f6Schristos# See the comment in AC_LBL_LIBPCAP in aclocal.m4 for the reason
824*c41df9f6Schristos# why we don't check for remote-capture APIs if we're building
825*c41df9f6Schristos# with the system libpcap on macOS.
826*c41df9f6Schristos#
827*c41df9f6Schristosif test "$_dont_check_for_remote_apis" != "yes"; then
828d881c474Schristos	AC_CHECK_FUNCS(pcap_open pcap_findalldevs_ex)
829*c41df9f6Schristosfi
830d881c474SchristosAC_REPLACE_FUNCS(pcap_dump_ftell)
8314c1a0b88Schristos
8324c1a0b88Schristos#
8334c1a0b88Schristos# Check for special debugging functions
8344c1a0b88Schristos#
8354c1a0b88SchristosAC_CHECK_FUNCS(pcap_set_parser_debug)
8364c1a0b88Schristosif test "$ac_cv_func_pcap_set_parser_debug" = "no" ; then
8374c1a0b88Schristos	#
8384c1a0b88Schristos	# OK, we don't have pcap_set_parser_debug() to set the libpcap
8394c1a0b88Schristos	# filter expression parser debug flag; can we directly set the
8404c1a0b88Schristos	# flag?
8414c1a0b88Schristos	AC_MSG_CHECKING(whether pcap_debug is defined by libpcap)
842*c41df9f6Schristos	AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
8434c1a0b88Schristos		extern int pcap_debug;
8444c1a0b88Schristos
8454c1a0b88Schristos		return pcap_debug;
846*c41df9f6Schristos	   ]])
8474c1a0b88Schristos	   ],
848*c41df9f6Schristos	   [ac_lbl_cv_pcap_debug_defined=yes],
849*c41df9f6Schristos	   [ac_lbl_cv_pcap_debug_defined=no])
8504c1a0b88Schristos	if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
8514c1a0b88Schristos		AC_MSG_RESULT(yes)
8524c1a0b88Schristos		AC_DEFINE(HAVE_PCAP_DEBUG, 1, [define if libpcap has pcap_debug])
8534c1a0b88Schristos	else
8544c1a0b88Schristos		AC_MSG_RESULT(no)
8554c1a0b88Schristos		#
8564c1a0b88Schristos		# OK, what about "yydebug"?
8574c1a0b88Schristos		#
8584c1a0b88Schristos		AC_MSG_CHECKING(whether yydebug is defined by libpcap)
859*c41df9f6Schristos		AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
8604c1a0b88Schristos			extern int yydebug;
8614c1a0b88Schristos
8624c1a0b88Schristos			return yydebug;
863*c41df9f6Schristos		   ]])
8644c1a0b88Schristos		   ],
865*c41df9f6Schristos		   [ac_lbl_cv_yydebug_defined=yes],
866*c41df9f6Schristos		   [ac_lbl_cv_yydebug_defined=no])
8674c1a0b88Schristos		if test "$ac_lbl_cv_yydebug_defined" = yes ; then
8684c1a0b88Schristos			AC_MSG_RESULT(yes)
8694c1a0b88Schristos			AC_DEFINE(HAVE_YYDEBUG, 1, [define if libpcap has yydebug])
8704c1a0b88Schristos		else
8714c1a0b88Schristos			AC_MSG_RESULT(no)
8724c1a0b88Schristos		fi
8734c1a0b88Schristos	fi
8744c1a0b88Schristosfi
8754c1a0b88SchristosAC_CHECK_FUNCS(pcap_set_optimizer_debug)
8764c1a0b88SchristosAC_REPLACE_FUNCS(bpf_dump)	dnl moved to libpcap in 0.6
8774c1a0b88Schristos
8784c1a0b88Schristos#
8794c1a0b88Schristos# Assume V7/BSD convention for man pages (file formats in section 5,
8804c1a0b88Schristos# miscellaneous info in section 7).
8814c1a0b88Schristos#
8824c1a0b88SchristosMAN_FILE_FORMATS=5
8834c1a0b88SchristosMAN_MISC_INFO=7
8844c1a0b88Schristoscase "$host_os" in
8854c1a0b88Schristos
8864c1a0b88Schristosaix*)
8874c1a0b88Schristos	dnl Workaround to enable certain features
8884c1a0b88Schristos	AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
8894c1a0b88Schristos	;;
8904c1a0b88Schristos
8914c1a0b88Schristoshpux*)
8924c1a0b88Schristos	#
8934c1a0b88Schristos	# Use System V conventions for man pages.
8944c1a0b88Schristos	#
8954c1a0b88Schristos	MAN_FILE_FORMATS=4
8964c1a0b88Schristos	MAN_MISC_INFO=5
8974c1a0b88Schristos	;;
8984c1a0b88Schristos
8994c1a0b88Schristosirix*)
9004c1a0b88Schristos	V_GROUP=sys
9014c1a0b88Schristos
9024c1a0b88Schristos	#
9034c1a0b88Schristos	# Use System V conventions for man pages.
9044c1a0b88Schristos	#
9054c1a0b88Schristos	MAN_FILE_FORMATS=4
9064c1a0b88Schristos	MAN_MISC_INFO=5
9074c1a0b88Schristos	;;
9084c1a0b88Schristos
9094c1a0b88Schristososf*)
9104c1a0b88Schristos	V_GROUP=system
9114c1a0b88Schristos
9124c1a0b88Schristos	#
9134c1a0b88Schristos	# Use System V conventions for man pages.
9144c1a0b88Schristos	#
9154c1a0b88Schristos	MAN_FILE_FORMATS=4
9164c1a0b88Schristos	MAN_MISC_INFO=5
9174c1a0b88Schristos	;;
9184c1a0b88Schristos
9194c1a0b88Schristossolaris*)
9204c1a0b88Schristos	#
9214c1a0b88Schristos	# Use System V conventions for man pages.
9224c1a0b88Schristos	#
9234c1a0b88Schristos	MAN_FILE_FORMATS=4
9244c1a0b88Schristos	MAN_MISC_INFO=5
9254c1a0b88Schristos	;;
9264c1a0b88Schristosesac
9274c1a0b88Schristos
9284c1a0b88Schristos#
9294c1a0b88Schristos# Make sure we have a definition for C99's uintptr_t (regardless of
9304c1a0b88Schristos# whether the environment is a C99 environment or not).
9314c1a0b88Schristos#
9324c1a0b88SchristosAC_TYPE_UINTPTR_T
9334c1a0b88Schristos
934*c41df9f6Schristossavedcppflags="$CPPFLAGS"
935*c41df9f6SchristosCPPFLAGS="$CPPFLAGS $V_INCLS"
936*c41df9f6Schristos
9374c1a0b88Schristos#
938d881c474Schristos# Check whether we have pcap/pcap-inttypes.h.
939d881c474Schristos# If we do, we use that to get the C99 types defined.
940d881c474Schristos#
941d881c474SchristosAC_CHECK_HEADERS(pcap/pcap-inttypes.h)
942*c41df9f6Schristos
943*c41df9f6Schristos#
944*c41df9f6Schristos# At compile time HAVE_PCAP_FINDALLDEVS depends on HAVE_PCAP_IF_T.
945*c41df9f6Schristos#
946*c41df9f6SchristosAC_CHECK_TYPES(pcap_if_t, , , [#include <pcap.h>])
947*c41df9f6Schristos
948d881c474SchristosCPPFLAGS="$savedcppflags"
949d881c474Schristos
950d881c474Schristos#
9514c1a0b88Schristos# Define the old BSD specified-width types in terms of the C99 types;
9524c1a0b88Schristos# we may need them with libpcap include files.
9534c1a0b88Schristos#
9544c1a0b88SchristosAC_CHECK_TYPE([u_int8_t], ,
9554c1a0b88Schristos	[AC_DEFINE([u_int8_t], [uint8_t],
9564c1a0b88Schristos	[Define to `uint8_t' if u_int8_t not defined.])],
9574c1a0b88Schristos	[AC_INCLUDES_DEFAULT
9584c1a0b88Schristos#include <sys/types.h>
9594c1a0b88Schristos])
9604c1a0b88SchristosAC_CHECK_TYPE([u_int16_t], ,
9614c1a0b88Schristos	[AC_DEFINE([u_int16_t], [uint16_t],
9624c1a0b88Schristos	[Define to `uint16_t' if u_int16_t not defined.])],
9634c1a0b88Schristos	[AC_INCLUDES_DEFAULT
9644c1a0b88Schristos#include <sys/types.h>
9654c1a0b88Schristos])
9664c1a0b88SchristosAC_CHECK_TYPE([u_int32_t], ,
9674c1a0b88Schristos	[AC_DEFINE([u_int32_t], [uint32_t],
9684c1a0b88Schristos	[Define to `uint32_t' if u_int32_t not defined.])],
9694c1a0b88Schristos	[AC_INCLUDES_DEFAULT
9704c1a0b88Schristos#include <sys/types.h>
9714c1a0b88Schristos])
9724c1a0b88SchristosAC_CHECK_TYPE([u_int64_t], ,
9734c1a0b88Schristos	[AC_DEFINE([u_int64_t], [uint64_t],
9744c1a0b88Schristos	[Define to `uint64_t' if u_int64_t not defined.])],
9754c1a0b88Schristos	[AC_INCLUDES_DEFAULT
9764c1a0b88Schristos#include <sys/types.h>
9774c1a0b88Schristos])
9784c1a0b88Schristos
9794c1a0b88SchristosAC_PROG_RANLIB
9804c1a0b88SchristosAC_CHECK_TOOL([AR], [ar])
9814c1a0b88Schristos
9824c1a0b88SchristosAC_LBL_DEVEL(V_CCOPT)
9834c1a0b88Schristos
9844c1a0b88Schristos# Check for OpenSSL/libressl libcrypto
9854c1a0b88SchristosAC_MSG_CHECKING(whether to use OpenSSL/libressl libcrypto)
9864c1a0b88Schristos# Specify location for both includes and libraries.
9874c1a0b88Schristoswant_libcrypto=ifavailable
9884c1a0b88SchristosAC_ARG_WITH(crypto,
9894c1a0b88Schristos    AS_HELP_STRING([--with-crypto]@<:@=DIR@:>@,
9904c1a0b88Schristos		   [use OpenSSL/libressl libcrypto (located in directory DIR, if specified) @<:@default=yes, if available@:>@]),
9914c1a0b88Schristos[
9924c1a0b88Schristos	if test $withval = no
9934c1a0b88Schristos	then
9944c1a0b88Schristos		# User doesn't want to link with libcrypto.
9954c1a0b88Schristos		want_libcrypto=no
9964c1a0b88Schristos		AC_MSG_RESULT(no)
9974c1a0b88Schristos	elif test $withval = yes
9984c1a0b88Schristos	then
9994c1a0b88Schristos		# User wants to link with libcrypto but hasn't specified
10004c1a0b88Schristos		# a directory.
10014c1a0b88Schristos		want_libcrypto=yes
10024c1a0b88Schristos		AC_MSG_RESULT(yes)
10034c1a0b88Schristos	else
10044c1a0b88Schristos		# User wants to link with libcrypto and has specified
10054c1a0b88Schristos		# a directory, so use the provided value.
10064c1a0b88Schristos		want_libcrypto=yes
10074c1a0b88Schristos		libcrypto_root=$withval
10084c1a0b88Schristos		AC_MSG_RESULT([yes, using the version installed in $withval])
10094c1a0b88Schristos	fi
10104c1a0b88Schristos],[
10114c1a0b88Schristos	#
10124c1a0b88Schristos	# Use libcrypto if it's present, otherwise don't; no directory
10134c1a0b88Schristos	# was specified.
10144c1a0b88Schristos	#
10154c1a0b88Schristos	want_libcrypto=ifavailable
10164c1a0b88Schristos	AC_MSG_RESULT([yes, if available])
10174c1a0b88Schristos])
10184c1a0b88Schristosif test "$want_libcrypto" != "no"; then
10194c1a0b88Schristos	#
1020*c41df9f6Schristos	# Were we told where to look for libcrypto?
10214c1a0b88Schristos	#
1022*c41df9f6Schristos	if test -z "$libcrypto_root"; then
1023*c41df9f6Schristos		#
1024*c41df9f6Schristos		# No.
1025*c41df9f6Schristos		#
1026*c41df9f6Schristos		# First, try looking for it with pkg-config, if we have it.
1027*c41df9f6Schristos		#
1028*c41df9f6Schristos		# Homebrew's pkg-config does not, by default, look for
1029*c41df9f6Schristos		# pkg-config files for packages it has installed.
1030*c41df9f6Schristos		# Furthermore, at least for OpenSSL, they appear to be
1031*c41df9f6Schristos		# dumped in package-specific directories whose paths are
1032*c41df9f6Schristos		# not only package-specific but package-version-specific.
1033*c41df9f6Schristos		#
1034*c41df9f6Schristos		# So the only way to find openssl is to get the value of
1035*c41df9f6Schristos		# PKG_CONFIG_PATH from "brew --env openssl" and add that
1036*c41df9f6Schristos		# to PKG_CONFIG_PATH.  (No, we can't just assume it's under
1037*c41df9f6Schristos		# /usr/local; Homebrew have conveniently chosen to put it
1038*c41df9f6Schristos		# under /opt/homebrew on ARM.)
1039*c41df9f6Schristos		#
1040*c41df9f6Schristos		# That's the nice thing about Homebrew - it makes things easier!
1041*c41df9f6Schristos		# Thanks!
1042*c41df9f6Schristos		#
1043*c41df9f6Schristos		save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
1044*c41df9f6Schristos		if test -n "$BREW"; then
1045*c41df9f6Schristos			openssl_pkgconfig_dir=`$BREW --env --plain openssl | sed -n 's/PKG_CONFIG_PATH: //p'`
1046*c41df9f6Schristos			PKG_CONFIG_PATH="$openssl_pkgconfig_dir:$PKG_CONFIG_PATH"
1047*c41df9f6Schristos		fi
1048*c41df9f6Schristos		PKG_CHECK_MODULE(LIBCRYPTO, libcrypto,
10494c1a0b88Schristos		    [
1050*c41df9f6Schristos			#
1051*c41df9f6Schristos			# We found OpenSSL/libressl libcrypto.
1052*c41df9f6Schristos			#
1053*c41df9f6Schristos			HAVE_LIBCRYPTO=yes
1054*c41df9f6Schristos		    ])
1055*c41df9f6Schristos		PKG_CONFIG_PATH="$save_PKG_CONFIG_PATH"
1056*c41df9f6Schristos
1057*c41df9f6Schristos		#
1058*c41df9f6Schristos		# If it wasn't found, and we have Homebrew installed, see
1059*c41df9f6Schristos		# if it's in Homebrew.
1060*c41df9f6Schristos		#
1061*c41df9f6Schristos		if test "x$HAVE_LIBCRYPTO" != "xyes" -a -n "$BREW"; then
1062*c41df9f6Schristos			AC_MSG_CHECKING(for openssl in Homebrew)
1063*c41df9f6Schristos			#
1064*c41df9f6Schristos			# The brew man page lies when it speaks of
1065*c41df9f6Schristos			# $BREW --prefix --installed <formula>
1066*c41df9f6Schristos			# outputting nothing.  In Homebrew 3.3.16,
1067*c41df9f6Schristos			# it produces output regardless of whether
1068*c41df9f6Schristos			# the formula is installed or not, so we
1069*c41df9f6Schristos			# send the standard output and error to
1070*c41df9f6Schristos			# the bit bucket.
1071*c41df9f6Schristos			#
1072*c41df9f6Schristos			# libcrypto isn't a formula, openssl is a formula.
1073*c41df9f6Schristos			#
1074*c41df9f6Schristos			if $BREW --prefix --installed openssl >/dev/null 2>&1; then
1075*c41df9f6Schristos				#
1076*c41df9f6Schristos				# Yes.  Get the include directory and library
1077*c41df9f6Schristos				# directory.  (No, we can't just assume it's
1078*c41df9f6Schristos				# under /usr/local; Homebrew have conveniently
1079*c41df9f6Schristos				# chosen to put it under /opt/homebrew on ARM.)
1080*c41df9f6Schristos				#
1081*c41df9f6Schristos				AC_MSG_RESULT(yes)
1082*c41df9f6Schristos				HAVE_LIBCRYPTO=yes
1083*c41df9f6Schristos				openssl_path=`$BREW --prefix openssl`
1084*c41df9f6Schristos				LIBCRYPTO_CFLAGS="-I$openssl_path/include"
1085*c41df9f6Schristos				LIBCRYPTO_LIBS="-L$openssl_path/lib -lcrypto"
1086*c41df9f6Schristos			else
1087*c41df9f6Schristos				AC_MSG_RESULT(no)
1088*c41df9f6Schristos			fi
1089*c41df9f6Schristos		fi
1090*c41df9f6Schristos
1091*c41df9f6Schristos		#
1092*c41df9f6Schristos		# If it wasn't found, and /usr/local/include and /usr/local/lib
1093*c41df9f6Schristos		# exist, check if it's in /usr/local.  (We check whether they
1094*c41df9f6Schristos		# exist because, if they don't exist, the compiler will warn
1095*c41df9f6Schristos		# about that and then ignore the argument, so they test
1096*c41df9f6Schristos		# using just the system header files and libraries.)
1097*c41df9f6Schristos		#
1098*c41df9f6Schristos		# We include the standard include file to 1) make sure that
1099*c41df9f6Schristos		# it's installed (if it's just a shared library for the
1100*c41df9f6Schristos		# benefit of existing programs, that's not useful) and 2)
1101*c41df9f6Schristos		# because SSL_library_init() is a library routine in some
1102*c41df9f6Schristos		# versions and a #defined wrapper around OPENSSL_init_ssl()
1103*c41df9f6Schristos		# in others.
1104*c41df9f6Schristos		#
1105*c41df9f6Schristos		if test "x$HAVE_LIBCRYPTO" != "xyes" -a -d "/usr/local/include" -a -d "/usr/local/lib"; then
1106*c41df9f6Schristos			AC_LBL_SAVE_CHECK_STATE
1107*c41df9f6Schristos			CFLAGS="$CFLAGS -I/usr/local/include"
1108*c41df9f6Schristos			LIBS="$LIBS -L/usr/local/lib -lcrypto"
1109*c41df9f6Schristos			AC_MSG_CHECKING(whether we have an OpenSSL/libressl libcrypto in /usr/local that we can use)
1110*c41df9f6Schristos			AC_LINK_IFELSE([AC_LANG_PROGRAM(
1111*c41df9f6Schristos			    [[
1112*c41df9f6Schristos#include <openssl/evp.h>
1113*c41df9f6Schristos			    ]],
1114*c41df9f6Schristos			    [[
1115*c41df9f6SchristosEVP_CIPHER_CTX_block_size((EVP_CIPHER_CTX *)0);
1116*c41df9f6Schristosreturn 0;
1117*c41df9f6Schristos			    ]])],
1118*c41df9f6Schristos			    [
1119*c41df9f6Schristos				AC_MSG_RESULT(yes)
1120*c41df9f6Schristos				HAVE_LIBCRYPTO=yes
1121*c41df9f6Schristos				LIBCRYPTO_CFLAGS="-I/usr/local/include"
1122*c41df9f6Schristos				LIBCRYPTO_LIBS="-L/usr/local/lib -lcrypto"
1123*c41df9f6Schristos			    ],
1124*c41df9f6Schristos			    AC_MSG_RESULT(no))
1125*c41df9f6Schristos			AC_LBL_RESTORE_CHECK_STATE
1126*c41df9f6Schristos		fi
1127*c41df9f6Schristos
1128*c41df9f6Schristos		#
1129*c41df9f6Schristos		# If it wasn't found, check if it's a system library.
1130*c41df9f6Schristos		#
1131*c41df9f6Schristos		# We include the standard include file to 1) make sure that
1132*c41df9f6Schristos		# it's installed (if it's just a shared library for the
1133*c41df9f6Schristos		# benefit of existing programs, that's not useful) and 2)
1134*c41df9f6Schristos		# make sure this isn't a newer macOS that provides libcrypto
1135*c41df9f6Schristos		# as a shared library but doesn't provide headers - Apple,
1136*c41df9f6Schristos		# bless their pointy little heads, apparently ship libcrypto
1137*c41df9f6Schristos		# as a library, but not the header files, in El Capitan and
1138*c41df9f6Schristos		# later, probably because they don't want you writing nasty
1139*c41df9f6Schristos		# portable code that could run on other UN*Xes, they want you
1140*c41df9f6Schristos		# writing code that uses their Shiny New Crypto Library and
1141*c41df9f6Schristos		# that thus only runs on macOS.
1142*c41df9f6Schristos		#
1143*c41df9f6Schristos		if test "x$HAVE_LIBCRYPTO" != "xyes"; then
1144*c41df9f6Schristos			AC_LBL_SAVE_CHECK_STATE
1145*c41df9f6Schristos			LIBS="$LIBS -lcrypto"
1146*c41df9f6Schristos			AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use)
1147*c41df9f6Schristos			AC_LINK_IFELSE([AC_LANG_PROGRAM(
1148*c41df9f6Schristos			    [[
1149*c41df9f6Schristos#include <openssl/evp.h>
1150*c41df9f6Schristos			    ]],
1151*c41df9f6Schristos			    [[
1152*c41df9f6SchristosEVP_CIPHER_CTX_block_size((EVP_CIPHER_CTX *)0);
1153*c41df9f6Schristosreturn 0;
1154*c41df9f6Schristos			    ]])],
1155*c41df9f6Schristos			    [
1156*c41df9f6Schristos				AC_MSG_RESULT(yes)
1157*c41df9f6Schristos				HAVE_LIBCRYPTO=yes
1158*c41df9f6Schristos				LIBCRYPTO_LIBS="-lcrypto"
1159*c41df9f6Schristos			    ],
1160*c41df9f6Schristos			    AC_MSG_RESULT(no))
1161*c41df9f6Schristos			AC_LBL_RESTORE_CHECK_STATE
1162*c41df9f6Schristos		fi
1163*c41df9f6Schristos	else
1164*c41df9f6Schristos		#
1165*c41df9f6Schristos		# Yes.
1166*c41df9f6Schristos		#
1167*c41df9f6Schristos		# Look for it there.
1168*c41df9f6Schristos		#
1169*c41df9f6Schristos		AC_LBL_SAVE_CHECK_STATE
1170*c41df9f6Schristos		CFLAGS="$CFLAGS -I$libcrypto_root/include"
1171*c41df9f6Schristos		LIBS="$LIBS -L$libcrypto_root/lib -lcrypto"
1172*c41df9f6Schristos		AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use)
1173*c41df9f6Schristos		AC_LINK_IFELSE([AC_LANG_PROGRAM(
1174*c41df9f6Schristos		    [[
1175*c41df9f6Schristos#include <openssl/evp.h>
1176*c41df9f6Schristos		    ]],
1177*c41df9f6Schristos		    [[
1178*c41df9f6SchristosEVP_CIPHER_CTX_block_size((EVP_CIPHER_CTX *)0);
1179*c41df9f6Schristosreturn 0;
1180*c41df9f6Schristos		    ]])],
1181*c41df9f6Schristos		    [
1182*c41df9f6Schristos			AC_MSG_RESULT(yes)
1183*c41df9f6Schristos			HAVE_LIBCRYPTO=yes
1184*c41df9f6Schristos			LIBCRYPTO_CFLAGS="-I$libcrypto_root/include"
1185*c41df9f6Schristos			LIBCRYPTO_LIBS="-L$libcrypto_root/lib -lcrypto"
1186*c41df9f6Schristos		    ],
1187*c41df9f6Schristos		    AC_MSG_RESULT(no))
1188*c41df9f6Schristos		AC_LBL_RESTORE_CHECK_STATE
1189*c41df9f6Schristos	fi
1190*c41df9f6Schristos
1191*c41df9f6Schristos	#
1192*c41df9f6Schristos	# OK, did we find it?
1193*c41df9f6Schristos	#
1194*c41df9f6Schristos	if test "x$HAVE_LIBCRYPTO" = "xyes"; then
1195*c41df9f6Schristos		AC_DEFINE([HAVE_LIBCRYPTO], [1], [Define to 1 if you have a usable `crypto' library (-lcrypto).])
1196*c41df9f6Schristos
1197*c41df9f6Schristos		#
1198*c41df9f6Schristos		# Put the subdirectories of the libcrypto root directory
1199*c41df9f6Schristos		# at the end of the header and library search path, to
1200*c41df9f6Schristos		# make sure they come after any -I or -L flags for
1201*c41df9f6Schristos		# a local libpcap - those must take precedence of any
1202*c41df9f6Schristos		# directory that might contain an installed version of
1203*c41df9f6Schristos		# libpcap.
1204*c41df9f6Schristos		#
1205*c41df9f6Schristos		V_INCLS="$V_INCLS $LIBCRYPTO_CFLAGS"
1206*c41df9f6Schristos		LIBS="$LIBS $LIBCRYPTO_LIBS"
1207*c41df9f6Schristos
12084c1a0b88Schristos		#
12094c1a0b88Schristos		# OK, then:
12104c1a0b88Schristos		#
12114c1a0b88Schristos		# 1) do we have EVP_CIPHER_CTX_new?
1212*c41df9f6Schristos		# If so, we use it to allocate an EVP_CIPHER_CTX, as
1213*c41df9f6Schristos		# EVP_CIPHER_CTX may be opaque; otherwise, we allocate it
1214*c41df9f6Schristos		# ourselves.
12154c1a0b88Schristos		#
1216d881c474Schristos		# 2) do we have EVP_DecryptInit_ex()?
1217*c41df9f6Schristos		# If so, we use it, because we need to be able to make
1218*c41df9f6Schristos		# two "initialize the cipher" calls, one with the cipher
1219*c41df9f6Schristos		# and key, and one with the IV, and, as of OpenSSL 1.1,
1220*c41df9f6Schristos		# You Can't Do That with EVP_DecryptInit(), because a
1221*c41df9f6Schristos		# call to EVP_DecryptInit() will unconditionally clear
1222*c41df9f6Schristos		# the context, and if you don't supply a cipher, it'll
1223*c41df9f6Schristos		# clear the cipher, rendering the context unusable and
1224*c41df9f6Schristos		# causing a crash.
12254c1a0b88Schristos		#
1226d881c474Schristos		AC_CHECK_FUNCS(EVP_CIPHER_CTX_new EVP_DecryptInit_ex)
1227*c41df9f6Schristos	else
1228*c41df9f6Schristos		AC_MSG_NOTICE(OpenSSL/libressl libcrypto not found)
12294c1a0b88Schristos	fi
12304c1a0b88Schristosfi
12314c1a0b88Schristos
12324c1a0b88Schristos# Check for libcap-ng
12334c1a0b88SchristosAC_MSG_CHECKING(whether to use libcap-ng)
12344c1a0b88Schristos# Specify location for both includes and libraries.
12354c1a0b88Schristoswant_libcap_ng=ifavailable
12364c1a0b88SchristosAC_ARG_WITH(cap_ng,
12374c1a0b88Schristos    AS_HELP_STRING([--with-cap-ng],
12384c1a0b88Schristos		   [use libcap-ng @<:@default=yes, if available@:>@]),
12394c1a0b88Schristos[
12404c1a0b88Schristos	if test $withval = no
12414c1a0b88Schristos	then
12424c1a0b88Schristos		want_libcap_ng=no
12434c1a0b88Schristos		AC_MSG_RESULT(no)
12444c1a0b88Schristos	elif test $withval = yes
12454c1a0b88Schristos	then
12464c1a0b88Schristos		want_libcap_ng=yes
12474c1a0b88Schristos		AC_MSG_RESULT(yes)
12484c1a0b88Schristos	fi
12494c1a0b88Schristos],[
12504c1a0b88Schristos	#
12514c1a0b88Schristos	# Use libcap-ng if it's present, otherwise don't.
12524c1a0b88Schristos	#
12534c1a0b88Schristos	want_libcap_ng=ifavailable
12544c1a0b88Schristos	AC_MSG_RESULT([yes, if available])
12554c1a0b88Schristos])
12564c1a0b88Schristosif test "$want_libcap_ng" != "no"; then
12574c1a0b88Schristos	AC_CHECK_LIB(cap-ng, capng_change_id)
12584c1a0b88Schristos	AC_CHECK_HEADERS(cap-ng.h)
12594c1a0b88Schristosfi
12604c1a0b88Schristos
12614c1a0b88Schristosdnl
12624c1a0b88Schristosdnl set additional include path if necessary
12634c1a0b88Schristosif test "$missing_includes" = "yes"; then
12644c1a0b88Schristos	CPPFLAGS="$CPPFLAGS -I$srcdir/missing"
12654c1a0b88Schristos	V_INCLS="$V_INCLS -I$srcdir/missing"
12664c1a0b88Schristosfi
12674c1a0b88Schristos
12684c1a0b88SchristosAC_SUBST(V_CCOPT)
12694c1a0b88SchristosAC_SUBST(V_DEFS)
12704c1a0b88SchristosAC_SUBST(V_INCLS)
12714c1a0b88SchristosAC_SUBST(V_PCAPDEP)
12724c1a0b88SchristosAC_SUBST(LOCALSRC)
12734c1a0b88SchristosAC_SUBST(MAN_FILE_FORMATS)
12744c1a0b88SchristosAC_SUBST(MAN_MISC_INFO)
12754c1a0b88Schristos
12764c1a0b88SchristosAC_PROG_INSTALL
12774c1a0b88Schristos
12784c1a0b88SchristosAC_CONFIG_HEADER(config.h)
12794c1a0b88Schristos
1280*c41df9f6SchristosAC_CONFIG_COMMANDS([.devel],[[if test -f .devel; then
12814c1a0b88Schristos	echo timestamp > stamp-h
1282d881c474Schristos	cat $srcdir/Makefile-devel-adds >> Makefile
1283d881c474Schristos	make depend || exit 1
1284*c41df9f6Schristosfi]],[[]])
1285*c41df9f6SchristosAC_CONFIG_FILES([Makefile tcpdump.1])
1286*c41df9f6SchristosAC_OUTPUT
12874c1a0b88Schristosexit 0
1288