• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1dnl
2dnl Copyright (c) 1994, 1995, 1996, 1997
3dnl	The Regents of the University of California.  All rights reserved.
4dnl
5dnl Process this file with autoconf to produce a configure script.
6dnl
7
8#
9# See
10#
11#	https://ftp.gnu.org/gnu/config/README
12#
13# for the URLs to use to fetch new versions of config.guess and
14# config.sub.
15#
16
17AC_PREREQ(2.64)
18
19AC_INIT(pcap, m4_esyscmd_s([cat VERSION]))
20AC_CONFIG_SRCDIR(pcap.c)
21AC_SUBST(PACKAGE_NAME)
22
23AC_CANONICAL_SYSTEM
24
25AC_LBL_C_INIT_BEFORE_CC(V_CCOPT, V_INCLS)
26#
27# We require C99 or later.
28# Try to get it, which may involve adding compiler flags;
29# if that fails, give up.
30#
31AC_PROG_CC_C99
32if test "$ac_cv_prog_cc_c99" = "no"; then
33	AC_MSG_ERROR([The C compiler does not support C99])
34fi
35case "$host_os" in
36haiku*)
37	#
38	# Haiku's platform file is in C++.
39	#
40	AC_PROG_CXX
41	;;
42esac
43
44AC_LBL_C_INIT(V_CCOPT, V_INCLS)
45AC_LBL_SHLIBS_INIT
46AC_LBL_C_INLINE
47
48#
49# Try to arrange for large file support.
50#
51AC_SYS_LARGEFILE
52AC_FUNC_FSEEKO
53
54dnl
55dnl Even if <net/bpf.h> were, on all OSes that support BPF, fixed to
56dnl include <sys/ioccom.h>, and we were to drop support for older
57dnl releases without that fix, so that pcap-bpf.c doesn't need to
58dnl include <sys/ioccom.h>, the test program in "AC_LBL_FIXINCLUDES"
59dnl in "aclocal.m4" uses it, so we would still have to test for it
60dnl and set "HAVE_SYS_IOCCOM_H" if we have it, otherwise
61dnl "AC_LBL_FIXINCLUDES" wouldn't work on some platforms such as Solaris.
62dnl
63AC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h)
64AC_CHECK_HEADERS(netpacket/packet.h)
65AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
66#include <sys/socket.h>
67#include <net/if.h>])
68if test "$ac_cv_header_net_pfvar_h" = yes; then
69	#
70	# Check for various PF actions.
71	#
72	AC_MSG_CHECKING(whether net/pfvar.h defines PF_NAT through PF_NORDR)
73	AC_TRY_COMPILE(
74	    [#include <sys/types.h>
75	    #include <sys/socket.h>
76	    #include <net/if.h>
77	    #include <net/pfvar.h>],
78	    [return PF_NAT+PF_NONAT+PF_BINAT+PF_NOBINAT+PF_RDR+PF_NORDR;],
79	    [
80		AC_MSG_RESULT(yes)
81		AC_DEFINE(HAVE_PF_NAT_THROUGH_PF_NORDR, 1,
82		    [define if net/pfvar.h defines PF_NAT through PF_NORDR])
83	    ],
84	    AC_MSG_RESULT(no))
85fi
86
87case "$host_os" in
88haiku*)
89	#
90	# Haiku needs _BSD_SOURCE for the _IO* macros because it doesn't use them.
91	#
92	CFLAGS="$CFLAGS -D_BSD_SOURCE"
93	;;
94esac
95
96AC_LBL_FIXINCLUDES
97
98AC_CHECK_FUNCS(strerror)
99AC_CHECK_FUNC(strerror_r,
100    [
101	#
102	# We have strerror_r; if we define _GNU_SOURCE, is it a
103	# POSIX-compliant strerror_r() or a GNU strerror_r()?
104	#
105	AC_MSG_CHECKING(whether strerror_r is GNU-style)
106	AC_COMPILE_IFELSE(
107	    [
108		AC_LANG_SOURCE(
109#define _GNU_SOURCE
110#include <string.h>
111
112/* Define it GNU-style; that will cause an error if it's not GNU-style */
113extern char *strerror_r(int, char *, size_t);
114
115int
116main(void)
117{
118	return 0;
119}
120)
121	    ],
122	    [
123	        # GNU-style
124		AC_MSG_RESULT(yes)
125		AC_DEFINE(HAVE_GNU_STRERROR_R,,
126		    [Define to 1 if you have a GNU-style `strerror_r' function.])
127	    ],
128	    [
129		AC_MSG_RESULT(no)
130		AC_DEFINE(HAVE_POSIX_STRERROR_R,,
131		    [Define to 1 if you have a POSIX-style `strerror_r' function.])
132	    ])
133    ],
134    [
135	#
136	# We don't have strerror_r; do we have _wcserror_s?
137	#
138	AC_CHECK_FUNCS(_wcserror_s)
139    ])
140
141#
142# Thanks, IBM, for not providing vsyslog() in AIX!
143#
144AC_CHECK_FUNCS(vsyslog)
145
146#
147# Make sure we have vsnprintf() and snprintf(); we require them.
148#
149AC_CHECK_FUNC(vsnprintf,,
150    AC_MSG_ERROR([vsnprintf() is required but wasn't found]))
151AC_CHECK_FUNC(snprintf,,
152    AC_MSG_ERROR([snprintf() is required but wasn't found]))
153
154needasprintf=no
155AC_CHECK_FUNCS(vasprintf asprintf,,
156	[needasprintf=yes])
157if test $needasprintf = yes; then
158	AC_LIBOBJ([asprintf])
159fi
160
161needstrlcat=no
162AC_CHECK_FUNCS(strlcat,,
163	[needstrlcat=yes])
164if test $needstrlcat = yes; then
165	AC_LIBOBJ([strlcat])
166fi
167
168needstrlcpy=no
169AC_CHECK_FUNCS(strlcpy,,
170	[needstrlcpy=yes])
171if test $needstrlcpy = yes; then
172	AC_LIBOBJ([strlcpy])
173fi
174
175needstrtok_r=no
176AC_CHECK_FUNCS(strtok_r,,
177	[needstrtok_r=yes])
178if test $needstrtok_r = yes; then
179	AC_LIBOBJ([strtok_r])
180fi
181
182#
183# Do we have ffs(), and is it declared in <strings.h>?
184#
185AC_CHECK_FUNCS(ffs)
186if test "$ac_cv_func_ffs" = yes; then
187	#
188	# We have ffs(); is it declared in <strings.h>?
189	#
190	# This test fails if we don't have <strings.h> or if we do
191	# but it doesn't declare ffs().
192	#
193	AC_CHECK_DECL(ffs,
194	    [
195		AC_DEFINE(STRINGS_H_DECLARES_FFS,,
196		    [Define to 1 if strings.h declares `ffs'])
197	    ],,
198	    [
199#include <strings.h>
200	    ])
201fi
202
203#
204# Do this before checking for ether_hostton(), as it's a
205# "getaddrinfo()-ish function".
206#
207AC_LBL_LIBRARY_NET
208
209#
210# Check for reentrant versions of getnetbyname_r(), as provided by
211# Linux (glibc), Solaris/IRIX, and AIX (with three different APIs!).
212# If we don't find one, we just use getnetbyname(), which uses
213# thread-specific data on many platforms, but doesn't use it on
214# NetBSD or OpenBSD, and may not use it on older versions of other
215# platforms.
216#
217# Only do the check if we have a declaration of getnetbyname_r();
218# without it, we can't check which API it has.  (We assume that
219# if there's a declaration, it has a prototype, so that the API
220# can be checked.)
221#
222AC_CHECK_DECL(getnetbyname_r,
223    [
224	AC_MSG_CHECKING([for the Linux getnetbyname_r()])
225	AC_TRY_LINK(
226	    [#include <netdb.h>],
227	    [
228		struct netent netent_buf;
229		char buf[1024];
230		struct netent *resultp;
231		int h_errnoval;
232
233		return getnetbyname_r((const char *)0, &netent_buf, buf, sizeof buf, &resultp, &h_errnoval);
234	    ],
235	    [
236		AC_MSG_RESULT(yes)
237		AC_DEFINE(HAVE_LINUX_GETNETBYNAME_R, 1,
238		    [define if we have the Linux getnetbyname_r()])
239	    ],
240	    [
241		AC_MSG_RESULT(no)
242
243		AC_MSG_CHECKING([for Solaris/IRIX getnetbyname_r()])
244		AC_TRY_LINK(
245		    [#include <netdb.h>],
246		    [
247			struct netent netent_buf;
248			char buf[1024];
249
250			return getnetbyname_r((const char *)0, &netent_buf, buf, (int)sizeof buf) != NULL;
251		    ],
252		    [
253			AC_MSG_RESULT(yes)
254			AC_DEFINE(HAVE_SOLARIS_IRIX_GETNETBYNAME_R, 1,
255			    [define if we have the Solaris/IRIX getnetbyname_r()])
256		    ],
257		    [
258			AC_MSG_RESULT(no)
259
260			AC_MSG_CHECKING([for AIX getnetbyname_r()])
261			AC_TRY_LINK(
262			    [#include <netdb.h>],
263			    [
264				struct netent netent_buf;
265				struct netent_data net_data;
266
267				return getnetbyname_r((const char *)0, &netent_buf, &net_data);
268			    ],
269			    [
270				AC_MSG_RESULT(yes)
271				AC_DEFINE(HAVE_AIX_GETNETBYNAME_R, 1,
272				    [define if we have the AIX getnetbyname_r()])
273			    ],
274			    [
275				AC_MSG_RESULT(no)
276			    ])
277		    ])
278	    ])
279    ],,[#include <netdb.h>])
280
281#
282# Check for reentrant versions of getprotobyname_r(), as provided by
283# Linux (glibc), Solaris/IRIX, and AIX (with three different APIs!).
284# If we don't find one, we just use getprotobyname(), which uses
285# thread-specific data on many platforms, but doesn't use it on
286# NetBSD or OpenBSD, and may not use it on older versions of other
287# platforms.
288#
289# Only do the check if we have a declaration of getprotobyname_r();
290# without it, we can't check which API it has.  (We assume that
291# if there's a declaration, it has a prototype, so that the API
292# can be checked.)
293#
294AC_CHECK_DECL(getprotobyname_r,
295    [
296	AC_MSG_CHECKING([for the Linux getprotobyname_r()])
297	AC_TRY_LINK(
298	    [#include <netdb.h>],
299	    [
300		struct protoent protoent_buf;
301		char buf[1024];
302		struct protoent *resultp;
303
304		return getprotobyname_r((const char *)0, &protoent_buf, buf, sizeof buf, &resultp);
305	    ],
306	    [
307		AC_MSG_RESULT(yes)
308		AC_DEFINE(HAVE_LINUX_GETPROTOBYNAME_R, 1,
309		    [define if we have the Linux getprotobyname_r()])
310	    ],
311	    [
312		AC_MSG_RESULT(no)
313
314		AC_MSG_CHECKING([for Solaris/IRIX getprotobyname_r()])
315		AC_TRY_LINK(
316		    [#include <netdb.h>],
317		    [
318			struct protoent protoent_buf;
319			char buf[1024];
320
321			return getprotobyname_r((const char *)0, &protoent_buf, buf, (int)sizeof buf) != NULL;
322		    ],
323		    [
324			AC_MSG_RESULT(yes)
325			AC_DEFINE(HAVE_SOLARIS_IRIX_GETPROTOBYNAME_R, 1,
326			    [define if we have the Solaris/IRIX getprotobyname_r()])
327		    ],
328		    [
329			AC_MSG_RESULT(no)
330
331			AC_MSG_CHECKING([for AIX getprotobyname_r()])
332			AC_TRY_LINK(
333			    [#include <netdb.h>],
334			    [
335				struct protoent protoent_buf;
336				struct protoent_data proto_data;
337
338				return getprotobyname_r((const char *)0, &protoent_buf, &proto_data);
339			    ],
340			    [
341				AC_MSG_RESULT(yes)
342				AC_DEFINE(HAVE_AIX_GETPROTOBYNAME_R, 1,
343				    [define if we have the AIX getprotobyname_r()])
344			    ],
345			    [
346				AC_MSG_RESULT(no)
347			    ])
348		    ])
349	    ])
350    ],,[#include <netdb.h>])
351
352#
353# You are in a twisty little maze of UN*Xes, all different.
354# Some might not have ether_hostton().
355# Some might have it and declare it in <net/ethernet.h>.
356# Some might have it and declare it in <netinet/ether.h>
357# Some might have it and declare it in <sys/ethernet.h>.
358# Some might have it and declare it in <arpa/inet.h>.
359# Some might have it and declare it in <netinet/if_ether.h>.
360# Some might have it and not declare it in any header file.
361#
362# Before you is a C compiler.
363#
364AC_CHECK_FUNCS(ether_hostton)
365if test "$ac_cv_func_ether_hostton" = yes; then
366	#
367	# OK, we have ether_hostton().  Is it declared in <net/ethernet.h>?
368	#
369	# This test fails if we don't have <net/ethernet.h> or if we do
370	# but it doesn't declare ether_hostton().
371	#
372	AC_CHECK_DECL(ether_hostton,
373	    [
374		AC_DEFINE(NET_ETHERNET_H_DECLARES_ETHER_HOSTTON,,
375		    [Define to 1 if net/ethernet.h declares `ether_hostton'])
376	    ],,
377	    [
378#include <net/ethernet.h>
379	    ])
380	#
381	# Did that succeed?
382	#
383	if test "$ac_cv_have_decl_ether_hostton" != yes; then
384		#
385		# No, how about <netinet/ether.h>, as on Linux?
386		#
387		# This test fails if we don't have <netinet/ether.h>
388		# or if we do but it doesn't declare ether_hostton().
389		#
390		# Unset ac_cv_have_decl_ether_hostton so we don't
391		# treat the previous failure as a cached value and
392		# suppress the next test.
393		#
394		unset ac_cv_have_decl_ether_hostton
395		AC_CHECK_DECL(ether_hostton,
396		    [
397			AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_HOSTTON,,
398			    [Define to 1 if netinet/ether.h declares `ether_hostton'])
399		    ],,
400		    [
401#include <netinet/ether.h>
402		    ])
403	fi
404	#
405	# Did that succeed?
406	#
407	if test "$ac_cv_have_decl_ether_hostton" != yes; then
408		#
409		# No, how about <sys/ethernet.h>, as on Solaris 10
410		# and later?
411		#
412		# This test fails if we don't have <sys/ethernet.h>
413		# or if we do but it doesn't declare ether_hostton().
414		#
415		# Unset ac_cv_have_decl_ether_hostton so we don't
416		# treat the previous failure as a cached value and
417		# suppress the next test.
418		#
419		unset ac_cv_have_decl_ether_hostton
420		AC_CHECK_DECL(ether_hostton,
421		    [
422			AC_DEFINE(SYS_ETHERNET_H_DECLARES_ETHER_HOSTTON,,
423			    [Define to 1 if sys/ethernet.h declares `ether_hostton'])
424		    ],,
425		    [
426#include <sys/ethernet.h>
427		    ])
428	fi
429	#
430	# Did that succeed?
431	#
432	if test "$ac_cv_have_decl_ether_hostton" != yes; then
433		#
434		# No, how about <arpa/inet.h>, as in AIX?
435		#
436		# This test fails if we don't have <arpa/inet.h>
437		# (if we have ether_hostton(), we should have
438		# networking, and if we have networking, we should
439		# have <arapa/inet.h>) or if we do but it doesn't
440		# declare ether_hostton().
441		#
442		# Unset ac_cv_have_decl_ether_hostton so we don't
443		# treat the previous failure as a cached value and
444		# suppress the next test.
445		#
446		unset ac_cv_have_decl_ether_hostton
447		AC_CHECK_DECL(ether_hostton,
448		    [
449			AC_DEFINE(ARPA_INET_H_DECLARES_ETHER_HOSTTON,,
450			    [Define to 1 if arpa/inet.h declares `ether_hostton'])
451		    ],,
452		    [
453#include <arpa/inet.h>
454		    ])
455	fi
456	#
457	# Did that succeed?
458	#
459	if test "$ac_cv_have_decl_ether_hostton" != yes; then
460		#
461		# No, how about <netinet/if_ether.h>?
462		# On some platforms, it requires <net/if.h> and
463		# <netinet/in.h>, and we always include it with
464		# both of them, so test it with both of them.
465		#
466		# This test fails if we don't have <netinet/if_ether.h>
467		# and the headers we include before it, or if we do but
468		# <netinet/if_ether.h> doesn't declare ether_hostton().
469		#
470		# Unset ac_cv_have_decl_ether_hostton so we don't
471		# treat the previous failure as a cached value and
472		# suppress the next test.
473		#
474		unset ac_cv_have_decl_ether_hostton
475		AC_CHECK_DECL(ether_hostton,
476		    [
477			AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON,,
478			    [Define to 1 if netinet/if_ether.h declares `ether_hostton'])
479		    ],,
480		    [
481#include <sys/types.h>
482#include <sys/socket.h>
483#include <net/if.h>
484#include <netinet/in.h>
485#include <netinet/if_ether.h>
486		    ])
487	fi
488	#
489	# After all that, is ether_hostton() declared?
490	#
491	if test "$ac_cv_have_decl_ether_hostton" = yes; then
492		#
493		# Yes.
494		#
495		AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 1,
496		    [Define to 1 if you have the declaration of `ether_hostton'])
497        else
498		#
499		# No, we'll have to declare it ourselves.
500		# Do we have "struct ether_addr" if we include
501		# <netinet/if_ether.h>?
502		#
503		AC_CHECK_TYPES(struct ether_addr,,,
504		    [
505			#include <sys/types.h>
506			#include <sys/socket.h>
507			#include <net/if.h>
508			#include <netinet/in.h>
509			#include <netinet/if_ether.h>
510		    ])
511	fi
512fi
513
514#
515# For various things that might use pthreads.
516#
517AC_CHECK_HEADER(pthread.h,
518    [
519	#
520	# OK, we have pthread.h.  Do we have pthread_create in the
521	# system libraries?
522	#
523	AC_CHECK_FUNC(pthread_create,
524	    [
525		#
526		# Yes.
527		#
528		ac_lbl_have_pthreads="found"
529	    ],
530	    [
531		#
532		# No - do we have it in -lpthreads?
533		#
534		AC_CHECK_LIB(pthreads, pthread_create,
535		    [
536			#
537			# Yes - add -lpthreads.
538			#
539			ac_lbl_have_pthreads="found"
540			PTHREAD_LIBS="$PTHREAD_LIBS -lpthreads"
541		    ],
542		    [
543			#
544			# No - do we have it in -lpthread?
545			#
546			AC_CHECK_LIB(pthread, pthread_create,
547			    [
548				#
549				# Yes - add -lpthread.
550				#
551                                ac_lbl_have_pthreads="found"
552				PTHREAD_LIBS="$PTHREAD_LIBS -lpthread"
553			    ],
554			    [
555				#
556				# No.
557				#
558				ac_lbl_have_pthreads="not found"
559			    ])
560		    ])
561	    ])
562    ],
563    [
564	#
565	# We didn't find pthread.h.
566	#
567	ac_lbl_have_pthreads="not found"
568    ]
569)
570
571dnl to pacify those who hate protochain insn
572AC_MSG_CHECKING(if --disable-protochain option is specified)
573AC_ARG_ENABLE(protochain,
574AC_HELP_STRING([--disable-protochain],[disable \"protochain\" insn]))
575case "x$enable_protochain" in
576xyes)	enable_protochain=enabled	;;
577xno)	enable_protochain=disabled	;;
578x)	enable_protochain=enabled	;;
579esac
580
581if test "$enable_protochain" = "disabled"; then
582	AC_DEFINE(NO_PROTOCHAIN,1,[do not use protochain])
583fi
584AC_MSG_RESULT(${enable_protochain})
585
586#
587# valgrindtest directly uses the native capture mechanism, but
588# only tests with BPF and PF_PACKET sockets; only enable it if
589# we have BPF or PF_PACKET sockets.
590#
591VALGRINDTEST_SRC=
592
593AC_ARG_WITH(pcap,
594AC_HELP_STRING([--with-pcap=TYPE],[use packet capture TYPE]))
595if test ! -z "$with_pcap" ; then
596	V_PCAP="$withval"
597else
598	#
599	# Check for a bunch of headers for various packet
600	# capture mechanisms.
601	#
602	AC_CHECK_HEADERS(net/bpf.h)
603	if test "$ac_cv_header_net_bpf_h" = yes; then
604		#
605		# Does it define BIOCSETIF?
606		# I.e., is it a header for an LBL/BSD-style capture
607		# mechanism, or is it just a header for a BPF filter
608		# engine?  Some versions of Arch Linux, for example,
609		# have a net/bpf.h that doesn't define BIOCSETIF;
610		# as it's a Linux, it should use packet sockets,
611		# instead.
612		#
613		# We need:
614		#
615		#  sys/types.h, because FreeBSD 10's net/bpf.h
616		#  requires that various BSD-style integer types
617		#  be defined;
618		#
619		#  sys/time.h, because AIX 5.2 and 5.3's net/bpf.h
620		#  doesn't include it but does use struct timeval
621		#  in ioctl definitions;
622		#
623		#  sys/ioctl.h and, if we have it, sys/ioccom.h,
624		#  because net/bpf.h defines ioctls;
625		#
626		#  net/if.h, because it defines some structures
627		#  used in ioctls defined by net/bpf.h;
628		#
629		#  sys/socket.h, because OpenBSD 5.9's net/bpf.h
630		#  defines some structure fields as being
631		#  struct sockaddrs;
632		#
633		# and net/bpf.h doesn't necessarily include all
634		# of those headers itself.
635		#
636		AC_MSG_CHECKING(if net/bpf.h defines BIOCSETIF)
637		AC_CACHE_VAL(ac_cv_lbl_bpf_h_defines_biocsetif,
638			AC_TRY_COMPILE(
639[
640#include <sys/types.h>
641#include <sys/time.h>
642#include <sys/ioctl.h>
643#include <sys/socket.h>
644#ifdef HAVE_SYS_IOCCOM_H
645#include <sys/ioccom.h>
646#endif
647#include <net/bpf.h>
648#include <net/if.h>
649],
650			[u_int i = BIOCSETIF;],
651			ac_cv_lbl_bpf_h_defines_biocsetif=yes,
652			ac_cv_lbl_bpf_h_defines_biocsetif=no))
653		AC_MSG_RESULT($ac_cv_lbl_bpf_h_defines_biocsetif)
654	fi
655	AC_CHECK_HEADERS(net/pfilt.h net/enet.h)
656	AC_CHECK_HEADERS(net/nit.h sys/net/nit.h)
657	AC_CHECK_HEADERS(linux/socket.h net/raw.h sys/dlpi.h)
658	AC_CHECK_HEADERS(config/HaikuConfig.h)
659
660	if test "$ac_cv_lbl_bpf_h_defines_biocsetif" = yes; then
661		#
662		# BPF.
663		# Check this before DLPI, so that we pick BPF on
664		# Solaris 11 and later.
665		#
666		V_PCAP=bpf
667
668		#
669		# We have BPF, so build valgrindtest with "make test"
670		# on macOS and FreeBSD (add your OS once there's a
671		# valgrind for it).
672		#
673		case "$host_os" in
674
675		freebsd*|darwin*|linux*)
676			VALGRINDTEST_SRC=valgrindtest.c
677			;;
678		esac
679	elif test "$ac_cv_header_linux_socket_h" = yes; then
680		#
681		# No prizes for guessing this one.
682		#
683		V_PCAP=linux
684		VALGRINDTEST_SRC=valgrindtest.c
685	elif test "$ac_cv_header_net_pfilt_h" = yes; then
686	        #
687	        # DEC OSF/1, Digital UNIX, Tru64 UNIX
688        	#
689		V_PCAP=pf
690	elif test "$ac_cv_header_net_enet_h" = yes; then
691		#
692		# Stanford Enetfilter.
693		#
694		V_PCAP=enet
695	elif test "$ac_cv_header_net_nit_h" = yes; then
696		#
697		# SunOS 4.x STREAMS NIT.
698		#
699		V_PCAP=snit
700	elif test "$ac_cv_header_sys_net_nit_h" = yes; then
701		#
702		# Pre-SunOS 4.x non-STREAMS NIT.
703		#
704		V_PCAP=nit
705	elif test "$ac_cv_header_net_raw_h" = yes; then
706		#
707		# IRIX snoop.
708		#
709		V_PCAP=snoop
710	elif test "$ac_cv_header_sys_dlpi_h" = yes; then
711		#
712		# DLPI on pre-Solaris 11 SunOS 5, HP-UX, possibly others.
713		#
714		V_PCAP=dlpi
715	elif test "$ac_cv_header_config_HaikuConfig_h" = yes; then
716		#
717		# Haiku.
718		#
719		V_PCAP=haiku
720	else
721		#
722		# Nothing we support.
723		#
724		V_PCAP=null
725		AC_MSG_WARN(cannot determine packet capture interface)
726		AC_MSG_WARN((see the INSTALL doc for more info))
727	fi
728fi
729AC_MSG_CHECKING(packet capture type)
730AC_MSG_RESULT($V_PCAP)
731AC_SUBST(VALGRINDTEST_SRC)
732
733#
734# Do we have pkg-config?
735#
736AC_CHECK_PROG([PKGCONFIG], [pkg-config], [pkg-config], [no])
737
738#
739# Handle each capture type.
740#
741case "$V_PCAP" in
742dlpi)
743	#
744	# Checks for some header files.
745	#
746	AC_CHECK_HEADERS(sys/bufmod.h sys/dlpi_ext.h)
747
748	#
749	# Checks to see if Solaris has the public libdlpi(3LIB) library.
750	# Note: The existence of /usr/include/libdlpi.h does not mean it is the
751	# public libdlpi(3LIB) version. Before libdlpi was made public, a
752	# private version also existed, which did not have the same APIs.
753	# Due to a gcc bug, the default search path for 32-bit libraries does
754	# not include /lib, we add it explicitly here.
755	# [http://bugs.opensolaris.org/view_bug.do?bug_id=6619485].
756	# Also, due to the bug above applications that link to libpcap with
757	# libdlpi will have to add "-L/lib" option to "configure".
758	#
759	save_LDFLAGS="$LDFLAGS"
760	LDFLAGS="$LIBS -L/lib"
761	AC_CHECK_LIB(dlpi, dlpi_walk,
762		[
763			LIBS="-ldlpi $LIBS"
764			V_PCAP=libdlpi
765
766			#
767			# Capture module plus common code needed for
768			# common functions used by pcap-[dlpi,libdlpi].c
769			#
770			PLATFORM_C_SRC="pcap-libdlpi.c dlpisubs.c"
771			AC_DEFINE(HAVE_LIBDLPI,1,[if libdlpi exists])
772		],
773		[
774			V_PCAP=dlpi
775
776			#
777			# Capture module plus common code needed for
778			# common functions used by pcap-[dlpi,libdlpi].c
779			#
780			PLATFORM_C_SRC="pcap-dlpi.c dlpisubs.c"
781		])
782	LDFLAGS="$save_LDFLAGS"
783
784	#
785	# Checks whether <sys/dlpi.h> is usable, to catch weird SCO
786	# versions of DLPI.
787	#
788	AC_MSG_CHECKING(whether <sys/dlpi.h> is usable)
789	AC_CACHE_VAL(ac_cv_sys_dlpi_usable,
790		AC_TRY_COMPILE(
791		    [
792			#include <sys/types.h>
793			#include <sys/time.h>
794			#include <sys/dlpi.h>
795		    ],
796		    [int i = DL_PROMISC_PHYS;],
797		    ac_cv_sys_dlpi_usable=yes,
798		    ac_cv_sys_dlpi_usable=no))
799	AC_MSG_RESULT($ac_cv_sys_dlpi_usable)
800	if test $ac_cv_sys_dlpi_usable = no ; then
801		AC_MSG_ERROR(<sys/dlpi.h> is not usable on this system; it probably has a non-standard DLPI)
802	fi
803
804	#
805	# Check to see if Solaris has the dl_passive_req_t struct defined
806	# in <sys/dlpi.h>.
807	# This check is for DLPI support for passive modes.
808	# See dlpi(7P) for more details.
809	#
810	AC_CHECK_TYPES(dl_passive_req_t,,,
811	    [
812		#include <sys/types.h>
813		#include <sys/dlpi.h>
814	    ])
815	;;
816
817enet)
818	#
819	# Capture module
820	#
821 	PLATFORM_C_SRC="pcap-enet.c"
822	;;
823
824haiku)
825	#
826	# Capture module
827	#
828 	PLATFORM_CXX_SRC="pcap-haiku.cpp"
829
830	#
831	# Just for the sake of it.
832	#
833	AC_CHECK_HEADERS(net/if.h net/if_dl.h net/if_types.h)
834	;;
835
836linux)
837	#
838	# Capture module
839	#
840 	PLATFORM_C_SRC="pcap-linux.c"
841
842	#
843	# Do we have the wireless extensions?
844	#
845	AC_CHECK_HEADERS(linux/wireless.h, [], [],
846	[
847#include <sys/socket.h>
848#include <linux/if.h>
849#include <linux/types.h>
850	])
851
852	#
853	# Do we have libnl?
854	# We only want version 3.  Version 2 was, apparently,
855	# short-lived, and version 1 is source and binary
856	# incompatible with version 3, and it appears that,
857	# these days, everybody's using version 3.  We're
858	# not supporting older versions of the Linux kernel;
859	# let's drop support for older versions of libnl, too.
860	#
861	AC_ARG_WITH(libnl,
862	AC_HELP_STRING([--without-libnl],[disable libnl support @<:@default=yes, on Linux, if present@:>@]),
863		with_libnl=$withval,with_libnl=if_available)
864
865	if test x$with_libnl != xno ; then
866		if test "x$PKGCONFIG" != "xno"; then
867			#
868			# We have pkg-config; see if we have libnl-genl-3.0
869			# as a package.
870			#
871			AC_MSG_CHECKING([for libnl-genl-3.0 with pkg-config])
872			if "$PKGCONFIG" libnl-genl-3.0; then
873				AC_MSG_RESULT([found])
874				pkg_config_found_libnl=yes
875				libnl_genl_cflags=`"$PKGCONFIG" --cflags libnl-genl-3.0`
876				V_INCLS="$V_INCLS ${libnl_genl_cflags}"
877				libnl_genl_libs=`"$PKGCONFIG" --libs libnl-genl-3.0`
878				LIBS="${libnl_genl_libs} $LIBS"
879				AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
880			else
881				AC_MSG_RESULT([not found])
882			fi
883		fi
884
885		if test x$pkg_config_found_libnl != xyes; then
886			#
887			# OK, either we don't have pkg-config or there
888			# wasn't a .pc file for it; Check for it directly.
889			#
890			case "$with_libnl" in
891
892			yes|if_available)
893				incdir=-I/usr/include/libnl3
894				libnldir=
895				;;
896
897			*)
898				if test -d $withval; then
899					libnldir=-L${withval}/lib
900					incdir=-I${withval}/include
901				fi
902				;;
903			esac
904
905			AC_CHECK_LIB(nl-3, nl_socket_alloc,
906			[
907				#
908				# Yes, we have libnl 3.x.
909				#
910				LIBS="${libnldir} -lnl-genl-3 -lnl-3 $LIBS"
911				AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
912				V_INCLS="$V_INCLS ${incdir}"
913			],[
914				#
915				# No, we don't have libnl at all.
916				# Fail if the user explicitly requested
917				# it.
918				#
919				if test x$with_libnl = xyes ; then
920					AC_MSG_ERROR([libnl support requested but libnl not found])
921				fi
922			], ${incdir} ${libnldir} -lnl-genl-3 -lnl-3 )
923		fi
924	fi
925
926	#
927	# Check to see if the tpacket_auxdata struct has a tp_vlan_tci member.
928	#
929	# NOTE: any failure means we conclude that it doesn't have that
930	# member, so if we don't have tpacket_auxdata, we conclude it
931	# doesn't have that member (which is OK, as either we won't be
932	# using code that would use that member, or we wouldn't compile
933	# in any case).
934	AC_CHECK_MEMBERS([struct tpacket_auxdata.tp_vlan_tci],,,
935	    [
936		#include <sys/types.h>
937		#include <linux/if_packet.h>
938	    ])
939	;;
940
941bpf)
942	#
943	# Capture module
944	#
945 	PLATFORM_C_SRC="pcap-bpf.c"
946
947	#
948	# Check whether we have the *BSD-style ioctls.
949	#
950	AC_CHECK_HEADERS(net/if_media.h)
951
952	#
953	# Check whether we have struct BPF_TIMEVAL.
954	#
955	AC_CHECK_TYPES(struct BPF_TIMEVAL,,,
956	    [
957		#include <sys/types.h>
958		#include <sys/ioctl.h>
959		#ifdef HAVE_SYS_IOCCOM_H
960		#include <sys/ioccom.h>
961		#endif
962		#include <net/bpf.h>
963	    ])
964	;;
965
966pf)
967	#
968	# Capture module
969	#
970 	PLATFORM_C_SRC="pcap-pf.c"
971	;;
972
973snit)
974	#
975	# Capture module
976	#
977 	PLATFORM_C_SRC="pcap-snit.c"
978	;;
979
980snoop)
981	#
982	# Capture module
983	#
984 	PLATFORM_C_SRC="pcap-snoop.c"
985	;;
986
987dag)
988	#
989	# --with-pcap=dag is the only way to get here, and it means
990	# "DAG support but nothing else"
991	#
992	V_DEFS="$V_DEFS -DDAG_ONLY"
993	PLATFORM_C_SRC="pcap-dag.c"
994	xxx_only=yes
995	;;
996
997dpdk)
998	#
999	# --with-pcap=dpdk is the only way to get here, and it means
1000	# "DPDK support but nothing else"
1001	#
1002	V_DEFS="$V_DEFS -DDPDK_ONLY"
1003	PLATFORM_C_SRC="pcap-dpdk.c"
1004	xxx_only=yes
1005	;;
1006
1007septel)
1008	#
1009	# --with-pcap=septel is the only way to get here, and it means
1010	# "Septel support but nothing else"
1011	#
1012	V_DEFS="$V_DEFS -DSEPTEL_ONLY"
1013	PLATFORM_C_SRC="pcap-septel.c"
1014	xxx_only=yes
1015	;;
1016
1017snf)
1018	#
1019	# --with-pcap=snf is the only way to get here, and it means
1020	# "SNF support but nothing else"
1021	#
1022	V_DEFS="$V_DEFS -DSNF_ONLY"
1023	PLATFORM_C_SRC="pcap-snf.c"
1024	xxx_only=yes
1025	;;
1026
1027null)
1028	#
1029	# Capture module
1030	#
1031 	PLATFORM_C_SRC="pcap-null.c"
1032	;;
1033
1034*)
1035	AC_MSG_ERROR($V_PCAP is not a valid pcap type)
1036	;;
1037esac
1038
1039dnl
1040dnl Now figure out how we get a list of interfaces and addresses,
1041dnl if we support capturing.  Don't bother if we don't support
1042dnl capturing.
1043dnl
1044if test "$V_PCAP" != null
1045then
1046	AC_CHECK_FUNC(getifaddrs,[
1047		#
1048		# We have "getifaddrs()"; make sure we have <ifaddrs.h>
1049		# as well, just in case some platform is really weird.
1050		#
1051		AC_CHECK_HEADER(ifaddrs.h,[
1052		    #
1053		    # We have the header, so we use "getifaddrs()" to
1054		    # get the list of interfaces.
1055		    #
1056		    PLATFORM_C_SRC="$PLATFORM_C_SRC fad-getad.c"
1057		],[
1058		    #
1059		    # We don't have the header - give up.
1060		    # XXX - we could also fall back on some other
1061		    # mechanism, but, for now, this'll catch this
1062		    # problem so that we can at least try to figure
1063		    # out something to do on systems with "getifaddrs()"
1064		    # but without "ifaddrs.h", if there is something
1065		    # we can do on those systems.
1066		    #
1067		    AC_MSG_ERROR([Your system has getifaddrs() but doesn't have a usable <ifaddrs.h>.])
1068		])
1069	],[
1070		#
1071		# Well, we don't have "getifaddrs()", at least not with the
1072		# libraries with which we've decided we need to link
1073		# libpcap with, so we have to use some other mechanism.
1074		#
1075		# Note that this may happen on Solaris, which has
1076		# getifaddrs(), but in -lsocket, not in -lxnet, so we
1077		# won't find it if we link with -lxnet, which we want
1078		# to do for other reasons.
1079		#
1080		# For now, we use either the SIOCGIFCONF ioctl or the
1081		# SIOCGLIFCONF ioctl, preferring the latter if we have
1082		# it; the latter is a Solarisism that first appeared
1083		# in Solaris 8.  (Solaris's getifaddrs() appears to
1084		# be built atop SIOCGLIFCONF; using it directly
1085		# avoids a not-all-that-useful middleman.)
1086		#
1087		AC_MSG_CHECKING(whether we have SIOCGLIFCONF)
1088		AC_CACHE_VAL(ac_cv_lbl_have_siocglifconf,
1089		    AC_TRY_COMPILE(
1090			[#include <sys/param.h>
1091			#include <sys/file.h>
1092			#include <sys/ioctl.h>
1093			#include <sys/socket.h>
1094			#include <sys/sockio.h>],
1095			[ioctl(0, SIOCGLIFCONF, (char *)0);],
1096			ac_cv_lbl_have_siocglifconf=yes,
1097			ac_cv_lbl_have_siocglifconf=no))
1098		AC_MSG_RESULT($ac_cv_lbl_have_siocglifconf)
1099		if test $ac_cv_lbl_have_siocglifconf = yes ; then
1100			PLATFORM_C_SRC="$PLATFORM_C_SRC fad-glifc.c"
1101		else
1102			PLATFORM_C_SRC="$PLATFORM_C_SRC fad-gifc.c"
1103		fi
1104	])
1105fi
1106
1107dnl check for hardware timestamp support
1108case "$host_os" in
1109linux*)
1110	AC_CHECK_HEADERS([linux/net_tstamp.h])
1111	;;
1112*)
1113	AC_MSG_NOTICE(no hardware timestamp support implemented for $host_os)
1114	;;
1115esac
1116
1117#
1118# Check for socklen_t.
1119#
1120AC_CHECK_TYPES(socklen_t,,,
1121    [
1122	#include <sys/types.h>
1123	#include <sys/socket.h>
1124    ])
1125
1126AC_ARG_ENABLE(ipv6,
1127AC_HELP_STRING([--enable-ipv6],[build IPv6-capable version @<:@default=yes@:>@]),
1128    [],
1129    [enable_ipv6=yes])
1130if test "$enable_ipv6" != "no"; then
1131	#
1132	# We've already made sure we have getaddrinfo above in
1133	# AC_LBL_LIBRARY_NET.
1134	#
1135	AC_DEFINE(INET6,1,[IPv6])
1136fi
1137
1138# Check for Endace DAG card support.
1139AC_ARG_WITH([dag],
1140AC_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support (located in directory DIR, if supplied).  @<:@default=yes, if present@:>@]),
1141[
1142	if test "$withval" = no
1143	then
1144		# User doesn't want DAG support.
1145		want_dag=no
1146	elif test "$withval" = yes
1147	then
1148		# User wants DAG support but hasn't specified a directory.
1149		want_dag=yes
1150	else
1151		# User wants DAG support and has specified a directory, so use the provided value.
1152		want_dag=yes
1153		dag_root=$withval
1154	fi
1155],[
1156	if test "$V_PCAP" = dag; then
1157		# User requested DAG-only libpcap, so we'd better have
1158		# the DAG API.
1159		want_dag=yes
1160	elif test "xxx_only" = yes; then
1161		# User requested something-else-only pcap, so they don't
1162		# want DAG support.
1163		want_dag=no
1164	else
1165		#
1166		# Use DAG API if present, otherwise don't
1167		#
1168		want_dag=ifpresent
1169	fi
1170])
1171
1172AC_ARG_WITH([dag-includes],
1173AC_HELP_STRING([--with-dag-includes=IDIR],[Endace DAG include directory, if not DIR/include]),
1174[
1175	# User wants DAG support and has specified a header directory, so use the provided value.
1176	want_dag=yes
1177	dag_include_dir=$withval
1178],[])
1179
1180AC_ARG_WITH([dag-libraries],
1181AC_HELP_STRING([--with-dag-libraries=LDIR],[Endace DAG library directory, if not DIR/lib]),
1182[
1183	# User wants DAG support and has specified a library directory, so use the provided value.
1184	want_dag=yes
1185	dag_lib_dir=$withval
1186],[])
1187
1188if test "$want_dag" != no; then
1189
1190	# If necessary, set default paths for DAG API headers and libraries.
1191	if test -z "$dag_root"; then
1192		dag_root=/usr/local
1193	fi
1194
1195	if test -z "$dag_include_dir"; then
1196		dag_include_dir="$dag_root/include"
1197	fi
1198
1199	if test -z "$dag_lib_dir"; then
1200		dag_lib_dir="$dag_root/lib"
1201		#
1202		# Handle multiarch systems.
1203		#
1204		if test -d "$dag_lib_dir/$host"
1205		then
1206			dag_lib_dir="$dag_lib_dir/$host"
1207		fi
1208	fi
1209
1210	save_CFLAGS="$CFLAGS"
1211	CFLAGS="$CFLAGS -I$dag_include_dir"
1212	AC_CHECK_HEADERS([dagapi.h])
1213
1214	if test "$ac_cv_header_dagapi_h" = yes; then
1215
1216		V_INCLS="$V_INCLS -I$dag_include_dir"
1217
1218		if test $V_PCAP != dag ; then
1219			 MODULE_C_SRC="$MODULE_C_SRC pcap-dag.c"
1220		fi
1221
1222		# Check for various DAG API functions.
1223		# Don't need to save and restore LIBS to prevent -ldag being
1224		# included if there's a found-action (arg 3).
1225		save_LDFLAGS="$LDFLAGS"
1226		LDFLAGS="-L$dag_lib_dir"
1227		AC_CHECK_LIB([dag], [dag_attach_stream],
1228		    [],
1229		    [AC_MSG_ERROR(DAG library lacks streams support)])
1230		AC_CHECK_LIB([dag], [dag_attach_stream64], [dag_large_streams="1"], [dag_large_streams="0"])
1231		AC_CHECK_LIB([dag],[dag_get_erf_types], [
1232			AC_DEFINE(HAVE_DAG_GET_ERF_TYPES, 1, [define if you have dag_get_erf_types()])])
1233		AC_CHECK_LIB([dag],[dag_get_stream_erf_types], [
1234			AC_DEFINE(HAVE_DAG_GET_STREAM_ERF_TYPES, 1, [define if you have dag_get_stream_erf_types()])])
1235
1236		LDFLAGS="$save_LDFLAGS"
1237
1238		#
1239		# We assume that if we have libdag we have libdagconf,
1240		# as they're installed at the same time from the same
1241		# package.
1242		#
1243		LIBS="$LIBS -ldag -ldagconf"
1244		LDFLAGS="$LDFLAGS -L$dag_lib_dir"
1245
1246		if test "$dag_large_streams" = 1; then
1247			AC_DEFINE(HAVE_DAG_LARGE_STREAMS_API, 1, [define if you have large streams capable DAG API])
1248			AC_CHECK_LIB([vdag],[vdag_set_device_info], [ac_dag_have_vdag="1"], [ac_dag_have_vdag="0"])
1249			if test "$ac_dag_have_vdag" = 1; then
1250				AC_DEFINE(HAVE_DAG_VDAG, 1, [define if you have vdag_set_device_info()])
1251				if test "$ac_lbl_have_pthreads" != "found"; then
1252					AC_MSG_ERROR([DAG requires pthreads, but we didn't find them])
1253				fi
1254				LIBS="$LIBS $PTHREAD_LIBS"
1255			fi
1256		fi
1257
1258		AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
1259	else
1260
1261		if test "$V_PCAP" = dag; then
1262			# User requested "dag" capture type but we couldn't
1263			# find the DAG API support.
1264			AC_MSG_ERROR([DAG support requested with --with-pcap=dag, but the DAG headers weren't found at $dag_include_dir: make sure the DAG support is installed, specify a different path or paths if necessary, or don't request DAG support])
1265		fi
1266
1267		if test "$want_dag" = yes; then
1268			# User wanted DAG support but we couldn't find it.
1269			AC_MSG_ERROR([DAG support requested with --with-dag, but the DAG headers weren't found at $dag_include_dir: make sure the DAG support is installed, specify a different path or paths if necessary, or don't request DAG support])
1270		fi
1271	fi
1272	CFLAGS="$save_CFLAGS"
1273fi
1274
1275AC_ARG_WITH(septel,
1276AC_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in directory DIR, if supplied).  @<:@default=yes, if present@:>@]),
1277[
1278	if test "$withval" = no
1279	then
1280		want_septel=no
1281	elif test "$withval" = yes
1282	then
1283		want_septel=yes
1284		septel_root=
1285	else
1286		want_septel=yes
1287		septel_root=$withval
1288	fi
1289],[
1290	if test "$V_PCAP" = septel; then
1291		# User requested Septel-only libpcap, so we'd better have
1292		# the Septel API.
1293		want_septel=yes
1294	elif test "xxx_only" = yes; then
1295		# User requested something-else-only pcap, so they don't
1296		# want Septel support.
1297		want_septel=no
1298	else
1299		#
1300		# Use Septel API if present, otherwise don't
1301		#
1302		want_septel=ifpresent
1303	fi
1304])
1305
1306ac_cv_lbl_septel_api=no
1307if test "$with_septel" != no; then
1308
1309	AC_MSG_CHECKING([whether we have Septel API headers])
1310
1311	# If necessary, set default paths for Septel API headers and libraries.
1312	if test -z "$septel_root"; then
1313		septel_root=$srcdir/../septel
1314	fi
1315
1316	septel_tools_dir="$septel_root"
1317	septel_include_dir="$septel_root/INC"
1318
1319	if test -r "$septel_include_dir/msg.h"; then
1320		ac_cv_lbl_septel_api=yes
1321	fi
1322
1323	if test "$ac_cv_lbl_septel_api" = yes; then
1324		AC_MSG_RESULT([yes ($septel_include_dir)])
1325
1326		V_INCLS="$V_INCLS -I$septel_include_dir"
1327		ADDLOBJS="$ADDLOBJS $septel_tools_dir/asciibin.o $septel_tools_dir/bit2byte.o $septel_tools_dir/confirm.o $septel_tools_dir/fmtmsg.o $septel_tools_dir/gct_unix.o $septel_tools_dir/hqueue.o $septel_tools_dir/ident.o $septel_tools_dir/mem.o $septel_tools_dir/pack.o $septel_tools_dir/parse.o $septel_tools_dir/pool.o $septel_tools_dir/sdlsig.o $septel_tools_dir/strtonum.o $septel_tools_dir/timer.o $septel_tools_dir/trace.o"
1328		ADDLARCHIVEOBJS="$ADDLARCHIVEOBJS $septel_tools_dir/asciibin.o $septel_tools_dir/bit2byte.o $septel_tools_dir/confirm.o $septel_tools_dir/fmtmsg.o $septel_tools_dir/gct_unix.o $septel_tools_dir/hqueue.o $septel_tools_dir/ident.o $septel_tools_dir/mem.o $septel_tools_dir/pack.o $septel_tools_dir/parse.o $septel_tools_dir/pool.o $septel_tools_dir/sdlsig.o $septel_tools_dir/strtonum.o $septel_tools_dir/timer.o $septel_tools_dir/trace.o"
1329
1330		if test "$V_PCAP" != septel ; then
1331			 MODULE_C_SRC="$MODULE_C_SRC pcap-septel.c"
1332		fi
1333
1334		AC_DEFINE(HAVE_SEPTEL_API, 1, [define if you have the Septel API])
1335	else
1336		AC_MSG_RESULT(no)
1337
1338		if test "$V_PCAP" = septel; then
1339			# User requested "septel" capture type but
1340			# we couldn't find the Septel API support.
1341			AC_MSG_ERROR([Septel support requested with --with-pcap=septel, but the Septel headers weren't found at $septel_include_dir: make sure the Septel support is installed, specify a different path or paths if necessary, or don't request Septel support])
1342		fi
1343
1344		if test "$want_septel" = yes; then
1345			# User wanted Septel support but we couldn't find it.
1346			AC_MSG_ERROR([Septel support requested with --with-septel, but the Septel headers weren't found at $septel_include_dir: make sure the Septel support is installed, specify a different path or paths if necessary, or don't request Septel support])
1347		fi
1348	fi
1349fi
1350
1351# Check for Myricom SNF support.
1352AC_ARG_WITH([snf],
1353AC_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support (located in directory DIR, if supplied).  @<:@default=yes, if present@:>@]),
1354[
1355	if test "$withval" = no
1356	then
1357		# User explicitly doesn't want SNF
1358		want_snf=no
1359	elif test "$withval" = yes
1360	then
1361		# User wants SNF support but hasn't specified a directory.
1362		want_snf=yes
1363	else
1364		# User wants SNF support with a specified directory.
1365		want_snf=yes
1366		snf_root=$withval
1367	fi
1368],[
1369	if test "$V_PCAP" = snf; then
1370		# User requested Sniffer-only libpcap, so we'd better have
1371		# the Sniffer API.
1372		want_snf=yes
1373	elif test "xxx_only" = yes; then
1374		# User requested something-else-only pcap, so they don't
1375		# want SNF support.
1376		want_snf=no
1377	else
1378		#
1379		# Use Sniffer API if present, otherwise don't
1380		#
1381		want_snf=ifpresent
1382	fi
1383])
1384
1385AC_ARG_WITH([snf-includes],
1386AC_HELP_STRING([--with-snf-includes=IDIR],[Myricom SNF include directory, if not DIR/include]),
1387[
1388	# User wants SNF with specific header directory
1389	want_snf=yes
1390	snf_include_dir=$withval
1391],[])
1392
1393AC_ARG_WITH([snf-libraries],
1394AC_HELP_STRING([--with-snf-libraries=LDIR],[Myricom SNF library directory, if not DIR/lib]),
1395[
1396	# User wants SNF with specific lib directory
1397	want_snf=yes
1398	snf_lib_dir=$withval
1399],[])
1400
1401ac_cv_lbl_snf_api=no
1402if test "$with_snf" != no; then
1403
1404	AC_MSG_CHECKING(whether we have Myricom Sniffer API)
1405
1406	# If necessary, set default paths for Sniffer headers and libraries.
1407	if test -z "$snf_root"; then
1408		snf_root=/opt/snf
1409	fi
1410
1411	if test -z "$snf_include_dir"; then
1412		snf_include_dir="$snf_root/include"
1413	fi
1414
1415	if test -z "$snf_lib_dir"; then
1416		snf_lib_dir="$snf_root/lib"
1417		#
1418		# Handle multiarch systems.
1419		#
1420		if test -d "$snf_lib_dir/$host"
1421		then
1422			snf_lib_dir="$snf_lib_dir/$host"
1423		fi
1424	fi
1425
1426	if test -f "$snf_include_dir/snf.h"; then
1427		# We found a header; make sure we can link with the library
1428		save_LDFLAGS="$LDFLAGS"
1429		LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1430		AC_CHECK_LIB([snf], [snf_init], [ac_cv_lbl_snf_api="yes"])
1431		LDFLAGS="$save_LDFLAGS"
1432		if test "$ac_cv_lbl_snf_api" = no; then
1433			AC_MSG_ERROR(SNF API cannot correctly be linked; check config.log)
1434		fi
1435	fi
1436
1437	if test "$ac_cv_lbl_snf_api" = yes; then
1438		AC_MSG_RESULT([yes ($snf_root)])
1439
1440		V_INCLS="$V_INCLS -I$snf_include_dir"
1441		LIBS="$LIBS -lsnf"
1442		LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1443
1444		if test "$V_PCAP" != snf ; then
1445			MODULE_C_SRC="$MODULE_C_SRC pcap-snf.c"
1446		fi
1447
1448		AC_DEFINE(HAVE_SNF_API, 1, [define if you have the Myricom SNF API])
1449	else
1450		AC_MSG_RESULT(no)
1451
1452		if test "$want_snf" = yes; then
1453			# User requested "snf" capture type but
1454			# we couldn't find the Sniffer API support.
1455			AC_MSG_ERROR([Myricom Sniffer support requested with --with-pcap=snf, but the Sniffer headers weren't found at $snf_include_dir: make sure the Sniffer support is installed, specify a different path or paths if necessary, or don't request Sniffer support])
1456		fi
1457
1458		if test "$want_snf" = yes; then
1459			AC_MSG_ERROR([Myricom Sniffer support requested with --with-snf, but the Sniffer headers weren't found at $snf_include_dir: make sure the Sniffer support is installed, specify a different path or paths if necessary, or don't request Sniffer support])
1460		fi
1461	fi
1462fi
1463
1464# Check for Riverbed TurboCap support.
1465AC_ARG_WITH([turbocap],
1466AC_HELP_STRING([--with-turbocap@<:@=DIR@:>@],[include Riverbed TurboCap support (located in directory DIR, if supplied).  @<:@default=yes, if present@:>@]),
1467[
1468	if test "$withval" = no
1469	then
1470		# User explicitly doesn't want TurboCap
1471		want_turbocap=no
1472	elif test "$withval" = yes
1473	then
1474		# User wants TurboCap support but hasn't specified a directory.
1475		want_turbocap=yes
1476	else
1477		# User wants TurboCap support with a specified directory.
1478		want_turbocap=yes
1479		turbocap_root=$withval
1480	fi
1481],[
1482	if test "xxx_only" = yes; then
1483		# User requested something-else-only pcap, so they don't
1484		# want TurboCap support.
1485		want_turbocap=no
1486	else
1487		#
1488		# Use TurboCap API if present, otherwise don't
1489		#
1490		want_turbocap=ifpresent
1491	fi
1492])
1493
1494ac_cv_lbl_turbocap_api=no
1495if test "$want_turbocap" != no; then
1496
1497	AC_MSG_CHECKING(whether TurboCap is supported)
1498
1499	save_CFLAGS="$CFLAGS"
1500	save_LIBS="$LIBS"
1501	if test ! -z "$turbocap_root"; then
1502		TURBOCAP_CFLAGS="-I$turbocap_root/include"
1503		TURBOCAP_LIBS="-L$turbocap_root/lib"
1504		CFLAGS="$CFLAGS $TURBOCAP_CFLAGS"
1505	fi
1506
1507	AC_TRY_COMPILE(
1508	[
1509	    #include <TcApi.h>
1510	],
1511	[
1512	    TC_INSTANCE a; TC_PORT b; TC_BOARD c;
1513	    TC_INSTANCE i;
1514	    (void)TcInstanceCreateByName("foo", &i);
1515	],
1516	ac_cv_lbl_turbocap_api=yes)
1517
1518	CFLAGS="$save_CFLAGS"
1519	if test $ac_cv_lbl_turbocap_api = yes; then
1520		AC_MSG_RESULT(yes)
1521
1522		MODULE_C_SRC="$MODULE_C_SRC pcap-tc.c"
1523		V_INCLS="$V_INCLS $TURBOCAP_CFLAGS"
1524		LIBS="$LIBS $TURBOCAP_LIBS -lTcApi -lpthread -lstdc++"
1525
1526		AC_DEFINE(HAVE_TC_API, 1, [define if you have the TurboCap API])
1527	else
1528		AC_MSG_RESULT(no)
1529
1530		if test "$want_turbocap" = yes; then
1531			# User wanted Turbo support but we couldn't find it.
1532			AC_MSG_ERROR([TurboCap support requested with --with-turbocap, but the TurboCap headers weren't found: make sure the TurboCap support is installed or don't request TurboCap support])
1533		fi
1534	fi
1535fi
1536
1537dnl
1538dnl Allow the user to enable remote capture.
1539dnl It's off by default, as that increases the attack surface of
1540dnl libpcap, exposing it to malicious servers.
1541dnl
1542AC_MSG_CHECKING([whether to enable remote packet capture])
1543AC_ARG_ENABLE(remote,
1544[  --enable-remote         enable remote packet capture @<:@default=no@:>@
1545  --disable-remote        disable remote packet capture],,
1546   enableval=no)
1547case "$enableval" in
1548yes)	AC_MSG_RESULT(yes)
1549	AC_WARN([Remote packet capture may expose libpcap-based applications])
1550	AC_WARN([to attacks by malicious remote capture servers!])
1551	#
1552	# rpcapd requires pthreads on UN*X.
1553	#
1554	if test "$ac_lbl_have_pthreads" != "found"; then
1555		AC_MSG_ERROR([rpcapd requires pthreads, but we didn't find them])
1556	fi
1557	#
1558	# It also requires crypt().
1559	# Do we have it in the system libraries?
1560	#
1561	AC_CHECK_FUNC(crypt,,
1562	    [
1563		#
1564		# No.  Do we have it in -lcrypt?
1565		#
1566		AC_CHECK_LIB(crypt, crypt,
1567		    [
1568			#
1569			# Yes; add -lcrypt to the libraries for rpcapd.
1570			#
1571			RPCAPD_LIBS="$RPCAPD_LIBS -lcrypt"
1572		    ],
1573		    [
1574			AC_MSG_ERROR([rpcapd requires crypt(), but we didn't find it])
1575		    ])
1576	    ])
1577
1578	#
1579	# OK, we have crypt().  Do we have getspnam()?
1580	#
1581	AC_CHECK_FUNCS(getspnam)
1582
1583	#
1584	# Check for various members of struct msghdr.
1585	#
1586	AC_CHECK_MEMBERS([struct msghdr.msg_control],,,
1587	    [
1588		#include "ftmacros.h"
1589		#include <sys/socket.h>
1590	    ])
1591	AC_CHECK_MEMBERS([struct msghdr.msg_flags],,,
1592	    [
1593		#include "ftmacros.h"
1594		#include <sys/socket.h>
1595	    ])
1596
1597	#
1598	# Optionally, we may want to support SSL.
1599	# Check for OpenSSL/libressl.
1600	#
1601	# First, try looking for it as a regular system library.
1602	# Make sure we can find SSL_library_init() using the
1603	# standard headers, just in case we're running a version
1604	# of macOS that ships with the OpenSSL library but not
1605	# the OpenSSL headers, and have also installed another
1606	# version of OpenSSL with headers.
1607	#
1608	save_LIBS="$LIBS"
1609	LIBS="-lssl -lcrypto"
1610	AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use)
1611	AC_TRY_LINK(
1612	    [
1613#include <openssl/ssl.h>
1614	    ],
1615	    [
1616SSL_library_init();
1617return 0;
1618	    ],
1619	    [
1620		AC_MSG_RESULT(yes)
1621		HAVE_OPENSSL=yes
1622		OPENSSL_LIBS="-lssl -lcrypto"
1623	    ],
1624	    AC_MSG_RESULT(no))
1625	LIBS="$save_LIBS"
1626
1627	#
1628	# If we didn't find it, check for it with pkg-config.
1629	#
1630	if test "x$HAVE_OPENSSL" != "xyes"; then
1631		if test "x$PKGCONFIG" != "xno"; then
1632			#
1633			# We have pkg-config; see if we have OpenSSL/
1634			# libressl installed as a package.
1635			#
1636			AC_MSG_CHECKING([for OpenSSL/libressl with pkg-config])
1637			if "$PKGCONFIG" openssl; then
1638				AC_MSG_RESULT([found])
1639				HAVE_OPENSSL=yes
1640				OPENSSL_CFLAGS=`"$PKGCONFIG" --cflags openssl`
1641				OPENSSL_LIBS=`"$PKGCONFIG" --libs openssl`
1642			else
1643				AC_MSG_RESULT([not found])
1644			fi
1645		fi
1646	fi
1647
1648	#
1649	# If we didn't find it, check for it under /usr/local/opt/openssl;
1650	# that's where Homebrew puts it on macOS.  Feel free to add other
1651	# -L directories as necessary; the "system library" check should
1652	# also handle "add-on library under /usr/local", so that shouldn't
1653	# be necessary here.
1654	#
1655	if test "x$HAVE_OPENSSL" != "xyes"; then
1656		save_CFLAGS="$CFLAGS"
1657		save_LIBS="$LIBS"
1658		CFLAGS="$CFLAGS -L/usr/local/opt/openssl/include"
1659		LIBS="$LIBS -L/usr/local/opt/openssl/lib -lssl -lcrypto"
1660		AC_MSG_CHECKING(whether we have OpenSSL/libressl in /usr/local/opt that we can use)
1661		AC_TRY_LINK(
1662		    [
1663#include <openssl/ssl.h>
1664		    ],
1665		    [
1666SSL_library_init();
1667return 0;
1668		    ],
1669		    [
1670			AC_MSG_RESULT(yes)
1671			HAVE_OPENSSL=yes
1672			OPENSSL_CFLAGS="-I/usr/local/opt/openssl/include"
1673			OPENSSL_LIBS="-L/usr/local/opt/openssl/lib -lssl -lcrypto"
1674		    ],
1675		    AC_MSG_RESULT(no))
1676		CFLAGS="$save_CFLAGS"
1677		LIBS="$save_LIBS"
1678	fi
1679
1680	#
1681	# OK, did we find it?
1682	#
1683	if test "x$HAVE_OPENSSL" = "xyes"; then
1684		AC_DEFINE([HAVE_OPENSSL], [1], [Use OpenSSL])
1685		CFLAGS="$CFLAGS $OPENSSL_CFLAGS"
1686		LIBS="$LIBS $OPENSSL_LIBS"
1687	else
1688		AC_MSG_NOTICE(OpenSSL not found)
1689	fi
1690
1691	AC_DEFINE(ENABLE_REMOTE,,
1692	    [Define to 1 if remote packet capture is to be supported])
1693	REMOTE_C_SRC="$REMOTE_C_SRC pcap-new.c pcap-rpcap.c rpcap-protocol.c sockutils.c sslutils.c"
1694	BUILD_RPCAPD=build-rpcapd
1695	INSTALL_RPCAPD=install-rpcapd
1696	;;
1697*)	AC_MSG_RESULT(no)
1698	;;
1699esac
1700
1701AC_MSG_CHECKING(whether to build optimizer debugging code)
1702AC_ARG_ENABLE(optimizer-dbg,
1703AC_HELP_STRING([--enable-optimizer-dbg],[build optimizer debugging code]))
1704if test "$enable_optimizer_dbg" = "yes"; then
1705	AC_DEFINE(BDEBUG,1,[Enable optimizer debugging])
1706fi
1707AC_MSG_RESULT(${enable_optimizer_dbg-no})
1708
1709AC_MSG_CHECKING(whether to build parser debugging code)
1710AC_ARG_ENABLE(yydebug,
1711AC_HELP_STRING([--enable-yydebug],[build parser debugging code]))
1712if test "$enable_yydebug" = "yes"; then
1713	AC_DEFINE(YYDEBUG,1,[Enable parser debugging])
1714fi
1715AC_MSG_RESULT(${enable_yydebug-no})
1716
1717#
1718# Look for {f}lex.
1719#
1720AC_PROG_LEX
1721if test "$LEX" = ":"; then
1722	AC_MSG_ERROR([Neither flex nor lex was found.])
1723fi
1724
1725#
1726# Make sure {f}lex supports the -P, --header-file, and --nounput flags
1727# and supports processing our scanner.l.
1728#
1729AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex,
1730	if $LEX -P pcap_ --header-file=/dev/null --nounput -t $srcdir/scanner.l > /dev/null 2>&1; then
1731	    tcpdump_cv_capable_lex=yes
1732	else
1733	    tcpdump_cv_capable_lex=insufficient
1734	fi)
1735if test $tcpdump_cv_capable_lex = insufficient ; then
1736	AC_MSG_ERROR([$LEX is insufficient to compile libpcap.
1737 libpcap requires Flex 2.5.31 or later, or a compatible version of lex.])
1738fi
1739
1740#
1741# Look for yacc/bison/byacc.
1742#
1743AC_PROG_YACC
1744
1745case "$YACC" in
1746
1747*yacc)
1748	#
1749	# Make sure this is Berkeley YACC, not AT&T YACC; the latter
1750	# doesn't support reentrant parsers.  Run it with "-V";
1751	# that succeeds and reports the version number with
1752	# Berkeley YACC, but will (probably) fail with various
1753	# vendor flavors of AT&T YACC.
1754	#
1755	AC_CACHE_CHECK([for capable yacc], tcpdump_cv_capable_yacc,
1756	    if $YACC -V >/dev/null 2>&1; then
1757		tcpdump_cv_capable_yacc=yes
1758	    else
1759		tcpdump_cv_capable_yacc=insufficient
1760	    fi)
1761	if test $tcpdump_cv_capable_yacc = insufficient ; then
1762	    AC_MSG_ERROR([$YACC is insufficient to compile libpcap.
1763 libpcap requires Bison, a newer version of Berkeley YACC with support
1764 for reentrant parsers, or another YACC compatible with them.])
1765	fi
1766
1767	#
1768	# Berkeley YACC doesn't support "%define api.pure", so use
1769	# "%pure-parser".
1770	#
1771	REENTRANT_PARSER="%pure-parser"
1772	;;
1773
1774*)
1775	#
1776	# Bison prior to 2.4(.1) doesn't support "%define api.pure", so use
1777	# "%pure-parser".
1778	#
1779	bison_major_version=`$YACC -V | sed -n 's/.* \(@<:@1-9@:>@@<:@0-9@:>@*\)\.@<:@1-9@:>@@<:@0-9.@:>@*/\1/p'`
1780	bison_minor_version=`$YACC -V | sed -n 's/.* @<:@1-9@:>@@<:@0-9@:>@*\.\(@<:@1-9@:>@@<:@0-9@:>@*\).*/\1/p'`
1781	if test "$bison_major_version" -lt 2 -o \
1782	    \( "$bison_major_version" -eq 2 -a "$bison_major_version" -lt 4 \)
1783	then
1784		REENTRANT_PARSER="%pure-parser"
1785	else
1786		REENTRANT_PARSER="%define api.pure"
1787	fi
1788	;;
1789esac
1790AC_SUBST(REENTRANT_PARSER)
1791
1792#
1793# Do various checks for various OSes and versions of those OSes.
1794#
1795# Assume, by default, no support for shared libraries and V7/BSD
1796# convention for man pages (devices in section 4, file formats in
1797# section 5, miscellaneous info in section 7, administrative commands
1798# and daemons in section 8).  Individual cases can override this.
1799#
1800DYEXT="none"
1801MAN_DEVICES=4
1802MAN_FILE_FORMATS=5
1803MAN_MISC_INFO=7
1804MAN_ADMIN_COMMANDS=8
1805case "$host_os" in
1806
1807aix*)
1808	dnl Workaround to enable certain features
1809	AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
1810
1811	#
1812	# AIX makes it fun to build shared and static libraries,
1813	# because they're *both* ".a" archive libraries.  We
1814	# build the static library for the benefit of the traditional
1815	# scheme of building libpcap and tcpdump in subdirectories of
1816	# the same directory, with tcpdump statically linked with the
1817	# libpcap in question, but we also build a shared library as
1818	# "libpcap.shareda" and install *it*, rather than the static
1819	# library, as "libpcap.a".
1820	#
1821	DYEXT="shareda"
1822
1823	case "$V_PCAP" in
1824
1825	dlpi)
1826		#
1827		# If we're using DLPI, applications will need to
1828		# use /lib/pse.exp if present, as we use the
1829		# STREAMS routines.
1830		#
1831		pseexe="/lib/pse.exp"
1832		AC_MSG_CHECKING(for $pseexe)
1833		if test -f $pseexe ; then
1834			AC_MSG_RESULT(yes)
1835			LIBS="-I:$pseexe"
1836		fi
1837		;;
1838
1839	bpf)
1840		#
1841		# If we're using BPF, we need "-lodm" and "-lcfg", as
1842		# we use them to load the BPF module.
1843		#
1844		LIBS="-lodm -lcfg"
1845		;;
1846	esac
1847	;;
1848
1849darwin*)
1850	DYEXT="dylib"
1851	V_CCOPT="$V_CCOPT -fno-common"
1852	AC_ARG_ENABLE(universal,
1853	AC_HELP_STRING([--disable-universal],[don't build universal on macOS]))
1854	if test "$enable_universal" != "no"; then
1855		case "$host_os" in
1856
1857		darwin[[0-7]].*)
1858			#
1859			# Pre-Tiger.  Build only for 32-bit PowerPC; no
1860			# need for any special compiler or linker flags.
1861			#
1862			;;
1863
1864		darwin8.[[0123]]|darwin8.[[0123]].*)
1865			#
1866			# Tiger, prior to Intel support.  Build
1867			# libraries and executables for 32-bit PowerPC
1868			# and 64-bit PowerPC, with 32-bit PowerPC first.
1869			# (I'm guessing that's what Apple does.)
1870			#
1871			# (The double brackets are needed because
1872			# autotools/m4 use brackets as a quoting
1873			# character; the double brackets turn into
1874			# single brackets in the generated configure
1875			# file.)
1876			#
1877			V_LIB_CCOPT_FAT="-arch ppc -arch ppc64"
1878			V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64"
1879			V_PROG_CCOPT_FAT="-arch ppc -arch ppc64"
1880			V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64"
1881			;;
1882
1883		darwin8.[[456]]|darwin.[[456]].*)
1884			#
1885			# Tiger, subsequent to Intel support but prior
1886			# to x86-64 support.  Build libraries and
1887			# executables for 32-bit PowerPC, 64-bit
1888			# PowerPC, and 32-bit x86, with 32-bit PowerPC
1889			# first.  (I'm guessing that's what Apple does.)
1890			#
1891			# (The double brackets are needed because
1892			# autotools/m4 use brackets as a quoting
1893			# character; the double brackets turn into
1894			# single brackets in the generated configure
1895			# file.)
1896			#
1897			V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386"
1898			V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386"
1899			V_PROG_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386"
1900			V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386"
1901			;;
1902
1903		darwin8.*)
1904			#
1905			# All other Tiger, so subsequent to x86-64
1906			# support.  Build libraries and executables for
1907			# 32-bit PowerPC, 64-bit PowerPC, 32-bit x86,
1908			# and x86-64, with 32-bit PowerPC first.  (I'm
1909			# guessing that's what Apple does.)
1910			#
1911			V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1912			V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1913			V_PROG_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1914			V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1915			;;
1916
1917		darwin9.*)
1918			#
1919			# Leopard.  Build libraries for 32-bit PowerPC,
1920			# 64-bit PowerPC, 32-bit x86, and x86-64, with
1921			# 32-bit PowerPC first, and build executables
1922			# for 32-bit x86 and 32-bit PowerPC, with 32-bit
1923			# x86 first.  (That's what Apple does.)
1924			#
1925			V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1926			V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1927			V_PROG_CCOPT_FAT="-arch i386 -arch ppc"
1928			V_PROG_LDFLAGS_FAT="-arch i386 -arch ppc"
1929			;;
1930
1931		darwin10.*)
1932			#
1933			# Snow Leopard.  Build libraries for x86-64,
1934			# 32-bit x86, and 32-bit PowerPC, with x86-64
1935			# first, and build executables for x86-64 and
1936			# 32-bit x86, with x86-64 first.  (That's what
1937			# Apple does, even though Snow Leopard doesn't
1938			# run on PPC, so PPC libpcap runs under Rosetta,
1939			# and Rosetta doesn't support BPF ioctls, so PPC
1940			# programs can't do live captures.)
1941			#
1942			V_LIB_CCOPT_FAT="-arch x86_64 -arch i386 -arch ppc"
1943			V_LIB_LDFLAGS_FAT="-arch x86_64 -arch i386 -arch ppc"
1944			V_PROG_CCOPT_FAT="-arch x86_64 -arch i386"
1945			V_PROG_LDFLAGS_FAT="-arch x86_64 -arch i386"
1946			;;
1947
1948		darwin*)
1949			#
1950			# Post-Snow Leopard.  Build libraries for x86-64
1951			# and 32-bit x86, with x86-64 first, and build
1952			# executables only for x86-64.  (That's what
1953			# Apple does.)  This requires no special flags
1954			# for programs.
1955			# XXX - update if and when Apple drops support
1956			# for 32-bit x86 code and if and when Apple adds
1957			# ARM-based Macs.  (You're on your own for iOS
1958			# etc.)
1959			#
1960			# XXX - check whether we *can* build for
1961			# i386 and, if not, suggest that the user
1962			# install the /usr/include headers if they
1963			# want to build fat.
1964			#
1965			AC_MSG_CHECKING(whether building for 32-bit x86 is supported)
1966			save_CFLAGS="$CFLAGS"
1967			CFLAGS="$CFLAGS -arch i386"
1968			AC_TRY_LINK(
1969			    [],
1970			    [return 0;],
1971			    [
1972				AC_MSG_RESULT(yes)
1973				V_LIB_CCOPT_FAT="-arch x86_64"
1974				V_LIB_LDFLAGS_FAT="-arch x86_64"
1975
1976				#
1977				# OpenSSL installation on macOS seems
1978				# to install only the libs for 64-bit
1979				# x86 - at least that's what Brew does:
1980				# only configure 32-bit builds if we
1981				# don't have OpenSSL.
1982				#
1983				if test "$HAVE_OPENSSL" != yes; then
1984					V_LIB_CCOPT_FAT="$V_LIB_CCOPT_FAT -arch i386"
1985					V_LIB_LDFLAGS_FAT="$V_LIB_LDFLAGS_FAT -arch i386"
1986				fi
1987			    ],
1988			    [
1989				AC_MSG_RESULT(no)
1990				V_LIB_CCOPT_FAT="-arch x86_64"
1991				V_LIB_LDFLAGS_FAT="-arch x86_64"
1992				case "$host_os" in
1993
1994				darwin18.*)
1995					#
1996					# Mojave; you need to install the
1997					# /usr/include headers to get
1998					# 32-bit x86 builds to work.
1999					#
2000					AC_MSG_WARN([Compiling for 32-bit x86 gives an error; try installing the command-line tools and, after that, installing the /usr/include headers from the /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg package])
2001					;;
2002
2003				*)
2004					#
2005					# Pre-Mojave; the command-line
2006					# tools should be sufficient to
2007					# enable 32-bit x86 builds.
2008					#
2009					AC_MSG_WARN([Compiling for 32-bit x86 gives an error; try installing the command-line tools])
2010					;;
2011				esac
2012			    ])
2013			CFLAGS="$save_CFLAGS"
2014			;;
2015		esac
2016	fi
2017	;;
2018
2019hpux9*)
2020	AC_DEFINE(HAVE_HPUX9,1,[on HP-UX 9.x])
2021
2022	#
2023	# Use System V conventions for man pages.
2024	#
2025	MAN_ADMIN_COMMANDS=1m
2026	MAN_FILE_FORMATS=4
2027	MAN_MISC_INFO=5
2028	;;
2029
2030hpux10.0*)
2031
2032	#
2033	# Use System V conventions for man pages.
2034	#
2035	MAN_ADMIN_COMMANDS=1m
2036	MAN_FILE_FORMATS=4
2037	MAN_MISC_INFO=5
2038	;;
2039
2040hpux10.1*)
2041
2042	#
2043	# Use System V conventions for man pages.
2044	#
2045	MAN_ADMIN_COMMANDS=1m
2046	MAN_FILE_FORMATS=4
2047	MAN_MISC_INFO=5
2048	;;
2049
2050hpux*)
2051	dnl HPUX 10.20 and above is similar to HPUX 9, but
2052	dnl not the same....
2053	dnl
2054	dnl XXX - DYEXT should be set to "sl" if this is building
2055	dnl for 32-bit PA-RISC, but should be left as "so" for
2056	dnl 64-bit PA-RISC or, I suspect, IA-64.
2057	AC_DEFINE(HAVE_HPUX10_20_OR_LATER,1,[on HP-UX 10.20 or later])
2058	if test "`uname -m`" = "ia64"; then
2059		DYEXT="so"
2060	else
2061		DYEXT="sl"
2062	fi
2063
2064	#
2065	# "-b" builds a shared library; "+h" sets the soname.
2066	#
2067	SHLIB_OPT="-b"
2068	SONAME_OPT="+h"
2069
2070	#
2071	# Use System V conventions for man pages.
2072	#
2073	MAN_FILE_FORMATS=4
2074	MAN_MISC_INFO=5
2075	;;
2076
2077irix*)
2078	#
2079	# Use IRIX conventions for man pages; they're the same as the
2080	# System V conventions, except that they use section 8 for
2081	# administrative commands and daemons.
2082	#
2083	MAN_FILE_FORMATS=4
2084	MAN_MISC_INFO=5
2085	;;
2086
2087linux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*|haiku*|midipix*)
2088	DYEXT="so"
2089
2090	#
2091	# Compiler assumed to be GCC; run-time linker may require a -R
2092	# flag.
2093	#
2094	if test "$libdir" != "/usr/lib"; then
2095		V_RFLAGS=-Wl,-R$libdir
2096	fi
2097	;;
2098
2099osf*)
2100	DYEXT="so"
2101
2102	#
2103	# DEC OSF/1, a/k/a Digial UNIX, a/k/a Tru64 UNIX.
2104	# Use Tru64 UNIX conventions for man pages; they're the same as
2105	# the System V conventions except that they use section 8 for
2106	# administrative commands and daemons.
2107	#
2108	MAN_FILE_FORMATS=4
2109	MAN_MISC_INFO=5
2110	MAN_DEVICES=7
2111	;;
2112
2113sinix*)
2114	AC_MSG_CHECKING(if SINIX compiler defines sinix)
2115	AC_CACHE_VAL(ac_cv_cc_sinix_defined,
2116		AC_TRY_COMPILE(
2117		    [],
2118		    [int i = sinix;],
2119		    ac_cv_cc_sinix_defined=yes,
2120		    ac_cv_cc_sinix_defined=no))
2121	    AC_MSG_RESULT($ac_cv_cc_sinix_defined)
2122	    if test $ac_cv_cc_sinix_defined = no ; then
2123		    AC_DEFINE(sinix,1,[on sinix])
2124	    fi
2125	;;
2126
2127solaris*)
2128	AC_DEFINE(HAVE_SOLARIS,1,[On solaris])
2129
2130	DYEXT="so"
2131
2132	#
2133	# Make sure errno is thread-safe, in case we're called in
2134	# a multithreaded program.  We don't guarantee that two
2135	# threads can use the *same* pcap_t safely, but the
2136	# current version does guarantee that you can use different
2137	# pcap_t's in different threads, and even that pcap_compile()
2138	# is thread-safe (it wasn't thread-safe in some older versions).
2139	#
2140	V_CCOPT="$V_CCOPT -D_TS_ERRNO"
2141
2142	case "`uname -r`" in
2143
2144	5.12)
2145		;;
2146
2147	*)
2148		#
2149		# Use System V conventions for man pages.
2150		#
2151		MAN_ADMIN_COMMANDS=1m
2152		MAN_FILE_FORMATS=4
2153		MAN_MISC_INFO=5
2154		MAN_DEVICES=7D
2155	esac
2156	;;
2157esac
2158
2159AC_ARG_ENABLE(shared,
2160AC_HELP_STRING([--enable-shared],[build shared libraries @<:@default=yes, if support available@:>@]))
2161test "x$enable_shared" = "xno" && DYEXT="none"
2162
2163AC_PROG_RANLIB
2164AC_CHECK_TOOL([AR], [ar])
2165
2166AC_PROG_LN_S
2167AC_SUBST(LN_S)
2168
2169AC_LBL_DEVEL(V_CCOPT)
2170
2171#
2172# Check to see if the sockaddr struct has the 4.4 BSD sa_len member.
2173#
2174AC_CHECK_MEMBERS([struct sockaddr.sa_len],,,
2175    [
2176	#include <sys/types.h>
2177	#include <sys/socket.h>
2178    ])
2179
2180#
2181# Check to see if there's a sockaddr_storage structure.
2182#
2183AC_CHECK_TYPES(struct sockaddr_storage,,,
2184    [
2185	#include <sys/types.h>
2186	#include <sys/socket.h>
2187    ])
2188
2189#
2190# Check to see if the dl_hp_ppa_info_t struct has the HP-UX 11.00
2191# dl_module_id_1 member.
2192#
2193# NOTE: any failure means we conclude that it doesn't have that member,
2194# so if we don't have DLPI, don't have a <sys/dlpi_ext.h> header, or
2195# have one that doesn't declare a dl_hp_ppa_info_t type, we conclude
2196# it doesn't have that member (which is OK, as either we won't be
2197# using code that would use that member, or we wouldn't compile in
2198# any case).
2199#
2200AC_CHECK_MEMBERS([dl_hp_ppa_info_t.dl_module_id_1],,,
2201    [
2202	#include <sys/types.h>
2203	#include <sys/dlpi.h>
2204	#include <sys/dlpi_ext.h>
2205    ])
2206
2207AC_SUBST(V_CCOPT)
2208AC_SUBST(V_LIB_CCOPT_FAT)
2209AC_SUBST(V_LIB_LDFLAGS_FAT)
2210AC_SUBST(V_PROG_CCOPT_FAT)
2211AC_SUBST(V_PROG_LDFLAGS_FAT)
2212AC_SUBST(V_DEFS)
2213AC_SUBST(V_INCLS)
2214AC_SUBST(V_LEX)
2215AC_SUBST(V_SHLIB_CCOPT)
2216AC_SUBST(V_SHLIB_CMD)
2217AC_SUBST(V_SHLIB_OPT)
2218AC_SUBST(V_SONAME_OPT)
2219AC_SUBST(V_RPATH_OPT)
2220AC_SUBST(V_YACC)
2221AC_SUBST(ADDLOBJS)
2222AC_SUBST(ADDLARCHIVEOBJS)
2223AC_SUBST(PLATFORM_C_SRC)
2224AC_SUBST(PLATFORM_CXX_SRC)
2225AC_SUBST(MODULE_C_SRC)
2226AC_SUBST(REMOTE_C_SRC)
2227AC_SUBST(DYEXT)
2228AC_SUBST(MAN_DEVICES)
2229AC_SUBST(MAN_FILE_FORMATS)
2230AC_SUBST(MAN_MISC_INFO)
2231AC_SUBST(MAN_ADMIN_COMMANDS)
2232AC_SUBST(PTHREAD_LIBS)
2233AC_SUBST(BUILD_RPCAPD)
2234AC_SUBST(INSTALL_RPCAPD)
2235AC_SUBST(RPCAPD_LIBS)
2236AC_SUBST(EXTRA_NETWORK_LIBS)
2237
2238#
2239# Various Linux-specific mechanisms.
2240#
2241AC_ARG_ENABLE([usb],
2242[AC_HELP_STRING([--enable-usb],[enable Linux usbmon USB capture support @<:@default=yes, if support available@:>@])],
2243    [],
2244    [enable_usb=yes])
2245
2246#
2247# If somebody requested an XXX-only pcap, that doesn't include
2248# additional mechanisms.
2249#
2250if test "xxx_only" != yes; then
2251  case "$host_os" in
2252  linux*)
2253    dnl check for USB sniffing support
2254    AC_MSG_CHECKING(for Linux usbmon USB sniffing support)
2255    if test "x$enable_usb" != "xno" ; then
2256      AC_DEFINE(PCAP_SUPPORT_LINUX_USBMON, 1, [target host supports Linux usbmon for USB sniffing])
2257      MODULE_C_SRC="$MODULE_C_SRC pcap-usb-linux.c"
2258      AC_MSG_RESULT(yes)
2259      ac_usb_dev_name=`udevinfo -q name -p /sys/class/usb_device/usbmon 2>/dev/null`
2260      if test $? -ne 0 ; then
2261        ac_usb_dev_name="usbmon"
2262      fi
2263      AC_DEFINE_UNQUOTED(LINUX_USB_MON_DEV, "/dev/$ac_usb_dev_name", [path for device for USB sniffing])
2264      AC_MSG_NOTICE(Device for USB sniffing is /dev/$ac_usb_dev_name)
2265      #
2266      # Do we have a version of <linux/compiler.h> available?
2267      # If so, we might need it for <linux/usbdevice_fs.h>.
2268      #
2269      AC_CHECK_HEADERS(linux/compiler.h)
2270      if test "$ac_cv_header_linux_compiler_h" = yes; then
2271        #
2272        # Yes - include it when testing for <linux/usbdevice_fs.h>.
2273        #
2274        AC_CHECK_HEADERS(linux/usbdevice_fs.h,,,[#include <linux/compiler.h>])
2275      else
2276        AC_CHECK_HEADERS(linux/usbdevice_fs.h)
2277      fi
2278      if test "$ac_cv_header_linux_usbdevice_fs_h" = yes; then
2279        #
2280        # OK, does it define bRequestType?  Older versions of the kernel
2281        # define fields with names like "requesttype, "request", and
2282        # "value", rather than "bRequestType", "bRequest", and
2283        # "wValue".
2284        #
2285        AC_CHECK_MEMBERS([struct usbdevfs_ctrltransfer.bRequestType],,,
2286          [
2287            AC_INCLUDES_DEFAULT
2288            #ifdef HAVE_LINUX_COMPILER_H
2289            #include <linux/compiler.h>
2290            #endif
2291            #include <linux/usbdevice_fs.h>
2292          ])
2293      fi
2294    else
2295      AC_MSG_RESULT(no)
2296    fi
2297
2298    #
2299    # Life's too short to deal with trying to get this to compile
2300    # if you don't get the right types defined with
2301    # __KERNEL_STRICT_NAMES getting defined by some other include.
2302    #
2303    # Check whether the includes Just Work.  If not, don't turn on
2304    # netfilter support.
2305    #
2306    AC_MSG_CHECKING(whether we can compile the netfilter support)
2307    AC_CACHE_VAL(ac_cv_netfilter_can_compile,
2308      AC_TRY_COMPILE([
2309AC_INCLUDES_DEFAULT
2310#include <sys/socket.h>
2311#include <netinet/in.h>
2312#include <linux/types.h>
2313
2314#include <linux/netlink.h>
2315#include <linux/netfilter.h>
2316#include <linux/netfilter/nfnetlink.h>
2317#include <linux/netfilter/nfnetlink_log.h>
2318#include <linux/netfilter/nfnetlink_queue.h>],
2319        [],
2320        ac_cv_netfilter_can_compile=yes,
2321        ac_cv_netfilter_can_compile=no))
2322    AC_MSG_RESULT($ac_cv_netfilter_can_compile)
2323    if test $ac_cv_netfilter_can_compile = yes ; then
2324      AC_DEFINE(PCAP_SUPPORT_NETFILTER, 1,
2325        [target host supports netfilter sniffing])
2326      MODULE_C_SRC="$MODULE_C_SRC pcap-netfilter-linux.c"
2327    fi
2328    ;;
2329  esac
2330fi
2331AC_SUBST(PCAP_SUPPORT_LINUX_USBMON)
2332AC_SUBST(PCAP_SUPPORT_NETFILTER)
2333
2334AC_ARG_ENABLE([netmap],
2335[AC_HELP_STRING([--enable-netmap],[enable netmap support @<:@default=yes, if support available@:>@])],
2336    [],
2337    [enable_netmap=yes])
2338
2339if test "x$enable_netmap" != "xno" ; then
2340	#
2341	# Check whether net/netmap_user.h is usable if NETMAP_WITH_LIBS is
2342	# defined; it's not usable on DragonFly BSD 4.6 if NETMAP_WITH_LIBS
2343	# is defined, for example, as it includes a non-existent malloc.h
2344	# header.
2345	#
2346	AC_MSG_CHECKING(whether we can compile the netmap support)
2347	AC_CACHE_VAL(ac_cv_net_netmap_user_can_compile,
2348	  AC_TRY_COMPILE([
2349AC_INCLUDES_DEFAULT
2350#define NETMAP_WITH_LIBS
2351#include <net/netmap_user.h>],
2352	    [],
2353	    ac_cv_net_netmap_user_can_compile=yes,
2354	    ac_cv_net_netmap_user_can_compile=no))
2355	AC_MSG_RESULT($ac_cv_net_netmap_user_can_compile)
2356	if test $ac_cv_net_netmap_user_can_compile = yes ; then
2357	  AC_DEFINE(PCAP_SUPPORT_NETMAP, 1,
2358	    [target host supports netmap])
2359	    MODULE_C_SRC="$MODULE_C_SRC pcap-netmap.c"
2360	fi
2361	AC_SUBST(PCAP_SUPPORT_NETMAP)
2362fi
2363
2364# Check for DPDK support.
2365AC_ARG_WITH([dpdk],
2366AC_HELP_STRING([--with-dpdk@<:@=DIR@:>@],[include DPDK support (located in directory DIR, if supplied).  @<:@default=yes, if present@:>@]),
2367[
2368	if test "$withval" = no
2369	then
2370		# User doesn't want DPDK support.
2371		want_dpdk=no
2372	elif test "$withval" = yes
2373	then
2374		# User wants DPDK support but hasn't specified a directory.
2375		want_dpdk=yes
2376	else
2377		# User wants DPDK support and has specified a directory,
2378		# so use the provided value.
2379		want_dpdk=yes
2380		dpdk_dir=$withval
2381	fi
2382],[
2383	if test "$V_PCAP" = dpdk; then
2384		# User requested DPDK-only libpcap, so we'd better have
2385		# the DPDK API.
2386		want_dpdk=yes
2387	elif test "xxx_only" = yes; then
2388		# User requested something-else-only pcap, so they don't
2389		# want DPDK support.
2390		want_dpdk=no
2391	else
2392		#
2393		# Use DPDK API if present, otherwise don't
2394		#
2395		want_dpdk=ifpresent
2396	fi
2397])
2398
2399if test "$want_dpdk" != no; then
2400	if test "x$PKGCONFIG" != "xno"
2401	then
2402		#
2403		# We have pkg-config; see if we have DPDK installed
2404		# as a package.
2405		#
2406		AC_MSG_CHECKING([for DPDK with pkg-config])
2407		if "$PKGCONFIG" libdpdk
2408		then
2409			AC_MSG_RESULT([found])
2410			found_dpdk_with_pkg_config=yes
2411			DPDK_CFLAGS=`"$PKGCONFIG" --cflags libdpdk`
2412			DPDK_LDFLAGS=`"$PKGCONFIG" --libs libdpdk`
2413		else
2414			AC_MSG_RESULT([not found])
2415		fi
2416	fi
2417
2418	#
2419	# If we didn't find it with pkg-config, try checking for
2420	# it manually.
2421	#
2422	if test "x$found_dpdk_with_pkg_config" != "xyes"
2423	then
2424		if test -z "$dpdk_dir"; then
2425			#
2426			# The user didn't specify a directory containing
2427			# the DPDK headers and libraries.  If we find
2428			# a /usr/local/include/dpdk directory, assume
2429			# it's /usr/local, otherwise assume it's /usr.
2430			#
2431			if test -d "/usr/local/include/dpdk"; then
2432				dpdk_dir="/usr/local"
2433			else
2434				dpdk_dir="/usr"
2435			fi
2436		fi
2437		#
2438		# The convention appears to be that 1) there's a "dpdk"
2439		# subdirectory of the include directory, containing DPDK
2440		# headers (at least in the installation on Ubuntu with
2441		# the system DPDK packages) and 2) includes of DPDK
2442		# headers don't use "dpdk/{header}" (at least from the
2443		# way the DPDK documentation is written).
2444		#
2445		# So we add "/dpdk" to the include directory, and always
2446		# add that to the list of include directories to search.
2447		#
2448		dpdk_inc_dir="$dpdk_dir/include/dpdk"
2449		dpdk_inc_flags="-I$dpdk_inc_dir"
2450		dpdk_lib_dir="$dpdk_dir/lib"
2451		#
2452		# Handle multiarch systems.
2453		#
2454		# Step 1: run the C compiler with the -dumpmachine option;
2455		# if it succeeds, the output would be the multiarch directory
2456		# name if your system has multiarch directories.
2457		#
2458		multiarch_dir=`$CC -dumpmachine 2>/dev/null`
2459		if test ! -z "$multiarch_dir"
2460		then
2461			#
2462			# OK, we have a multiarch directory.
2463			#
2464			# Now deal with includes.  On Ubuntu 20.04, for
2465			# example, we have /usr/include/dpdk *and*
2466			# /usr/include/$multiarch_dir/dpdk, and must
2467			# search both.
2468			#
2469			if test -d "$dpdk_dir/include/$multiarch_dir/dpdk"
2470			then
2471				dpdk_inc_flags="-I$dpdk_dir/include/$multiarch_dir/dpdk $dpdk_inc_flags"
2472			fi
2473
2474			#
2475			# Now deal with libraries.
2476			#
2477			if test -d "$dpdk_lib_dir/$multiarch_dir"
2478			then
2479				dpdk_lib_dir="$dpdk_lib_dir/$multiarch_dir"
2480			fi
2481		fi
2482		DPDK_MACHINE_CFLAGS="-march=native"
2483		DPDK_CFLAGS="$DPDK_MACHINE_CFLAGS $dpdk_inc_flags"
2484		DPDK_LDFLAGS="-L$dpdk_lib_dir -ldpdk -lrt -lm -lnuma -ldl -pthread"
2485	fi
2486
2487	save_CFLAGS="$CFLAGS"
2488	save_LIBS="$LIBS"
2489	save_LDFLAGS="$LDFLAGS"
2490	CFLAGS="$CFLAGS $DPDK_CFLAGS"
2491	LIBS="$LIBS $DPDK_LDFLAGS"
2492	LDFLAGS="$LDFLAGS $DPDK_LDFLAGS"
2493
2494	AC_MSG_CHECKING(whether we can compile the DPDK support)
2495	AC_CACHE_VAL(ac_cv_dpdk_can_compile,
2496	AC_TRY_COMPILE([
2497AC_INCLUDES_DEFAULT
2498#include <rte_common.h>],
2499	    [],
2500	    ac_cv_dpdk_can_compile=yes,
2501	    ac_cv_dpdk_can_compile=no))
2502	AC_MSG_RESULT($ac_cv_dpdk_can_compile)
2503
2504	#
2505	# We include rte_bus.h, and older versions of DPDK
2506	# didn't have it, so check for it.
2507	#
2508	if test "$ac_cv_dpdk_can_compile" = yes; then
2509		#
2510		# This runs the preprocessor, so make sure it
2511		# looks in the DPDK directories.  Instead of
2512		# including dpdk/XXX.h, we include just XXX.h
2513		# and assume DPDK_CFLAGS is the directory
2514		# containing the DPDK headers (that's how
2515		# pkg-config sets it, at least on Ubuntu),
2516		# so just looking under /usr/include won't
2517		# find it.
2518		#
2519		save_CPPFLAGS="$CPPFLAGS"
2520		CPPFLAGS="$CPPFLAGS $DPDK_CFLAGS"
2521		AC_CHECK_HEADER(rte_bus.h)
2522		CPPFLAGS="$save_CPPFLAGS"
2523	fi
2524
2525	#
2526	# We call rte_eth_dev_count_avail(), and older versions
2527	# of DPDK didn't have it, so check for it.
2528	#
2529	if test "$ac_cv_header_rte_bus_h" = yes; then
2530		AC_CHECK_FUNC(rte_eth_dev_count_avail)
2531	fi
2532
2533	CFLAGS="$save_CFLAGS"
2534	LIBS="$save_LIBS"
2535	LDFLAGS="$save_LDFLAGS"
2536
2537	if test "$ac_cv_func_rte_eth_dev_count_avail" = yes; then
2538		CFLAGS="$CFLAGS $DPDK_CFLAGS"
2539		LIBS="$LIBS $DPDK_LDFLAGS"
2540		LDFLAGS="$LDFLAGS $DPDK_LDFLAGS"
2541		V_INCLS="$V_INCLS $DPDK_CFLAGS"
2542		AC_DEFINE(PCAP_SUPPORT_DPDK, 1, [target host supports DPDK])
2543		if test $V_PCAP != dpdk ; then
2544			MODULE_C_SRC="$MODULE_C_SRC pcap-dpdk.c"
2545		fi
2546
2547		#
2548		# Check whether the rte_ether.h file defines
2549		# struct ether_addr or struct rte_ether_addr.
2550		#
2551		# ("API compatibility?  That's for losers!")
2552		#
2553		AC_CHECK_TYPES(struct rte_ether_addr,,,
2554		    [
2555			#include <rte_ether.h>
2556		    ])
2557	else
2558		if test "$V_PCAP" = dpdk; then
2559			# User requested DPDK-only capture support, but
2560			# we couldn't the DPDK API support at all, or we
2561			# found it but it wasn't a sufficiently recent
2562			# version.
2563			if test "$ac_cv_dpdk_can_compile" != yes; then
2564				#
2565				# Couldn't even find the headers.
2566				#
2567				AC_MSG_ERROR([DPDK support requested with --with-pcap=dpdk, but the DPDK headers weren't found at $dpdk_inc_dir: make sure the DPDK support is installed, specify a different path or paths if necessary, or don't request DPDK support])
2568			else
2569				#
2570				# Found the headers, but we couldn't find
2571				# rte_bus.h or rte_eth_dev_count_avail(),
2572				# we don't have a sufficiently recent
2573				# version of DPDK.
2574				#
2575				AC_MSG_ERROR([DPDK support requested with --with-pcap=dpdk, but we require DPDK 18.x or later; install a newer version of DPDK, or don't request DPDK support])
2576			fi
2577		fi
2578
2579		if test "$want_dpdk" = yes; then
2580			# User requested DPDK-only capture support, but
2581			# we couldn't the DPDK API support at all, or we
2582			# found it but it wasn't a sufficiently recent
2583			# version.
2584			if test "$ac_cv_dpdk_can_compile" != yes; then
2585				#
2586				# Couldn't even find the headers.
2587				#
2588				AC_MSG_ERROR([DPDK support requested with --with-pcap=dpdk, but the DPDK headers weren't found at $dpdk_inc_dir: make sure the DPDK support is installed, specify a different path or paths if necessary, or don't request DPDK support])
2589			else
2590				#
2591				# Found the headers, but we couldn't find
2592				# rte_bus.h or rte_eth_dev_count_avail(),
2593				# we don't have a sufficiently recent
2594				# version of DPDK.
2595				#
2596				AC_MSG_ERROR([DPDK support requested with --with-pcap=dpdk, but we require DPDK 18.x or later: install a newer version of DPDK, or don't request DPDK support])
2597			fi
2598		fi
2599	fi
2600fi
2601AC_SUBST(PCAP_SUPPORT_DPDK)
2602
2603AC_ARG_ENABLE([bluetooth],
2604[AC_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])],
2605    [],
2606    [enable_bluetooth=ifsupportavailable])
2607
2608if test "xxx_only" = yes; then
2609	# User requested something-else-only pcap, so they don't
2610	# want Bluetooth support.
2611	enable_bluetooth=no
2612fi
2613
2614if test "x$enable_bluetooth" != "xno" ; then
2615	dnl check for Bluetooth sniffing support
2616	case "$host_os" in
2617	linux*)
2618		AC_CHECK_HEADER(bluetooth/bluetooth.h,
2619		    [
2620			#
2621			# We have bluetooth.h, so we support Bluetooth
2622			# sniffing.
2623			#
2624			AC_DEFINE(PCAP_SUPPORT_BT, 1, [target host supports Bluetooth sniffing])
2625			MODULE_C_SRC="$MODULE_C_SRC pcap-bt-linux.c"
2626			AC_MSG_NOTICE(Bluetooth sniffing is supported)
2627			ac_lbl_bluetooth_available=yes
2628
2629			#
2630			# OK, does struct sockaddr_hci have an hci_channel
2631			# member?
2632			#
2633			AC_CHECK_MEMBERS([struct sockaddr_hci.hci_channel],
2634			    [
2635				#
2636				# Yes; is HCI_CHANNEL_MONITOR defined?
2637				#
2638				AC_MSG_CHECKING(if HCI_CHANNEL_MONITOR is defined)
2639				AC_CACHE_VAL(ac_cv_lbl_hci_channel_monitor_is_defined,
2640				    AC_TRY_COMPILE(
2641					[
2642					    #include <bluetooth/bluetooth.h>
2643					    #include <bluetooth/hci.h>
2644					],
2645					[
2646					    u_int i = HCI_CHANNEL_MONITOR;
2647					],
2648					[
2649					    AC_MSG_RESULT(yes)
2650					    AC_DEFINE(PCAP_SUPPORT_BT_MONITOR,,
2651					      [target host supports Bluetooth Monitor])
2652					    MODULE_C_SRC="$MODULE_C_SRC pcap-bt-monitor-linux.c"
2653					],
2654					[
2655					    AC_MSG_RESULT(no)
2656					]))
2657			    ],,
2658			    [
2659				#include <bluetooth/bluetooth.h>
2660				#include <bluetooth/hci.h>
2661			    ])
2662		    ],
2663		    [
2664			#
2665			# We don't have bluetooth.h, so we don't support
2666			# Bluetooth sniffing.
2667			#
2668			if test "x$enable_bluetooth" = "xyes" ; then
2669				AC_MSG_ERROR(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
2670			else
2671				AC_MSG_NOTICE(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
2672			fi
2673		    ])
2674		;;
2675	*)
2676		if test "x$enable_bluetooth" = "xyes" ; then
2677			AC_MSG_ERROR(no Bluetooth sniffing support implemented for $host_os)
2678		else
2679			AC_MSG_NOTICE(no Bluetooth sniffing support implemented for $host_os)
2680		fi
2681		;;
2682	esac
2683	AC_SUBST(PCAP_SUPPORT_BT)
2684fi
2685
2686AC_ARG_ENABLE([dbus],
2687[AC_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=yes, if support available@:>@])],
2688    [],
2689    [enable_dbus=ifavailable])
2690
2691if test "xxx_only" = yes; then
2692	# User requested something-else-only pcap, so they don't
2693	# want D-Bus support.
2694	enable_dbus=no
2695fi
2696
2697if test "x$enable_dbus" != "xno"; then
2698	if test "x$enable_dbus" = "xyes"; then
2699		case "$host_os" in
2700
2701		darwin*)
2702			#
2703			# We don't support D-Bus sniffing on macOS; see
2704			#
2705			# https://bugs.freedesktop.org/show_bug.cgi?id=74029
2706			#
2707			# The user requested it, so fail.
2708			#
2709			AC_MSG_ERROR([Due to freedesktop.org bug 74029, D-Bus capture support is not available on macOS])
2710		esac
2711	else
2712		case "$host_os" in
2713
2714		darwin*)
2715			#
2716			# We don't support D-Bus sniffing on macOS; see
2717			#
2718			# https://bugs.freedesktop.org/show_bug.cgi?id=74029
2719			#
2720			# The user dind't explicitly request it, so just
2721			# silently refuse to enable it.
2722			#
2723			enable_dbus="no"
2724			;;
2725		esac
2726	fi
2727fi
2728
2729if test "x$enable_dbus" != "xno"; then
2730	if test "x$PKGCONFIG" != "xno"; then
2731		AC_MSG_CHECKING([for D-Bus])
2732		if "$PKGCONFIG" dbus-1; then
2733			AC_MSG_RESULT([yes])
2734			DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1`
2735			DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1`
2736			save_CFLAGS="$CFLAGS"
2737			save_LIBS="$LIBS"
2738			CFLAGS="$CFLAGS $DBUS_CFLAGS"
2739			LIBS="$LIBS $DBUS_LIBS"
2740			AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write)
2741			AC_TRY_LINK(
2742			    [#include <string.h>
2743
2744			     #include <time.h>
2745			     #include <sys/time.h>
2746
2747			     #include <dbus/dbus.h>],
2748			    [return dbus_connection_read_write(NULL, 0);],
2749			    [
2750				AC_MSG_RESULT([yes])
2751				AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing])
2752				MODULE_C_SRC="$MODULE_C_SRC pcap-dbus.c"
2753				V_INCLS="$V_INCLS $DBUS_CFLAGS"
2754			    ],
2755			    [
2756				AC_MSG_RESULT([no])
2757				if test "x$enable_dbus" = "xyes"; then
2758				    AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()])
2759				fi
2760				LIBS="$save_LIBS"
2761			     ])
2762			CFLAGS="$save_CFLAGS"
2763		else
2764			AC_MSG_RESULT([no])
2765			if test "x$enable_dbus" = "xyes"; then
2766				AC_MSG_ERROR([--enable-dbus was given, but the dbus-1 package is not installed])
2767			fi
2768		fi
2769	fi
2770	AC_SUBST(PCAP_SUPPORT_DBUS)
2771fi
2772
2773AC_ARG_ENABLE([rdma],
2774[AC_HELP_STRING([--enable-rdma],[enable RDMA capture support @<:@default=yes, if support available@:>@])],
2775    [],
2776    [enable_rdma=ifavailable])
2777
2778if test "xxx_only" = yes; then
2779	# User requested something-else-only pcap, so they don't
2780	# want RDMA support.
2781	enable_rdma=no
2782fi
2783
2784if test "x$enable_rdma" != "xno"; then
2785	AC_CHECK_LIB(ibverbs, ibv_get_device_list, [
2786		AC_CHECK_HEADER(infiniband/verbs.h, [
2787			#
2788			# ibv_create_flow may be defined as a static inline
2789			# function in infiniband/verbs.h, so we can't
2790			# use AC_CHECK_LIB.
2791			#
2792			# Too bad autoconf has no AC_SYMBOL_EXISTS()
2793			# macro that works like CMake's check_symbol_exists()
2794			# function, to check do a compile check like
2795			# this (they do a clever trick to avoid having
2796			# to know the function's signature).
2797			#
2798			AC_MSG_CHECKING(whether libibverbs defines ibv_create_flow)
2799			AC_TRY_LINK(
2800				[
2801					#include <infiniband/verbs.h>
2802				],
2803				[
2804					(void) ibv_create_flow((struct ibv_qp *) NULL,
2805							       (struct ibv_flow_attr *) NULL);
2806				],
2807				[
2808					AC_MSG_RESULT([yes])
2809					AC_DEFINE(PCAP_SUPPORT_RDMASNIFF, , [target host supports RDMA sniffing])
2810					MODULE_C_SRC="$MODULE_C_SRC pcap-rdmasniff.c"
2811					LIBS="-libverbs $LIBS"
2812				],
2813				[
2814					AC_MSG_RESULT([no])
2815				]
2816			)
2817		])
2818	])
2819	AC_SUBST(PCAP_SUPPORT_RDMASNIFF)
2820fi
2821
2822AC_PROG_INSTALL
2823
2824AC_CONFIG_HEADER(config.h)
2825
2826AC_OUTPUT_COMMANDS([if test -f .devel; then
2827	echo timestamp > stamp-h
2828	cat $srcdir/Makefile-devel-adds >> Makefile
2829	make depend
2830fi])
2831AC_OUTPUT(Makefile grammar.y pcap-filter.manmisc pcap-linktype.manmisc
2832	pcap-tstamp.manmisc pcap-savefile.manfile pcap.3pcap
2833	pcap_compile.3pcap pcap_datalink.3pcap pcap_dump_open.3pcap
2834	pcap_get_tstamp_precision.3pcap pcap_list_datalinks.3pcap
2835	pcap_list_tstamp_types.3pcap pcap_open_dead.3pcap
2836	pcap_open_offline.3pcap pcap_set_immediate_mode.3pcap
2837	pcap_set_tstamp_precision.3pcap pcap_set_tstamp_type.3pcap
2838	rpcapd/Makefile rpcapd/rpcapd.manadmin rpcapd/rpcapd-config.manfile
2839	testprogs/Makefile)
2840exit 0
2841