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