1 dnl Copyright (c) 1994, 1995, 1996, 1997
2 dnl The Regents of the University of California. All rights reserved.
4 dnl Process this file with autoconf to produce a configure script.
10 # https://ftp.gnu.org/gnu/config/README
12 # for the URLs to use to fetch new versions of config.guess and
17 AC_INIT([tcpdump],[m4_esyscmd_s(cat VERSION)])
18 AC_CONFIG_SRCDIR(tcpdump.c)
22 AC_LBL_C_INIT_BEFORE_CC(V_INCLS)
24 # Try to enable as many C99 features as we can.
25 # At minimum, we want C++/C99-style // comments.
28 if test "$ac_cv_prog_cc_c99" = "no"; then
29 AC_MSG_WARN([The C compiler does not support C99; there may be compiler errors])
31 AC_LBL_C_INIT(V_CCOPT, V_INCLS)
34 AC_CHECK_HEADERS(rpc/rpc.h rpc/rpcent.h net/if.h)
36 # On Linux, if Autoconf version >= 2.72 and GNU C Library version >= 2.34,
37 # uncomment AC_SYS_YEAR2038_RECOMMENDED to ensure time_t is Y2038-safe.
38 # (Can be done by autogen.sh)
39 # AC_SYS_YEAR2038_RECOMMENDED
41 # Get the size of a void *, to know whether this is a 32-bit or 64-bit build.
43 AC_CHECK_SIZEOF([void *])
46 # Get the size of a time_t, to know whether it's 32-bit or 64-bit.
48 AC_CHECK_SIZEOF([time_t],,[#include <time.h>])
53 AC_ARG_ENABLE(universal,
54 AS_HELP_STRING([--disable-universal],[don't build universal on macOS]))
55 if test "$enable_universal" != "no"; then
60 # Leopard. Build for x86 and 32-bit PowerPC, with
61 # x86 first. (That's what Apple does.)
63 V_CCOPT="$V_CCOPT -arch i386 -arch ppc"
64 LDFLAGS="$LDFLAGS -arch i386 -arch ppc"
69 # Snow Leopard. Build for x86-64 and x86, with
70 # x86-64 first. (That's what Apple does.)
72 V_CCOPT="$V_CCOPT -arch x86_64 -arch i386"
73 LDFLAGS="$LDFLAGS -arch x86_64 -arch i386"
81 # Do we have pkg-config?
86 # Do we have the brew command from Homebrew?
88 AC_PATH_PROG([BREW], [brew])
91 [AS_HELP_STRING([--with-smi],
92 [link with libsmi (allows to load MIBs on the fly to decode SNMP packets) [default=yes, if available]])],
96 if test "x$with_smi" != "xno" ; then
97 AC_CHECK_HEADER(smi.h,
100 # OK, we found smi.h. Do we have libsmi with smiInit?
102 AC_CHECK_LIB(smi, smiInit,
105 # OK, we have libsmi with smiInit. Can we use it?
107 AC_MSG_CHECKING([whether to enable libsmi])
110 AC_RUN_IFELSE([AC_LANG_SOURCE([[
111 /* libsmi available check */
118 int current, revision, age, n;
119 const int required = 2;
122 if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
124 n = sscanf(smi_library_version, "%d:%d:%d", ¤t, &revision, &age);
127 if (required < current - age || required > current)
135 AC_DEFINE(USE_LIBSMI, 1,
136 [Define if you enable support for libsmi])
139 dnl autoconf documentation says that
140 dnl $? contains the exit value.
141 dnl reality is that it does not.
142 dnl We leave this in just in case
143 dnl autoconf ever comes back to
144 dnl match the documentation.
146 1) AC_MSG_RESULT(no - smiInit failed) ;;
147 2) AC_MSG_RESULT(no - header/library version mismatch) ;;
148 3) AC_MSG_RESULT(no - can't determine library version) ;;
149 4) AC_MSG_RESULT(no - too old) ;;
150 *) AC_MSG_RESULT(no) ;;
155 AC_MSG_RESULT(not when cross-compiling)
163 AC_MSG_CHECKING([whether to enable the instrument functions code])
164 AC_ARG_ENABLE([instrument-functions],
165 [AS_HELP_STRING([--enable-instrument-functions],
166 [enable instrument functions code [default=no]])],
170 yes) AC_MSG_RESULT(yes)
171 AC_CHECK_LIB([bfd], [bfd_init],
174 [--enable-instrument-functions was given, but test for library libbfd failed. Please install the 'binutils-dev' package.])],
176 AC_DEFINE(ENABLE_INSTRUMENT_FUNCTIONS, 1,
177 [define if you want to build the instrument functions code])
178 LOCALSRC="$LOCALSRC instrument-functions.c"
179 # Add '-finstrument-functions' instrumentation option to generate
180 # instrumentation calls for entry and exit to functions.
181 # Try to avoid Address Space Layout Randomization (ALSR).
182 CFLAGS="$CFLAGS -O0 -ggdb -finstrument-functions -fno-stack-protector -fno-pic"
183 LDFLAGS="$LDFLAGS -O0 -ggdb -fno-stack-protector -no-pie"
190 AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer])
192 [AS_HELP_STRING([--enable-smb],
193 [enable possibly-buggy SMB printer [default=no]])],
197 yes) AC_MSG_RESULT(yes)
198 AC_DEFINE(ENABLE_SMB, 1,
199 [define if you want to build the possibly-buggy SMB printer])
200 LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
206 AC_MSG_CHECKING([whether to drop root privileges by default])
209 [AS_HELP_STRING([--with-user=USERNAME],
210 [drop privileges by default to USERNAME]
214 AS_CASE(["$withval"],
215 [no], [AC_MSG_RESULT(no)],
216 [''|yes], [AC_MSG_ERROR([--with-user requires a username])],
218 AC_DEFINE_UNQUOTED(WITH_USER, "$withval",
219 [define if should drop privileges by default])
220 AC_MSG_RESULT([yes, to user "$withval"])
224 AC_MSG_CHECKING([whether to chroot])
227 [AS_HELP_STRING([--with-chroot=DIRECTORY],
228 [when dropping privileges, chroot to DIRECTORY]
233 AS_CASE(["$withval"],
234 [no], [AC_MSG_RESULT(no)],
235 [''|yes], [AC_MSG_ERROR([--with-chroot requires a directory])],
237 AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval",
238 [define if should chroot when dropping privileges])
239 AC_MSG_RESULT([yes, to directory "$withval"])
243 AC_ARG_WITH(sandbox-capsicum,
244 AS_HELP_STRING([--with-sandbox-capsicum],
245 [use Capsicum security functions @<:@default=yes, if available@:>@]))
247 # Check whether various functions are available. If any are, set
248 # ac_lbl_capsicum_function_seen to yes; if any are not, set
249 # ac_lbl_capsicum_function_not_seen to yes.
251 # We don't check cap_rights_init(), as it's a macro, wrapping another
252 # function, in at least some versions of FreeBSD, and AC_CHECK_FUNCS()
253 # doesn't handle that.
255 # All of the ones we check for must be available in order to enable
256 # capsicum sandboxing.
258 # XXX - do we need to check for all of them, or are there some that, if
259 # present, imply others are present?
261 if test -z "$with_sandbox_capsicum" || test "$with_sandbox_capsicum" != "no" ; then
263 # First, make sure we have the required header.
265 AC_CHECK_HEADER(sys/capsicum.h,
268 # We do; now make sure we have the required functions.
270 AC_CHECK_FUNCS(cap_enter cap_rights_limit cap_ioctls_limit openat,
271 ac_lbl_capsicum_function_seen=yes,
272 ac_lbl_capsicum_function_not_seen=yes)
274 AC_CHECK_LIB(casper, cap_init, LIBS="$LIBS -lcasper")
275 AC_CHECK_LIB(cap_dns, cap_gethostbyaddr, LIBS="$LIBS -lcap_dns")
277 AC_MSG_CHECKING([whether to sandbox using capsicum])
278 if test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then
279 AC_DEFINE(HAVE_CAPSICUM, 1, [capsicum support available])
284 AC_MSG_CHECKING([whether to sandbox using Casper library])
285 if test "x$ac_cv_lib_casper_cap_init" = "xyes" -a "x$ac_cv_lib_cap_dns_cap_gethostbyaddr" = "xyes"; then
286 AC_DEFINE(HAVE_CASPER, 1, [Casper support available])
293 # We must check this before checking whether to check the OS's IPv6,
294 # support because, on some platforms (such as SunOS 5.x), the test
295 # program requires the extra networking libraries.
300 # Check whether AF_INET6 and struct in6_addr are defined.
301 # If they aren't both defined, we don't have sufficient OS
302 # support for IPv6, so we don't look for IPv6 support libraries,
303 # and we define AF_INET6 and struct in6_addr ourselves.
305 AC_MSG_CHECKING([whether the operating system supports IPv6])
311 /* AF_INET6 available check */
312 #include <sys/types.h>
314 #include <ws2tcpip.h>
316 #include <sys/socket.h>
317 #include <netinet/in.h>
321 foo(struct in6_addr *addr)
323 memset(addr, 0, sizeof (struct in6_addr));
326 #error "AF_INET6 not defined"
332 AC_DEFINE(HAVE_OS_IPV6_SUPPORT, 1,
333 [define if the OS provides AF_INET6 and struct in6_addr])
346 if test "$ipv6" = "yes"; then
347 AC_MSG_CHECKING([ipv6 stack type])
348 for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do
351 dnl http://www.kame.net/
353 [#include <netinet/in.h>
354 #ifdef IPV6_INRIA_VERSION
360 dnl http://www.kame.net/
362 [#include <netinet/in.h>
368 ipv6libdir=/usr/local/v6/lib;
372 dnl http://www.v6.linux.or.jp/
374 [#include <features.h>
375 #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
381 dnl http://www.v6.linux.or.jp/
383 dnl This also matches Solaris 8 and Tru64 UNIX 5.1,
384 dnl and possibly other versions of those OSes
386 if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then
389 ipv6libdir=/usr/inet6/lib
391 CFLAGS="-I/usr/inet6/include $CFLAGS"
396 [#include <sys/param.h>
397 #ifdef _TOSHIBA_INET6
402 ipv6libdir=/usr/local/v6/lib])
406 [#include </usr/local/v6/include/sys/v6config.h>
412 ipv6libdir=/usr/local/v6/lib;
413 CFLAGS="-I/usr/local/v6/include $CFLAGS"])
417 [#include <sys/param.h>
418 #ifdef _ZETA_MINAMI_INET6
423 ipv6libdir=/usr/local/v6/lib])
426 if test "$ipv6type" != "unknown"; then
430 AC_MSG_RESULT($ipv6type)
433 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
434 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
435 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
436 echo "You have $ipv6lib library, using it"
438 if test "$ipv6trylibc" = "yes"; then
439 echo "You do not have $ipv6lib library, using libc"
441 echo 'Fatal: no $ipv6lib library found. cannot continue.'
442 echo "You need to fetch lib$ipv6lib.a from appropriate"
443 echo 'ipv6 kit and compile beforehand.'
449 AC_REPLACE_FUNCS(strlcat strlcpy strdup strsep getservent getopt_long)
450 AC_CHECK_FUNCS(fork vfork)
451 AC_CHECK_FUNCS(setlinebuf)
454 # It became apparent at some point that using a suitable C99 compiler does not
455 # automatically mean snprintf(3) implementation in the libc supports all the
456 # modifiers and specifiers used in the project, so let's test that before the
459 # Testing the sizeof_t length modifier takes making an snprintf() call and
460 # comparing the actual result with the expected result. If this fails, it will
461 # most likely happen at run time, not compile time.
463 # Testing the 64-bit conversion specifiers in addition to that requires the
464 # <inttypes.h> header to be present and the macros to be defined, so if this
465 # fails, it will more likely happen at compile time.
467 AC_MSG_CHECKING([whether snprintf is suitable])
473 #include <inttypes.h>
474 #include <sys/types.h>
476 #if defined(_WIN32) && !defined(_SSIZE_T_DEFINED)
478 * On UN*Xes, this is a signed integer type of the same size as size_t.
480 * It's not defined by Visual Studio; we assume that ptrdiff_t will
481 * be a type that is a signed integer type of the same size as size_t.
483 typedef ptrdiff_t ssize_t;
487 * Avoid trying to cast negative values to unsigned types, or doing
488 * shifts of signed types, in order not to have the test program fail
489 * if we're building with undefined-behavior sanitizers enabled.
494 unsigned int ui = sizeof(buf);
496 int64_t i64 = INT64_C(0x100000000);
497 uint64_t ui64 = UINT64_C(0x100000000);
499 snprintf(buf, sizeof(buf), "%zu", (size_t)ui);
500 if (strncmp(buf, "100", sizeof(buf)))
503 snprintf(buf, sizeof(buf), "%zd", (ssize_t)(-i));
504 if (strncmp(buf, "-100", sizeof(buf)))
507 snprintf(buf, sizeof(buf), "%" PRId64, -i64);
508 if (strncmp(buf, "-4294967296", sizeof(buf)))
511 snprintf(buf, sizeof(buf), "0o%" PRIo64, ui64);
512 if (strncmp(buf, "0o40000000000", sizeof(buf)))
515 snprintf(buf, sizeof(buf), "0x%" PRIx64, ui64);
516 if (strncmp(buf, "0x100000000", sizeof(buf)))
519 snprintf(buf, sizeof(buf), "%" PRIu64, ui64);
520 if (strncmp(buf, "4294967296", sizeof(buf)))
533 [The snprintf(3) implementation in this libc is not suitable,
534 tcpdump would not work correctly even if it managed to compile.])
537 AC_MSG_RESULT(not while cross-compiling)
541 AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc
543 dnl Some platforms may need -lnsl for getrpcbynumber.
544 AC_SEARCH_LIBS(getrpcbynumber, nsl,
545 AC_DEFINE(HAVE_GETRPCBYNUMBER, 1, [define if you have getrpcbynumber()]))
547 AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
550 # Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
551 # libraries (e.g., "-lsocket -lnsl" on Solaris).
553 # You are in a twisty little maze of UN*Xes, all different.
554 # Some might not have ether_ntohost().
555 # Some might have it and declare it in <net/ethernet.h>.
556 # Some might have it and declare it in <netinet/ether.h>
557 # Some might have it and declare it in <sys/ethernet.h>.
558 # Some might have it and declare it in <arpa/inet.h>.
559 # Some might have it and declare it in <netinet/if_ether.h>.
560 # Some might have it and not declare it in any header file.
562 # Before you is a C compiler.
564 AC_CHECK_FUNCS(ether_ntohost, [
565 AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [
566 AC_RUN_IFELSE([AC_LANG_SOURCE([[
568 #include <netinet/ether.h>
570 #include <sys/types.h>
571 #include <sys/param.h>
572 #include <sys/socket.h>
575 main(int argc, char **argv)
577 u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff };
578 char name[MAXHOSTNAMELEN];
580 ether_ntohost(name, (struct ether_addr *)ea);
584 ], [ac_cv_buggy_ether_ntohost=no],
585 [ac_cv_buggy_ether_ntohost=yes],
586 [ac_cv_buggy_ether_ntohost="not while cross-compiling"])])
587 if test "$ac_cv_buggy_ether_ntohost" = "no"; then
588 AC_DEFINE(USE_ETHER_NTOHOST, 1,
589 [define if you have ether_ntohost() and it works])
592 if test "$ac_cv_func_ether_ntohost" = yes -a \
593 "$ac_cv_buggy_ether_ntohost" = "no"; then
595 # OK, we have ether_ntohost(). Is it declared in <net/ethernet.h>?
597 # This test fails if we don't have <net/ethernet.h> or if we do
598 # but it doesn't declare ether_ntohost().
600 AC_CHECK_DECL(ether_ntohost,
602 AC_DEFINE(NET_ETHERNET_H_DECLARES_ETHER_NTOHOST,,
603 [Define to 1 if net/ethernet.h declares `ether_ntohost'])
606 #include <net/ethernet.h>
611 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
613 # No, how about <netinet/ether.h>, as on Linux?
615 # This test fails if we don't have <netinet/ether.h>
616 # or if we do but it doesn't declare ether_ntohost().
618 # Unset ac_cv_have_decl_ether_ntohost so we don't
619 # treat the previous failure as a cached value and
620 # suppress the next test.
622 unset ac_cv_have_decl_ether_ntohost
623 AC_CHECK_DECL(ether_ntohost,
625 AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,1,
626 [Define to 1 if netinet/ether.h declares `ether_ntohost'])
629 #include <netinet/ether.h>
635 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
637 # No, how about <sys/ethernet.h>, as on Solaris 10
640 # This test fails if we don't have <sys/ethernet.h>
641 # or if we do but it doesn't declare ether_ntohost().
643 # Unset ac_cv_have_decl_ether_ntohost so we don't
644 # treat the previous failure as a cached value and
645 # suppress the next test.
647 unset ac_cv_have_decl_ether_ntohost
648 AC_CHECK_DECL(ether_ntohost,
650 AC_DEFINE(SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST,,
651 [Define to 1 if sys/ethernet.h declares `ether_ntohost'])
654 #include <sys/ethernet.h>
660 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
662 # No, how about <arpa/inet.h>, as in AIX?
664 # This test fails if we don't have <arpa/inet.h>
665 # (if we have ether_ntohost(), we should have
666 # networking, and if we have networking, we should
667 # have <arpa/inet.h>) or if we do but it doesn't
668 # declare ether_ntohost().
670 # Unset ac_cv_have_decl_ether_ntohost so we don't
671 # treat the previous failure as a cached value and
672 # suppress the next test.
674 unset ac_cv_have_decl_ether_ntohost
675 AC_CHECK_DECL(ether_ntohost,
677 AC_DEFINE(ARPA_INET_H_DECLARES_ETHER_NTOHOST,,
678 [Define to 1 if arpa/inet.h declares `ether_ntohost'])
681 #include <arpa/inet.h>
687 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
689 # No, how about <netinet/if_ether.h>?
690 # On some platforms, it requires <net/if.h> and
691 # <netinet/in.h>, and we always include it with
692 # both of them, so test it with both of them.
694 # This test fails if we don't have <netinet/if_ether.h>
695 # and the headers we include before it, or if we do but
696 # <netinet/if_ether.h> doesn't declare ether_hostton().
698 # Unset ac_cv_have_decl_ether_ntohost so we don't
699 # treat the previous failure as a cached value and
700 # suppress the next test.
702 unset ac_cv_have_decl_ether_ntohost
703 AC_CHECK_DECL(ether_ntohost,
705 AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST,,
706 [Define to 1 if netinet/if_ether.h declares `ether_ntohost'])
709 #include <sys/types.h>
710 #include <sys/socket.h>
712 #include <netinet/in.h>
713 #include <netinet/if_ether.h>
717 # After all that, is ether_ntohost() declared?
719 if test "$ac_cv_have_decl_ether_ntohost" = yes; then
723 AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 1,
724 [Define to 1 if you have the declaration of `ether_ntohost'])
727 # No, we'll have to declare it ourselves.
728 # Do we have "struct ether_addr" if we include
729 # <netinet/if_ether.h>?
731 AC_CHECK_TYPES(struct ether_addr,,,
733 #include <sys/types.h>
734 #include <sys/socket.h>
736 #include <netinet/in.h>
737 #include <netinet/if_ether.h>
743 dnl Check for "pcap_list_datalinks()" and use a substitute version if
744 dnl it's not present. If it is present, check for "pcap_free_datalinks()";
745 dnl if it's not present, we don't replace it for now. (We could do so
746 dnl on UN*X, but not on Windows, where hilarity ensues if a program
747 dnl built with one version of the MSVC support library tries to free
748 dnl something allocated by a library built with another version of
749 dnl the MSVC support library.)
751 AC_CHECK_FUNC(pcap_list_datalinks,
753 AC_DEFINE(HAVE_PCAP_LIST_DATALINKS, 1,
754 [define if libpcap has pcap_list_datalinks()])
755 AC_CHECK_FUNCS(pcap_free_datalinks)
762 dnl Check for "pcap_datalink_name_to_val()", and use a substitute
763 dnl version if it's not present. If it is present, check for
764 dnl "pcap_datalink_val_to_description()", and if we don't have it,
765 dnl use a substitute version.
767 AC_CHECK_FUNC(pcap_datalink_name_to_val,
769 AC_DEFINE(HAVE_PCAP_DATALINK_NAME_TO_VAL, 1,
770 [define if libpcap has pcap_datalink_name_to_val()])
771 AC_CHECK_FUNC(pcap_datalink_val_to_description,
772 AC_DEFINE(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION, 1,
773 [define if libpcap has pcap_datalink_val_to_description()]),
783 dnl Check for "pcap_set_datalink()"; you can't substitute for it if
784 dnl it's absent (it has hooks into libpcap), so just define the
785 dnl HAVE_ value if it's there.
787 AC_CHECK_FUNCS(pcap_set_datalink)
790 dnl Check for "pcap_breakloop()"; you can't substitute for it if
791 dnl it's absent (it has hooks into the live capture routines),
792 dnl so just define the HAVE_ value if it's there.
794 AC_CHECK_FUNCS(pcap_breakloop)
797 # Do we have the new open API? Check for pcap_create, and assume that,
798 # if we do, we also have pcap_activate() and the other new routines
799 # introduced in libpcap 1.0.0.
801 AC_CHECK_FUNCS(pcap_create)
802 if test $ac_cv_func_pcap_create = "yes" ; then
804 # OK, do we have pcap_set_tstamp_type? If so, assume we have
805 # pcap_list_tstamp_types and pcap_free_tstamp_types as well.
807 AC_CHECK_FUNCS(pcap_set_tstamp_type)
809 # And do we have pcap_set_tstamp_precision? If so, we assume
810 # we also have pcap_open_offline_with_tstamp_precision.
812 AC_CHECK_FUNCS(pcap_set_tstamp_precision)
816 # Check for a miscellaneous collection of functions which we use
819 AC_CHECK_FUNCS(pcap_findalldevs)
820 AC_CHECK_FUNCS(pcap_dump_flush pcap_lib_version)
821 if test $ac_cv_func_pcap_lib_version = "no" ; then
822 AC_MSG_CHECKING(whether pcap_version is defined by libpcap)
823 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
824 extern char pcap_version[];
826 return (int)pcap_version;
829 [ac_lbl_cv_pcap_version_defined=yes],
830 [ac_lbl_cv_pcap_version_defined=no])
831 if test "$ac_lbl_cv_pcap_version_defined" = yes ; then
833 AC_DEFINE(HAVE_PCAP_VERSION, 1, [define if libpcap has pcap_version])
838 AC_CHECK_FUNCS(pcap_setdirection pcap_set_immediate_mode pcap_dump_ftell64)
840 # See the comment in AC_LBL_LIBPCAP in aclocal.m4 for the reason
841 # why we don't check for remote-capture APIs if we're building
842 # with the system libpcap on macOS.
844 if test "$_dont_check_for_remote_apis" != "yes"; then
845 AC_CHECK_FUNCS(pcap_open pcap_findalldevs_ex)
847 AC_REPLACE_FUNCS(pcap_dump_ftell)
850 # Check for special debugging functions
852 AC_CHECK_FUNCS(pcap_set_parser_debug)
853 if test "$ac_cv_func_pcap_set_parser_debug" = "no" ; then
855 # OK, we don't have pcap_set_parser_debug() to set the libpcap
856 # filter expression parser debug flag; can we directly set the
858 AC_MSG_CHECKING(whether pcap_debug is defined by libpcap)
859 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
860 extern int pcap_debug;
865 [ac_lbl_cv_pcap_debug_defined=yes],
866 [ac_lbl_cv_pcap_debug_defined=no])
867 if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
869 AC_DEFINE(HAVE_PCAP_DEBUG, 1, [define if libpcap has pcap_debug])
873 # OK, what about "yydebug"?
875 AC_MSG_CHECKING(whether yydebug is defined by libpcap)
876 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
882 [ac_lbl_cv_yydebug_defined=yes],
883 [ac_lbl_cv_yydebug_defined=no])
884 if test "$ac_lbl_cv_yydebug_defined" = yes ; then
886 AC_DEFINE(HAVE_YYDEBUG, 1, [define if libpcap has yydebug])
892 AC_CHECK_FUNCS(pcap_set_optimizer_debug)
893 AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6
896 # Assume V7/BSD convention for man pages (file formats in section 5,
897 # miscellaneous info in section 7).
904 dnl Workaround to enable certain features
905 AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
910 # Use System V conventions for man pages.
920 # Use System V conventions for man pages.
930 # Use System V conventions for man pages.
938 # Use System V conventions for man pages.
946 # Make sure we have a definition for C99's uintptr_t (regardless of
947 # whether the environment is a C99 environment or not).
951 savedcppflags="$CPPFLAGS"
952 CPPFLAGS="$CPPFLAGS $V_INCLS"
955 # Check whether we have pcap/pcap-inttypes.h.
956 # If we do, we use that to get the C99 types defined.
958 AC_CHECK_HEADERS(pcap/pcap-inttypes.h)
961 # At compile time HAVE_PCAP_FINDALLDEVS depends on HAVE_PCAP_IF_T.
963 AC_CHECK_TYPES(pcap_if_t, , , [#include <pcap.h>])
965 CPPFLAGS="$savedcppflags"
968 # Define the old BSD specified-width types in terms of the C99 types;
969 # we may need them with libpcap include files.
971 AC_CHECK_TYPE([u_int8_t], ,
972 [AC_DEFINE([u_int8_t], [uint8_t],
973 [Define to `uint8_t' if u_int8_t not defined.])],
975 #include <sys/types.h>
977 AC_CHECK_TYPE([u_int16_t], ,
978 [AC_DEFINE([u_int16_t], [uint16_t],
979 [Define to `uint16_t' if u_int16_t not defined.])],
981 #include <sys/types.h>
983 AC_CHECK_TYPE([u_int32_t], ,
984 [AC_DEFINE([u_int32_t], [uint32_t],
985 [Define to `uint32_t' if u_int32_t not defined.])],
987 #include <sys/types.h>
989 AC_CHECK_TYPE([u_int64_t], ,
990 [AC_DEFINE([u_int64_t], [uint64_t],
991 [Define to `uint64_t' if u_int64_t not defined.])],
993 #include <sys/types.h>
997 AC_CHECK_TOOL([AR], [ar])
999 AC_LBL_DEVEL(V_CCOPT)
1001 # Check for OpenSSL/libressl libcrypto
1002 AC_MSG_CHECKING(whether to use OpenSSL/libressl libcrypto)
1003 # Specify location for both includes and libraries.
1004 want_libcrypto=ifavailable
1006 AS_HELP_STRING([--with-crypto]@<:@=DIR@:>@,
1007 [use OpenSSL/libressl libcrypto (located in directory DIR, if specified) @<:@default=yes, if available@:>@]),
1009 if test $withval = no
1011 # User doesn't want to link with libcrypto.
1014 elif test $withval = yes
1016 # User wants to link with libcrypto but hasn't specified
1021 # User wants to link with libcrypto and has specified
1022 # a directory, so use the provided value.
1024 libcrypto_root=$withval
1025 AC_MSG_RESULT([yes, using the version installed in $withval])
1029 # Use libcrypto if it's present, otherwise don't; no directory
1032 want_libcrypto=ifavailable
1033 AC_MSG_RESULT([yes, if available])
1035 if test "$want_libcrypto" != "no"; then
1037 # Were we told where to look for libcrypto?
1039 if test -z "$libcrypto_root"; then
1043 # First, try looking for it with pkg-config, if we have it.
1045 # Homebrew's pkg-config does not, by default, look for
1046 # pkg-config files for packages it has installed.
1047 # Furthermore, at least for OpenSSL, they appear to be
1048 # dumped in package-specific directories whose paths are
1049 # not only package-specific but package-version-specific.
1051 # So the only way to find openssl is to get the value of
1052 # PKG_CONFIG_PATH from "brew --env openssl" and add that
1053 # to PKG_CONFIG_PATH. (No, we can't just assume it's under
1054 # /usr/local; Homebrew have conveniently chosen to put it
1055 # under /opt/homebrew on ARM.)
1057 # That's the nice thing about Homebrew - it makes things easier!
1060 save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
1061 if test -n "$BREW"; then
1062 openssl_pkgconfig_dir=`$BREW --env --plain openssl | sed -n 's/PKG_CONFIG_PATH: //p'`
1063 PKG_CONFIG_PATH="$openssl_pkgconfig_dir:$PKG_CONFIG_PATH"
1065 PKG_CHECK_MODULE(LIBCRYPTO, libcrypto,
1068 # We found OpenSSL/libressl libcrypto.
1072 PKG_CONFIG_PATH="$save_PKG_CONFIG_PATH"
1075 # If it wasn't found, and we have Homebrew installed, see
1076 # if it's in Homebrew.
1078 if test "x$HAVE_LIBCRYPTO" != "xyes" -a -n "$BREW"; then
1079 AC_MSG_CHECKING(for openssl in Homebrew)
1081 # The brew man page lies when it speaks of
1082 # $BREW --prefix --installed <formula>
1083 # outputting nothing. In Homebrew 3.3.16,
1084 # it produces output regardless of whether
1085 # the formula is installed or not, so we
1086 # send the standard output and error to
1089 # libcrypto isn't a formula, openssl is a formula.
1091 if $BREW --prefix --installed openssl >/dev/null 2>&1; then
1093 # Yes. Get the include directory and library
1094 # directory. (No, we can't just assume it's
1095 # under /usr/local; Homebrew have conveniently
1096 # chosen to put it under /opt/homebrew on ARM.)
1100 openssl_path=`$BREW --prefix openssl`
1101 LIBCRYPTO_CFLAGS="-I$openssl_path/include"
1102 LIBCRYPTO_LIBS="-L$openssl_path/lib -lcrypto"
1109 # If it wasn't found, and /usr/local/include and /usr/local/lib
1110 # exist, check if it's in /usr/local. (We check whether they
1111 # exist because, if they don't exist, the compiler will warn
1112 # about that and then ignore the argument, so they test
1113 # using just the system header files and libraries.)
1115 # We include the standard include file to 1) make sure that
1116 # it's installed (if it's just a shared library for the
1117 # benefit of existing programs, that's not useful) and 2)
1118 # because SSL_library_init() is a library routine in some
1119 # versions and a #defined wrapper around OPENSSL_init_ssl()
1122 if test "x$HAVE_LIBCRYPTO" != "xyes" -a -d "/usr/local/include" -a -d "/usr/local/lib"; then
1123 AC_LBL_SAVE_CHECK_STATE
1124 CFLAGS="$CFLAGS -I/usr/local/include"
1125 LIBS="$LIBS -L/usr/local/lib -lcrypto"
1126 AC_MSG_CHECKING(whether we have an OpenSSL/libressl libcrypto in /usr/local that we can use)
1127 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1129 #include <openssl/evp.h>
1132 EVP_CIPHER_CTX_block_size((EVP_CIPHER_CTX *)0);
1138 LIBCRYPTO_CFLAGS="-I/usr/local/include"
1139 LIBCRYPTO_LIBS="-L/usr/local/lib -lcrypto"
1142 AC_LBL_RESTORE_CHECK_STATE
1146 # If it wasn't found, check if it's a system library.
1148 # We include the standard include file to 1) make sure that
1149 # it's installed (if it's just a shared library for the
1150 # benefit of existing programs, that's not useful) and 2)
1151 # make sure this isn't a newer macOS that provides libcrypto
1152 # as a shared library but doesn't provide headers - Apple,
1153 # bless their pointy little heads, apparently ship libcrypto
1154 # as a library, but not the header files, in El Capitan and
1155 # later, probably because they don't want you writing nasty
1156 # portable code that could run on other UN*Xes, they want you
1157 # writing code that uses their Shiny New Crypto Library and
1158 # that thus only runs on macOS.
1160 if test "x$HAVE_LIBCRYPTO" != "xyes"; then
1161 AC_LBL_SAVE_CHECK_STATE
1162 LIBS="$LIBS -lcrypto"
1163 AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use)
1164 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1166 #include <openssl/evp.h>
1169 EVP_CIPHER_CTX_block_size((EVP_CIPHER_CTX *)0);
1175 LIBCRYPTO_LIBS="-lcrypto"
1178 AC_LBL_RESTORE_CHECK_STATE
1184 # Look for it there.
1186 AC_LBL_SAVE_CHECK_STATE
1187 CFLAGS="$CFLAGS -I$libcrypto_root/include"
1188 LIBS="$LIBS -L$libcrypto_root/lib -lcrypto"
1189 AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use)
1190 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1192 #include <openssl/evp.h>
1195 EVP_CIPHER_CTX_block_size((EVP_CIPHER_CTX *)0);
1201 LIBCRYPTO_CFLAGS="-I$libcrypto_root/include"
1202 LIBCRYPTO_LIBS="-L$libcrypto_root/lib -lcrypto"
1205 AC_LBL_RESTORE_CHECK_STATE
1209 # OK, did we find it?
1211 if test "x$HAVE_LIBCRYPTO" = "xyes"; then
1212 AC_DEFINE([HAVE_LIBCRYPTO], [1], [Define to 1 if you have a usable `crypto' library (-lcrypto).])
1215 # Put the subdirectories of the libcrypto root directory
1216 # at the end of the header and library search path, to
1217 # make sure they come after any -I or -L flags for
1218 # a local libpcap - those must take precedence of any
1219 # directory that might contain an installed version of
1222 V_INCLS="$V_INCLS $LIBCRYPTO_CFLAGS"
1223 LIBS="$LIBS $LIBCRYPTO_LIBS"
1228 # 1) do we have EVP_CIPHER_CTX_new?
1229 # If so, we use it to allocate an EVP_CIPHER_CTX, as
1230 # EVP_CIPHER_CTX may be opaque; otherwise, we allocate it
1233 # 2) do we have EVP_DecryptInit_ex()?
1234 # If so, we use it, because we need to be able to make
1235 # two "initialize the cipher" calls, one with the cipher
1236 # and key, and one with the IV, and, as of OpenSSL 1.1,
1237 # You Can't Do That with EVP_DecryptInit(), because a
1238 # call to EVP_DecryptInit() will unconditionally clear
1239 # the context, and if you don't supply a cipher, it'll
1240 # clear the cipher, rendering the context unusable and
1243 AC_CHECK_FUNCS(EVP_CIPHER_CTX_new EVP_DecryptInit_ex)
1245 AC_MSG_NOTICE(OpenSSL/libressl libcrypto not found)
1249 # Check for libcap-ng
1250 AC_MSG_CHECKING(whether to use libcap-ng)
1251 # Specify location for both includes and libraries.
1252 want_libcap_ng=ifavailable
1254 AS_HELP_STRING([--with-cap-ng],
1255 [use libcap-ng @<:@default=yes, if available@:>@]),
1257 if test $withval = no
1261 elif test $withval = yes
1268 # Use libcap-ng if it's present, otherwise don't.
1270 want_libcap_ng=ifavailable
1271 AC_MSG_RESULT([yes, if available])
1273 if test "$want_libcap_ng" != "no"; then
1274 AC_CHECK_LIB(cap-ng, capng_change_id)
1275 AC_CHECK_HEADERS(cap-ng.h)
1279 dnl set additional include path if necessary
1280 if test "$missing_includes" = "yes"; then
1281 CPPFLAGS="$CPPFLAGS -I$srcdir/missing"
1282 V_INCLS="$V_INCLS -I$srcdir/missing"
1290 AC_SUBST(MAN_FILE_FORMATS)
1291 AC_SUBST(MAN_MISC_INFO)
1295 AC_CONFIG_HEADER(config.h)
1297 AC_CONFIG_COMMANDS([.devel],[[if test -f .devel; then
1298 echo timestamp > stamp-h
1299 cat $srcdir/Makefile-devel-adds >> Makefile
1300 make depend || exit 1
1302 AC_CONFIG_FILES([Makefile tcpdump.1])