2 dnl Copyright (c) 1994, 1995, 1996, 1997
3 dnl The Regents of the University of California. All rights reserved.
5 dnl Process this file with autoconf to produce a configure script.
11 # https://ftp.gnu.org/gnu/config/README
13 # for the URLs to use to fetch new versions of config.guess and
19 AC_INIT(pcap, m4_esyscmd_s([cat VERSION]))
20 AC_CONFIG_SRCDIR(pcap.c)
21 AC_SUBST(PACKAGE_NAME)
25 AC_LBL_C_INIT_BEFORE_CC(V_CCOPT, V_INCLS)
27 # We require C99 or later.
28 # Try to get it, which may involve adding compiler flags;
29 # if that fails, give up.
32 if test "$ac_cv_prog_cc_c99" = "no"; then
33 AC_MSG_ERROR([The C compiler does not support C99])
38 # Haiku's platform file is in C++.
44 AC_LBL_C_INIT(V_CCOPT, V_INCLS)
50 # Try to arrange for large file support.
56 dnl Even if <net/bpf.h> were, on all OSes that support BPF, fixed to
57 dnl include <sys/ioccom.h>, and we were to drop support for older
58 dnl releases without that fix, so that pcap-bpf.c doesn't need to
59 dnl include <sys/ioccom.h>, the test program in "AC_LBL_FIXINCLUDES"
60 dnl in "aclocal.m4" uses it, so we would still have to test for it
61 dnl and set "HAVE_SYS_IOCCOM_H" if we have it, otherwise
62 dnl "AC_LBL_FIXINCLUDES" wouldn't work on some platforms such as Solaris.
64 AC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h)
65 AC_CHECK_HEADERS(netpacket/packet.h)
66 AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
67 #include <sys/socket.h>
69 if test "$ac_cv_header_net_pfvar_h" = yes; then
71 # Check for various PF actions.
73 AC_MSG_CHECKING(whether net/pfvar.h defines PF_NAT through PF_NORDR)
75 [#include <sys/types.h>
76 #include <sys/socket.h>
78 #include <net/pfvar.h>],
79 [return PF_NAT+PF_NONAT+PF_BINAT+PF_NOBINAT+PF_RDR+PF_NORDR;],
82 AC_DEFINE(HAVE_PF_NAT_THROUGH_PF_NORDR, 1,
83 [define if net/pfvar.h defines PF_NAT through PF_NORDR])
91 # Haiku needs _BSD_SOURCE for the _IO* macros because it doesn't use them.
93 CFLAGS="$CFLAGS -D_BSD_SOURCE"
99 AC_CHECK_FUNCS(strerror)
100 AC_CHECK_FUNC(strerror_r,
103 # We have strerror_r; if we define _GNU_SOURCE, is it a
104 # POSIX-compliant strerror_r() or a GNU strerror_r()?
106 AC_MSG_CHECKING(whether strerror_r is GNU-style)
113 /* Define it GNU-style; that will cause an error if it's not GNU-style */
114 extern char *strerror_r(int, char *, size_t);
126 AC_DEFINE(HAVE_GNU_STRERROR_R,,
127 [Define to 1 if you have a GNU-style `strerror_r' function.])
131 AC_DEFINE(HAVE_POSIX_STRERROR_R,,
132 [Define to 1 if you have a POSIX-style `strerror_r' function.])
137 # We don't have strerror_r; do we have _wcserror_s?
139 AC_CHECK_FUNCS(_wcserror_s)
143 # Thanks, IBM, for not providing vsyslog() in AIX!
145 AC_CHECK_FUNCS(vsyslog)
148 # Make sure we have vsnprintf() and snprintf(); we require them.
150 AC_CHECK_FUNC(vsnprintf,,
151 AC_MSG_ERROR([vsnprintf() is required but wasn't found]))
152 AC_CHECK_FUNC(snprintf,,
153 AC_MSG_ERROR([snprintf() is required but wasn't found]))
156 AC_CHECK_FUNCS(vasprintf asprintf,,
158 if test $needasprintf = yes; then
159 AC_LIBOBJ([asprintf])
163 AC_CHECK_FUNCS(strlcat,,
165 if test $needstrlcat = yes; then
170 AC_CHECK_FUNCS(strlcpy,,
172 if test $needstrlcpy = yes; then
177 AC_CHECK_FUNCS(strtok_r,,
179 if test $needstrtok_r = yes; then
180 AC_LIBOBJ([strtok_r])
184 # Do we have ffs(), and is it declared in <strings.h>?
187 if test "$ac_cv_func_ffs" = yes; then
189 # We have ffs(); is it declared in <strings.h>?
191 # This test fails if we don't have <strings.h> or if we do
192 # but it doesn't declare ffs().
196 AC_DEFINE(STRINGS_H_DECLARES_FFS,,
197 [Define to 1 if strings.h declares `ffs'])
205 # Do this before checking for ether_hostton(), as it's a
206 # "getaddrinfo()-ish function".
211 # Check for reentrant versions of getnetbyname_r(), as provided by
212 # Linux (glibc), Solaris/IRIX, and AIX (with three different APIs!).
213 # If we don't find one, we just use getnetbyname(), which uses
214 # thread-specific data on many platforms, but doesn't use it on
215 # NetBSD or OpenBSD, and may not use it on older versions of other
218 # Only do the check if we have a declaration of getnetbyname_r();
219 # without it, we can't check which API it has. (We assume that
220 # if there's a declaration, it has a prototype, so that the API
223 AC_CHECK_DECL(getnetbyname_r,
225 AC_MSG_CHECKING([for the Linux getnetbyname_r()])
227 [#include <netdb.h>],
229 struct netent netent_buf;
231 struct netent *resultp;
234 return getnetbyname_r((const char *)0, &netent_buf, buf, sizeof buf, &resultp, &h_errnoval);
238 AC_DEFINE(HAVE_LINUX_GETNETBYNAME_R, 1,
239 [define if we have the Linux getnetbyname_r()])
244 AC_MSG_CHECKING([for Solaris/IRIX getnetbyname_r()])
246 [#include <netdb.h>],
248 struct netent netent_buf;
251 return getnetbyname_r((const char *)0, &netent_buf, buf, (int)sizeof buf) != NULL;
255 AC_DEFINE(HAVE_SOLARIS_IRIX_GETNETBYNAME_R, 1,
256 [define if we have the Solaris/IRIX getnetbyname_r()])
261 AC_MSG_CHECKING([for AIX getnetbyname_r()])
263 [#include <netdb.h>],
265 struct netent netent_buf;
266 struct netent_data net_data;
268 return getnetbyname_r((const char *)0, &netent_buf, &net_data);
272 AC_DEFINE(HAVE_AIX_GETNETBYNAME_R, 1,
273 [define if we have the AIX getnetbyname_r()])
280 ],,[#include <netdb.h>])
283 # Check for reentrant versions of getprotobyname_r(), as provided by
284 # Linux (glibc), Solaris/IRIX, and AIX (with three different APIs!).
285 # If we don't find one, we just use getprotobyname(), which uses
286 # thread-specific data on many platforms, but doesn't use it on
287 # NetBSD or OpenBSD, and may not use it on older versions of other
290 # Only do the check if we have a declaration of getprotobyname_r();
291 # without it, we can't check which API it has. (We assume that
292 # if there's a declaration, it has a prototype, so that the API
295 AC_CHECK_DECL(getprotobyname_r,
297 AC_MSG_CHECKING([for the Linux getprotobyname_r()])
299 [#include <netdb.h>],
301 struct protoent protoent_buf;
303 struct protoent *resultp;
305 return getprotobyname_r((const char *)0, &protoent_buf, buf, sizeof buf, &resultp);
309 AC_DEFINE(HAVE_LINUX_GETPROTOBYNAME_R, 1,
310 [define if we have the Linux getprotobyname_r()])
315 AC_MSG_CHECKING([for Solaris/IRIX getprotobyname_r()])
317 [#include <netdb.h>],
319 struct protoent protoent_buf;
322 return getprotobyname_r((const char *)0, &protoent_buf, buf, (int)sizeof buf) != NULL;
326 AC_DEFINE(HAVE_SOLARIS_IRIX_GETPROTOBYNAME_R, 1,
327 [define if we have the Solaris/IRIX getprotobyname_r()])
332 AC_MSG_CHECKING([for AIX getprotobyname_r()])
334 [#include <netdb.h>],
336 struct protoent protoent_buf;
337 struct protoent_data proto_data;
339 return getprotobyname_r((const char *)0, &protoent_buf, &proto_data);
343 AC_DEFINE(HAVE_AIX_GETPROTOBYNAME_R, 1,
344 [define if we have the AIX getprotobyname_r()])
351 ],,[#include <netdb.h>])
354 # You are in a twisty little maze of UN*Xes, all different.
355 # Some might not have ether_hostton().
356 # Some might have it and declare it in <net/ethernet.h>.
357 # Some might have it and declare it in <netinet/ether.h>
358 # Some might have it and declare it in <sys/ethernet.h>.
359 # Some might have it and declare it in <arpa/inet.h>.
360 # Some might have it and declare it in <netinet/if_ether.h>.
361 # Some might have it and not declare it in any header file.
363 # Before you is a C compiler.
365 AC_CHECK_FUNCS(ether_hostton)
366 if test "$ac_cv_func_ether_hostton" = yes; then
368 # OK, we have ether_hostton(). Is it declared in <net/ethernet.h>?
370 # This test fails if we don't have <net/ethernet.h> or if we do
371 # but it doesn't declare ether_hostton().
373 AC_CHECK_DECL(ether_hostton,
375 AC_DEFINE(NET_ETHERNET_H_DECLARES_ETHER_HOSTTON,,
376 [Define to 1 if net/ethernet.h declares `ether_hostton'])
379 #include <net/ethernet.h>
384 if test "$ac_cv_have_decl_ether_hostton" != yes; then
386 # No, how about <netinet/ether.h>, as on Linux?
388 # This test fails if we don't have <netinet/ether.h>
389 # or if we do but it doesn't declare ether_hostton().
391 # Unset ac_cv_have_decl_ether_hostton so we don't
392 # treat the previous failure as a cached value and
393 # suppress the next test.
395 unset ac_cv_have_decl_ether_hostton
396 AC_CHECK_DECL(ether_hostton,
398 AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_HOSTTON,,
399 [Define to 1 if netinet/ether.h declares `ether_hostton'])
402 #include <netinet/ether.h>
408 if test "$ac_cv_have_decl_ether_hostton" != yes; then
410 # No, how about <sys/ethernet.h>, as on Solaris 10
413 # This test fails if we don't have <sys/ethernet.h>
414 # or if we do but it doesn't declare ether_hostton().
416 # Unset ac_cv_have_decl_ether_hostton so we don't
417 # treat the previous failure as a cached value and
418 # suppress the next test.
420 unset ac_cv_have_decl_ether_hostton
421 AC_CHECK_DECL(ether_hostton,
423 AC_DEFINE(SYS_ETHERNET_H_DECLARES_ETHER_HOSTTON,,
424 [Define to 1 if sys/ethernet.h declares `ether_hostton'])
427 #include <sys/ethernet.h>
433 if test "$ac_cv_have_decl_ether_hostton" != yes; then
435 # No, how about <arpa/inet.h>, as in AIX?
437 # This test fails if we don't have <arpa/inet.h>
438 # (if we have ether_hostton(), we should have
439 # networking, and if we have networking, we should
440 # have <arapa/inet.h>) or if we do but it doesn't
441 # declare ether_hostton().
443 # Unset ac_cv_have_decl_ether_hostton so we don't
444 # treat the previous failure as a cached value and
445 # suppress the next test.
447 unset ac_cv_have_decl_ether_hostton
448 AC_CHECK_DECL(ether_hostton,
450 AC_DEFINE(ARPA_INET_H_DECLARES_ETHER_HOSTTON,,
451 [Define to 1 if arpa/inet.h declares `ether_hostton'])
454 #include <arpa/inet.h>
460 if test "$ac_cv_have_decl_ether_hostton" != yes; then
462 # No, how about <netinet/if_ether.h>?
463 # On some platforms, it requires <net/if.h> and
464 # <netinet/in.h>, and we always include it with
465 # both of them, so test it with both of them.
467 # This test fails if we don't have <netinet/if_ether.h>
468 # and the headers we include before it, or if we do but
469 # <netinet/if_ether.h> doesn't declare ether_hostton().
471 # Unset ac_cv_have_decl_ether_hostton so we don't
472 # treat the previous failure as a cached value and
473 # suppress the next test.
475 unset ac_cv_have_decl_ether_hostton
476 AC_CHECK_DECL(ether_hostton,
478 AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON,,
479 [Define to 1 if netinet/if_ether.h declares `ether_hostton'])
482 #include <sys/types.h>
483 #include <sys/socket.h>
485 #include <netinet/in.h>
486 #include <netinet/if_ether.h>
490 # After all that, is ether_hostton() declared?
492 if test "$ac_cv_have_decl_ether_hostton" = yes; then
496 AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 1,
497 [Define to 1 if you have the declaration of `ether_hostton'])
500 # No, we'll have to declare it ourselves.
501 # Do we have "struct ether_addr" if we include
502 # <netinet/if_ether.h>?
504 AC_CHECK_TYPES(struct ether_addr,,,
506 #include <sys/types.h>
507 #include <sys/socket.h>
509 #include <netinet/in.h>
510 #include <netinet/if_ether.h>
516 # For various things that might use pthreads.
518 AC_CHECK_HEADER(pthread.h,
521 # OK, we have pthread.h. Do we have pthread_create in the
524 AC_CHECK_FUNC(pthread_create,
529 ac_lbl_have_pthreads="found"
533 # No - do we have it in -lpthreads?
535 AC_CHECK_LIB(pthreads, pthread_create,
538 # Yes - add -lpthreads.
540 ac_lbl_have_pthreads="found"
541 PTHREAD_LIBS="$PTHREAD_LIBS -lpthreads"
545 # No - do we have it in -lpthread?
547 AC_CHECK_LIB(pthread, pthread_create,
550 # Yes - add -lpthread.
552 ac_lbl_have_pthreads="found"
553 PTHREAD_LIBS="$PTHREAD_LIBS -lpthread"
559 ac_lbl_have_pthreads="not found"
566 # We didn't find pthread.h.
568 ac_lbl_have_pthreads="not found"
572 dnl to pacify those who hate protochain insn
573 AC_MSG_CHECKING(if --disable-protochain option is specified)
574 AC_ARG_ENABLE(protochain,
575 AS_HELP_STRING([--disable-protochain],[disable \"protochain\" insn]))
576 case "x$enable_protochain" in
577 xyes) enable_protochain=enabled ;;
578 xno) enable_protochain=disabled ;;
579 x) enable_protochain=enabled ;;
582 if test "$enable_protochain" = "disabled"; then
583 AC_DEFINE(NO_PROTOCHAIN,1,[do not use protochain])
585 AC_MSG_RESULT(${enable_protochain})
588 # valgrindtest directly uses the native capture mechanism, but
589 # only tests with BPF and PF_PACKET sockets; only enable it if
590 # we have BPF or PF_PACKET sockets.
595 AS_HELP_STRING([--with-pcap=TYPE],[use packet capture TYPE]))
596 if test ! -z "$with_pcap" ; then
600 # Check for a bunch of headers for various packet
601 # capture mechanisms.
603 AC_CHECK_HEADERS(net/bpf.h)
604 if test "$ac_cv_header_net_bpf_h" = yes; then
606 # Does it define BIOCSETIF?
607 # I.e., is it a header for an LBL/BSD-style capture
608 # mechanism, or is it just a header for a BPF filter
609 # engine? Some versions of Arch Linux, for example,
610 # have a net/bpf.h that doesn't define BIOCSETIF;
611 # as it's a Linux, it should use packet sockets,
616 # sys/types.h, because FreeBSD 10's net/bpf.h
617 # requires that various BSD-style integer types
620 # sys/time.h, because AIX 5.2 and 5.3's net/bpf.h
621 # doesn't include it but does use struct timeval
622 # in ioctl definitions;
624 # sys/ioctl.h and, if we have it, sys/ioccom.h,
625 # because net/bpf.h defines ioctls;
627 # net/if.h, because it defines some structures
628 # used in ioctls defined by net/bpf.h;
630 # sys/socket.h, because OpenBSD 5.9's net/bpf.h
631 # defines some structure fields as being
634 # and net/bpf.h doesn't necessarily include all
635 # of those headers itself.
637 AC_MSG_CHECKING(if net/bpf.h defines BIOCSETIF)
638 AC_CACHE_VAL(ac_cv_lbl_bpf_h_defines_biocsetif,
641 #include <sys/types.h>
642 #include <sys/time.h>
643 #include <sys/ioctl.h>
644 #include <sys/socket.h>
645 #ifdef HAVE_SYS_IOCCOM_H
646 #include <sys/ioccom.h>
651 [u_int i = BIOCSETIF;],
652 ac_cv_lbl_bpf_h_defines_biocsetif=yes,
653 ac_cv_lbl_bpf_h_defines_biocsetif=no))
654 AC_MSG_RESULT($ac_cv_lbl_bpf_h_defines_biocsetif)
656 AC_CHECK_HEADERS(net/pfilt.h net/enet.h)
657 AC_CHECK_HEADERS(net/nit.h sys/net/nit.h)
658 AC_CHECK_HEADERS(linux/socket.h net/raw.h sys/dlpi.h)
659 AC_CHECK_HEADERS(config/HaikuConfig.h)
661 if test "$ac_cv_lbl_bpf_h_defines_biocsetif" = yes; then
664 # Check this before DLPI, so that we pick BPF on
665 # Solaris 11 and later.
670 # We have BPF, so build valgrindtest with "make test"
671 # on macOS and FreeBSD (add your OS once there's a
676 freebsd*|darwin*|linux*)
677 VALGRINDTEST_SRC=valgrindtest.c
680 elif test "$ac_cv_header_linux_socket_h" = yes; then
682 # No prizes for guessing this one.
685 VALGRINDTEST_SRC=valgrindtest.c
686 elif test "$ac_cv_header_net_pfilt_h" = yes; then
688 # DEC OSF/1, Digital UNIX, Tru64 UNIX
691 elif test "$ac_cv_header_net_enet_h" = yes; then
693 # Stanford Enetfilter.
696 elif test "$ac_cv_header_net_nit_h" = yes; then
698 # SunOS 4.x STREAMS NIT.
701 elif test "$ac_cv_header_sys_net_nit_h" = yes; then
703 # Pre-SunOS 4.x non-STREAMS NIT.
706 elif test "$ac_cv_header_net_raw_h" = yes; then
711 elif test "$ac_cv_header_sys_dlpi_h" = yes; then
713 # DLPI on pre-Solaris 11 SunOS 5, HP-UX, possibly others.
716 elif test "$ac_cv_header_config_HaikuConfig_h" = yes; then
723 # Nothing we support.
726 AC_MSG_WARN(cannot determine packet capture interface)
727 AC_MSG_WARN((see the INSTALL doc for more info))
730 AC_MSG_CHECKING(packet capture type)
731 AC_MSG_RESULT($V_PCAP)
732 AC_SUBST(VALGRINDTEST_SRC)
735 # Do we have pkg-config?
737 AC_CHECK_PROG([PKGCONFIG], [pkg-config], [pkg-config], [no])
740 # Handle each capture type.
745 # Checks for some header files.
747 AC_CHECK_HEADERS(sys/bufmod.h sys/dlpi_ext.h)
750 # Checks to see if Solaris has the public libdlpi(3LIB) library.
751 # Note: The existence of /usr/include/libdlpi.h does not mean it is the
752 # public libdlpi(3LIB) version. Before libdlpi was made public, a
753 # private version also existed, which did not have the same APIs.
754 # Due to a gcc bug, the default search path for 32-bit libraries does
755 # not include /lib, we add it explicitly here.
756 # [http://bugs.opensolaris.org/view_bug.do?bug_id=6619485].
757 # Also, due to the bug above applications that link to libpcap with
758 # libdlpi will have to add "-L/lib" option to "configure".
760 save_LDFLAGS="$LDFLAGS"
761 LDFLAGS="$LIBS -L/lib"
762 AC_CHECK_LIB(dlpi, dlpi_walk,
768 # Capture module plus common code needed for
769 # common functions used by pcap-[dlpi,libdlpi].c
771 PLATFORM_C_SRC="pcap-libdlpi.c dlpisubs.c"
772 AC_DEFINE(HAVE_LIBDLPI,1,[if libdlpi exists])
778 # Capture module plus common code needed for
779 # common functions used by pcap-[dlpi,libdlpi].c
781 PLATFORM_C_SRC="pcap-dlpi.c dlpisubs.c"
783 LDFLAGS="$save_LDFLAGS"
786 # Checks whether <sys/dlpi.h> is usable, to catch weird SCO
789 AC_MSG_CHECKING(whether <sys/dlpi.h> is usable)
790 AC_CACHE_VAL(ac_cv_sys_dlpi_usable,
793 #include <sys/types.h>
794 #include <sys/time.h>
795 #include <sys/dlpi.h>
797 [int i = DL_PROMISC_PHYS;],
798 ac_cv_sys_dlpi_usable=yes,
799 ac_cv_sys_dlpi_usable=no))
800 AC_MSG_RESULT($ac_cv_sys_dlpi_usable)
801 if test $ac_cv_sys_dlpi_usable = no ; then
802 AC_MSG_ERROR(<sys/dlpi.h> is not usable on this system; it probably has a non-standard DLPI)
806 # Check to see if Solaris has the dl_passive_req_t struct defined
808 # This check is for DLPI support for passive modes.
809 # See dlpi(7P) for more details.
811 AC_CHECK_TYPES(dl_passive_req_t,,,
813 #include <sys/types.h>
814 #include <sys/dlpi.h>
822 PLATFORM_C_SRC="pcap-enet.c"
829 PLATFORM_CXX_SRC="pcap-haiku.cpp"
832 # Just for the sake of it.
834 AC_CHECK_HEADERS(net/if.h net/if_dl.h net/if_types.h)
841 PLATFORM_C_SRC="pcap-linux.c"
844 # Do we have the wireless extensions?
846 AC_CHECK_HEADERS(linux/wireless.h, [], [],
848 #include <sys/socket.h>
849 #include <linux/if.h>
850 #include <linux/types.h>
855 # We only want version 3. Version 2 was, apparently,
856 # short-lived, and version 1 is source and binary
857 # incompatible with version 3, and it appears that,
858 # these days, everybody's using version 3. We're
859 # not supporting older versions of the Linux kernel;
860 # let's drop support for older versions of libnl, too.
863 AS_HELP_STRING([--without-libnl],[disable libnl support @<:@default=yes, on Linux, if present@:>@]),
864 with_libnl=$withval,with_libnl=if_available)
866 if test x$with_libnl != xno ; then
867 if test "x$PKGCONFIG" != "xno"; then
869 # We have pkg-config; see if we have libnl-genl-3.0
872 AC_MSG_CHECKING([for libnl-genl-3.0 with pkg-config])
873 if "$PKGCONFIG" libnl-genl-3.0; then
874 AC_MSG_RESULT([found])
875 pkg_config_found_libnl=yes
876 libnl_genl_cflags=`"$PKGCONFIG" --cflags libnl-genl-3.0`
877 V_INCLS="$V_INCLS ${libnl_genl_cflags}"
878 libnl_genl_libs=`"$PKGCONFIG" --libs libnl-genl-3.0`
879 LIBS="${libnl_genl_libs} $LIBS"
880 AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
882 AC_MSG_RESULT([not found])
886 if test x$pkg_config_found_libnl != xyes; then
888 # OK, either we don't have pkg-config or there
889 # wasn't a .pc file for it; Check for it directly.
891 case "$with_libnl" in
894 incdir=-I/usr/include/libnl3
899 if test -d $withval; then
900 libnldir=-L${withval}/lib
901 incdir=-I${withval}/include
906 AC_CHECK_LIB(nl-3, nl_socket_alloc,
909 # Yes, we have libnl 3.x.
911 LIBS="${libnldir} -lnl-genl-3 -lnl-3 $LIBS"
912 AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
913 V_INCLS="$V_INCLS ${incdir}"
916 # No, we don't have libnl at all.
917 # Fail if the user explicitly requested
920 if test x$with_libnl = xyes ; then
921 AC_MSG_ERROR([libnl support requested but libnl not found])
923 ], ${incdir} ${libnldir} -lnl-genl-3 -lnl-3 )
928 # Check to see if the tpacket_auxdata struct has a tp_vlan_tci member.
930 # NOTE: any failure means we conclude that it doesn't have that
931 # member, so if we don't have tpacket_auxdata, we conclude it
932 # doesn't have that member (which is OK, as either we won't be
933 # using code that would use that member, or we wouldn't compile
935 AC_CHECK_MEMBERS([struct tpacket_auxdata.tp_vlan_tci],,,
937 #include <sys/types.h>
938 #include <linux/if_packet.h>
946 PLATFORM_C_SRC="pcap-bpf.c"
949 # Check whether we have the *BSD-style ioctls.
951 AC_CHECK_HEADERS(net/if_media.h)
954 # Check whether we have struct BPF_TIMEVAL.
956 AC_CHECK_TYPES(struct BPF_TIMEVAL,,,
958 #include <sys/types.h>
959 #include <sys/ioctl.h>
960 #ifdef HAVE_SYS_IOCCOM_H
961 #include <sys/ioccom.h>
971 PLATFORM_C_SRC="pcap-pf.c"
978 PLATFORM_C_SRC="pcap-snit.c"
985 PLATFORM_C_SRC="pcap-snoop.c"
990 # --with-pcap=dag is the only way to get here, and it means
991 # "DAG support but nothing else"
993 V_DEFS="$V_DEFS -DDAG_ONLY"
994 PLATFORM_C_SRC="pcap-dag.c"
1000 # --with-pcap=dpdk is the only way to get here, and it means
1001 # "DPDK support but nothing else"
1003 V_DEFS="$V_DEFS -DDPDK_ONLY"
1004 PLATFORM_C_SRC="pcap-dpdk.c"
1010 # --with-pcap=septel is the only way to get here, and it means
1011 # "Septel support but nothing else"
1013 V_DEFS="$V_DEFS -DSEPTEL_ONLY"
1014 PLATFORM_C_SRC="pcap-septel.c"
1020 # --with-pcap=snf is the only way to get here, and it means
1021 # "SNF support but nothing else"
1023 V_DEFS="$V_DEFS -DSNF_ONLY"
1024 PLATFORM_C_SRC="pcap-snf.c"
1032 PLATFORM_C_SRC="pcap-null.c"
1036 AC_MSG_ERROR($V_PCAP is not a valid pcap type)
1041 dnl Now figure out how we get a list of interfaces and addresses,
1042 dnl if we support capturing. Don't bother if we don't support
1045 if test "$V_PCAP" != null
1047 AC_CHECK_FUNC(getifaddrs,[
1049 # We have "getifaddrs()"; make sure we have <ifaddrs.h>
1050 # as well, just in case some platform is really weird.
1052 AC_CHECK_HEADER(ifaddrs.h,[
1054 # We have the header, so we use "getifaddrs()" to
1055 # get the list of interfaces.
1057 PLATFORM_C_SRC="$PLATFORM_C_SRC fad-getad.c"
1060 # We don't have the header - give up.
1061 # XXX - we could also fall back on some other
1062 # mechanism, but, for now, this'll catch this
1063 # problem so that we can at least try to figure
1064 # out something to do on systems with "getifaddrs()"
1065 # but without "ifaddrs.h", if there is something
1066 # we can do on those systems.
1068 AC_MSG_ERROR([Your system has getifaddrs() but doesn't have a usable <ifaddrs.h>.])
1072 # Well, we don't have "getifaddrs()", at least not with the
1073 # libraries with which we've decided we need to link
1074 # libpcap with, so we have to use some other mechanism.
1076 # Note that this may happen on Solaris, which has
1077 # getifaddrs(), but in -lsocket, not in -lxnet, so we
1078 # won't find it if we link with -lxnet, which we want
1079 # to do for other reasons.
1081 # For now, we use either the SIOCGIFCONF ioctl or the
1082 # SIOCGLIFCONF ioctl, preferring the latter if we have
1083 # it; the latter is a Solarisism that first appeared
1084 # in Solaris 8. (Solaris's getifaddrs() appears to
1085 # be built atop SIOCGLIFCONF; using it directly
1086 # avoids a not-all-that-useful middleman.)
1088 AC_MSG_CHECKING(whether we have SIOCGLIFCONF)
1089 AC_CACHE_VAL(ac_cv_lbl_have_siocglifconf,
1091 [#include <sys/param.h>
1092 #include <sys/file.h>
1093 #include <sys/ioctl.h>
1094 #include <sys/socket.h>
1095 #include <sys/sockio.h>],
1096 [ioctl(0, SIOCGLIFCONF, (char *)0);],
1097 ac_cv_lbl_have_siocglifconf=yes,
1098 ac_cv_lbl_have_siocglifconf=no))
1099 AC_MSG_RESULT($ac_cv_lbl_have_siocglifconf)
1100 if test $ac_cv_lbl_have_siocglifconf = yes ; then
1101 PLATFORM_C_SRC="$PLATFORM_C_SRC fad-glifc.c"
1103 PLATFORM_C_SRC="$PLATFORM_C_SRC fad-gifc.c"
1108 dnl check for hardware timestamp support
1111 AC_CHECK_HEADERS([linux/net_tstamp.h])
1114 AC_MSG_NOTICE(no hardware timestamp support implemented for $host_os)
1119 # Check for socklen_t.
1121 AC_CHECK_TYPES(socklen_t,,,
1123 #include <sys/types.h>
1124 #include <sys/socket.h>
1128 AS_HELP_STRING([--enable-ipv6],[build IPv6-capable version @<:@default=yes@:>@]),
1131 if test "$enable_ipv6" != "no"; then
1133 # We've already made sure we have getaddrinfo above in
1134 # AC_LBL_LIBRARY_NET.
1136 AC_DEFINE(INET6,1,[IPv6])
1139 # Check for Endace DAG card support.
1141 AS_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1143 if test "$withval" = no
1145 # User doesn't want DAG support.
1147 elif test "$withval" = yes
1149 # User wants DAG support but hasn't specified a directory.
1152 # User wants DAG support and has specified a directory, so use the provided value.
1157 if test "$V_PCAP" = dag; then
1158 # User requested DAG-only libpcap, so we'd better have
1161 elif test "xxx_only" = yes; then
1162 # User requested something-else-only pcap, so they don't
1167 # Use DAG API if present, otherwise don't
1173 AC_ARG_WITH([dag-includes],
1174 AS_HELP_STRING([--with-dag-includes=IDIR],[Endace DAG include directory, if not DIR/include]),
1176 # User wants DAG support and has specified a header directory, so use the provided value.
1178 dag_include_dir=$withval
1181 AC_ARG_WITH([dag-libraries],
1182 AS_HELP_STRING([--with-dag-libraries=LDIR],[Endace DAG library directory, if not DIR/lib]),
1184 # User wants DAG support and has specified a library directory, so use the provided value.
1186 dag_lib_dir=$withval
1189 if test "$want_dag" != no; then
1191 # If necessary, set default paths for DAG API headers and libraries.
1192 if test -z "$dag_root"; then
1196 if test -z "$dag_include_dir"; then
1197 dag_include_dir="$dag_root/include"
1200 if test -z "$dag_lib_dir"; then
1201 dag_lib_dir="$dag_root/lib"
1203 # Handle multiarch systems.
1205 if test -d "$dag_lib_dir/$host"
1207 dag_lib_dir="$dag_lib_dir/$host"
1211 save_CFLAGS="$CFLAGS"
1212 CFLAGS="$CFLAGS -I$dag_include_dir"
1213 AC_CHECK_HEADERS([dagapi.h])
1215 if test "$ac_cv_header_dagapi_h" = yes; then
1217 V_INCLS="$V_INCLS -I$dag_include_dir"
1219 if test $V_PCAP != dag ; then
1220 MODULE_C_SRC="$MODULE_C_SRC pcap-dag.c"
1223 # Check for various DAG API functions.
1224 # Don't need to save and restore LIBS to prevent -ldag being
1225 # included if there's a found-action (arg 3).
1226 save_LDFLAGS="$LDFLAGS"
1227 LDFLAGS="-L$dag_lib_dir"
1228 AC_CHECK_LIB([dag], [dag_attach_stream],
1230 [AC_MSG_ERROR(DAG library lacks streams support)])
1231 AC_CHECK_LIB([dag], [dag_attach_stream64], [dag_large_streams="1"], [dag_large_streams="0"])
1232 AC_CHECK_LIB([dag],[dag_get_erf_types], [
1233 AC_DEFINE(HAVE_DAG_GET_ERF_TYPES, 1, [define if you have dag_get_erf_types()])])
1234 AC_CHECK_LIB([dag],[dag_get_stream_erf_types], [
1235 AC_DEFINE(HAVE_DAG_GET_STREAM_ERF_TYPES, 1, [define if you have dag_get_stream_erf_types()])])
1237 LDFLAGS="$save_LDFLAGS"
1240 # We assume that if we have libdag we have libdagconf,
1241 # as they're installed at the same time from the same
1244 LIBS="$LIBS -ldag -ldagconf"
1245 LDFLAGS="$LDFLAGS -L$dag_lib_dir"
1247 if test "$dag_large_streams" = 1; then
1248 AC_DEFINE(HAVE_DAG_LARGE_STREAMS_API, 1, [define if you have large streams capable DAG API])
1249 AC_CHECK_LIB([vdag],[vdag_set_device_info], [ac_dag_have_vdag="1"], [ac_dag_have_vdag="0"])
1250 if test "$ac_dag_have_vdag" = 1; then
1251 AC_DEFINE(HAVE_DAG_VDAG, 1, [define if you have vdag_set_device_info()])
1252 if test "$ac_lbl_have_pthreads" != "found"; then
1253 AC_MSG_ERROR([DAG requires pthreads, but we didn't find them])
1255 LIBS="$LIBS $PTHREAD_LIBS"
1259 AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
1262 if test "$V_PCAP" = dag; then
1263 # User requested "dag" capture type but we couldn't
1264 # find the DAG API support.
1265 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])
1268 if test "$want_dag" = yes; then
1269 # User wanted DAG support but we couldn't find it.
1270 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])
1273 CFLAGS="$save_CFLAGS"
1277 AS_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1279 if test "$withval" = no
1282 elif test "$withval" = yes
1288 septel_root=$withval
1291 if test "$V_PCAP" = septel; then
1292 # User requested Septel-only libpcap, so we'd better have
1295 elif test "xxx_only" = yes; then
1296 # User requested something-else-only pcap, so they don't
1297 # want Septel support.
1301 # Use Septel API if present, otherwise don't
1303 want_septel=ifpresent
1307 ac_cv_lbl_septel_api=no
1308 if test "$with_septel" != no; then
1310 AC_MSG_CHECKING([whether we have Septel API headers])
1312 # If necessary, set default paths for Septel API headers and libraries.
1313 if test -z "$septel_root"; then
1314 septel_root=$srcdir/../septel
1317 septel_tools_dir="$septel_root"
1318 septel_include_dir="$septel_root/INC"
1320 if test -r "$septel_include_dir/msg.h"; then
1321 ac_cv_lbl_septel_api=yes
1324 if test "$ac_cv_lbl_septel_api" = yes; then
1325 AC_MSG_RESULT([yes ($septel_include_dir)])
1327 V_INCLS="$V_INCLS -I$septel_include_dir"
1328 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"
1329 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"
1331 if test "$V_PCAP" != septel ; then
1332 MODULE_C_SRC="$MODULE_C_SRC pcap-septel.c"
1335 AC_DEFINE(HAVE_SEPTEL_API, 1, [define if you have the Septel API])
1339 if test "$V_PCAP" = septel; then
1340 # User requested "septel" capture type but
1341 # we couldn't find the Septel API support.
1342 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])
1345 if test "$want_septel" = yes; then
1346 # User wanted Septel support but we couldn't find it.
1347 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])
1352 # Check for Myricom SNF support.
1354 AS_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1356 if test "$withval" = no
1358 # User explicitly doesn't want SNF
1360 elif test "$withval" = yes
1362 # User wants SNF support but hasn't specified a directory.
1365 # User wants SNF support with a specified directory.
1370 if test "$V_PCAP" = snf; then
1371 # User requested Sniffer-only libpcap, so we'd better have
1374 elif test "xxx_only" = yes; then
1375 # User requested something-else-only pcap, so they don't
1380 # Use Sniffer API if present, otherwise don't
1386 AC_ARG_WITH([snf-includes],
1387 AS_HELP_STRING([--with-snf-includes=IDIR],[Myricom SNF include directory, if not DIR/include]),
1389 # User wants SNF with specific header directory
1391 snf_include_dir=$withval
1394 AC_ARG_WITH([snf-libraries],
1395 AS_HELP_STRING([--with-snf-libraries=LDIR],[Myricom SNF library directory, if not DIR/lib]),
1397 # User wants SNF with specific lib directory
1399 snf_lib_dir=$withval
1402 ac_cv_lbl_snf_api=no
1403 if test "$with_snf" != no; then
1405 AC_MSG_CHECKING(whether we have Myricom Sniffer API)
1407 # If necessary, set default paths for Sniffer headers and libraries.
1408 if test -z "$snf_root"; then
1412 if test -z "$snf_include_dir"; then
1413 snf_include_dir="$snf_root/include"
1416 if test -z "$snf_lib_dir"; then
1417 snf_lib_dir="$snf_root/lib"
1419 # Handle multiarch systems.
1421 if test -d "$snf_lib_dir/$host"
1423 snf_lib_dir="$snf_lib_dir/$host"
1427 if test -f "$snf_include_dir/snf.h"; then
1428 # We found a header; make sure we can link with the library
1429 save_LDFLAGS="$LDFLAGS"
1430 LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1431 AC_CHECK_LIB([snf], [snf_init], [ac_cv_lbl_snf_api="yes"])
1432 LDFLAGS="$save_LDFLAGS"
1433 if test "$ac_cv_lbl_snf_api" = no; then
1434 AC_MSG_ERROR(SNF API cannot correctly be linked; check config.log)
1438 if test "$ac_cv_lbl_snf_api" = yes; then
1439 AC_MSG_RESULT([yes ($snf_root)])
1441 V_INCLS="$V_INCLS -I$snf_include_dir"
1443 LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1445 if test "$V_PCAP" != snf ; then
1446 MODULE_C_SRC="$MODULE_C_SRC pcap-snf.c"
1449 AC_DEFINE(HAVE_SNF_API, 1, [define if you have the Myricom SNF API])
1453 if test "$want_snf" = yes; then
1454 # User requested "snf" capture type but
1455 # we couldn't find the Sniffer API support.
1456 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])
1459 if test "$want_snf" = yes; then
1460 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])
1465 # Check for Riverbed TurboCap support.
1466 AC_ARG_WITH([turbocap],
1467 AS_HELP_STRING([--with-turbocap@<:@=DIR@:>@],[include Riverbed TurboCap support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1469 if test "$withval" = no
1471 # User explicitly doesn't want TurboCap
1473 elif test "$withval" = yes
1475 # User wants TurboCap support but hasn't specified a directory.
1478 # User wants TurboCap support with a specified directory.
1480 turbocap_root=$withval
1483 if test "xxx_only" = yes; then
1484 # User requested something-else-only pcap, so they don't
1485 # want TurboCap support.
1489 # Use TurboCap API if present, otherwise don't
1491 want_turbocap=ifpresent
1495 ac_cv_lbl_turbocap_api=no
1496 if test "$want_turbocap" != no; then
1498 AC_MSG_CHECKING(whether TurboCap is supported)
1500 save_CFLAGS="$CFLAGS"
1502 if test ! -z "$turbocap_root"; then
1503 TURBOCAP_CFLAGS="-I$turbocap_root/include"
1504 TURBOCAP_LIBS="-L$turbocap_root/lib"
1505 CFLAGS="$CFLAGS $TURBOCAP_CFLAGS"
1513 TC_INSTANCE a; TC_PORT b; TC_BOARD c;
1515 (void)TcInstanceCreateByName("foo", &i);
1517 ac_cv_lbl_turbocap_api=yes)
1519 CFLAGS="$save_CFLAGS"
1520 if test $ac_cv_lbl_turbocap_api = yes; then
1523 MODULE_C_SRC="$MODULE_C_SRC pcap-tc.c"
1524 V_INCLS="$V_INCLS $TURBOCAP_CFLAGS"
1525 LIBS="$LIBS $TURBOCAP_LIBS -lTcApi -lpthread -lstdc++"
1527 AC_DEFINE(HAVE_TC_API, 1, [define if you have the TurboCap API])
1531 if test "$want_turbocap" = yes; then
1532 # User wanted Turbo support but we couldn't find it.
1533 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])
1539 dnl Allow the user to enable remote capture.
1540 dnl It's off by default, as that increases the attack surface of
1541 dnl libpcap, exposing it to malicious servers.
1543 AC_MSG_CHECKING([whether to enable remote packet capture])
1544 AC_ARG_ENABLE(remote,
1545 [ --enable-remote enable remote packet capture @<:@default=no@:>@
1546 --disable-remote disable remote packet capture],,
1548 case "$enableval" in
1549 yes) AC_MSG_RESULT(yes)
1550 AC_WARN([Remote packet capture may expose libpcap-based applications])
1551 AC_WARN([to attacks by malicious remote capture servers!])
1553 # rpcapd requires pthreads on UN*X.
1555 if test "$ac_lbl_have_pthreads" != "found"; then
1556 AC_MSG_ERROR([rpcapd requires pthreads, but we didn't find them])
1559 # It also requires crypt().
1560 # Do we have it in the system libraries?
1562 AC_CHECK_FUNC(crypt,,
1565 # No. Do we have it in -lcrypt?
1567 AC_CHECK_LIB(crypt, crypt,
1570 # Yes; add -lcrypt to the libraries for rpcapd.
1572 RPCAPD_LIBS="$RPCAPD_LIBS -lcrypt"
1575 AC_MSG_ERROR([rpcapd requires crypt(), but we didn't find it])
1580 # OK, we have crypt(). Do we have getspnam()?
1582 AC_CHECK_FUNCS(getspnam)
1585 # Check for various members of struct msghdr.
1587 AC_CHECK_MEMBERS([struct msghdr.msg_control],,,
1589 #include "ftmacros.h"
1590 #include <sys/socket.h>
1592 AC_CHECK_MEMBERS([struct msghdr.msg_flags],,,
1594 #include "ftmacros.h"
1595 #include <sys/socket.h>
1599 # Optionally, we may want to support SSL.
1600 # Check for OpenSSL/libressl.
1602 # First, try looking for it as a regular system library.
1603 # Make sure we can find SSL_library_init() using the
1604 # standard headers, just in case we're running a version
1605 # of macOS that ships with the OpenSSL library but not
1606 # the OpenSSL headers, and have also installed another
1607 # version of OpenSSL with headers.
1610 LIBS="-lssl -lcrypto"
1611 AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use)
1614 #include <openssl/ssl.h>
1623 OPENSSL_LIBS="-lssl -lcrypto"
1629 # If we didn't find it, check for it with pkg-config.
1631 if test "x$HAVE_OPENSSL" != "xyes"; then
1632 if test "x$PKGCONFIG" != "xno"; then
1634 # We have pkg-config; see if we have OpenSSL/
1635 # libressl installed as a package.
1637 AC_MSG_CHECKING([for OpenSSL/libressl with pkg-config])
1638 if "$PKGCONFIG" openssl; then
1639 AC_MSG_RESULT([found])
1641 OPENSSL_CFLAGS=`"$PKGCONFIG" --cflags openssl`
1642 OPENSSL_LIBS=`"$PKGCONFIG" --libs openssl`
1644 AC_MSG_RESULT([not found])
1650 # If we didn't find it, check for it under /usr/local/opt/openssl;
1651 # that's where Homebrew puts it on macOS. Feel free to add other
1652 # -L directories as necessary; the "system library" check should
1653 # also handle "add-on library under /usr/local", so that shouldn't
1654 # be necessary here.
1656 if test "x$HAVE_OPENSSL" != "xyes"; then
1657 save_CFLAGS="$CFLAGS"
1659 CFLAGS="$CFLAGS -L/usr/local/opt/openssl/include"
1660 LIBS="$LIBS -L/usr/local/opt/openssl/lib -lssl -lcrypto"
1661 AC_MSG_CHECKING(whether we have OpenSSL/libressl in /usr/local/opt that we can use)
1664 #include <openssl/ssl.h>
1673 OPENSSL_CFLAGS="-I/usr/local/opt/openssl/include"
1674 OPENSSL_LIBS="-L/usr/local/opt/openssl/lib -lssl -lcrypto"
1677 CFLAGS="$save_CFLAGS"
1682 # OK, did we find it?
1684 if test "x$HAVE_OPENSSL" = "xyes"; then
1685 AC_DEFINE([HAVE_OPENSSL], [1], [Use OpenSSL])
1686 CFLAGS="$CFLAGS $OPENSSL_CFLAGS"
1687 LIBS="$LIBS $OPENSSL_LIBS"
1689 AC_MSG_NOTICE(OpenSSL not found)
1692 AC_DEFINE(ENABLE_REMOTE,,
1693 [Define to 1 if remote packet capture is to be supported])
1694 REMOTE_C_SRC="$REMOTE_C_SRC pcap-new.c pcap-rpcap.c rpcap-protocol.c sockutils.c sslutils.c"
1695 BUILD_RPCAPD=build-rpcapd
1696 INSTALL_RPCAPD=install-rpcapd
1698 *) AC_MSG_RESULT(no)
1702 AC_MSG_CHECKING(whether to build optimizer debugging code)
1703 AC_ARG_ENABLE(optimizer-dbg,
1704 AS_HELP_STRING([--enable-optimizer-dbg],[build optimizer debugging code]))
1705 if test "$enable_optimizer_dbg" = "yes"; then
1706 AC_DEFINE(BDEBUG,1,[Enable optimizer debugging])
1708 AC_MSG_RESULT(${enable_optimizer_dbg-no})
1710 AC_MSG_CHECKING(whether to build parser debugging code)
1711 AC_ARG_ENABLE(yydebug,
1712 AS_HELP_STRING([--enable-yydebug],[build parser debugging code]))
1713 if test "$enable_yydebug" = "yes"; then
1714 AC_DEFINE(YYDEBUG,1,[Enable parser debugging])
1716 AC_MSG_RESULT(${enable_yydebug-no})
1722 if test "$LEX" = ":"; then
1723 AC_MSG_ERROR([Neither flex nor lex was found.])
1727 # Make sure {f}lex supports the -P, --header-file, and --nounput flags
1728 # and supports processing our scanner.l.
1730 AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex,
1731 if $LEX -P pcap_ --header-file=/dev/null --nounput -t $srcdir/scanner.l > /dev/null 2>&1; then
1732 tcpdump_cv_capable_lex=yes
1734 tcpdump_cv_capable_lex=insufficient
1736 if test $tcpdump_cv_capable_lex = insufficient ; then
1737 AC_MSG_ERROR([$LEX is insufficient to compile libpcap.
1738 libpcap requires Flex 2.5.31 or later, or a compatible version of lex.
1739 If a suitable version of Lex/Flex is available as a non-standard command
1740 and/or not in the PATH, you can specify it using the LEX environment
1741 variable. That said, on some systems the error can mean that Flex/Lex is
1742 actually acceptable, but m4 is not. Likewise, if a suitable version of
1743 m4 (such as GNU M4) is available but has not been detected, you can
1744 specify it using the M4 environment variable.])
1748 # Look for yacc/bison/byacc.
1749 # If it's Bison, we do not want -y, as 1) we will be using -o to cause
1750 # the output for XXX.y to be written to XXX.c and 2) we don't want
1751 # it to issue warnings about stuff not supported by POSIX YACC - we
1752 # want to use that stuff, and don't care whether plain YACC supports
1753 # it or not, we require either Bison or Berkeley YACC.
1759 AC_CHECK_PROGS(BISON_BYACC, bison)
1760 if test x"$BISON_BYACC" != x; then
1764 # Bison prior to 2.4(.1) doesn't support "%define api.pure", so use
1767 bison_major_version=`$BISON_BYACC -V | sed -n 's/.* \(@<:@1-9@:>@@<:@0-9@:>@*\)\.@<:@0-9@:>@@<:@0-9.@:>@*/\1/p'`
1768 bison_minor_version=`$BISON_BYACC -V | sed -n 's/.* @<:@1-9@:>@@<:@0-9@:>@*\.\(@<:@0-9@:>@+\).*/\1/p'`
1769 if test "$bison_major_version" -lt 2 -o \
1770 \( "$bison_major_version" -eq 2 -a "$bison_major_version" -lt 4 \)
1772 REENTRANT_PARSER="%pure-parser"
1774 REENTRANT_PARSER="%define api.pure"
1778 # We didn't find Bison; check for Berkeley YACC, under the
1779 # names byacc and yacc.
1781 AC_CHECK_PROGS(BISON_BYACC, byacc yacc)
1782 if test x"$BISON_BYACC" != x; then
1784 # Make sure this is Berkeley YACC, not AT&T YACC;
1785 # the latter doesn't support reentrant parsers.
1786 # Run it with "-V"; that succeeds and reports the
1787 # version number with Berkeley YACC, but will
1788 # (probably) fail with various vendor flavors
1791 # Hopefully this also eliminates any versions
1792 # of Berkeley YACC that don't support reentrant
1793 # parsers, if there are any.
1795 AC_CACHE_CHECK([for capable yacc], tcpdump_cv_capable_yacc,
1796 if $BISON_BYACC -V >/dev/null 2>&1; then
1797 tcpdump_cv_capable_yacc=yes
1799 tcpdump_cv_capable_yacc=insufficient
1801 if test $tcpdump_cv_capable_yacc = insufficient ; then
1802 AC_MSG_ERROR([$BISON_BYACC is insufficient to compile libpcap.
1803 libpcap requires Bison, a newer version of Berkeley YACC with support
1804 for reentrant parsers, or another YACC compatible with them.])
1808 # OK, we found neither byacc nor yacc.
1810 AC_MSG_ERROR([Neither bison, byacc, nor yacc was found.
1811 libpcap requires Bison, a newer version of Berkeley YACC with support
1812 for reentrant parsers, or another YACC compatible with them.])
1816 # Berkeley YACC doesn't support "%define api.pure", so use
1819 REENTRANT_PARSER="%pure-parser"
1821 AC_SUBST(BISON_BYACC)
1822 AC_SUBST(REENTRANT_PARSER)
1825 # Do various checks for various OSes and versions of those OSes.
1827 # Assume, by default, no support for shared libraries and V7/BSD
1828 # convention for man pages (devices in section 4, file formats in
1829 # section 5, miscellaneous info in section 7, administrative commands
1830 # and daemons in section 8). Individual cases can override this.
1836 MAN_ADMIN_COMMANDS=8
1840 dnl Workaround to enable certain features
1841 AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
1844 # AIX makes it fun to build shared and static libraries,
1845 # because they're *both* ".a" archive libraries. We
1846 # build the static library for the benefit of the traditional
1847 # scheme of building libpcap and tcpdump in subdirectories of
1848 # the same directory, with tcpdump statically linked with the
1849 # libpcap in question, but we also build a shared library as
1850 # "libpcap.shareda" and install *it*, rather than the static
1851 # library, as "libpcap.a".
1859 # If we're using DLPI, applications will need to
1860 # use /lib/pse.exp if present, as we use the
1863 pseexe="/lib/pse.exp"
1864 AC_MSG_CHECKING(for $pseexe)
1865 if test -f $pseexe ; then
1873 # If we're using BPF, we need "-lodm" and "-lcfg", as
1874 # we use them to load the BPF module.
1883 V_CCOPT="$V_CCOPT -fno-common"
1884 AC_ARG_ENABLE(universal,
1885 AS_HELP_STRING([--disable-universal],[don't build universal on macOS]))
1886 if test "$enable_universal" != "no"; then
1891 # Pre-Tiger. Build only for 32-bit PowerPC; no
1892 # need for any special compiler or linker flags.
1896 darwin8.[[0123]]|darwin8.[[0123]].*)
1898 # Tiger, prior to Intel support. Build
1899 # libraries and executables for 32-bit PowerPC
1900 # and 64-bit PowerPC, with 32-bit PowerPC first.
1901 # (I'm guessing that's what Apple does.)
1903 # (The double brackets are needed because
1904 # autotools/m4 use brackets as a quoting
1905 # character; the double brackets turn into
1906 # single brackets in the generated configure
1909 V_LIB_CCOPT_FAT="-arch ppc -arch ppc64"
1910 V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64"
1911 V_PROG_CCOPT_FAT="-arch ppc -arch ppc64"
1912 V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64"
1915 darwin8.[[456]]|darwin.[[456]].*)
1917 # Tiger, subsequent to Intel support but prior
1918 # to x86-64 support. Build libraries and
1919 # executables for 32-bit PowerPC, 64-bit
1920 # PowerPC, and 32-bit x86, with 32-bit PowerPC
1921 # first. (I'm guessing that's what Apple does.)
1923 # (The double brackets are needed because
1924 # autotools/m4 use brackets as a quoting
1925 # character; the double brackets turn into
1926 # single brackets in the generated configure
1929 V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386"
1930 V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386"
1931 V_PROG_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386"
1932 V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386"
1937 # All other Tiger, so subsequent to x86-64
1938 # support. Build libraries and executables for
1939 # 32-bit PowerPC, 64-bit PowerPC, 32-bit x86,
1940 # and x86-64, with 32-bit PowerPC first. (I'm
1941 # guessing that's what Apple does.)
1943 V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1944 V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1945 V_PROG_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1946 V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1951 # Leopard. Build libraries for 32-bit PowerPC,
1952 # 64-bit PowerPC, 32-bit x86, and x86-64, with
1953 # 32-bit PowerPC first, and build executables
1954 # for 32-bit x86 and 32-bit PowerPC, with 32-bit
1955 # x86 first. (That's what Apple does.)
1957 V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1958 V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
1959 V_PROG_CCOPT_FAT="-arch i386 -arch ppc"
1960 V_PROG_LDFLAGS_FAT="-arch i386 -arch ppc"
1965 # Snow Leopard. Build libraries for x86-64,
1966 # 32-bit x86, and 32-bit PowerPC, with x86-64
1967 # first, and build executables for x86-64 and
1968 # 32-bit x86, with x86-64 first. (That's what
1969 # Apple does, even though Snow Leopard doesn't
1970 # run on PPC, so PPC libpcap runs under Rosetta,
1971 # and Rosetta doesn't support BPF ioctls, so PPC
1972 # programs can't do live captures.)
1974 V_LIB_CCOPT_FAT="-arch x86_64 -arch i386 -arch ppc"
1975 V_LIB_LDFLAGS_FAT="-arch x86_64 -arch i386 -arch ppc"
1976 V_PROG_CCOPT_FAT="-arch x86_64 -arch i386"
1977 V_PROG_LDFLAGS_FAT="-arch x86_64 -arch i386"
1982 # Post-Snow Leopard. Build libraries for x86-64
1983 # and 32-bit x86, with x86-64 first, and build
1984 # executables only for x86-64. (That's what
1985 # Apple does.) This requires no special flags
1987 # XXX - update if and when Apple drops support
1988 # for 32-bit x86 code and if and when Apple adds
1989 # ARM-based Macs. (You're on your own for iOS
1992 # XXX - check whether we *can* build for
1993 # i386 and, if not, suggest that the user
1994 # install the /usr/include headers if they
1995 # want to build fat.
1997 AC_MSG_CHECKING(whether building for 32-bit x86 is supported)
1998 save_CFLAGS="$CFLAGS"
1999 CFLAGS="$CFLAGS -arch i386"
2005 V_LIB_CCOPT_FAT="-arch x86_64"
2006 V_LIB_LDFLAGS_FAT="-arch x86_64"
2009 # OpenSSL installation on macOS seems
2010 # to install only the libs for 64-bit
2011 # x86 - at least that's what Brew does:
2012 # only configure 32-bit builds if we
2013 # don't have OpenSSL.
2015 if test "$HAVE_OPENSSL" != yes; then
2016 V_LIB_CCOPT_FAT="$V_LIB_CCOPT_FAT -arch i386"
2017 V_LIB_LDFLAGS_FAT="$V_LIB_LDFLAGS_FAT -arch i386"
2022 V_LIB_CCOPT_FAT="-arch x86_64"
2023 V_LIB_LDFLAGS_FAT="-arch x86_64"
2028 # Mojave; you need to install the
2029 # /usr/include headers to get
2030 # 32-bit x86 builds to work.
2032 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])
2037 # Pre-Mojave; the command-line
2038 # tools should be sufficient to
2039 # enable 32-bit x86 builds.
2041 AC_MSG_WARN([Compiling for 32-bit x86 gives an error; try installing the command-line tools])
2045 CFLAGS="$save_CFLAGS"
2052 AC_DEFINE(HAVE_HPUX9,1,[on HP-UX 9.x])
2055 # Use System V conventions for man pages.
2057 MAN_ADMIN_COMMANDS=1m
2065 # Use System V conventions for man pages.
2067 MAN_ADMIN_COMMANDS=1m
2075 # Use System V conventions for man pages.
2077 MAN_ADMIN_COMMANDS=1m
2083 dnl HPUX 10.20 and above is similar to HPUX 9, but
2084 dnl not the same....
2086 dnl XXX - DYEXT should be set to "sl" if this is building
2087 dnl for 32-bit PA-RISC, but should be left as "so" for
2088 dnl 64-bit PA-RISC or, I suspect, IA-64.
2089 AC_DEFINE(HAVE_HPUX10_20_OR_LATER,1,[on HP-UX 10.20 or later])
2090 if test "`uname -m`" = "ia64"; then
2097 # "-b" builds a shared library; "+h" sets the soname.
2103 # Use System V conventions for man pages.
2111 # Use IRIX conventions for man pages; they're the same as the
2112 # System V conventions, except that they use section 8 for
2113 # administrative commands and daemons.
2119 linux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*|haiku*|midipix*)
2123 # Compiler assumed to be GCC; run-time linker may require a -R
2126 if test "$libdir" != "/usr/lib"; then
2127 V_RFLAGS=-Wl,-R$libdir
2135 # DEC OSF/1, a/k/a Digial UNIX, a/k/a Tru64 UNIX.
2136 # Use Tru64 UNIX conventions for man pages; they're the same as
2137 # the System V conventions except that they use section 8 for
2138 # administrative commands and daemons.
2146 AC_MSG_CHECKING(if SINIX compiler defines sinix)
2147 AC_CACHE_VAL(ac_cv_cc_sinix_defined,
2151 ac_cv_cc_sinix_defined=yes,
2152 ac_cv_cc_sinix_defined=no))
2153 AC_MSG_RESULT($ac_cv_cc_sinix_defined)
2154 if test $ac_cv_cc_sinix_defined = no ; then
2155 AC_DEFINE(sinix,1,[on sinix])
2160 AC_DEFINE(HAVE_SOLARIS,1,[On solaris])
2165 # Make sure errno is thread-safe, in case we're called in
2166 # a multithreaded program. We don't guarantee that two
2167 # threads can use the *same* pcap_t safely, but the
2168 # current version does guarantee that you can use different
2169 # pcap_t's in different threads, and even that pcap_compile()
2170 # is thread-safe (it wasn't thread-safe in some older versions).
2172 V_CCOPT="$V_CCOPT -D_TS_ERRNO"
2174 case "`uname -r`" in
2181 # Use System V conventions for man pages.
2183 MAN_ADMIN_COMMANDS=1m
2191 AC_ARG_ENABLE(shared,
2192 AS_HELP_STRING([--enable-shared],[build shared libraries @<:@default=yes, if support available@:>@]))
2193 test "x$enable_shared" = "xno" && DYEXT="none"
2196 AC_CHECK_TOOL([AR], [ar])
2201 AC_LBL_DEVEL(V_CCOPT)
2204 # Check to see if the sockaddr struct has the 4.4 BSD sa_len member.
2206 AC_CHECK_MEMBERS([struct sockaddr.sa_len],,,
2208 #include <sys/types.h>
2209 #include <sys/socket.h>
2213 # Check to see if there's a sockaddr_storage structure.
2215 AC_CHECK_TYPES(struct sockaddr_storage,,,
2217 #include <sys/types.h>
2218 #include <sys/socket.h>
2222 # Check to see if the dl_hp_ppa_info_t struct has the HP-UX 11.00
2223 # dl_module_id_1 member.
2225 # NOTE: any failure means we conclude that it doesn't have that member,
2226 # so if we don't have DLPI, don't have a <sys/dlpi_ext.h> header, or
2227 # have one that doesn't declare a dl_hp_ppa_info_t type, we conclude
2228 # it doesn't have that member (which is OK, as either we won't be
2229 # using code that would use that member, or we wouldn't compile in
2232 AC_CHECK_MEMBERS([dl_hp_ppa_info_t.dl_module_id_1],,,
2234 #include <sys/types.h>
2235 #include <sys/dlpi.h>
2236 #include <sys/dlpi_ext.h>
2240 AC_SUBST(V_LIB_CCOPT_FAT)
2241 AC_SUBST(V_LIB_LDFLAGS_FAT)
2242 AC_SUBST(V_PROG_CCOPT_FAT)
2243 AC_SUBST(V_PROG_LDFLAGS_FAT)
2247 AC_SUBST(V_SHLIB_CCOPT)
2248 AC_SUBST(V_SHLIB_CMD)
2249 AC_SUBST(V_SHLIB_OPT)
2250 AC_SUBST(V_SONAME_OPT)
2251 AC_SUBST(V_RPATH_OPT)
2254 AC_SUBST(ADDLARCHIVEOBJS)
2255 AC_SUBST(PLATFORM_C_SRC)
2256 AC_SUBST(PLATFORM_CXX_SRC)
2257 AC_SUBST(MODULE_C_SRC)
2258 AC_SUBST(REMOTE_C_SRC)
2260 AC_SUBST(MAN_DEVICES)
2261 AC_SUBST(MAN_FILE_FORMATS)
2262 AC_SUBST(MAN_MISC_INFO)
2263 AC_SUBST(MAN_ADMIN_COMMANDS)
2264 AC_SUBST(PTHREAD_LIBS)
2265 AC_SUBST(BUILD_RPCAPD)
2266 AC_SUBST(INSTALL_RPCAPD)
2267 AC_SUBST(RPCAPD_LIBS)
2268 AC_SUBST(EXTRA_NETWORK_LIBS)
2271 # Various Linux-specific mechanisms.
2273 AC_ARG_ENABLE([usb],
2274 [AS_HELP_STRING([--enable-usb],[enable Linux usbmon USB capture support @<:@default=yes, if support available@:>@])],
2279 # If somebody requested an XXX-only pcap, that doesn't include
2280 # additional mechanisms.
2282 if test "xxx_only" != yes; then
2285 dnl check for USB sniffing support
2286 AC_MSG_CHECKING(for Linux usbmon USB sniffing support)
2287 if test "x$enable_usb" != "xno" ; then
2288 AC_DEFINE(PCAP_SUPPORT_LINUX_USBMON, 1, [target host supports Linux usbmon for USB sniffing])
2289 MODULE_C_SRC="$MODULE_C_SRC pcap-usb-linux.c"
2291 ac_usb_dev_name=`udevinfo -q name -p /sys/class/usb_device/usbmon 2>/dev/null`
2292 if test $? -ne 0 ; then
2293 ac_usb_dev_name="usbmon"
2295 AC_DEFINE_UNQUOTED(LINUX_USB_MON_DEV, "/dev/$ac_usb_dev_name", [path for device for USB sniffing])
2296 AC_MSG_NOTICE(Device for USB sniffing is /dev/$ac_usb_dev_name)
2298 # Do we have a version of <linux/compiler.h> available?
2299 # If so, we might need it for <linux/usbdevice_fs.h>.
2301 AC_CHECK_HEADERS(linux/compiler.h)
2302 if test "$ac_cv_header_linux_compiler_h" = yes; then
2304 # Yes - include it when testing for <linux/usbdevice_fs.h>.
2306 AC_CHECK_HEADERS(linux/usbdevice_fs.h,,,[#include <linux/compiler.h>])
2308 AC_CHECK_HEADERS(linux/usbdevice_fs.h)
2310 if test "$ac_cv_header_linux_usbdevice_fs_h" = yes; then
2312 # OK, does it define bRequestType? Older versions of the kernel
2313 # define fields with names like "requesttype, "request", and
2314 # "value", rather than "bRequestType", "bRequest", and
2317 AC_CHECK_MEMBERS([struct usbdevfs_ctrltransfer.bRequestType],,,
2320 #ifdef HAVE_LINUX_COMPILER_H
2321 #include <linux/compiler.h>
2323 #include <linux/usbdevice_fs.h>
2331 # Life's too short to deal with trying to get this to compile
2332 # if you don't get the right types defined with
2333 # __KERNEL_STRICT_NAMES getting defined by some other include.
2335 # Check whether the includes Just Work. If not, don't turn on
2336 # netfilter support.
2338 AC_MSG_CHECKING(whether we can compile the netfilter support)
2339 AC_CACHE_VAL(ac_cv_netfilter_can_compile,
2342 #include <sys/socket.h>
2343 #include <netinet/in.h>
2344 #include <linux/types.h>
2346 #include <linux/netlink.h>
2347 #include <linux/netfilter.h>
2348 #include <linux/netfilter/nfnetlink.h>
2349 #include <linux/netfilter/nfnetlink_log.h>
2350 #include <linux/netfilter/nfnetlink_queue.h>],
2352 ac_cv_netfilter_can_compile=yes,
2353 ac_cv_netfilter_can_compile=no))
2354 AC_MSG_RESULT($ac_cv_netfilter_can_compile)
2355 if test $ac_cv_netfilter_can_compile = yes ; then
2356 AC_DEFINE(PCAP_SUPPORT_NETFILTER, 1,
2357 [target host supports netfilter sniffing])
2358 MODULE_C_SRC="$MODULE_C_SRC pcap-netfilter-linux.c"
2363 AC_SUBST(PCAP_SUPPORT_LINUX_USBMON)
2364 AC_SUBST(PCAP_SUPPORT_NETFILTER)
2366 AC_ARG_ENABLE([netmap],
2367 [AS_HELP_STRING([--enable-netmap],[enable netmap support @<:@default=yes, if support available@:>@])],
2369 [enable_netmap=yes])
2371 if test "x$enable_netmap" != "xno" ; then
2373 # Check whether net/netmap_user.h is usable if NETMAP_WITH_LIBS is
2374 # defined; it's not usable on DragonFly BSD 4.6 if NETMAP_WITH_LIBS
2375 # is defined, for example, as it includes a non-existent malloc.h
2378 AC_MSG_CHECKING(whether we can compile the netmap support)
2379 AC_CACHE_VAL(ac_cv_net_netmap_user_can_compile,
2382 #define NETMAP_WITH_LIBS
2383 #include <net/netmap_user.h>],
2385 ac_cv_net_netmap_user_can_compile=yes,
2386 ac_cv_net_netmap_user_can_compile=no))
2387 AC_MSG_RESULT($ac_cv_net_netmap_user_can_compile)
2388 if test $ac_cv_net_netmap_user_can_compile = yes ; then
2389 AC_DEFINE(PCAP_SUPPORT_NETMAP, 1,
2390 [target host supports netmap])
2391 MODULE_C_SRC="$MODULE_C_SRC pcap-netmap.c"
2393 AC_SUBST(PCAP_SUPPORT_NETMAP)
2396 # Check for DPDK support.
2398 AS_HELP_STRING([--with-dpdk@<:@=DIR@:>@],[include DPDK support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
2400 if test "$withval" = no
2402 # User doesn't want DPDK support.
2404 elif test "$withval" = yes
2406 # User wants DPDK support but hasn't specified a directory.
2409 # User wants DPDK support and has specified a directory,
2410 # so use the provided value.
2415 if test "$V_PCAP" = dpdk; then
2416 # User requested DPDK-only libpcap, so we'd better have
2419 elif test "xxx_only" = yes; then
2420 # User requested something-else-only pcap, so they don't
2421 # want DPDK support.
2425 # Use DPDK API if present, otherwise don't
2431 if test "$want_dpdk" != no; then
2432 if test "x$PKGCONFIG" != "xno"
2435 # We have pkg-config; see if we have DPDK installed
2438 AC_MSG_CHECKING([for DPDK with pkg-config])
2439 if "$PKGCONFIG" libdpdk
2441 AC_MSG_RESULT([found])
2442 found_dpdk_with_pkg_config=yes
2443 DPDK_CFLAGS=`"$PKGCONFIG" --cflags libdpdk`
2444 DPDK_LDFLAGS=`"$PKGCONFIG" --libs libdpdk`
2446 AC_MSG_RESULT([not found])
2451 # If we didn't find it with pkg-config, try checking for
2454 if test "x$found_dpdk_with_pkg_config" != "xyes"
2456 if test -z "$dpdk_dir"; then
2458 # The user didn't specify a directory containing
2459 # the DPDK headers and libraries. If we find
2460 # a /usr/local/include/dpdk directory, assume
2461 # it's /usr/local, otherwise assume it's /usr.
2463 if test -d "/usr/local/include/dpdk"; then
2464 dpdk_dir="/usr/local"
2470 # The convention appears to be that 1) there's a "dpdk"
2471 # subdirectory of the include directory, containing DPDK
2472 # headers (at least in the installation on Ubuntu with
2473 # the system DPDK packages) and 2) includes of DPDK
2474 # headers don't use "dpdk/{header}" (at least from the
2475 # way the DPDK documentation is written).
2477 # So we add "/dpdk" to the include directory, and always
2478 # add that to the list of include directories to search.
2480 dpdk_inc_dir="$dpdk_dir/include/dpdk"
2481 dpdk_inc_flags="-I$dpdk_inc_dir"
2482 dpdk_lib_dir="$dpdk_dir/lib"
2484 # Handle multiarch systems.
2486 # Step 1: run the C compiler with the -dumpmachine option;
2487 # if it succeeds, the output would be the multiarch directory
2488 # name if your system has multiarch directories.
2490 multiarch_dir=`$CC -dumpmachine 2>/dev/null`
2491 if test ! -z "$multiarch_dir"
2494 # OK, we have a multiarch directory.
2496 # Now deal with includes. On Ubuntu 20.04, for
2497 # example, we have /usr/include/dpdk *and*
2498 # /usr/include/$multiarch_dir/dpdk, and must
2501 if test -d "$dpdk_dir/include/$multiarch_dir/dpdk"
2503 dpdk_inc_flags="-I$dpdk_dir/include/$multiarch_dir/dpdk $dpdk_inc_flags"
2507 # Now deal with libraries.
2509 if test -d "$dpdk_lib_dir/$multiarch_dir"
2511 dpdk_lib_dir="$dpdk_lib_dir/$multiarch_dir"
2514 DPDK_MACHINE_CFLAGS="-march=native"
2515 DPDK_CFLAGS="$DPDK_MACHINE_CFLAGS $dpdk_inc_flags"
2516 DPDK_LDFLAGS="-L$dpdk_lib_dir -ldpdk -lrt -lm -lnuma -ldl -pthread"
2519 save_CFLAGS="$CFLAGS"
2521 save_LDFLAGS="$LDFLAGS"
2522 CFLAGS="$CFLAGS $DPDK_CFLAGS"
2523 LIBS="$LIBS $DPDK_LDFLAGS"
2524 LDFLAGS="$LDFLAGS $DPDK_LDFLAGS"
2526 AC_MSG_CHECKING(whether we can compile the DPDK support)
2527 AC_CACHE_VAL(ac_cv_dpdk_can_compile,
2530 #include <rte_common.h>],
2532 ac_cv_dpdk_can_compile=yes,
2533 ac_cv_dpdk_can_compile=no))
2534 AC_MSG_RESULT($ac_cv_dpdk_can_compile)
2537 # We include rte_bus.h, and older versions of DPDK
2538 # didn't have it, so check for it.
2540 if test "$ac_cv_dpdk_can_compile" = yes; then
2542 # This runs the preprocessor, so make sure it
2543 # looks in the DPDK directories. Instead of
2544 # including dpdk/XXX.h, we include just XXX.h
2545 # and assume DPDK_CFLAGS is the directory
2546 # containing the DPDK headers (that's how
2547 # pkg-config sets it, at least on Ubuntu),
2548 # so just looking under /usr/include won't
2551 save_CPPFLAGS="$CPPFLAGS"
2552 CPPFLAGS="$CPPFLAGS $DPDK_CFLAGS"
2553 AC_CHECK_HEADER(rte_bus.h)
2554 CPPFLAGS="$save_CPPFLAGS"
2558 # We call rte_eth_dev_count_avail(), and older versions
2559 # of DPDK didn't have it, so check for it.
2561 if test "$ac_cv_header_rte_bus_h" = yes; then
2562 AC_CHECK_FUNC(rte_eth_dev_count_avail)
2565 CFLAGS="$save_CFLAGS"
2567 LDFLAGS="$save_LDFLAGS"
2569 if test "$ac_cv_func_rte_eth_dev_count_avail" = yes; then
2570 CFLAGS="$CFLAGS $DPDK_CFLAGS"
2571 LIBS="$LIBS $DPDK_LDFLAGS"
2572 LDFLAGS="$LDFLAGS $DPDK_LDFLAGS"
2573 V_INCLS="$V_INCLS $DPDK_CFLAGS"
2574 AC_DEFINE(PCAP_SUPPORT_DPDK, 1, [target host supports DPDK])
2575 if test $V_PCAP != dpdk ; then
2576 MODULE_C_SRC="$MODULE_C_SRC pcap-dpdk.c"
2580 # Check whether the rte_ether.h file defines
2581 # struct ether_addr or struct rte_ether_addr.
2583 # ("API compatibility? That's for losers!")
2585 AC_CHECK_TYPES(struct rte_ether_addr,,,
2587 #include <rte_ether.h>
2590 if test "$V_PCAP" = dpdk; then
2591 # User requested DPDK-only capture support, but
2592 # we couldn't the DPDK API support at all, or we
2593 # found it but it wasn't a sufficiently recent
2595 if test "$ac_cv_dpdk_can_compile" != yes; then
2597 # Couldn't even find the headers.
2599 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])
2602 # Found the headers, but we couldn't find
2603 # rte_bus.h or rte_eth_dev_count_avail(),
2604 # we don't have a sufficiently recent
2607 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])
2611 if test "$want_dpdk" = yes; then
2612 # User requested DPDK-only capture support, but
2613 # we couldn't the DPDK API support at all, or we
2614 # found it but it wasn't a sufficiently recent
2616 if test "$ac_cv_dpdk_can_compile" != yes; then
2618 # Couldn't even find the headers.
2620 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])
2623 # Found the headers, but we couldn't find
2624 # rte_bus.h or rte_eth_dev_count_avail(),
2625 # we don't have a sufficiently recent
2628 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])
2633 AC_SUBST(PCAP_SUPPORT_DPDK)
2635 AC_ARG_ENABLE([bluetooth],
2636 [AS_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])],
2638 [enable_bluetooth=ifsupportavailable])
2640 if test "xxx_only" = yes; then
2641 # User requested something-else-only pcap, so they don't
2642 # want Bluetooth support.
2646 if test "x$enable_bluetooth" != "xno" ; then
2647 dnl check for Bluetooth sniffing support
2650 AC_CHECK_HEADER(bluetooth/bluetooth.h,
2653 # We have bluetooth.h, so we support Bluetooth
2656 AC_DEFINE(PCAP_SUPPORT_BT, 1, [target host supports Bluetooth sniffing])
2657 MODULE_C_SRC="$MODULE_C_SRC pcap-bt-linux.c"
2658 AC_MSG_NOTICE(Bluetooth sniffing is supported)
2659 ac_lbl_bluetooth_available=yes
2662 # OK, does struct sockaddr_hci have an hci_channel
2665 AC_CHECK_MEMBERS([struct sockaddr_hci.hci_channel],
2668 # Yes; is HCI_CHANNEL_MONITOR defined?
2670 AC_MSG_CHECKING(if HCI_CHANNEL_MONITOR is defined)
2671 AC_CACHE_VAL(ac_cv_lbl_hci_channel_monitor_is_defined,
2674 #include <bluetooth/bluetooth.h>
2675 #include <bluetooth/hci.h>
2678 u_int i = HCI_CHANNEL_MONITOR;
2682 AC_DEFINE(PCAP_SUPPORT_BT_MONITOR,,
2683 [target host supports Bluetooth Monitor])
2684 MODULE_C_SRC="$MODULE_C_SRC pcap-bt-monitor-linux.c"
2691 #include <bluetooth/bluetooth.h>
2692 #include <bluetooth/hci.h>
2697 # We don't have bluetooth.h, so we don't support
2698 # Bluetooth sniffing.
2700 if test "x$enable_bluetooth" = "xyes" ; then
2701 AC_MSG_ERROR(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
2703 AC_MSG_NOTICE(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
2708 if test "x$enable_bluetooth" = "xyes" ; then
2709 AC_MSG_ERROR(no Bluetooth sniffing support implemented for $host_os)
2711 AC_MSG_NOTICE(no Bluetooth sniffing support implemented for $host_os)
2715 AC_SUBST(PCAP_SUPPORT_BT)
2718 AC_ARG_ENABLE([dbus],
2719 [AS_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=yes, if support available@:>@])],
2721 [enable_dbus=ifavailable])
2723 if test "xxx_only" = yes; then
2724 # User requested something-else-only pcap, so they don't
2725 # want D-Bus support.
2729 if test "x$enable_dbus" != "xno"; then
2730 if test "x$enable_dbus" = "xyes"; then
2735 # We don't support D-Bus sniffing on macOS; see
2737 # https://bugs.freedesktop.org/show_bug.cgi?id=74029
2739 # The user requested it, so fail.
2741 AC_MSG_ERROR([Due to freedesktop.org bug 74029, D-Bus capture support is not available on macOS])
2748 # We don't support D-Bus sniffing on macOS; see
2750 # https://bugs.freedesktop.org/show_bug.cgi?id=74029
2752 # The user dind't explicitly request it, so just
2753 # silently refuse to enable it.
2761 if test "x$enable_dbus" != "xno"; then
2762 if test "x$PKGCONFIG" != "xno"; then
2763 AC_MSG_CHECKING([for D-Bus])
2764 if "$PKGCONFIG" dbus-1; then
2765 AC_MSG_RESULT([yes])
2766 DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1`
2767 DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1`
2768 save_CFLAGS="$CFLAGS"
2770 CFLAGS="$CFLAGS $DBUS_CFLAGS"
2771 LIBS="$LIBS $DBUS_LIBS"
2772 AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write)
2774 [#include <string.h>
2777 #include <sys/time.h>
2779 #include <dbus/dbus.h>],
2780 [return dbus_connection_read_write(NULL, 0);],
2782 AC_MSG_RESULT([yes])
2783 AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing])
2784 MODULE_C_SRC="$MODULE_C_SRC pcap-dbus.c"
2785 V_INCLS="$V_INCLS $DBUS_CFLAGS"
2789 if test "x$enable_dbus" = "xyes"; then
2790 AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()])
2794 CFLAGS="$save_CFLAGS"
2797 if test "x$enable_dbus" = "xyes"; then
2798 AC_MSG_ERROR([--enable-dbus was given, but the dbus-1 package is not installed])
2802 AC_SUBST(PCAP_SUPPORT_DBUS)
2805 AC_ARG_ENABLE([rdma],
2806 [AS_HELP_STRING([--enable-rdma],[enable RDMA capture support @<:@default=yes, if support available@:>@])],
2808 [enable_rdma=ifavailable])
2810 if test "xxx_only" = yes; then
2811 # User requested something-else-only pcap, so they don't
2812 # want RDMA support.
2816 if test "x$enable_rdma" != "xno"; then
2817 AC_CHECK_LIB(ibverbs, ibv_get_device_list, [
2818 AC_CHECK_HEADER(infiniband/verbs.h, [
2820 # ibv_create_flow may be defined as a static inline
2821 # function in infiniband/verbs.h, so we can't
2824 # Too bad autoconf has no AC_SYMBOL_EXISTS()
2825 # macro that works like CMake's check_symbol_exists()
2826 # function, to check do a compile check like
2827 # this (they do a clever trick to avoid having
2828 # to know the function's signature).
2830 AC_MSG_CHECKING(whether libibverbs defines ibv_create_flow)
2833 #include <infiniband/verbs.h>
2836 (void) ibv_create_flow((struct ibv_qp *) NULL,
2837 (struct ibv_flow_attr *) NULL);
2840 AC_MSG_RESULT([yes])
2841 AC_DEFINE(PCAP_SUPPORT_RDMASNIFF, , [target host supports RDMA sniffing])
2842 MODULE_C_SRC="$MODULE_C_SRC pcap-rdmasniff.c"
2843 LIBS="-libverbs $LIBS"
2851 AC_SUBST(PCAP_SUPPORT_RDMASNIFF)
2856 AC_CONFIG_HEADER(config.h)
2858 AC_OUTPUT_COMMANDS([if test -f .devel; then
2859 echo timestamp > stamp-h
2860 cat $srcdir/Makefile-devel-adds >> Makefile
2861 make depend || exit 1
2863 AC_OUTPUT(Makefile grammar.y pcap-filter.manmisc pcap-linktype.manmisc
2864 pcap-tstamp.manmisc pcap-savefile.manfile pcap.3pcap
2865 pcap_compile.3pcap pcap_datalink.3pcap pcap_dump_open.3pcap
2866 pcap_get_tstamp_precision.3pcap pcap_list_datalinks.3pcap
2867 pcap_list_tstamp_types.3pcap pcap_open_dead.3pcap
2868 pcap_open_offline.3pcap pcap_set_immediate_mode.3pcap
2869 pcap_set_tstamp_precision.3pcap pcap_set_tstamp_type.3pcap
2870 rpcapd/Makefile rpcapd/rpcapd.manadmin rpcapd/rpcapd-config.manfile