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)],[https://github.com/the-tcpdump-group/libpcap/issues])
20 AC_CONFIG_SRCDIR(pcap.c)
21 AC_SUBST(PACKAGE_NAME)
24 # These are the variables that are used in Makefile, pcap-config, and
27 # CFLAGS: inherited from the environment, not modified by us except
28 # for flags required for the platform for which we're building (and
29 # except temporarily during tests that involve compilation). Used only
30 # when compiling C source.
32 # LDFLAGS: inherited from the environment, not modified by us.
34 # LIBS: inherited from the environment; we add libraries required by
35 # libpcap. Libraries that the core libpcap code requires are added
36 # first; libraries required by additional pcap modules are first
37 # added to ADDITIONAL_LIBS, and only added to LIBS at the end, after
38 # we're finished doing configuration tests for the modules.
40 # LIBS_STATIC: libraries with which a program using the libpcap *static*
41 # library needs to be linked. This is a superset of LIBS, used in
42 # pcap-config, so that "pcap-config --libs --static" will report them.
43 # Initialized to LIBS.
45 # REQUIRES_PRIVATE: pkg-config package names for additional libraries
46 # with which a program using the libpcap *static* library needs to be
47 # linked and for which a .pc file exists. This is used in libpcap.pc,
48 # so that "pkg-config --libs --static" will report them, and so that
49 # those libraries will be determined using the library's .pc file, not
50 # from our .pc file. Initialized to an empty string.
52 # V_CCOPT: additional compiler flags other than -I and -D flags
53 # needed when compiling libpcap. Used in Makefile for both C and
56 # V_DEFS: additional -D compiler flags needed when compiling
57 # libpcap. Used in Makefile for both C and C++ source.
59 # V_INCLS: additional -I compiler flags needed when compiling
60 # libpcap. Used in Makefile for both C and C++ source.
62 # ADDITIONAL_LIBS: additional libraries with which the libpcap dynamic
63 # library needs to be linked. Used in Makefile; not used in pcap-config
64 # or libpcap.pc, as, in all platforms on which we run, if a dynamic
65 # library is linked with other dynamic libraries, a program using
66 # that dynamic library doesn't have to link with those libraries -
67 # they will be automatically loaded at run time. Initialized to an
70 # ADDITIONAL_LIBS_STATIC: additional libraries with which a program
71 # using the libpcap *static* library needs to be linked. This is used
72 # in pcap-config, so that "pcap-config --libs --static" will report
73 # them. Initialized to an empty string.
75 # REQUIRES_PRIVATE: pkg-config package names for additional libraries
76 # with which a program using the libpcap *static* library needs to be
77 # linked and for which a .pc file exists. This is used in libpcap.pc,
78 # so that "pkg-config --libs --static" will report them, and so that
79 # those libraries will be determined using the library's .pc file, not
80 # from our .pc file. Initialized to an empty string.
82 # LIBS_PRIVATE: pkg-config package names for additional libraries with
83 # which a program using the libpcap *static* library needs to be linked
84 # and for which a .pc file does not exist. This is used in libpcap.pc,
85 # so that "pkg-config --libs --static" will report them (those libraries
86 # cannot be determined using the library's .pc file, as there is no such
87 # file, so it has to come from our .pc file. Initialized to an empty
98 AC_SUBST(REQUIRES_PRIVATE)
99 AC_SUBST(LIBS_PRIVATE)
103 AC_LBL_C_INIT_BEFORE_CC(V_CCOPT, V_INCLS)
105 # We require C99 or later.
106 # Try to get it, which may involve adding compiler flags;
107 # if that fails, give up.
110 if test "$ac_cv_prog_cc_c99" = "no"; then
111 AC_MSG_WARN([The C compiler does not support C99; there may be compiler errors])
115 # Try to arrange for large file support.
121 # Get the size of a void *, to determine whether this is a 32-bit
124 AC_CHECK_SIZEOF([void *])
125 ac_lbl_c_sizeof_void_p="$ac_cv_sizeof_void_p"
128 # Get the size of a time_t, to know whether it's 32-bit or 64-bit.
130 AC_CHECK_SIZEOF([time_t],,[#include <time.h>])
132 AC_LBL_C_INIT(V_CCOPT, V_INCLS)
137 dnl HAVE_SYS_IOCCOM_H will be required for a few workarounds until all
138 dnl supported OSes that use BPF have <net/bpf.h> that includes <sys/ioccom.h>
139 dnl (this might have already happened).
141 AC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h)
142 AC_CHECK_HEADERS(netpacket/packet.h)
145 # Check whether the platform for which we're compiling requires extra
146 # defines and libraries. If so, add them to CFLAGS and LIBS, as we want
147 # all subsequent tests to be done with those defines and libraries.
152 # Haiku needs _BSD_SOURCE for the _IO* macros because it doesn't
155 CFLAGS="$CFLAGS -D_BSD_SOURCE"
157 # Haiku has getpass in libbsd.
159 AC_CHECK_LIB(bsd, getpass)
163 AC_CHECK_FUNC(strerror_r,
166 # We have strerror_r; if we define _GNU_SOURCE, is it a
167 # POSIX-compliant strerror_r() or a GNU strerror_r()?
169 AC_MSG_CHECKING(whether strerror_r is GNU-style)
176 /* Define it GNU-style; that will cause an error if it's not GNU-style */
177 extern char *strerror_r(int, char *, size_t);
189 AC_DEFINE(HAVE_GNU_STRERROR_R, 1,
190 [Define to 1 if you have a GNU-style `strerror_r' function.])
194 AC_DEFINE(HAVE_POSIX_STRERROR_R, 1,
195 [Define to 1 if you have a POSIX-style `strerror_r' function.])
200 # We don't have strerror_r; do we have _wcserror_s?
202 AC_CHECK_FUNCS(_wcserror_s)
206 # Thanks, IBM, for not providing vsyslog() in AIX!
208 AC_CHECK_FUNCS(vsyslog)
211 # Require a proof of suitable snprintf(3), same as in tcpdump.
213 AC_MSG_CHECKING([whether snprintf is suitable])
219 #include <inttypes.h>
220 #include <sys/types.h>
225 uint64_t t = (uint64_t)1 << 32;
227 snprintf(buf, sizeof(buf), "%zu", sizeof(buf));
228 if (strncmp(buf, "100", sizeof(buf)))
231 snprintf(buf, sizeof(buf), "%zd", -sizeof(buf));
232 if (strncmp(buf, "-100", sizeof(buf)))
235 snprintf(buf, sizeof(buf), "%" PRId64, -t);
236 if (strncmp(buf, "-4294967296", sizeof(buf)))
239 snprintf(buf, sizeof(buf), "0o%" PRIo64, t);
240 if (strncmp(buf, "0o40000000000", sizeof(buf)))
243 snprintf(buf, sizeof(buf), "0x%" PRIx64, t);
244 if (strncmp(buf, "0x100000000", sizeof(buf)))
247 snprintf(buf, sizeof(buf), "%" PRIu64, t);
248 if (strncmp(buf, "4294967296", sizeof(buf)))
261 [The snprintf(3) implementation in this libc is not suitable,
262 libpcap would not work correctly even if it managed to compile.])
265 AC_MSG_RESULT(not while cross-compiling)
270 AC_CHECK_FUNCS(vasprintf asprintf,,
272 if test $needasprintf = yes; then
273 AC_LIBOBJ([asprintf])
277 AC_CHECK_FUNCS(strlcat,,
279 if test $needstrlcat = yes; then
284 AC_CHECK_FUNCS(strlcpy,,
286 if test $needstrlcpy = yes; then
291 AC_CHECK_FUNCS(strtok_r,,
293 if test $needstrtok_r = yes; then
294 AC_LIBOBJ([strtok_r])
298 # Do this before checking for ether_hostton(), as it's a
299 # "getaddrinfo()-ish function".
304 # Check for reentrant versions of getnetbyname_r(), as provided by
305 # Linux (glibc), Solaris, and AIX (with three different APIs!).
306 # If we don't find one, we just use getnetbyname(), which uses
307 # thread-specific data on many platforms, but doesn't use it on
308 # NetBSD or OpenBSD, and may not use it on older versions of other
311 # Only do the check if we have a declaration of getnetbyname_r();
312 # without it, we can't check which API it has. (We assume that
313 # if there's a declaration, it has a prototype, so that the API
316 AC_CHECK_DECL(getnetbyname_r,
318 AC_MSG_CHECKING([for the Linux getnetbyname_r()])
319 AC_LINK_IFELSE([AC_LANG_PROGRAM(
320 [[#include <netdb.h>]],
322 struct netent netent_buf;
324 struct netent *resultp;
327 return getnetbyname_r((const char *)0, &netent_buf, buf, sizeof buf, &resultp, &h_errnoval);
331 AC_DEFINE(HAVE_LINUX_GETNETBYNAME_R, 1,
332 [define if we have the Linux getnetbyname_r()])
337 AC_MSG_CHECKING([for Solaris getnetbyname_r()])
338 AC_LINK_IFELSE([AC_LANG_PROGRAM(
339 [[#include <netdb.h>]],
341 struct netent netent_buf;
344 return getnetbyname_r((const char *)0, &netent_buf, buf, (int)sizeof buf) != NULL;
348 AC_DEFINE(HAVE_SOLARIS_GETNETBYNAME_R, 1,
349 [define if we have the Solaris getnetbyname_r()])
354 AC_MSG_CHECKING([for AIX getnetbyname_r()])
355 AC_LINK_IFELSE([AC_LANG_PROGRAM(
356 [[#include <netdb.h>]],
358 struct netent netent_buf;
359 struct netent_data net_data;
361 return getnetbyname_r((const char *)0, &netent_buf, &net_data);
365 AC_DEFINE(HAVE_AIX_GETNETBYNAME_R, 1,
366 [define if we have the AIX getnetbyname_r()])
373 ],,[#include <netdb.h>])
376 # Check for reentrant versions of getprotobyname_r(), as provided by
377 # Linux (glibc), Solaris, and AIX (with three different APIs!).
378 # If we don't find one, we just use getprotobyname(), which uses
379 # thread-specific data on many platforms, but doesn't use it on
380 # NetBSD or OpenBSD, and may not use it on older versions of other
383 # Only do the check if we have a declaration of getprotobyname_r();
384 # without it, we can't check which API it has. (We assume that
385 # if there's a declaration, it has a prototype, so that the API
388 AC_CHECK_DECL(getprotobyname_r,
390 AC_MSG_CHECKING([for the Linux getprotobyname_r()])
391 AC_LINK_IFELSE([AC_LANG_PROGRAM(
392 [[#include <netdb.h>]],
394 struct protoent protoent_buf;
396 struct protoent *resultp;
398 return getprotobyname_r((const char *)0, &protoent_buf, buf, sizeof buf, &resultp);
402 AC_DEFINE(HAVE_LINUX_GETPROTOBYNAME_R, 1,
403 [define if we have the Linux getprotobyname_r()])
408 AC_MSG_CHECKING([for Solaris getprotobyname_r()])
409 AC_LINK_IFELSE([AC_LANG_PROGRAM(
410 [[#include <netdb.h>]],
412 struct protoent protoent_buf;
415 return getprotobyname_r((const char *)0, &protoent_buf, buf, (int)sizeof buf) != NULL;
419 AC_DEFINE(HAVE_SOLARIS_GETPROTOBYNAME_R, 1,
420 [define if we have the Solaris getprotobyname_r()])
425 AC_MSG_CHECKING([for AIX getprotobyname_r()])
426 AC_LINK_IFELSE([AC_LANG_PROGRAM(
427 [[#include <netdb.h>]],
429 struct protoent protoent_buf;
430 struct protoent_data proto_data;
432 return getprotobyname_r((const char *)0, &protoent_buf, &proto_data);
436 AC_DEFINE(HAVE_AIX_GETPROTOBYNAME_R, 1,
437 [define if we have the AIX getprotobyname_r()])
444 ],,[#include <netdb.h>])
447 # You are in a twisty little maze of UN*Xes, all different.
448 # Some might not have ether_hostton().
449 # Some might have it and declare it in <net/ethernet.h>.
450 # Some might have it and declare it in <netinet/ether.h>
451 # Some might have it and declare it in <sys/ethernet.h>.
452 # Some might have it and declare it in <arpa/inet.h>.
453 # Some might have it and declare it in <netinet/if_ether.h>.
454 # Some might have it and not declare it in any header file.
456 # Before you is a C compiler.
458 AC_CHECK_FUNCS(ether_hostton)
459 if test "$ac_cv_func_ether_hostton" = yes; then
461 # OK, we have ether_hostton(). Is it declared in <net/ethernet.h>?
463 # This test fails if we don't have <net/ethernet.h> or if we do
464 # but it doesn't declare ether_hostton().
466 AC_CHECK_DECL(ether_hostton,
468 AC_DEFINE(NET_ETHERNET_H_DECLARES_ETHER_HOSTTON, 1,
469 [Define to 1 if net/ethernet.h declares `ether_hostton'])
472 #include <net/ethernet.h>
477 if test "$ac_cv_have_decl_ether_hostton" != yes; then
479 # No, how about <netinet/ether.h>, as on Linux?
481 # This test fails if we don't have <netinet/ether.h>
482 # or if we do but it doesn't declare ether_hostton().
484 # Unset ac_cv_have_decl_ether_hostton so we don't
485 # treat the previous failure as a cached value and
486 # suppress the next test.
488 unset ac_cv_have_decl_ether_hostton
489 AC_CHECK_DECL(ether_hostton,
491 AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_HOSTTON, 1,
492 [Define to 1 if netinet/ether.h declares `ether_hostton'])
495 #include <netinet/ether.h>
501 if test "$ac_cv_have_decl_ether_hostton" != yes; then
503 # No, how about <sys/ethernet.h>, as on Solaris 10
506 # This test fails if we don't have <sys/ethernet.h>
507 # or if we do but it doesn't declare ether_hostton().
509 # Unset ac_cv_have_decl_ether_hostton so we don't
510 # treat the previous failure as a cached value and
511 # suppress the next test.
513 unset ac_cv_have_decl_ether_hostton
514 AC_CHECK_DECL(ether_hostton,
516 AC_DEFINE(SYS_ETHERNET_H_DECLARES_ETHER_HOSTTON, 1,
517 [Define to 1 if sys/ethernet.h declares `ether_hostton'])
520 #include <sys/ethernet.h>
526 if test "$ac_cv_have_decl_ether_hostton" != yes; then
528 # No, how about <arpa/inet.h>, as in AIX?
530 # This test fails if we don't have <arpa/inet.h>
531 # (if we have ether_hostton(), we should have
532 # networking, and if we have networking, we should
533 # have <arpa/inet.h>) or if we do but it doesn't
534 # declare ether_hostton().
536 # Unset ac_cv_have_decl_ether_hostton so we don't
537 # treat the previous failure as a cached value and
538 # suppress the next test.
540 unset ac_cv_have_decl_ether_hostton
541 AC_CHECK_DECL(ether_hostton,
543 AC_DEFINE(ARPA_INET_H_DECLARES_ETHER_HOSTTON, 1,
544 [Define to 1 if arpa/inet.h declares `ether_hostton'])
547 #include <arpa/inet.h>
553 if test "$ac_cv_have_decl_ether_hostton" != yes; then
555 # No, how about <netinet/if_ether.h>?
556 # On some platforms, it requires <net/if.h> and
557 # <netinet/in.h>, and we always include it with
558 # both of them, so test it with both of them.
560 # This test fails if we don't have <netinet/if_ether.h>
561 # and the headers we include before it, or if we do but
562 # <netinet/if_ether.h> doesn't declare ether_hostton().
564 # Unset ac_cv_have_decl_ether_hostton so we don't
565 # treat the previous failure as a cached value and
566 # suppress the next test.
568 unset ac_cv_have_decl_ether_hostton
569 AC_CHECK_DECL(ether_hostton,
571 AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON, 1,
572 [Define to 1 if netinet/if_ether.h declares `ether_hostton'])
575 #include <sys/types.h>
576 #include <sys/socket.h>
578 #include <netinet/in.h>
579 #include <netinet/if_ether.h>
583 # After all that, is ether_hostton() declared?
585 if test "$ac_cv_have_decl_ether_hostton" = yes; then
589 AC_DEFINE(HAVE_DECL_ETHER_HOSTTON, 1,
590 [Define to 1 if you have the declaration of `ether_hostton'])
593 # No, we'll have to declare it ourselves.
594 # Do we have "struct ether_addr" if we include
595 # <netinet/if_ether.h>?
597 AC_CHECK_TYPES(struct ether_addr,,,
599 #include <sys/types.h>
600 #include <sys/socket.h>
602 #include <netinet/in.h>
603 #include <netinet/if_ether.h>
609 # For various things that might use pthreads.
611 AC_CHECK_HEADER(pthread.h,
614 # OK, we have pthread.h. Do we have pthread_create in the
617 AC_CHECK_FUNC(pthread_create,
622 ac_lbl_have_pthreads="found"
626 # No - do we have it in -lpthreads?
628 AC_CHECK_LIB(pthreads, pthread_create,
631 # Yes - add -lpthreads.
633 ac_lbl_have_pthreads="found"
634 PTHREAD_LIBS="$PTHREAD_LIBS -lpthreads"
638 # No - do we have it in -lpthread?
640 AC_CHECK_LIB(pthread, pthread_create,
643 # Yes - add -lpthread.
645 ac_lbl_have_pthreads="found"
646 PTHREAD_LIBS="$PTHREAD_LIBS -lpthread"
652 ac_lbl_have_pthreads="not found"
659 # We didn't find pthread.h.
661 ac_lbl_have_pthreads="not found"
665 AC_MSG_CHECKING([whether to enable the instrument functions code])
666 AC_ARG_ENABLE([instrument-functions],
667 [AS_HELP_STRING([--enable-instrument-functions],
668 [enable instrument functions code [default=no]])],
672 yes) AC_MSG_RESULT(yes)
673 AC_DEFINE(ENABLE_INSTRUMENT_FUNCTIONS, 1,
674 [define if you want to build the instrument functions code])
675 # Add '-finstrument-functions' instrumentation option to generate
676 # instrumentation calls for entry and exit to functions.
677 # Use '--enable-instrument-functions' also with tcpdump (or tcpslice)
678 # to see the output. See also https://www.tcpdump.org/faq.html#q17.
679 CFLAGS="$CFLAGS -O0 -ggdb -finstrument-functions"
685 dnl to pacify those who hate protochain insn
686 AC_MSG_CHECKING(if --disable-protochain option is specified)
687 AC_ARG_ENABLE(protochain,
688 AS_HELP_STRING([--disable-protochain],[disable \"protochain\" insn]))
689 case "x$enable_protochain" in
690 xyes) enable_protochain=enabled ;;
691 xno) enable_protochain=disabled ;;
692 x) enable_protochain=enabled ;;
695 if test "$enable_protochain" = "disabled"; then
696 AC_DEFINE(NO_PROTOCHAIN,1,[do not use protochain])
698 AC_MSG_RESULT(${enable_protochain})
701 # valgrindtest directly uses the native capture mechanism, but
702 # only tests with BPF and PF_PACKET sockets; only enable it if
703 # we have BPF or PF_PACKET sockets.
708 AS_HELP_STRING([--with-pcap=TYPE],[use packet capture TYPE]))
709 if test ! -z "$with_pcap" ; then
713 # Check for a bunch of headers for various packet
714 # capture mechanisms.
716 AC_CHECK_HEADERS(net/bpf.h)
717 if test "$ac_cv_header_net_bpf_h" = yes; then
719 # Does it define BIOCSETIF?
720 # I.e., is it a header for an LBL/BSD-style capture
721 # mechanism, or is it just a header for a BPF filter
722 # engine? Some versions of Arch Linux, for example,
723 # have a net/bpf.h that doesn't define BIOCSETIF;
724 # as it's a Linux, it should use packet sockets,
729 # sys/types.h, because FreeBSD 10's net/bpf.h
730 # requires that various BSD-style integer types
733 # sys/time.h, because AIX 5.2 and 5.3's net/bpf.h
734 # doesn't include it but does use struct timeval
735 # in ioctl definitions;
737 # sys/ioctl.h and, if we have it, sys/ioccom.h,
738 # because net/bpf.h defines ioctls;
740 # net/if.h, because it defines some structures
741 # used in ioctls defined by net/bpf.h;
743 # sys/socket.h, because OpenBSD 5.9's net/bpf.h
744 # defines some structure fields as being
747 # and net/bpf.h doesn't necessarily include all
748 # of those headers itself.
750 AC_MSG_CHECKING(if net/bpf.h defines BIOCSETIF)
751 AC_CACHE_VAL(ac_cv_lbl_bpf_h_defines_biocsetif,
752 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
754 #include <sys/types.h>
755 #include <sys/time.h>
756 #include <sys/ioctl.h>
757 #include <sys/socket.h>
758 #ifdef HAVE_SYS_IOCCOM_H
759 #include <sys/ioccom.h>
764 [[u_int i = BIOCSETIF;]])],
765 [ac_cv_lbl_bpf_h_defines_biocsetif=yes],
766 [ac_cv_lbl_bpf_h_defines_biocsetif=no]))
767 AC_MSG_RESULT($ac_cv_lbl_bpf_h_defines_biocsetif)
769 AC_CHECK_HEADERS(linux/socket.h sys/dlpi.h)
770 AC_CHECK_HEADERS(config/HaikuConfig.h)
771 AC_CHECK_HEADERS(hurd.h)
773 if test "$ac_cv_lbl_bpf_h_defines_biocsetif" = yes; then
776 # Check this before DLPI, so that we pick BPF on
777 # Solaris 11 and later.
782 # We have BPF, so build valgrindtest with "make test"
783 # on macOS and FreeBSD (add your OS once there's a
788 freebsd*|darwin*|linux*)
789 VALGRINDTEST_SRC=valgrindtest.c
792 elif test "$ac_cv_header_linux_socket_h" = yes; then
794 # No prizes for guessing this one.
797 VALGRINDTEST_SRC=valgrindtest.c
798 elif test "$ac_cv_header_sys_dlpi_h" = yes; then
800 # DLPI on pre-Solaris 11 SunOS 5, HP-UX, possibly others.
803 elif test "$ac_cv_header_config_HaikuConfig_h" = yes; then
808 elif test "$ac_cv_header_hurd_h" = yes; then
815 # We don't have any capture type we know about.
816 # Report an error, and tell the user to configure with
817 # --with-pcap=null if they want a libpcap that can't
818 # capture but that can read capture files. That way,
819 # nobody gets surprised by getting a no-capture
820 # libpcap without asking for that.
822 AC_MSG_ERROR([No supported packet capture interface was found.
823 See the INSTALL.md file for information on packet capture support in
824 various operating systems.
825 If you want a libpcap that cannot capture packets but that can read
826 pcap and pcapng files, run configure with --with-pcap=null.])
829 AC_MSG_CHECKING(packet capture type)
830 AC_MSG_RESULT($V_PCAP)
831 AC_SUBST(VALGRINDTEST_SRC)
834 # Do we have pkg-config?
839 # Do we have the brew command from Homebrew?
841 AC_PATH_PROG([BREW], [brew])
844 # Solaris pkg-config is annoying. For at least one package (D-Bus, I'm
845 # looking at *you*!), there are separate include files for 32-bit and
846 # 64-bit builds (I guess using "unsigned long long" as a 64-bit integer
847 # type on a 64-bit build is like crossing the beams or something), and
848 # there are two separate .pc files, so if we're doing a 32-bit build we
849 # should make sure we look in /usr/lib/pkgconfig for .pc files and if
850 # we're doing a 64-bit build we should make sure we look in
851 # /usr/lib/amd64/pkgconfig for .pc files.
856 if test "$ac_cv_sizeof_void_p" -eq 8; then
858 # 64-bit build. If the path is empty, set it to
859 # /usr/lib/amd64/pkgconfig; otherwise, if
860 # /usr/lib/pkgconfig appears in the path, prepend
861 # /usr/lib/amd64/pkgconfig to it; otherwise, put
862 # /usr/lib/amd64/pkgconfig at the end.
864 if test -z "$PKG_CONFIG_PATH"; then
866 # Not set, or empty. Set it to
867 # /usr/lib/amd64/pkgconfig.
869 PKG_CONFIG_PATH=/usr/lib/amd64/pkgconfig
870 elif test ! -z `echo "$PKG_CONFIG_PATH" | grep "/usr/lib/pkgconfig"`; then
872 # It contains /usr/lib/pkgconfig. Prepend
873 # /usr/lib/amd64/pkgconfig to /usr/lib/pkgconfig.
875 PKG_CONFIG_PATH=`echo "$PKG_CONFIG_PATH" | sed "s;/usr/lib/pkgconfig;/usr/lib/amd64/pkgconfig:/usr/lib/pkgconfig;"`
878 # Not empty, but doesn't contain /usr/lib/pkgconfig.
879 # Append /usr/lib/amd64/pkgconfig to it.
881 PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/lib/amd64/pkgconfig"
883 export PKG_CONFIG_PATH
884 elif test "$ac_cv_sizeof_void_p" -eq 4; then
886 # 32-bit build. If /usr/amd64/lib/pkgconfig appears
887 # in the path, prepend /usr/lib/pkgconfig to it.
889 if test ! -z `echo "$PKG_CONFIG_PATH" | grep "/usr/lib/amd64/pkgconfig"`; then
891 # It contains /usr/lib/amd64/pkgconfig. Prepend
892 # /usr/lib/pkgconfig to /usr/lib/amd64/pkgconfig.
894 PKG_CONFIG_PATH=`echo "$PKG_CONFIG_PATH" | sed "s;/usr/lib/amd64/pkgconfig;/usr/lib/pkgconfig:/usr/lib/amd64/pkgconfig;"`
895 export PKG_CONFIG_PATH
901 # Handle each capture type.
906 # Checks for some header files.
908 AC_CHECK_HEADERS(sys/bufmod.h sys/dlpi_ext.h)
911 # Checks to see if Solaris has the public libdlpi(3LIB) library.
912 # Note: The existence of /usr/include/libdlpi.h does not mean it is the
913 # public libdlpi(3LIB) version. Before libdlpi was made public, a
914 # private version also existed, which did not have the same APIs.
915 # Due to a gcc bug, the default search path for 32-bit libraries does
916 # not include /lib, we add it explicitly here.
917 # [http://bugs.opensolaris.org/view_bug.do?bug_id=6619485].
918 # Also, due to the bug above applications that link to libpcap with
919 # libdlpi will have to add "-L/lib" option to "configure".
921 save_LDFLAGS="$LDFLAGS"
922 LDFLAGS="$LIBS -L/lib"
923 AC_CHECK_LIB(dlpi, dlpi_walk,
926 LIBS_STATIC="-ldlpi $LIBS_STATIC"
927 LIBS_PRIVATE="-ldlpi $LIBS_PRIVATE"
931 # Capture module plus common code needed for
932 # common functions used by pcap-[dlpi,libdlpi].c
934 PLATFORM_C_SRC="pcap-libdlpi.c dlpisubs.c"
935 AC_DEFINE(HAVE_LIBDLPI,1,[if libdlpi exists])
941 # Capture module plus common code needed for
942 # common functions used by pcap-[dlpi,libdlpi].c
944 PLATFORM_C_SRC="pcap-dlpi.c dlpisubs.c"
946 LDFLAGS="$save_LDFLAGS"
949 # Checks whether <sys/dlpi.h> is usable, to catch weird SCO
952 AC_MSG_CHECKING(whether <sys/dlpi.h> is usable)
953 AC_CACHE_VAL(ac_cv_sys_dlpi_usable,
954 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
956 #include <sys/types.h>
957 #include <sys/time.h>
958 #include <sys/dlpi.h>
960 [[int i = DL_PROMISC_PHYS;]])],
961 [ac_cv_sys_dlpi_usable=yes],
962 [ac_cv_sys_dlpi_usable=no]))
963 AC_MSG_RESULT($ac_cv_sys_dlpi_usable)
964 if test $ac_cv_sys_dlpi_usable = no ; then
965 AC_MSG_ERROR(<sys/dlpi.h> is not usable on this system; it probably has a non-standard DLPI)
969 # Check to see if Solaris has the dl_passive_req_t struct defined
971 # This check is for DLPI support for passive modes.
972 # See dlpi(7P) for more details.
974 AC_CHECK_TYPES(dl_passive_req_t,,,
976 #include <sys/types.h>
977 #include <sys/dlpi.h>
985 PLATFORM_C_SRC="pcap-haiku.c"
992 PLATFORM_C_SRC="pcap-linux.c"
996 # We only want version 3. Version 2 was, apparently,
997 # short-lived, and version 1 is source and binary
998 # incompatible with version 3, and it appears that,
999 # these days, everybody's using version 3. We're
1000 # not supporting older versions of the Linux kernel;
1001 # let's drop support for older versions of libnl, too.
1004 AS_HELP_STRING([--without-libnl],[disable libnl support @<:@default=yes, on Linux, if present@:>@]),
1005 with_libnl=$withval,with_libnl=if_available)
1007 if test x$with_libnl != xno ; then
1009 # Check for libnl-genl-3.0 with pkg-config.
1011 PKG_CHECK_MODULE(LIBNL, libnl-genl-3.0,
1013 pkg_config_found_libnl=yes
1014 V_INCLS="$V_INCLS $LIBNL_CFLAGS"
1015 ADDITIONAL_LIBS="$LIBNL_LIBS $ADDITIONAL_LIBS"
1016 ADDITIONAL_LIBS_STATIC="$LIBNL_LIBS_STATIC $ADDITIONAL_LIBS_STATIC"
1017 REQUIRES_PRIVATE="libnl-genl-3.0 $REQUIRES_PRIVATE"
1018 AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
1021 if test x$pkg_config_found_libnl != xyes; then
1023 # Check for libnl-tiny with pkg-config.
1025 PKG_CHECK_MODULE(LIBNL, libnl-tiny,
1027 pkg_config_found_libnl=yes
1028 V_INCLS="$V_INCLS $LIBNL_CFLAGS"
1029 ADDITIONAL_LIBS="$LIBNL_LIBS $ADDITIONAL_LIBS"
1030 ADDITIONAL_LIBS_STATIC="$LIBNL_LIBS_STATIC $ADDITIONAL_LIBS_STATIC"
1031 REQUIRES_PRIVATE="libnl-tiny $REQUIRES_PRIVATE"
1032 AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
1036 if test x$pkg_config_found_libnl != xyes; then
1038 # OK, either we don't have pkg-config or there
1039 # wasn't a .pc file for it; Check for it directly.
1041 case "$with_libnl" in
1044 incdir=-I/usr/include/libnl3
1049 if test -d $withval; then
1050 libnldir=-L${withval}/lib
1051 incdir=-I${withval}/include
1056 AC_CHECK_LIB(nl-3, nl_socket_alloc,
1059 # Yes, we have libnl 3.x.
1061 ADDITIONAL_LIBS="${libnldir} -lnl-genl-3 -lnl-3 $ADDITIONAL_LIBS"
1062 ADDITIONAL_LIBS_STATIC="${libnldir} -lnl-genl-3 -lnl-3 $ADDITIONAL_LIBS_STATIC"
1063 LIBS_PRIVATE="${libnldir} -lnl-genl-3 -lnl-3 $LIBS_PRIVATE"
1064 AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
1065 V_INCLS="$V_INCLS ${incdir}"
1068 # No, we don't have libnl at all.
1069 # Fail if the user explicitly requested
1072 if test x$with_libnl = xyes ; then
1073 AC_MSG_ERROR([libnl support requested but libnl not found])
1075 ], ${incdir} ${libnldir} -lnl-genl-3 -lnl-3 )
1080 # Check to see if the tpacket_auxdata struct has a tp_vlan_tci member.
1082 # NOTE: any failure means we conclude that it doesn't have that
1083 # member, so if we don't have tpacket_auxdata, we conclude it
1084 # doesn't have that member (which is OK, as either we won't be
1085 # using code that would use that member, or we wouldn't compile
1087 AC_CHECK_MEMBERS([struct tpacket_auxdata.tp_vlan_tci],,,
1089 #include <sys/types.h>
1090 #include <linux/if_packet.h>
1098 PLATFORM_C_SRC="pcap-bpf.c"
1101 # Check whether we have the *BSD-style ioctls.
1103 AC_CHECK_HEADERS(net/if_media.h)
1106 # Check whether we have struct BPF_TIMEVAL.
1108 AC_CHECK_TYPES(struct BPF_TIMEVAL,,,
1110 #include <sys/types.h>
1111 #include <sys/ioctl.h>
1112 #ifdef HAVE_SYS_IOCCOM_H
1113 #include <sys/ioccom.h>
1115 #include <net/bpf.h>
1119 # Check whether there's a net/ipnet.h header and,
1120 # if so, whether it defines IPNET_ANY_LINK - if so,
1121 # we assume we have the "any" device (that's a
1122 # Solaris header, and later versions of Solaris
1123 # have an "any" device).
1125 # Attempting to include it at compile time could
1126 # be a pain, as it's a kernel header.
1128 AC_MSG_CHECKING(whether the Solaris "any" device is supported)
1129 if test -e /usr/include/inet/ipnet.h &&
1130 grep -q IPNET_ANY_LINK /usr/include/inet/ipnet.h; then
1132 AC_DEFINE(HAVE_SOLARIS_ANY_DEVICE, 1, [target host supports Solaris "any" device])
1139 PLATFORM_C_SRC="pcap-hurd.c"
1145 # --with-pcap=dag is the only way to get here, and it means
1146 # "DAG support but nothing else"
1148 V_DEFS="$V_DEFS -DDAG_ONLY"
1149 PLATFORM_C_SRC="pcap-dag.c"
1155 # --with-pcap=dpdk is the only way to get here, and it means
1156 # "DPDK support but nothing else"
1158 V_DEFS="$V_DEFS -DDPDK_ONLY"
1159 PLATFORM_C_SRC="pcap-dpdk.c"
1165 # --with-pcap=septel is the only way to get here, and it means
1166 # "Septel support but nothing else"
1168 V_DEFS="$V_DEFS -DSEPTEL_ONLY"
1169 PLATFORM_C_SRC="pcap-septel.c"
1175 # --with-pcap=snf is the only way to get here, and it means
1176 # "SNF support but nothing else"
1178 V_DEFS="$V_DEFS -DSNF_ONLY"
1179 PLATFORM_C_SRC="pcap-snf.c"
1187 PLATFORM_C_SRC="pcap-null.c"
1191 AC_MSG_ERROR($V_PCAP is not a valid pcap type)
1196 dnl Now figure out how we get a list of interfaces and addresses,
1197 dnl if we support capturing. Don't bother if we don't support
1200 if test "$V_PCAP" != null
1202 AC_CHECK_FUNC(getifaddrs,[
1204 # We have "getifaddrs()"; make sure we have <ifaddrs.h>
1205 # as well, just in case some platform is really weird.
1207 AC_CHECK_HEADER(ifaddrs.h,[
1209 # We have the header, so we use "getifaddrs()" to
1210 # get the list of interfaces.
1212 PLATFORM_C_SRC="$PLATFORM_C_SRC fad-getad.c"
1215 # We don't have the header - give up.
1216 # XXX - we could also fall back on some other
1217 # mechanism, but, for now, this'll catch this
1218 # problem so that we can at least try to figure
1219 # out something to do on systems with "getifaddrs()"
1220 # but without "ifaddrs.h", if there is something
1221 # we can do on those systems.
1223 AC_MSG_ERROR([Your system has getifaddrs() but doesn't have a usable <ifaddrs.h>.])
1227 # Well, we don't have "getifaddrs()", at least not with the
1228 # libraries with which we've decided we need to link
1229 # libpcap with, so we have to use some other mechanism.
1231 # Note that this may happen on Solaris, which has
1232 # getifaddrs(), but in -lsocket, not in -lxnet, so we
1233 # won't find it if we link with -lxnet, which we want
1234 # to do for other reasons.
1236 # For now, we use either the SIOCGIFCONF ioctl or the
1237 # SIOCGLIFCONF ioctl, preferring the latter if we have
1238 # it; the latter is a Solarisism that first appeared
1239 # in Solaris 8. (Solaris's getifaddrs() appears to
1240 # be built atop SIOCGLIFCONF; using it directly
1241 # avoids a not-all-that-useful middleman.)
1243 AC_MSG_CHECKING(whether we have SIOCGLIFCONF)
1244 AC_CACHE_VAL(ac_cv_lbl_have_siocglifconf,
1245 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1246 [[#include <sys/param.h>
1247 #include <sys/file.h>
1248 #include <sys/ioctl.h>
1249 #include <sys/socket.h>
1250 #include <sys/sockio.h>]],
1251 [[ioctl(0, SIOCGLIFCONF, (char *)0);]])],
1252 [ac_cv_lbl_have_siocglifconf=yes],
1253 [ac_cv_lbl_have_siocglifconf=no]))
1254 AC_MSG_RESULT($ac_cv_lbl_have_siocglifconf)
1255 if test $ac_cv_lbl_have_siocglifconf = yes ; then
1256 PLATFORM_C_SRC="$PLATFORM_C_SRC fad-glifc.c"
1258 PLATFORM_C_SRC="$PLATFORM_C_SRC fad-gifc.c"
1263 dnl check for hardware timestamp support
1266 AC_CHECK_HEADERS([linux/net_tstamp.h])
1269 AC_MSG_NOTICE(no hardware timestamp support implemented for $host_os)
1274 # Check for socklen_t.
1276 AC_CHECK_TYPES(socklen_t,,,
1278 #include <sys/types.h>
1279 #include <sys/socket.h>
1283 AS_HELP_STRING([--enable-ipv6],[build IPv6-capable version @<:@default=yes@:>@]),
1286 if test "$enable_ipv6" != "no"; then
1288 # We've already made sure we have getaddrinfo above in
1289 # AC_LBL_LIBRARY_NET.
1291 AC_DEFINE(INET6,1,[IPv6])
1294 # Check for Endace DAG card support.
1296 AS_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1298 if test "$withval" = no
1300 # User doesn't want DAG support.
1302 elif test "$withval" = yes
1304 # User wants DAG support but hasn't specified a directory.
1307 # User wants DAG support and has specified a directory, so use the provided value.
1312 if test "$V_PCAP" = dag; then
1313 # User requested DAG-only libpcap, so we'd better have
1316 elif test "$xxx_only" = yes; then
1317 # User requested something-else-only pcap, so they don't
1322 # Use DAG API if present, otherwise don't
1328 AC_ARG_WITH([dag-includes],
1329 AS_HELP_STRING([--with-dag-includes=IDIR],[Endace DAG include directory, if not DIR/include]),
1331 # User wants DAG support and has specified a header directory, so use the provided value.
1333 dag_include_dir=$withval
1336 AC_ARG_WITH([dag-libraries],
1337 AS_HELP_STRING([--with-dag-libraries=LDIR],[Endace DAG library directory, if not DIR/lib]),
1339 # User wants DAG support and has specified a library directory, so use the provided value.
1341 dag_lib_dir=$withval
1344 if test "$want_dag" != no; then
1346 # If necessary, set default paths for DAG API headers and libraries.
1347 if test -z "$dag_root"; then
1351 if test -z "$dag_include_dir"; then
1352 dag_include_dir="$dag_root/include"
1355 if test -z "$dag_lib_dir"; then
1356 dag_lib_dir="$dag_root/lib"
1358 # Handle multiarch systems.
1360 if test -d "$dag_lib_dir/$host"
1362 dag_lib_dir="$dag_lib_dir/$host"
1366 AC_LBL_SAVE_CHECK_STATE
1367 CFLAGS="$CFLAGS -I$dag_include_dir"
1368 AC_CHECK_HEADERS([dagapi.h])
1369 AC_LBL_RESTORE_CHECK_STATE
1371 if test "$ac_cv_header_dagapi_h" = yes; then
1373 V_INCLS="$V_INCLS -I$dag_include_dir"
1375 if test $V_PCAP != dag ; then
1376 MODULE_C_SRC="$MODULE_C_SRC pcap-dag.c"
1379 # Check for various DAG API functions.
1380 # Don't need to save and restore LIBS to prevent -ldag being
1381 # included if there's a found-action (arg 3).
1382 AC_LBL_SAVE_CHECK_STATE
1383 LDFLAGS="-L$dag_lib_dir"
1384 AC_CHECK_LIB([dag], [dag_attach_stream64],
1387 # We assume that if we have libdag we have
1388 # libdagconf, as they're installed at the
1389 # same time from the same package.
1391 ADDITIONAL_LIBS="-L$dag_lib_dir $ADDITIONAL_LIBS -ldag -ldagconf"
1392 ADDITIONAL_LIBS_STATIC="-L$dag_lib_dir $ADDITIONAL_LIBS_STATIC -ldag -ldagconf"
1393 LIBS_PRIVATE="-L$dag_lib_dir $LIBS_PRIVATE -ldag -ldagconf"
1395 [AC_MSG_ERROR(DAG library lacks 64-bit streams support)])
1396 AC_LBL_RESTORE_CHECK_STATE
1399 # We assume that if we have libdag we have libdagconf,
1400 # as they're installed at the same time from the same
1403 AC_LBL_SAVE_CHECK_STATE
1404 LIBS="$LIBS -ldag -ldagconf"
1405 LDFLAGS="$LDFLAGS -L$dag_lib_dir"
1406 AC_CHECK_LIB([vdag],[vdag_set_device_info], [ac_dag_have_vdag="1"], [ac_dag_have_vdag="0"])
1407 AC_LBL_RESTORE_CHECK_STATE
1408 if test "$ac_dag_have_vdag" = 1; then
1409 AC_DEFINE(HAVE_DAG_VDAG, 1, [define if you have vdag_set_device_info()])
1410 if test "$ac_lbl_have_pthreads" != "found"; then
1411 AC_MSG_ERROR([DAG requires pthreads, but we didn't find them])
1413 ADDITIONAL_LIBS="$ADDITIONAL_LIBS $PTHREAD_LIBS"
1414 ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $PTHREAD_LIBS"
1415 LIBS_PRIVATE="$LIBS_PRIVATE $PTHREAD_LIBS"
1418 AC_MSG_NOTICE([using Endace DAG API headers from $dag_include_dir])
1419 AC_MSG_NOTICE([using Endace DAG API libraries from $dag_lib_dir])
1420 AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
1422 if test "$V_PCAP" = dag; then
1423 # User requested "dag" capture type but we couldn't
1424 # find the DAG API support.
1425 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])
1428 if test "$want_dag" = yes; then
1429 # User wanted DAG support but we couldn't find it.
1430 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])
1436 AS_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1438 if test "$withval" = no
1441 elif test "$withval" = yes
1447 septel_root=$withval
1450 if test "$V_PCAP" = septel; then
1451 # User requested Septel-only libpcap, so we'd better have
1454 elif test "$xxx_only" = yes; then
1455 # User requested something-else-only pcap, so they don't
1456 # want Septel support.
1460 # Use Septel API if present, otherwise don't
1462 want_septel=ifpresent
1466 ac_cv_lbl_septel_api=no
1467 if test "$with_septel" != no; then
1469 AC_MSG_CHECKING([whether we have Septel API headers])
1471 # If necessary, set default paths for Septel API headers and libraries.
1472 if test -z "$septel_root"; then
1473 septel_root=$srcdir/../septel
1476 septel_tools_dir="$septel_root"
1477 septel_include_dir="$septel_root/INC"
1479 if test -r "$septel_include_dir/msg.h"; then
1480 ac_cv_lbl_septel_api=yes
1483 if test "$ac_cv_lbl_septel_api" = yes; then
1484 AC_MSG_RESULT([yes ($septel_include_dir)])
1486 V_INCLS="$V_INCLS -I$septel_include_dir"
1487 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"
1488 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"
1490 if test "$V_PCAP" != septel ; then
1491 MODULE_C_SRC="$MODULE_C_SRC pcap-septel.c"
1494 AC_DEFINE(HAVE_SEPTEL_API, 1, [define if you have the Septel API])
1498 if test "$V_PCAP" = septel; then
1499 # User requested "septel" capture type but
1500 # we couldn't find the Septel API support.
1501 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])
1504 if test "$want_septel" = yes; then
1505 # User wanted Septel support but we couldn't find it.
1506 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])
1511 # Check for Myricom SNF support.
1513 AS_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1515 if test "$withval" = no
1517 # User explicitly doesn't want SNF
1519 elif test "$withval" = yes
1521 # User wants SNF support but hasn't specified a directory.
1524 # User wants SNF support with a specified directory.
1529 if test "$V_PCAP" = snf; then
1530 # User requested Sniffer-only libpcap, so we'd better have
1533 elif test "$xxx_only" = yes; then
1534 # User requested something-else-only pcap, so they don't
1539 # Use Sniffer API if present, otherwise don't
1545 AC_ARG_WITH([snf-includes],
1546 AS_HELP_STRING([--with-snf-includes=IDIR],[Myricom SNF include directory, if not DIR/include]),
1548 # User wants SNF with specific header directory
1550 snf_include_dir=$withval
1553 AC_ARG_WITH([snf-libraries],
1554 AS_HELP_STRING([--with-snf-libraries=LDIR],[Myricom SNF library directory, if not DIR/lib]),
1556 # User wants SNF with specific lib directory
1558 snf_lib_dir=$withval
1561 if test "$want_snf" != no; then
1562 # If necessary, set default paths for Sniffer headers and libraries.
1563 if test -z "$snf_root"; then
1567 if test -z "$snf_include_dir"; then
1568 snf_include_dir="$snf_root/include"
1571 if test -z "$snf_lib_dir"; then
1572 snf_lib_dir="$snf_root/lib"
1574 # Handle multiarch systems.
1576 if test -d "$snf_lib_dir/$host"
1578 snf_lib_dir="$snf_lib_dir/$host"
1582 AC_LBL_SAVE_CHECK_STATE
1583 CFLAGS="$CFLAGS -I$snf_include_dir"
1584 # Do not define a symbol.
1585 AC_CHECK_HEADER(snf.h)
1586 AC_LBL_RESTORE_CHECK_STATE
1588 if test "$ac_cv_header_snf_h" = yes; then
1589 # We found a header; make sure we can link with the library
1590 AC_LBL_SAVE_CHECK_STATE
1591 LDFLAGS="$LDFLAGS -L$snf_lib_dir"
1592 # Do not define a symbol.
1593 AC_CHECK_LIB([snf], [snf_init], [ac_cv_lbl_snf_api="yes"])
1594 AC_LBL_RESTORE_CHECK_STATE
1597 if test "$ac_cv_lbl_snf_api" = yes; then
1598 AC_MSG_NOTICE([using Myricom SNF API headers from $snf_include_dir])
1599 AC_MSG_NOTICE([using Myricom SNF API libraries from $snf_lib_dir])
1601 V_INCLS="$V_INCLS -I$snf_include_dir"
1602 ADDITIONAL_LIBS="$ADDITIONAL_LIBS -L$snf_lib_dir -lsnf"
1603 ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC -L$snf_lib_dir -lsnf"
1604 LIBS_PRIVATE="$LIBS_PRIVATE -L$snf_lib_dir -lsnf"
1606 if test "$V_PCAP" != snf ; then
1607 MODULE_C_SRC="$MODULE_C_SRC pcap-snf.c"
1610 AC_DEFINE(HAVE_SNF_API, 1, [define if you have the Myricom SNF API])
1612 if test "$V_PCAP" = snf; then
1613 # User requested "snf" capture type but
1614 # we couldn't find the Sniffer API support.
1615 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])
1618 if test "$want_snf" = yes; then
1619 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])
1624 # Check for Riverbed TurboCap support.
1625 AC_ARG_WITH([turbocap],
1626 AS_HELP_STRING([--with-turbocap@<:@=DIR@:>@],[include Riverbed TurboCap support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
1628 if test "$withval" = no
1630 # User explicitly doesn't want TurboCap
1632 elif test "$withval" = yes
1634 # User wants TurboCap support but hasn't specified a directory.
1637 # User wants TurboCap support with a specified directory.
1639 turbocap_root=$withval
1642 if test "$xxx_only" = yes; then
1643 # User requested something-else-only pcap, so they don't
1644 # want TurboCap support.
1648 # Use TurboCap API if present, otherwise don't
1650 want_turbocap=ifpresent
1654 ac_cv_lbl_turbocap_api=no
1655 if test "$want_turbocap" != no; then
1657 AC_MSG_CHECKING(whether TurboCap is supported)
1659 AC_LBL_SAVE_CHECK_STATE
1660 if test ! -z "$turbocap_root"; then
1661 TURBOCAP_CFLAGS="-I$turbocap_root/include"
1662 TURBOCAP_LDFLAGS="-L$turbocap_root/lib"
1663 CFLAGS="$CFLAGS $TURBOCAP_CFLAGS"
1664 LDFLAGS="$LDFLAGS $TURBOCAP_LDFLAGS"
1667 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1672 TC_INSTANCE a; TC_PORT b; TC_BOARD c;
1674 (void)TcInstanceCreateByName("foo", &i);
1676 [ac_cv_lbl_turbocap_api=yes])
1678 AC_LBL_RESTORE_CHECK_STATE
1679 if test $ac_cv_lbl_turbocap_api = yes; then
1682 MODULE_C_SRC="$MODULE_C_SRC pcap-tc.c"
1683 V_INCLS="$V_INCLS $TURBOCAP_CFLAGS"
1684 ADDITIONAL_LIBS="$ADDITIONAL_LIBS $TURBOCAP_LDFLAGS -lTcApi -lpthread -lstdc++"
1685 ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $TURBOCAP_LDFLAGS -lTcApi -lpthread -lstdc++"
1686 LIBS_PRIVATE="$LIBS_PRIVATE $TURBOCAP_LDFLAGS -lTcApi -lpthread -lstdc++"
1688 AC_DEFINE(HAVE_TC_API, 1, [define if you have the TurboCap API])
1692 if test "$want_turbocap" = yes; then
1693 # User wanted Turbo support but we couldn't find it.
1694 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])
1700 dnl Allow the user to enable remote capture.
1701 dnl It's off by default, as that increases the attack surface of
1702 dnl libpcap, exposing it to malicious servers.
1704 AC_MSG_CHECKING([whether to enable remote packet capture])
1705 AC_ARG_ENABLE([remote],
1706 [AS_HELP_STRING([--enable-remote],
1707 [enable remote packet capture @<:@default=no@:>@])],
1710 case "$enableval" in
1711 yes) AC_MSG_RESULT(yes)
1712 AC_MSG_WARN(Remote packet capture may expose libpcap-based applications)
1713 AC_MSG_WARN(to attacks by malicious remote capture servers!)
1715 # rpcapd requires pthreads on UN*X.
1717 if test "$ac_lbl_have_pthreads" != "found"; then
1718 AC_MSG_ERROR([rpcapd requires pthreads, but we didn't find them])
1721 # It also requires crypt().
1722 # Do we have it in the system libraries?
1724 AC_CHECK_FUNC(crypt,,
1727 # No. Do we have it in -lcrypt?
1729 AC_CHECK_LIB(crypt, crypt,
1732 # Yes; add -lcrypt to the libraries for rpcapd.
1734 RPCAPD_LIBS="$RPCAPD_LIBS -lcrypt"
1737 AC_MSG_ERROR([rpcapd requires crypt(), but we didn't find it])
1742 # OK, we have crypt(). Do we have getspnam()?
1744 AC_CHECK_FUNCS(getspnam)
1747 # Check for various members of struct msghdr.
1749 AC_CHECK_MEMBERS([struct msghdr.msg_control],,,
1751 #include "ftmacros.h"
1752 #include <sys/socket.h>
1754 AC_CHECK_MEMBERS([struct msghdr.msg_flags],,,
1756 #include "ftmacros.h"
1757 #include <sys/socket.h>
1761 # Optionally, we may want to support SSL.
1762 # Check for OpenSSL/libressl.
1764 # First, try looking for it with pkg-config, if we have it.
1766 # Homebrew's pkg-config does not, by default, look for
1767 # pkg-config files for packages it has installed.
1768 # Furthermore, at least for OpenSSL, they appear to be
1769 # dumped in package-specific directories whose paths are
1770 # not only package-specific but package-version-specific.
1772 # So the only way to find openssl is to get the value of
1773 # PKG_CONFIG_PATH from "brew --env openssl" and add that
1774 # to PKG_CONFIG_PATH. (No, we can't just assume it's under
1775 # /usr/local; Homebrew have conveniently chosen to put it
1776 # under /opt/homebrew on ARM.)
1778 # That's the nice thing about Homebrew - it makes things easier!
1781 save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
1782 if test -n "$BREW"; then
1783 openssl_pkgconfig_dir=`$BREW --env --plain openssl | sed -n 's/PKG_CONFIG_PATH: //p'`
1784 PKG_CONFIG_PATH="$openssl_pkgconfig_dir:$PKG_CONFIG_PATH"
1786 PKG_CHECK_MODULE(OPENSSL, openssl,
1789 # We found OpenSSL/libressl.
1792 REQUIRES_PRIVATE="$REQUIRES_PRIVATE openssl"
1794 PKG_CONFIG_PATH="$save_PKG_CONFIG_PATH"
1797 # If it wasn't found, and we have Homebrew installed, see
1798 # if it's in Homebrew.
1800 if test "x$HAVE_OPENSSL" != "xyes" -a -n "$BREW"; then
1801 AC_MSG_CHECKING(for openssl in Homebrew)
1803 # The brew man page lies when it speaks of
1804 # $BREW --prefix --installed <formula>
1805 # outputting nothing. In Homebrew 3.3.16,
1806 # it produces output regardless of whether
1807 # the formula is installed or not, so we
1808 # send the standard output and error to
1811 if $BREW --prefix --installed openssl >/dev/null 2>&1; then
1813 # Yes. Get the include directory and library
1814 # directory. (No, we can't just assume it's
1815 # under /usr/local; Homebrew have conveniently
1816 # chosen to put it under /opt/homebrew on ARM.)
1820 openssl_path=`$BREW --prefix openssl`
1821 OPENSSL_CFLAGS="-I$openssl_path/include"
1822 OPENSSL_LIBS="-L$openssl_path/lib -lssl -lcrypto"
1823 OPENSSL_LIBS_STATIC="-L$openssl_path/lib -lssl -lcrypto"
1824 OPENSSL_LIBS_PRIVATE="-L$openssl_path/lib -lssl -lcrypto"
1831 # If it wasn't found, and /usr/local/include and /usr/local/lib
1832 # exist, check if it's in /usr/local. (We check whether they
1833 # exist because, if they don't exist, the compiler will warn
1834 # about that and then ignore the argument, so they test
1835 # using just the system header files and libraries.)
1837 # We include the standard include file to 1) make sure that
1838 # it's installed (if it's just a shared library for the
1839 # benefit of existing programs, that's not useful) and 2)
1840 # because SSL_library_init() is a library routine in some
1841 # versions and a #defined wrapper around OPENSSL_init_ssl()
1844 if test "x$HAVE_OPENSSL" != "xyes" -a -d "/usr/local/include" -a -d "/usr/local/lib"; then
1845 AC_LBL_SAVE_CHECK_STATE
1846 CFLAGS="$CFLAGS -I/usr/local/include"
1847 LIBS="$LIBS -L/usr/local/lib -lssl -lcrypto"
1848 AC_MSG_CHECKING(whether we have OpenSSL/libressl in /usr/local that we can use)
1849 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1851 #include <openssl/ssl.h>
1860 OPENSSL_CFLAGS="-I/usr/local/include"
1861 OPENSSL_LIBS="-L/usr/local/lib -lssl -lcrypto"
1862 OPENSSL_LIBS_STATIC="-L/usr/local/lib -lssl -lcrypto"
1863 OPENSSL_LIBS_PRIVATE="-L/usr/local/lib -lssl -lcrypto"
1866 AC_LBL_RESTORE_CHECK_STATE
1870 # If it wasn't found, check if it's a system library.
1872 # We include the standard include file to 1) make sure that
1873 # it's installed (if it's just a shared library for the
1874 # benefit of existing programs, that's not useful) and 2)
1875 # because SSL_library_init() is a library routine in some
1876 # versions and a #defined wrapper around OPENSSL_init_ssl()
1879 if test "x$HAVE_OPENSSL" != "xyes"; then
1880 AC_LBL_SAVE_CHECK_STATE
1881 LIBS="$LIBS -lssl -lcrypto"
1882 AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use)
1883 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1885 #include <openssl/ssl.h>
1894 OPENSSL_LIBS="-lssl -lcrypto"
1895 OPENSSL_LIBS_STATIC="-lssl -lcrypto"
1896 OPENSSL_LIBS_PRIVATE="-lssl -lcrypto"
1899 AC_LBL_RESTORE_CHECK_STATE
1903 # OK, did we find it?
1905 if test "x$HAVE_OPENSSL" = "xyes"; then
1906 AC_DEFINE([HAVE_OPENSSL], [1], [Use OpenSSL])
1907 V_INCLS="$V_INCLS $OPENSSL_CFLAGS"
1908 ADDITIONAL_LIBS="$ADDITIONAL_LIBS $OPENSSL_LIBS"
1909 ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $OPENSSL_LIBS_STATIC"
1910 LIBS_PRIVATE="$LIBS_PRIVATE $OPENSSL_LIBS_PRIVATE"
1911 REQUIRES_PRIVATE="$REQUIRES_PRIVATE $OPENSSL_REQUIRES_PRIVATE"
1912 REMOTE_C_SRC="$REMOTE_C_SRC sslutils.c"
1914 AC_MSG_NOTICE(OpenSSL not found)
1917 AC_DEFINE(ENABLE_REMOTE, 1,
1918 [Define to 1 if remote packet capture is to be supported])
1919 REMOTE_C_SRC="$REMOTE_C_SRC pcap-rpcap.c rpcap-protocol.c sockutils.c"
1920 BUILD_RPCAPD=build-rpcapd
1921 INSTALL_RPCAPD=install-rpcapd
1923 *) AC_MSG_RESULT(no)
1927 AC_MSG_CHECKING(whether to build optimizer debugging code)
1928 AC_ARG_ENABLE(optimizer-dbg,
1929 AS_HELP_STRING([--enable-optimizer-dbg],[build optimizer debugging code]))
1930 if test "$enable_optimizer_dbg" = "yes"; then
1931 AC_DEFINE(BDEBUG,1,[Enable optimizer debugging])
1933 AC_MSG_RESULT(${enable_optimizer_dbg-no})
1935 AC_MSG_CHECKING(whether to build parser debugging code)
1936 AC_ARG_ENABLE(yydebug,
1937 AS_HELP_STRING([--enable-yydebug],[build parser debugging code]))
1938 if test "$enable_yydebug" = "yes"; then
1939 AC_DEFINE(YYDEBUG,1,[Enable parser debugging])
1941 AC_MSG_RESULT(${enable_yydebug-no})
1946 AC_PROG_LEX(noyywrap)
1947 if test "$LEX" = ":"; then
1948 AC_MSG_ERROR([Neither flex nor lex was found.])
1952 # Make sure {f}lex supports the -P, --header-file, and --nounput flags
1953 # and supports processing our scanner.l.
1955 AC_CACHE_CHECK([for capable lex], tcpdump_cv_capable_lex,
1956 if $LEX -P pcap_ --header-file=/dev/null --nounput -t $srcdir/scanner.l > /dev/null 2>&1; then
1957 tcpdump_cv_capable_lex=yes
1959 tcpdump_cv_capable_lex=insufficient
1961 if test $tcpdump_cv_capable_lex = insufficient ; then
1962 AC_MSG_ERROR([$LEX is insufficient to compile libpcap.
1963 libpcap requires Flex 2.5.31 or later, or a compatible version of lex.
1964 If a suitable version of Lex/Flex is available as a non-standard command
1965 and/or not in the PATH, you can specify it using the LEX environment
1966 variable. That said, on some systems the error can mean that Flex/Lex is
1967 actually acceptable, but m4 is not. Likewise, if a suitable version of
1968 m4 (such as GNU M4) is available but has not been detected, you can
1969 specify it using the M4 environment variable.])
1973 # Look for yacc/bison/byacc.
1974 # If it's Bison, we do not want -y, as 1) we will be using -o to cause
1975 # the output for XXX.y to be written to XXX.c and 2) we don't want
1976 # it to issue warnings about stuff not supported by POSIX YACC - we
1977 # want to use that stuff, and don't care whether plain YACC supports
1978 # it or not, we require either Bison or Berkeley YACC.
1984 AC_CHECK_PROGS(BISON_BYACC, bison)
1985 if test x"$BISON_BYACC" != x; then
1989 # Bison prior to 2.4(.1) doesn't support "%define api.pure", so use
1992 bison_major_version=`$BISON_BYACC -V | sed -n 's/.* \(@<:@1-9@:>@@<:@0-9@:>@*\)\.@<:@0-9@:>@@<:@0-9.@:>@*/\1/p'`
1993 bison_minor_version=`$BISON_BYACC -V | sed -n 's/.* @<:@1-9@:>@@<:@0-9@:>@*\.\(@<:@0-9@:>@+\).*/\1/p'`
1994 if test "$bison_major_version" -lt 2 -o \
1995 \( "$bison_major_version" -eq 2 -a "$bison_major_version" -lt 4 \)
1997 REENTRANT_PARSER="%pure-parser"
1999 REENTRANT_PARSER="%define api.pure"
2003 # We didn't find Bison; check for Berkeley YACC, under the
2004 # names byacc and yacc.
2006 AC_CHECK_PROGS(BISON_BYACC, byacc yacc)
2007 if test x"$BISON_BYACC" != x; then
2009 # Make sure this is Berkeley YACC, not AT&T YACC;
2010 # the latter doesn't support reentrant parsers.
2011 # Run it with "-V"; that succeeds and reports the
2012 # version number with Berkeley YACC, but will
2013 # (probably) fail with various vendor flavors
2016 # Hopefully this also eliminates any versions
2017 # of Berkeley YACC that don't support reentrant
2018 # parsers, if there are any.
2020 AC_CACHE_CHECK([for capable yacc], tcpdump_cv_capable_yacc,
2021 if $BISON_BYACC -V >/dev/null 2>&1; then
2022 tcpdump_cv_capable_yacc=yes
2024 tcpdump_cv_capable_yacc=insufficient
2026 if test $tcpdump_cv_capable_yacc = insufficient ; then
2027 AC_MSG_ERROR([$BISON_BYACC is insufficient to compile libpcap.
2028 libpcap requires Bison, a newer version of Berkeley YACC with support
2029 for reentrant parsers, or another YACC compatible with them.])
2033 # OK, we found neither byacc nor yacc.
2035 AC_MSG_ERROR([Neither bison, byacc, nor yacc was found.
2036 libpcap requires Bison, a newer version of Berkeley YACC with support
2037 for reentrant parsers, or another YACC compatible with them.])
2041 # Berkeley YACC doesn't support "%define api.pure", so use
2044 REENTRANT_PARSER="%pure-parser"
2046 AC_SUBST(BISON_BYACC)
2047 AC_SUBST(REENTRANT_PARSER)
2050 # Do various checks for various OSes and versions of those OSes.
2052 # Assume, by default, no support for shared libraries and V7/BSD
2053 # convention for man pages (devices in section 4, file formats in
2054 # section 5, miscellaneous info in section 7, administrative commands
2055 # and daemons in section 8). Individual cases can override this.
2061 MAN_ADMIN_COMMANDS=8
2066 # AIX makes it fun to build shared and static libraries,
2067 # because they're *both* ".a" archive libraries. We
2068 # build the static library for the benefit of the traditional
2069 # scheme of building libpcap and tcpdump in subdirectories of
2070 # the same directory, with tcpdump statically linked with the
2071 # libpcap in question, but we also build a shared library as
2072 # "libpcap.shareda" and install *it*, rather than the static
2073 # library, as "libpcap.a".
2081 # If we're using DLPI, applications will need to
2082 # use /lib/pse.exp if present, as we use the
2085 pseexe="/lib/pse.exp"
2086 AC_MSG_CHECKING(for $pseexe)
2087 if test -f $pseexe ; then
2095 # If we're using BPF, we need "-lodm" and "-lcfg", as
2096 # we use them to load the BPF module.
2105 V_CCOPT="$V_CCOPT -fno-common"
2106 AC_ARG_ENABLE(universal,
2107 AS_HELP_STRING([--disable-universal],[don't build universal on macOS]))
2108 if test "$enable_universal" != "no"; then
2113 # Pre-Tiger. Build only for 32-bit PowerPC; no
2114 # need for any special compiler or linker flags.
2118 darwin8.[[0123]]|darwin8.[[0123]].*)
2120 # Tiger, prior to Intel support. Build
2121 # libraries and executables for 32-bit PowerPC
2122 # and 64-bit PowerPC, with 32-bit PowerPC first.
2123 # (I'm guessing that's what Apple does.)
2125 # (The double brackets are needed because
2126 # autotools/m4 use brackets as a quoting
2127 # character; the double brackets turn into
2128 # single brackets in the generated configure
2131 V_LIB_CCOPT_FAT="-arch ppc -arch ppc64"
2132 V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64"
2133 V_PROG_CCOPT_FAT="-arch ppc -arch ppc64"
2134 V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64"
2137 darwin8.[[456]]|darwin8.[[456]].*)
2139 # Tiger, subsequent to Intel support but prior
2140 # to x86-64 support. Build libraries and
2141 # executables for 32-bit PowerPC, 64-bit
2142 # PowerPC, and 32-bit x86, with 32-bit PowerPC
2143 # first. (I'm guessing that's what Apple does.)
2145 # (The double brackets are needed because
2146 # autotools/m4 use brackets as a quoting
2147 # character; the double brackets turn into
2148 # single brackets in the generated configure
2151 V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386"
2152 V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386"
2153 V_PROG_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386"
2154 V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386"
2159 # All other Tiger, so subsequent to x86-64
2160 # support. Build libraries and executables for
2161 # 32-bit PowerPC, 64-bit PowerPC, 32-bit x86,
2162 # and x86-64, with 32-bit PowerPC first. (I'm
2163 # guessing that's what Apple does.)
2165 V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
2166 V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
2167 V_PROG_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
2168 V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
2173 # Leopard. Build libraries for 32-bit PowerPC,
2174 # 64-bit PowerPC, 32-bit x86, and x86-64, with
2175 # 32-bit PowerPC first, and build executables
2176 # for 32-bit x86 and 32-bit PowerPC, with 32-bit
2177 # x86 first. (That's what Apple does.)
2179 V_LIB_CCOPT_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
2180 V_LIB_LDFLAGS_FAT="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
2181 V_PROG_CCOPT_FAT="-arch i386 -arch ppc"
2182 V_PROG_LDFLAGS_FAT="-arch i386 -arch ppc"
2187 # Snow Leopard. Build libraries for x86-64,
2188 # 32-bit x86, and 32-bit PowerPC, with x86-64
2189 # first, and build executables for x86-64 and
2190 # 32-bit x86, with x86-64 first. (That's what
2191 # Apple does, even though Snow Leopard doesn't
2192 # run on PPC, so PPC libpcap runs under Rosetta,
2193 # and Rosetta doesn't support BPF ioctls, so PPC
2194 # programs can't do live captures.)
2196 V_LIB_CCOPT_FAT="-arch x86_64 -arch i386 -arch ppc"
2197 V_LIB_LDFLAGS_FAT="-arch x86_64 -arch i386 -arch ppc"
2198 V_PROG_CCOPT_FAT="-arch x86_64 -arch i386"
2199 V_PROG_LDFLAGS_FAT="-arch x86_64 -arch i386"
2204 # Post-Snow Leopard, pre-Catalina. Build
2205 # libraries for x86-64 and 32-bit x86, with
2206 # x86-64 first, and build executables only for
2207 # x86-64. (That's what Apple does.) This
2208 # requires no special flags for programs.
2210 # We check whether we *can* build for i386 and,
2211 # if not, suggest that the user install the
2212 # /usr/include headers if they want to build
2215 AC_MSG_CHECKING(whether building for 32-bit x86 is supported)
2216 AC_LBL_SAVE_CHECK_STATE
2217 CFLAGS="$CFLAGS -arch i386"
2218 AC_LINK_IFELSE([AC_LANG_PROGRAM(
2223 V_LIB_CCOPT_FAT="-arch x86_64"
2224 V_LIB_LDFLAGS_FAT="-arch x86_64"
2227 # OpenSSL installation on macOS seems
2228 # to install only the libs for 64-bit
2229 # x86 - at least that's what Brew does:
2230 # only configure 32-bit builds if we
2231 # don't have OpenSSL.
2233 if test "$HAVE_OPENSSL" != yes; then
2234 V_LIB_CCOPT_FAT="$V_LIB_CCOPT_FAT -arch i386"
2235 V_LIB_LDFLAGS_FAT="$V_LIB_LDFLAGS_FAT -arch i386"
2240 V_LIB_CCOPT_FAT="-arch x86_64"
2241 V_LIB_LDFLAGS_FAT="-arch x86_64"
2246 # Mojave; you need to install the
2247 # /usr/include headers to get
2248 # 32-bit x86 builds to work.
2250 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])
2255 # Pre-Mojave; the command-line
2256 # tools should be sufficient to
2257 # enable 32-bit x86 builds.
2259 AC_MSG_WARN([Compiling for 32-bit x86 gives an error; try installing the command-line tools])
2263 AC_LBL_RESTORE_CHECK_STATE
2268 # Catalina. Build libraries and executables
2269 # only for x86-64. (That's what Apple does;
2270 # 32-bit x86 binaries are not supported on
2273 V_LIB_CCOPT_FAT="-arch x86_64"
2274 V_LIB_LDFLAGS_FAT="-arch x86_64"
2275 V_PROG_CCOPT_FAT="-arch x86_64"
2276 V_PROG_LDFLAGS_FAT="-arch x86_64"
2281 # Post-Catalina. Build libraries and
2282 # executables for x86-64 and ARM64.
2283 # (That's what Apple does, except they
2284 # build for arm64e, which may include
2285 # some of the pointer-checking extensions.)
2287 # If we're building with libssl, make sure
2288 # we can build fat with it (i.e., that it
2289 # was built fat); if we can't, don't set
2290 # the target architectures, and just
2291 # build for the host we're on.
2293 # Otherwise, just add both of them.
2295 if test "$HAVE_OPENSSL" = yes; then
2296 AC_MSG_CHECKING(whether building fat with libssl is supported)
2297 AC_LBL_SAVE_CHECK_STATE
2298 CFLAGS="$CFLAGS -arch x86_64 -arch arm64"
2299 LDFLAGS="$LDFLAGS $OPENSSL_LIBS"
2300 AC_LINK_IFELSE([AC_LANG_PROGRAM(
2302 #include <openssl/ssl.h>
2310 V_LIB_CCOPT_FAT="-arch x86_64 -arch arm64"
2311 V_LIB_LDFLAGS_FAT="-arch x86_64 -arch arm64"
2312 V_PROG_CCOPT_FAT="-arch x86_64 -arch arm64"
2313 V_PROG_LDFLAGS_FAT="-arch x86_64 -arch arm64"
2317 AC_LBL_RESTORE_CHECK_STATE
2319 V_LIB_CCOPT_FAT="-arch x86_64 -arch arm64"
2320 V_LIB_LDFLAGS_FAT="-arch x86_64 -arch arm64"
2321 V_PROG_CCOPT_FAT="-arch x86_64 -arch arm64"
2322 V_PROG_LDFLAGS_FAT="-arch x86_64 -arch arm64"
2329 hpux9*|hpux10.[01]*)
2330 AC_MSG_ERROR([HP-UX version must be 10.20 or later, not $host_os])
2334 dnl HPUX 10.20 and above is similar to HPUX 9, but
2335 dnl not the same....
2337 dnl XXX - DYEXT should be set to "sl" if this is building
2338 dnl for 32-bit PA-RISC, but should be left as "so" for
2339 dnl 64-bit PA-RISC or, I suspect, IA-64.
2340 AC_DEFINE(HAVE_HPUX10_20_OR_LATER,1,[on HP-UX 10.20 or later])
2341 if test "`uname -m`" = "ia64"; then
2348 # "-b" builds a shared library; "+h" sets the soname.
2354 # Use System V conventions for man pages.
2360 linux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*|haiku*|midipix*)
2365 AC_DEFINE(HAVE_SOLARIS,1,[On solaris])
2370 # Make sure errno is thread-safe, in case we're called in
2371 # a multithreaded program. We don't guarantee that two
2372 # threads can use the *same* pcap_t safely, but the
2373 # current version does guarantee that you can use different
2374 # pcap_t's in different threads, and even that pcap_compile()
2375 # is thread-safe (it wasn't thread-safe in some older versions).
2377 V_CCOPT="$V_CCOPT -D_TS_ERRNO"
2379 case "`uname -r`" in
2386 # Use System V conventions for man pages.
2388 MAN_ADMIN_COMMANDS=1m
2395 AC_SUBST(V_LIB_CCOPT_FAT)
2396 AC_SUBST(V_LIB_LDFLAGS_FAT)
2397 AC_SUBST(V_PROG_CCOPT_FAT)
2398 AC_SUBST(V_PROG_LDFLAGS_FAT)
2400 AC_SUBST(MAN_DEVICES)
2401 AC_SUBST(MAN_FILE_FORMATS)
2402 AC_SUBST(MAN_MISC_INFO)
2403 AC_SUBST(MAN_ADMIN_COMMANDS)
2405 AC_ARG_ENABLE(shared,
2406 AS_HELP_STRING([--enable-shared],[build shared libraries @<:@default=yes, if support available@:>@]))
2407 test "x$enable_shared" = "xno" && DYEXT="none"
2410 AC_CHECK_TOOL([AR], [ar])
2415 AC_LBL_DEVEL(V_CCOPT)
2418 # Check to see if the sockaddr struct has the 4.4 BSD sa_len member.
2420 AC_CHECK_MEMBERS([struct sockaddr.sa_len],,,
2422 #include <sys/types.h>
2423 #include <sys/socket.h>
2427 # Check to see if the dl_hp_ppa_info_t struct has the HP-UX 11.00
2428 # dl_module_id_1 member.
2430 # NOTE: any failure means we conclude that it doesn't have that member,
2431 # so if we don't have DLPI, don't have a <sys/dlpi_ext.h> header, or
2432 # have one that doesn't declare a dl_hp_ppa_info_t type, we conclude
2433 # it doesn't have that member (which is OK, as either we won't be
2434 # using code that would use that member, or we wouldn't compile in
2437 AC_CHECK_MEMBERS([dl_hp_ppa_info_t.dl_module_id_1],,,
2439 #include <sys/types.h>
2440 #include <sys/dlpi.h>
2441 #include <sys/dlpi_ext.h>
2445 # Various Linux-specific mechanisms.
2447 AC_ARG_ENABLE([usb],
2448 [AS_HELP_STRING([--enable-usb],[enable Linux usbmon USB capture support @<:@default=yes, if support available@:>@])],
2453 # If somebody requested an XXX-only pcap, that doesn't include
2454 # additional mechanisms.
2456 if test "$xxx_only" != yes; then
2459 dnl check for USB sniffing support
2460 AC_MSG_CHECKING(for Linux usbmon USB sniffing support)
2461 if test "x$enable_usb" != "xno" ; then
2462 AC_DEFINE(PCAP_SUPPORT_LINUX_USBMON, 1, [target host supports Linux usbmon for USB sniffing])
2463 MODULE_C_SRC="$MODULE_C_SRC pcap-usb-linux.c"
2466 # Note: if the directory for special files is *EVER* somewhere
2467 # other than the UN*X standard of /dev (which will break any
2468 # software that looks for /dev/null or /dev/tty, for example,
2469 # so doing that is *REALLY* not a good idea), please provide
2470 # some mechanism to determine that directory at *run time*,
2471 # rather than *configure time*, so that it works when doing
2472 # a cross-build, and that works with *multiple* distributions,
2473 # with our without udev, and with multiple versions of udev,
2474 # with udevinfo or udevadm or any other mechanism to get the
2475 # special files directory.
2477 # Do we have a version of <linux/compiler.h> available?
2478 # If so, we might need it for <linux/usbdevice_fs.h>.
2480 AC_CHECK_HEADERS(linux/compiler.h)
2481 if test "$ac_cv_header_linux_compiler_h" = yes; then
2483 # Yes - include it when testing for <linux/usbdevice_fs.h>.
2485 AC_CHECK_HEADERS(linux/usbdevice_fs.h,,,[#include <linux/compiler.h>])
2487 AC_CHECK_HEADERS(linux/usbdevice_fs.h)
2489 if test "$ac_cv_header_linux_usbdevice_fs_h" = yes; then
2491 # OK, does it define bRequestType? Older versions of the kernel
2492 # define fields with names like "requesttype, "request", and
2493 # "value", rather than "bRequestType", "bRequest", and
2496 AC_CHECK_MEMBERS([struct usbdevfs_ctrltransfer.bRequestType],,,
2499 #ifdef HAVE_LINUX_COMPILER_H
2500 #include <linux/compiler.h>
2502 #include <linux/usbdevice_fs.h>
2510 # Life's too short to deal with trying to get this to compile
2511 # if you don't get the right types defined with
2512 # __KERNEL_STRICT_NAMES getting defined by some other include.
2514 # Check whether the includes Just Work. If not, don't turn on
2515 # netfilter support.
2517 AC_MSG_CHECKING(whether we can compile the netfilter support)
2518 AC_CACHE_VAL(ac_cv_netfilter_can_compile,
2519 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2521 #include <sys/socket.h>
2522 #include <netinet/in.h>
2523 #include <linux/types.h>
2525 #include <linux/netlink.h>
2526 #include <linux/netfilter.h>
2527 #include <linux/netfilter/nfnetlink.h>
2528 #include <linux/netfilter/nfnetlink_log.h>
2529 #include <linux/netfilter/nfnetlink_queue.h>]],
2531 [ac_cv_netfilter_can_compile=yes],
2532 [ac_cv_netfilter_can_compile=no]))
2533 AC_MSG_RESULT($ac_cv_netfilter_can_compile)
2534 if test $ac_cv_netfilter_can_compile = yes ; then
2535 AC_DEFINE(PCAP_SUPPORT_NETFILTER, 1,
2536 [target host supports netfilter sniffing])
2537 MODULE_C_SRC="$MODULE_C_SRC pcap-netfilter-linux.c"
2542 AC_SUBST(PCAP_SUPPORT_LINUX_USBMON)
2543 AC_SUBST(PCAP_SUPPORT_NETFILTER)
2545 AC_ARG_ENABLE([netmap],
2546 [AS_HELP_STRING([--enable-netmap],[enable netmap support @<:@default=yes, if support available@:>@])],
2548 [enable_netmap=yes])
2550 if test "x$enable_netmap" != "xno" ; then
2552 # Check whether net/netmap_user.h is usable if NETMAP_WITH_LIBS is
2553 # defined; it's not usable on DragonFly BSD 4.6 if NETMAP_WITH_LIBS
2554 # is defined, for example, as it includes a nonexistent malloc.h
2557 AC_MSG_CHECKING(whether we can compile the netmap support)
2558 AC_CACHE_VAL(ac_cv_net_netmap_user_can_compile,
2559 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2561 #define NETMAP_WITH_LIBS
2562 #include <net/netmap_user.h>]],
2564 [ac_cv_net_netmap_user_can_compile=yes],
2565 [ac_cv_net_netmap_user_can_compile=no]))
2566 AC_MSG_RESULT($ac_cv_net_netmap_user_can_compile)
2567 if test $ac_cv_net_netmap_user_can_compile = yes ; then
2568 AC_DEFINE(PCAP_SUPPORT_NETMAP, 1,
2569 [target host supports netmap])
2570 MODULE_C_SRC="$MODULE_C_SRC pcap-netmap.c"
2572 AC_SUBST(PCAP_SUPPORT_NETMAP)
2575 # Check for DPDK support.
2577 AS_HELP_STRING([--with-dpdk@<:@=DIR@:>@],[include DPDK support (located in directory DIR, if supplied). @<:@default=yes, if present@:>@]),
2579 if test "$withval" = no
2581 # User doesn't want DPDK support.
2583 elif test "$withval" = yes
2585 # User wants DPDK support but hasn't specified a directory.
2588 # User wants DPDK support and has specified a directory,
2589 # so use the provided value.
2594 if test "$V_PCAP" = dpdk; then
2595 # User requested DPDK-only libpcap, so we'd better have
2598 elif test "$xxx_only" = yes; then
2599 # User requested something-else-only pcap, so they don't
2600 # want DPDK support.
2604 # Use DPDK API if present, otherwise don't
2610 if test "$want_dpdk" != no; then
2612 # The user didn't explicitly say they don't want DPDK,
2613 # so see if we have it.
2615 # We only try to find it using pkg-config; DPDK is *SO*
2616 # complicated - DPDK 19.02, for example, has about 117(!)
2617 # libraries, and the precise set of libraries required has
2618 # changed over time - so attempting to guess which libraries
2619 # you need, and hardcoding that in an attempt to find the
2620 # libraries without DPDK, rather than relying on DPDK to
2621 # tell you, with a .pc file, what libraries are needed,
2622 # is *EXTREMELY* fragile and has caused some bug reports,
2623 # so we're just not going to do it.
2625 # If that causes a problem, the only thing we will do is
2626 # accept an alternative way of finding the appropriate
2627 # library set for the installed version of DPDK that is
2628 # as robust as pkg-config (i.e., it had better work as well
2629 # as pkg-config with *ALL* versions of DPDK that provide a
2632 # If --with-dpdk={path} was specified, add {path}/pkgconfig
2633 # to PKG_CONFIG_PATH, so we look for the .pc file there,
2636 save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
2637 if test -n "$dpdk_dir"; then
2638 PKG_CONFIG_PATH="$dpdk_dir:$PKG_CONFIG_PATH"
2640 PKG_CHECK_MODULE(DPDK, libdpdk,
2644 PKG_CONFIG_PATH="$save_PKG_CONFIG_PATH"
2649 if test "$found_dpdk" = yes; then
2653 # We call rte_eth_dev_count_avail(), and older versions
2654 # of DPDK didn't have it, so check for it.
2656 AC_LBL_SAVE_CHECK_STATE
2657 CFLAGS="$CFLAGS $DPDK_CFLAGS"
2658 LIBS="$LIBS $DPDK_LIBS"
2659 AC_CHECK_FUNC(rte_eth_dev_count_avail)
2660 AC_LBL_RESTORE_CHECK_STATE
2663 if test "$ac_cv_func_rte_eth_dev_count_avail" = yes; then
2665 # We found a usable DPDK.
2667 # Check whether the rte_ether.h file defines
2668 # struct ether_addr or struct rte_ether_addr.
2670 # ("API compatibility? That's for losers!")
2672 AC_LBL_SAVE_CHECK_STATE
2673 CFLAGS="$CFLAGS $DPDK_CFLAGS"
2674 LIBS="$LIBS $DPDK_LIBS"
2675 AC_CHECK_TYPES(struct rte_ether_addr,,,
2677 #include <rte_ether.h>
2679 AC_LBL_RESTORE_CHECK_STATE
2682 # We can build with DPDK.
2684 V_INCLS="$V_INCLS $DPDK_CFLAGS"
2685 ADDITIONAL_LIBS="$ADDITIONAL_LIBS $DPDK_LIBS"
2686 ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $DPDK_LIBS_STATIC"
2687 REQUIRES_PRIVATE="$REQUIRES_PRIVATE libdpdk"
2688 AC_DEFINE(PCAP_SUPPORT_DPDK, 1, [target host supports DPDK])
2689 if test $V_PCAP != dpdk ; then
2690 MODULE_C_SRC="$MODULE_C_SRC pcap-dpdk.c"
2694 # We didn't find a usable DPDK.
2695 # If we required it (with --with-dpdk or --with-pcap=dpdk),
2696 # fail with an appropriate message telling the user what
2697 # the problem was, otherwise note the problem with a
2700 if test "$found_dpdk" != yes; then
2702 # Not found with pkg-config. Note that we
2703 # require that DPDK must be findable with
2706 if test "$V_PCAP" = dpdk; then
2708 # User requested DPDK-only capture support.
2711 [DPDK support requested with --with-pcap=dpdk, but
2712 we couldn't find DPDK with pkg-config. Make sure that pkg-config is
2713 installed, that DPDK 18.02.2 or later is installed, and that DPDK
2714 provides a .pc file.])
2717 if test "$want_dpdk" = yes; then
2719 # User requested that libpcap include
2720 # DPDK capture support.
2723 [DPDK support requested with --with-dpdk, but we
2724 couldn't find DPDK with pkg-config. Make sure that pkg-config
2725 is installed, that DPDK 18.02.2 or later is installed, and that
2726 DPDK provides .pc file.])
2730 # User didn't indicate whether they wanted DPDK
2731 # or not; just warn why we didn't find it.
2734 [We couldn't find DPDK with pkg-config. If
2735 you want DPDK support, make sure that pkg-config is installed,
2736 that DPDK 18.02.2 or later is installed, and that DPDK provides a
2738 elif test "$ac_cv_func_rte_eth_dev_count_avail" != yes; then
2740 # Found with pkg-config, but we couldn't compile
2741 # a program that calls rte_eth_dev_count(); we
2742 # probably have the developer package installed,
2743 # but don't have a sufficiently recent version
2744 # of DPDK. Note that we need a sufficiently
2745 # recent version of DPDK.
2747 if test "$V_PCAP" = dpdk; then
2749 # User requested DPDK-only capture support.
2752 [DPDK support requested with --with-pcap=dpdk, but we
2753 can't compile libpcap with DPDK. Make sure that DPDK 18.02.2 or later
2757 if test "$want_dpdk" = yes; then
2759 # User requested that libpcap include
2760 # DPDK capture support.
2763 [DPDK support requested with --with-dpdk, but
2764 we can't compile libpcap with DPDK. Make sure that DPDK 18.02.2
2765 or later is DPDK is installed.])
2769 # User didn't indicate whether they wanted DPDK
2770 # or not; just warn why we didn't find it.
2773 [DPDK was found, but we can't compile libpcap with it.
2774 Make sure that DPDK 18.02.2 or later is installed.])
2778 AC_SUBST(PCAP_SUPPORT_DPDK)
2780 AC_ARG_ENABLE([bluetooth],
2781 [AS_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])],
2783 [enable_bluetooth=ifsupportavailable])
2785 if test "$xxx_only" = yes; then
2786 # User requested something-else-only pcap, so they don't
2787 # want Bluetooth support.
2791 if test "x$enable_bluetooth" != "xno" ; then
2792 dnl check for Bluetooth sniffing support
2795 AC_CHECK_HEADER(bluetooth/bluetooth.h,
2798 # We have bluetooth.h, so we support Bluetooth
2801 AC_DEFINE(PCAP_SUPPORT_BT, 1, [target host supports Bluetooth sniffing])
2802 MODULE_C_SRC="$MODULE_C_SRC pcap-bt-linux.c"
2803 AC_MSG_NOTICE(Bluetooth sniffing is supported)
2804 ac_lbl_bluetooth_available=yes
2807 # OK, does struct sockaddr_hci have an hci_channel
2810 AC_CHECK_MEMBERS([struct sockaddr_hci.hci_channel],
2813 # Yes; is HCI_CHANNEL_MONITOR defined?
2815 AC_MSG_CHECKING(if HCI_CHANNEL_MONITOR is defined)
2816 AC_CACHE_VAL(ac_cv_lbl_hci_channel_monitor_is_defined,
2817 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
2819 #include <bluetooth/bluetooth.h>
2820 #include <bluetooth/hci.h>
2823 int i = HCI_CHANNEL_MONITOR;
2827 AC_DEFINE(PCAP_SUPPORT_BT_MONITOR, 1,
2828 [target host supports Bluetooth Monitor])
2829 MODULE_C_SRC="$MODULE_C_SRC pcap-bt-monitor-linux.c"
2836 #include <bluetooth/bluetooth.h>
2837 #include <bluetooth/hci.h>
2842 # We don't have bluetooth.h, so we don't support
2843 # Bluetooth sniffing.
2845 if test "x$enable_bluetooth" = "xyes" ; then
2846 AC_MSG_ERROR(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
2848 AC_MSG_NOTICE(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
2853 if test "x$enable_bluetooth" = "xyes" ; then
2854 AC_MSG_ERROR(no Bluetooth sniffing support implemented for $host_os)
2856 AC_MSG_NOTICE(no Bluetooth sniffing support implemented for $host_os)
2860 AC_SUBST(PCAP_SUPPORT_BT)
2863 AC_ARG_ENABLE([dbus],
2864 [AS_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=yes, if support available@:>@])],
2866 [enable_dbus=ifavailable])
2868 if test "$xxx_only" = yes; then
2869 # User requested something-else-only pcap, so they don't
2870 # want D-Bus support.
2874 if test "x$enable_dbus" != "xno"; then
2875 if test "x$enable_dbus" = "xyes"; then
2880 # We don't support D-Bus sniffing on macOS; see
2882 # https://bugs.freedesktop.org/show_bug.cgi?id=74029
2884 # The user requested it, so fail.
2886 AC_MSG_ERROR([Due to freedesktop.org bug 74029, D-Bus capture support is not available on macOS])
2893 # We don't support D-Bus sniffing on macOS; see
2895 # https://bugs.freedesktop.org/show_bug.cgi?id=74029
2897 # The user didn't explicitly request it, so just
2898 # silently refuse to enable it.
2906 if test "x$enable_dbus" != "xno"; then
2907 PKG_CHECK_MODULE(DBUS, dbus-1,
2909 AC_LBL_SAVE_CHECK_STATE
2910 CFLAGS="$CFLAGS $DBUS_CFLAGS"
2911 LIBS="$LIBS $DBUS_LIBS"
2912 AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write)
2913 AC_LINK_IFELSE([AC_LANG_PROGRAM(
2914 [[#include <string.h>
2917 #include <sys/time.h>
2919 #include <dbus/dbus.h>]],
2920 [[return dbus_connection_read_write(NULL, 0);]])],
2922 AC_MSG_RESULT([yes])
2923 AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing])
2924 MODULE_C_SRC="$MODULE_C_SRC pcap-dbus.c"
2925 V_INCLS="$V_INCLS $DBUS_CFLAGS"
2926 ADDITIONAL_LIBS="$ADDITIONAL_LIBS $DBUS_LIBS"
2927 ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $DBUS_LIBS_STATIC"
2928 REQUIRES_PRIVATE="$REQUIRES_PRIVATE dbus-1"
2932 if test "x$enable_dbus" = "xyes"; then
2933 AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()])
2936 AC_LBL_RESTORE_CHECK_STATE
2939 if test "x$enable_dbus" = "xyes"; then
2940 AC_MSG_ERROR([--enable-dbus was given, but the dbus-1 package is not installed])
2943 AC_SUBST(PCAP_SUPPORT_DBUS)
2946 AC_ARG_ENABLE([rdma],
2947 [AS_HELP_STRING([--enable-rdma],[enable RDMA capture support @<:@default=yes, if support available@:>@])],
2949 [enable_rdma=ifavailable])
2951 if test "$xxx_only" = yes; then
2952 # User requested something-else-only pcap, so they don't
2953 # want RDMA support.
2957 if test "x$enable_rdma" != "xno"; then
2958 PKG_CHECK_MODULE(LIBIBVERBS, libibverbs,
2960 found_libibverbs=yes
2961 LIBIBVERBS_REQUIRES_PRIVATE="libibverbs"
2964 if test "x$found_libibverbs" != "xyes"; then
2965 AC_CHECK_LIB(ibverbs, ibv_get_device_list,
2967 found_libibverbs=yes
2968 LIBIBVERBS_CFLAGS=""
2969 LIBIBVERBS_LIBS="-libverbs"
2970 # XXX - at least on Ubuntu 20.04, there are many more
2971 # libraries needed; is there any platform where
2972 # libibverbs is available but where pkg-config isn't
2973 # available or libibverbs doesn't use it? If not,
2974 # we should only use pkg-config for it.
2975 LIBIBVERBS_LIBS_STATIC="-libverbs"
2976 LIBIBVERBS_LIBS_PRIVATE="-libverbs"
2981 if test "x$found_libibverbs" = "xyes"; then
2982 AC_LBL_SAVE_CHECK_STATE
2983 CFLAGS="$CFLAGS $LIBIBVERBS_CFLAGS"
2984 LIBS="$LIBS $LIBIBVERBS_LIBS"
2985 AC_CHECK_HEADER(infiniband/verbs.h, [
2987 # ibv_create_flow may be defined as a static inline
2988 # function in infiniband/verbs.h, so we can't
2991 # Too bad autoconf has no AC_SYMBOL_EXISTS()
2992 # macro that works like CMake's check_symbol_exists()
2993 # function, to check do a compile check like
2994 # this (they do a clever trick to avoid having
2995 # to know the function's signature).
2997 AC_MSG_CHECKING(whether libibverbs defines ibv_create_flow)
2998 AC_LINK_IFELSE([AC_LANG_PROGRAM(
3000 #include <infiniband/verbs.h>
3003 (void) ibv_create_flow((struct ibv_qp *) NULL,
3004 (struct ibv_flow_attr *) NULL);
3007 AC_MSG_RESULT([yes])
3008 found_usable_libibverbs=yes
3015 AC_LBL_RESTORE_CHECK_STATE
3018 if test "x$found_usable_libibverbs" = "xyes"
3020 AC_DEFINE(PCAP_SUPPORT_RDMASNIFF, 1, [target host supports RDMA sniffing])
3021 MODULE_C_SRC="$MODULE_C_SRC pcap-rdmasniff.c"
3022 CFLAGS="$LIBIBVERBS_CFLAGS $CFLAGS"
3023 ADDITIONAL_LIBS="$LIBIBVERBS_LIBS $ADDITIONAL_LIBS"
3024 ADDITIONAL_LIBS_STATIC="$LIBIBVERBS_LIBS_STATIC $ADDITIONAL_LIBS_STATIC"
3025 LIBS_PRIVATE="$LIBIBVERBS_LIBS_PRIVATE $LIBS_PRIVATE"
3026 REQUIRES_PRIVATE="$REQUIRES_PRIVATE $LIBIBVERBS_REQUIRES_PRIVATE"
3028 AC_SUBST(PCAP_SUPPORT_RDMASNIFF)
3032 # If this is a platform where we need to have the .pc file and
3033 # pcap-config script supply an rpath option to specify the directory
3034 # in which the libpcap shared library is installed, and the install
3035 # prefix /usr (meaning we're not installing a system library), provide
3038 # (We must check $prefix, as $libdir isn't necessarily /usr/lib in this
3039 # case - for example, Linux distributions for 64-bit platforms that
3040 # also provide support for binaries for a 32-bit version of the
3041 # platform may put the 64-bit libraries, the 32-bit libraries, or both
3042 # in directories other than /usr/lib.)
3044 # In AIX, do we have to do this?
3046 # In Darwin-based OSes, the full paths of the shared libraries with
3047 # which the program was linked are stored in the executable, so we don't
3048 # need to provide an rpath option.
3050 # With the HP-UX linker, directories specified with -L are, by default,
3051 # added to the run-time search path, so we don't need to supply them.
3053 # This must *not* depend on the compiler, as, on platforms where there's
3054 # a GCC-compatible compiler and a vendor compiler, we need to work with
3057 if test "$prefix" != "/usr"; then
3060 freebsd*|netbsd*|openbsd*|dragonfly*|linux*|haiku*|midipix*|gnu*)
3062 # Platforms where the "native" C compiler is GCC or
3063 # accepts compatible command-line arguments, and the
3064 # "native" linker is the GNU linker or accepts
3065 # compatible command-line arguments.
3067 RPATH="-Wl,-rpath,\${libdir}"
3072 # Sun/Oracle's linker, the GNU linker, and
3073 # GNU-compatible linkers all support -R.
3075 RPATH="-Wl,-R,\${libdir}"
3082 AC_CONFIG_HEADERS([config.h])
3084 AC_SUBST(V_SHLIB_CCOPT)
3085 AC_SUBST(V_SHLIB_CMD)
3086 AC_SUBST(V_SHLIB_OPT)
3087 AC_SUBST(V_SONAME_OPT)
3090 AC_SUBST(ADDLARCHIVEOBJS)
3091 AC_SUBST(PLATFORM_C_SRC)
3092 AC_SUBST(MODULE_C_SRC)
3093 AC_SUBST(REMOTE_C_SRC)
3094 AC_SUBST(PTHREAD_LIBS)
3095 AC_SUBST(BUILD_RPCAPD)
3096 AC_SUBST(INSTALL_RPCAPD)
3097 AC_SUBST(RPCAPD_LIBS)
3100 # We're done with configuration operations; add ADDITIONAL_LIBS and
3101 # ADDITIONAL_LIBS_STATIC to LIBS and LIBS_STATIC, respectively.
3103 LIBS="$ADDITIONAL_LIBS $LIBS"
3104 LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $LIBS_STATIC"
3106 AC_CONFIG_COMMANDS([.devel],[[if test -f .devel; then
3107 echo timestamp > stamp-h
3108 cat $srcdir/Makefile-devel-adds >> Makefile
3109 make depend || exit 1
3111 AC_CONFIG_FILES([Makefile grammar.y pcap-filter.manmisc pcap-linktype.manmisc
3112 pcap-tstamp.manmisc cbpf-savefile.manfile pcap-savefile.manfile pcap.3pcap
3113 pcap_compile.3pcap pcap_datalink.3pcap pcap_dump_open.3pcap
3114 pcap_get_tstamp_precision.3pcap pcap_list_datalinks.3pcap
3115 pcap_list_tstamp_types.3pcap pcap_open_dead.3pcap
3116 pcap_open_offline.3pcap pcap_set_immediate_mode.3pcap
3117 pcap_set_tstamp_precision.3pcap pcap_set_tstamp_type.3pcap
3118 rpcapd/Makefile rpcapd/rpcapd.manadmin rpcapd/rpcapd-config.manfile
3119 testprogs/Makefile])