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 # Get the size of a void *, to know whether this is a 32-bit or 64-bit build.
38 AC_CHECK_SIZEOF([void *])
41 # Get the size of a time_t, to know whether it's 32-bit or 64-bit.
43 AC_CHECK_SIZEOF([time_t],,[#include <time.h>])
48 AC_ARG_ENABLE(universal,
49 AS_HELP_STRING([--disable-universal],[don't build universal on macOS]))
50 if test "$enable_universal" != "no"; then
55 # Leopard. Build for x86 and 32-bit PowerPC, with
56 # x86 first. (That's what Apple does.)
58 V_CCOPT="$V_CCOPT -arch i386 -arch ppc"
59 LDFLAGS="$LDFLAGS -arch i386 -arch ppc"
64 # Snow Leopard. Build for x86-64 and x86, with
65 # x86-64 first. (That's what Apple does.)
67 V_CCOPT="$V_CCOPT -arch x86_64 -arch i386"
68 LDFLAGS="$LDFLAGS -arch x86_64 -arch i386"
76 # Do we have pkg-config?
81 # Do we have the brew command from Homebrew?
83 AC_PATH_PROG([BREW], [brew])
86 [AS_HELP_STRING([--with-smi],
87 [link with libsmi (allows to load MIBs on the fly to decode SNMP packets) [default=yes, if available]])],
91 if test "x$with_smi" != "xno" ; then
92 AC_CHECK_HEADER(smi.h,
95 # OK, we found smi.h. Do we have libsmi with smiInit?
97 AC_CHECK_LIB(smi, smiInit,
100 # OK, we have libsmi with smiInit. Can we use it?
102 AC_MSG_CHECKING([whether to enable libsmi])
105 AC_RUN_IFELSE([AC_LANG_SOURCE([[
106 /* libsmi available check */
113 int current, revision, age, n;
114 const int required = 2;
117 if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
119 n = sscanf(smi_library_version, "%d:%d:%d", ¤t, &revision, &age);
122 if (required < current - age || required > current)
130 AC_DEFINE(USE_LIBSMI, 1,
131 [Define if you enable support for libsmi])
134 dnl autoconf documentation says that
135 dnl $? contains the exit value.
136 dnl reality is that it does not.
137 dnl We leave this in just in case
138 dnl autoconf ever comes back to
139 dnl match the documentation.
141 1) AC_MSG_RESULT(no - smiInit failed) ;;
142 2) AC_MSG_RESULT(no - header/library version mismatch) ;;
143 3) AC_MSG_RESULT(no - can't determine library version) ;;
144 4) AC_MSG_RESULT(no - too old) ;;
145 *) AC_MSG_RESULT(no) ;;
150 AC_MSG_RESULT(not when cross-compiling)
158 AC_MSG_CHECKING([whether to enable the instrument functions code])
159 AC_ARG_ENABLE([instrument-functions],
160 [AS_HELP_STRING([--enable-instrument-functions],
161 [enable instrument functions code [default=no]])],
165 yes) AC_MSG_RESULT(yes)
166 AC_CHECK_LIB([bfd], [bfd_init],
169 [--enable-instrument-functions was given, but test for library libbfd failed. Please install the 'binutils-dev' package.])],
171 AC_DEFINE(ENABLE_INSTRUMENT_FUNCTIONS, 1,
172 [define if you want to build the instrument functions code])
173 LOCALSRC="$LOCALSRC instrument-functions.c"
174 # Add '-finstrument-functions' instrumentation option to generate
175 # instrumentation calls for entry and exit to functions.
176 # Try to avoid Address Space Layout Randomization (ALSR).
177 CFLAGS="$CFLAGS -O0 -ggdb -finstrument-functions -fno-stack-protector -fno-pic"
178 LDFLAGS="$LDFLAGS -O0 -ggdb -fno-stack-protector -no-pie"
185 AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer])
187 [AS_HELP_STRING([--enable-smb],
188 [enable possibly-buggy SMB printer [default=no]])],
192 yes) AC_MSG_RESULT(yes)
193 AC_DEFINE(ENABLE_SMB, 1,
194 [define if you want to build the possibly-buggy SMB printer])
195 LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
201 AC_MSG_CHECKING([whether to drop root privileges by default])
204 [AS_HELP_STRING([--with-user=USERNAME],
205 [drop privileges by default to USERNAME]
209 AS_CASE(["$withval"],
210 [no], [AC_MSG_RESULT(no)],
211 [''|yes], [AC_MSG_ERROR([--with-user requires a username])],
213 AC_DEFINE_UNQUOTED(WITH_USER, "$withval",
214 [define if should drop privileges by default])
215 AC_MSG_RESULT([yes, to user "$withval"])
219 AC_MSG_CHECKING([whether to chroot])
222 [AS_HELP_STRING([--with-chroot=DIRECTORY],
223 [when dropping privileges, chroot to DIRECTORY]
228 AS_CASE(["$withval"],
229 [no], [AC_MSG_RESULT(no)],
230 [''|yes], [AC_MSG_ERROR([--with-chroot requires a directory])],
232 AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval",
233 [define if should chroot when dropping privileges])
234 AC_MSG_RESULT([yes, to directory "$withval"])
238 AC_ARG_WITH(sandbox-capsicum,
239 AS_HELP_STRING([--with-sandbox-capsicum],
240 [use Capsicum security functions @<:@default=yes, if available@:>@]))
242 # Check whether various functions are available. If any are, set
243 # ac_lbl_capsicum_function_seen to yes; if any are not, set
244 # ac_lbl_capsicum_function_not_seen to yes.
246 # We don't check cap_rights_init(), as it's a macro, wrapping another
247 # function, in at least some versions of FreeBSD, and AC_CHECK_FUNCS()
248 # doesn't handle that.
250 # All of the ones we check for must be available in order to enable
251 # capsicum sandboxing.
253 # XXX - do we need to check for all of them, or are there some that, if
254 # present, imply others are present?
256 if test -z "$with_sandbox_capsicum" || test "$with_sandbox_capsicum" != "no" ; then
258 # First, make sure we have the required header.
260 AC_CHECK_HEADER(sys/capsicum.h,
263 # We do; now make sure we have the required functions.
265 AC_CHECK_FUNCS(cap_enter cap_rights_limit cap_ioctls_limit openat,
266 ac_lbl_capsicum_function_seen=yes,
267 ac_lbl_capsicum_function_not_seen=yes)
269 AC_CHECK_LIB(casper, cap_init, LIBS="$LIBS -lcasper")
270 AC_CHECK_LIB(cap_dns, cap_gethostbyaddr, LIBS="$LIBS -lcap_dns")
272 AC_MSG_CHECKING([whether to sandbox using capsicum])
273 if test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then
274 AC_DEFINE(HAVE_CAPSICUM, 1, [capsicum support available])
279 AC_MSG_CHECKING([whether to sandbox using Casper library])
280 if test "x$ac_cv_lib_casper_cap_init" = "xyes" -a "x$ac_cv_lib_cap_dns_cap_gethostbyaddr" = "xyes"; then
281 AC_DEFINE(HAVE_CASPER, 1, [Casper support available])
288 # We must check this before checking whether to check the OS's IPv6,
289 # support because, on some platforms (such as SunOS 5.x), the test
290 # program requires the extra networking libraries.
295 # Check whether AF_INET6 and struct in6_addr are defined.
296 # If they aren't both defined, we don't have sufficient OS
297 # support for IPv6, so we don't look for IPv6 support libraries,
298 # and we define AF_INET6 and struct in6_addr ourselves.
300 AC_MSG_CHECKING([whether the operating system supports IPv6])
306 /* AF_INET6 available check */
307 #include <sys/types.h>
309 #include <ws2tcpip.h>
311 #include <sys/socket.h>
312 #include <netinet/in.h>
316 foo(struct in6_addr *addr)
318 memset(addr, 0, sizeof (struct in6_addr));
321 #error "AF_INET6 not defined"
327 AC_DEFINE(HAVE_OS_IPV6_SUPPORT, 1,
328 [define if the OS provides AF_INET6 and struct in6_addr])
341 if test "$ipv6" = "yes"; then
342 AC_MSG_CHECKING([ipv6 stack type])
343 for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do
346 dnl http://www.kame.net/
348 [#include <netinet/in.h>
349 #ifdef IPV6_INRIA_VERSION
355 dnl http://www.kame.net/
357 [#include <netinet/in.h>
363 ipv6libdir=/usr/local/v6/lib;
367 dnl http://www.v6.linux.or.jp/
369 [#include <features.h>
370 #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
376 dnl http://www.v6.linux.or.jp/
378 dnl This also matches Solaris 8 and Tru64 UNIX 5.1,
379 dnl and possibly other versions of those OSes
381 if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then
384 ipv6libdir=/usr/inet6/lib
386 CFLAGS="-I/usr/inet6/include $CFLAGS"
391 [#include <sys/param.h>
392 #ifdef _TOSHIBA_INET6
397 ipv6libdir=/usr/local/v6/lib])
401 [#include </usr/local/v6/include/sys/v6config.h>
407 ipv6libdir=/usr/local/v6/lib;
408 CFLAGS="-I/usr/local/v6/include $CFLAGS"])
412 [#include <sys/param.h>
413 #ifdef _ZETA_MINAMI_INET6
418 ipv6libdir=/usr/local/v6/lib])
421 if test "$ipv6type" != "unknown"; then
425 AC_MSG_RESULT($ipv6type)
428 if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
429 if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
430 LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
431 echo "You have $ipv6lib library, using it"
433 if test "$ipv6trylibc" = "yes"; then
434 echo "You do not have $ipv6lib library, using libc"
436 echo 'Fatal: no $ipv6lib library found. cannot continue.'
437 echo "You need to fetch lib$ipv6lib.a from appropriate"
438 echo 'ipv6 kit and compile beforehand.'
444 AC_REPLACE_FUNCS(strlcat strlcpy strdup strsep getservent getopt_long)
445 AC_CHECK_FUNCS(fork vfork)
446 AC_CHECK_FUNCS(setlinebuf)
449 # Make sure we have snprintf(); we require it.
451 AC_CHECK_FUNC(snprintf,,
452 AC_MSG_ERROR([snprintf() is required but wasn't found]))
455 # It became apparent at some point that using a suitable C99 compiler does not
456 # automatically mean snprintf(3) implementation in the libc supports all the
457 # modifiers and specifiers used in the project, so let's test that before the
460 # Testing the sizeof_t length modifier takes making an snprintf() call and
461 # comparing the actual result with the expected result. If this fails, it will
462 # most likely happen at run time, not compile time.
464 # Testing the 64-bit conversion specifiers in addition to that requires the
465 # <inttypes.h> header to be present and the macros to be defined, so if this
466 # fails, it will more likely happen at compile time.
468 AC_MSG_CHECKING([whether snprintf is suitable])
474 #include <inttypes.h>
475 #include <sys/types.h>
480 uint64_t t = (uint64_t)1 << 32;
482 snprintf(buf, sizeof(buf), "%zu", sizeof(buf));
483 if (strncmp(buf, "100", sizeof(buf)))
486 snprintf(buf, sizeof(buf), "%zd", -sizeof(buf));
487 if (strncmp(buf, "-100", sizeof(buf)))
490 snprintf(buf, sizeof(buf), "%" PRId64, -t);
491 if (strncmp(buf, "-4294967296", sizeof(buf)))
494 snprintf(buf, sizeof(buf), "0o%" PRIo64, t);
495 if (strncmp(buf, "0o40000000000", sizeof(buf)))
498 snprintf(buf, sizeof(buf), "0x%" PRIx64, t);
499 if (strncmp(buf, "0x100000000", sizeof(buf)))
502 snprintf(buf, sizeof(buf), "%" PRIu64, t);
503 if (strncmp(buf, "4294967296", sizeof(buf)))
516 [The snprintf(3) implementation in this libc is not suitable,
517 tcpdump would not work correctly even if it managed to compile.])
520 AC_MSG_RESULT(not while cross-compiling)
524 AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc
526 dnl Some platforms may need -lnsl for getrpcbynumber.
527 AC_SEARCH_LIBS(getrpcbynumber, nsl,
528 AC_DEFINE(HAVE_GETRPCBYNUMBER, 1, [define if you have getrpcbynumber()]))
530 AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
533 # Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
534 # libraries (e.g., "-lsocket -lnsl" on Solaris).
536 # You are in a twisty little maze of UN*Xes, all different.
537 # Some might not have ether_ntohost().
538 # Some might have it and declare it in <net/ethernet.h>.
539 # Some might have it and declare it in <netinet/ether.h>
540 # Some might have it and declare it in <sys/ethernet.h>.
541 # Some might have it and declare it in <arpa/inet.h>.
542 # Some might have it and declare it in <netinet/if_ether.h>.
543 # Some might have it and not declare it in any header file.
545 # Before you is a C compiler.
547 AC_CHECK_FUNCS(ether_ntohost, [
548 AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [
549 AC_RUN_IFELSE([AC_LANG_SOURCE([[
551 #include <netinet/ether.h>
553 #include <sys/types.h>
554 #include <sys/param.h>
555 #include <sys/socket.h>
558 main(int argc, char **argv)
560 u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff };
561 char name[MAXHOSTNAMELEN];
563 ether_ntohost(name, (struct ether_addr *)ea);
567 ], [ac_cv_buggy_ether_ntohost=no],
568 [ac_cv_buggy_ether_ntohost=yes],
569 [ac_cv_buggy_ether_ntohost="not while cross-compiling"])])
570 if test "$ac_cv_buggy_ether_ntohost" = "no"; then
571 AC_DEFINE(USE_ETHER_NTOHOST, 1,
572 [define if you have ether_ntohost() and it works])
575 if test "$ac_cv_func_ether_ntohost" = yes -a \
576 "$ac_cv_buggy_ether_ntohost" = "no"; then
578 # OK, we have ether_ntohost(). Is it declared in <net/ethernet.h>?
580 # This test fails if we don't have <net/ethernet.h> or if we do
581 # but it doesn't declare ether_ntohost().
583 AC_CHECK_DECL(ether_ntohost,
585 AC_DEFINE(NET_ETHERNET_H_DECLARES_ETHER_NTOHOST,,
586 [Define to 1 if net/ethernet.h declares `ether_ntohost'])
589 #include <net/ethernet.h>
594 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
596 # No, how about <netinet/ether.h>, as on Linux?
598 # This test fails if we don't have <netinet/ether.h>
599 # or if we do but it doesn't declare ether_ntohost().
601 # Unset ac_cv_have_decl_ether_ntohost so we don't
602 # treat the previous failure as a cached value and
603 # suppress the next test.
605 unset ac_cv_have_decl_ether_ntohost
606 AC_CHECK_DECL(ether_ntohost,
608 AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,1,
609 [Define to 1 if netinet/ether.h declares `ether_ntohost'])
612 #include <netinet/ether.h>
618 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
620 # No, how about <sys/ethernet.h>, as on Solaris 10
623 # This test fails if we don't have <sys/ethernet.h>
624 # or if we do but it doesn't declare ether_ntohost().
626 # Unset ac_cv_have_decl_ether_ntohost so we don't
627 # treat the previous failure as a cached value and
628 # suppress the next test.
630 unset ac_cv_have_decl_ether_ntohost
631 AC_CHECK_DECL(ether_ntohost,
633 AC_DEFINE(SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST,,
634 [Define to 1 if sys/ethernet.h declares `ether_ntohost'])
637 #include <sys/ethernet.h>
643 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
645 # No, how about <arpa/inet.h>, as in AIX?
647 # This test fails if we don't have <arpa/inet.h>
648 # (if we have ether_ntohost(), we should have
649 # networking, and if we have networking, we should
650 # have <arpa/inet.h>) or if we do but it doesn't
651 # declare ether_ntohost().
653 # Unset ac_cv_have_decl_ether_ntohost so we don't
654 # treat the previous failure as a cached value and
655 # suppress the next test.
657 unset ac_cv_have_decl_ether_ntohost
658 AC_CHECK_DECL(ether_ntohost,
660 AC_DEFINE(ARPA_INET_H_DECLARES_ETHER_NTOHOST,,
661 [Define to 1 if arpa/inet.h declares `ether_ntohost'])
664 #include <arpa/inet.h>
670 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
672 # No, how about <netinet/if_ether.h>?
673 # On some platforms, it requires <net/if.h> and
674 # <netinet/in.h>, and we always include it with
675 # both of them, so test it with both of them.
677 # This test fails if we don't have <netinet/if_ether.h>
678 # and the headers we include before it, or if we do but
679 # <netinet/if_ether.h> doesn't declare ether_hostton().
681 # Unset ac_cv_have_decl_ether_ntohost so we don't
682 # treat the previous failure as a cached value and
683 # suppress the next test.
685 unset ac_cv_have_decl_ether_ntohost
686 AC_CHECK_DECL(ether_ntohost,
688 AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST,,
689 [Define to 1 if netinet/if_ether.h declares `ether_ntohost'])
692 #include <sys/types.h>
693 #include <sys/socket.h>
695 #include <netinet/in.h>
696 #include <netinet/if_ether.h>
700 # After all that, is ether_ntohost() declared?
702 if test "$ac_cv_have_decl_ether_ntohost" = yes; then
706 AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 1,
707 [Define to 1 if you have the declaration of `ether_ntohost'])
710 # No, we'll have to declare it ourselves.
711 # Do we have "struct ether_addr" if we include
712 # <netinet/if_ether.h>?
714 AC_CHECK_TYPES(struct ether_addr,,,
716 #include <sys/types.h>
717 #include <sys/socket.h>
719 #include <netinet/in.h>
720 #include <netinet/if_ether.h>
726 dnl Check for "pcap_list_datalinks()" and use a substitute version if
727 dnl it's not present. If it is present, check for "pcap_free_datalinks()";
728 dnl if it's not present, we don't replace it for now. (We could do so
729 dnl on UN*X, but not on Windows, where hilarity ensues if a program
730 dnl built with one version of the MSVC support library tries to free
731 dnl something allocated by a library built with another version of
732 dnl the MSVC support library.)
734 AC_CHECK_FUNC(pcap_list_datalinks,
736 AC_DEFINE(HAVE_PCAP_LIST_DATALINKS, 1,
737 [define if libpcap has pcap_list_datalinks()])
738 AC_CHECK_FUNCS(pcap_free_datalinks)
745 dnl Check for "pcap_datalink_name_to_val()", and use a substitute
746 dnl version if it's not present. If it is present, check for
747 dnl "pcap_datalink_val_to_description()", and if we don't have it,
748 dnl use a substitute version.
750 AC_CHECK_FUNC(pcap_datalink_name_to_val,
752 AC_DEFINE(HAVE_PCAP_DATALINK_NAME_TO_VAL, 1,
753 [define if libpcap has pcap_datalink_name_to_val()])
754 AC_CHECK_FUNC(pcap_datalink_val_to_description,
755 AC_DEFINE(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION, 1,
756 [define if libpcap has pcap_datalink_val_to_description()]),
766 dnl Check for "pcap_set_datalink()"; you can't substitute for it if
767 dnl it's absent (it has hooks into libpcap), so just define the
768 dnl HAVE_ value if it's there.
770 AC_CHECK_FUNCS(pcap_set_datalink)
773 dnl Check for "pcap_breakloop()"; you can't substitute for it if
774 dnl it's absent (it has hooks into the live capture routines),
775 dnl so just define the HAVE_ value if it's there.
777 AC_CHECK_FUNCS(pcap_breakloop)
780 # Do we have the new open API? Check for pcap_create, and assume that,
781 # if we do, we also have pcap_activate() and the other new routines
782 # introduced in libpcap 1.0.0.
784 AC_CHECK_FUNCS(pcap_create)
785 if test $ac_cv_func_pcap_create = "yes" ; then
787 # OK, do we have pcap_set_tstamp_type? If so, assume we have
788 # pcap_list_tstamp_types and pcap_free_tstamp_types as well.
790 AC_CHECK_FUNCS(pcap_set_tstamp_type)
792 # And do we have pcap_set_tstamp_precision? If so, we assume
793 # we also have pcap_open_offline_with_tstamp_precision.
795 AC_CHECK_FUNCS(pcap_set_tstamp_precision)
799 # Check for a miscellaneous collection of functions which we use
802 AC_CHECK_FUNCS(pcap_findalldevs)
803 AC_CHECK_FUNCS(pcap_dump_flush pcap_lib_version)
804 if test $ac_cv_func_pcap_lib_version = "no" ; then
805 AC_MSG_CHECKING(whether pcap_version is defined by libpcap)
806 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
807 extern char pcap_version[];
809 return (int)pcap_version;
812 [ac_lbl_cv_pcap_version_defined=yes],
813 [ac_lbl_cv_pcap_version_defined=no])
814 if test "$ac_lbl_cv_pcap_version_defined" = yes ; then
816 AC_DEFINE(HAVE_PCAP_VERSION, 1, [define if libpcap has pcap_version])
821 AC_CHECK_FUNCS(pcap_setdirection pcap_set_immediate_mode pcap_dump_ftell64)
823 # See the comment in AC_LBL_LIBPCAP in aclocal.m4 for the reason
824 # why we don't check for remote-capture APIs if we're building
825 # with the system libpcap on macOS.
827 if test "$_dont_check_for_remote_apis" != "yes"; then
828 AC_CHECK_FUNCS(pcap_open pcap_findalldevs_ex)
830 AC_REPLACE_FUNCS(pcap_dump_ftell)
833 # Check for special debugging functions
835 AC_CHECK_FUNCS(pcap_set_parser_debug)
836 if test "$ac_cv_func_pcap_set_parser_debug" = "no" ; then
838 # OK, we don't have pcap_set_parser_debug() to set the libpcap
839 # filter expression parser debug flag; can we directly set the
841 AC_MSG_CHECKING(whether pcap_debug is defined by libpcap)
842 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
843 extern int pcap_debug;
848 [ac_lbl_cv_pcap_debug_defined=yes],
849 [ac_lbl_cv_pcap_debug_defined=no])
850 if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
852 AC_DEFINE(HAVE_PCAP_DEBUG, 1, [define if libpcap has pcap_debug])
856 # OK, what about "yydebug"?
858 AC_MSG_CHECKING(whether yydebug is defined by libpcap)
859 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
865 [ac_lbl_cv_yydebug_defined=yes],
866 [ac_lbl_cv_yydebug_defined=no])
867 if test "$ac_lbl_cv_yydebug_defined" = yes ; then
869 AC_DEFINE(HAVE_YYDEBUG, 1, [define if libpcap has yydebug])
875 AC_CHECK_FUNCS(pcap_set_optimizer_debug)
876 AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6
879 # Assume V7/BSD convention for man pages (file formats in section 5,
880 # miscellaneous info in section 7).
887 dnl Workaround to enable certain features
888 AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
893 # Use System V conventions for man pages.
903 # Use System V conventions for man pages.
913 # Use System V conventions for man pages.
921 # Use System V conventions for man pages.
929 # Make sure we have a definition for C99's uintptr_t (regardless of
930 # whether the environment is a C99 environment or not).
934 savedcppflags="$CPPFLAGS"
935 CPPFLAGS="$CPPFLAGS $V_INCLS"
938 # Check whether we have pcap/pcap-inttypes.h.
939 # If we do, we use that to get the C99 types defined.
941 AC_CHECK_HEADERS(pcap/pcap-inttypes.h)
944 # At compile time HAVE_PCAP_FINDALLDEVS depends on HAVE_PCAP_IF_T.
946 AC_CHECK_TYPES(pcap_if_t, , , [#include <pcap.h>])
948 CPPFLAGS="$savedcppflags"
951 # Define the old BSD specified-width types in terms of the C99 types;
952 # we may need them with libpcap include files.
954 AC_CHECK_TYPE([u_int8_t], ,
955 [AC_DEFINE([u_int8_t], [uint8_t],
956 [Define to `uint8_t' if u_int8_t not defined.])],
958 #include <sys/types.h>
960 AC_CHECK_TYPE([u_int16_t], ,
961 [AC_DEFINE([u_int16_t], [uint16_t],
962 [Define to `uint16_t' if u_int16_t not defined.])],
964 #include <sys/types.h>
966 AC_CHECK_TYPE([u_int32_t], ,
967 [AC_DEFINE([u_int32_t], [uint32_t],
968 [Define to `uint32_t' if u_int32_t not defined.])],
970 #include <sys/types.h>
972 AC_CHECK_TYPE([u_int64_t], ,
973 [AC_DEFINE([u_int64_t], [uint64_t],
974 [Define to `uint64_t' if u_int64_t not defined.])],
976 #include <sys/types.h>
980 AC_CHECK_TOOL([AR], [ar])
982 AC_LBL_DEVEL(V_CCOPT)
984 # Check for OpenSSL/libressl libcrypto
985 AC_MSG_CHECKING(whether to use OpenSSL/libressl libcrypto)
986 # Specify location for both includes and libraries.
987 want_libcrypto=ifavailable
989 AS_HELP_STRING([--with-crypto]@<:@=DIR@:>@,
990 [use OpenSSL/libressl libcrypto (located in directory DIR, if specified) @<:@default=yes, if available@:>@]),
992 if test $withval = no
994 # User doesn't want to link with libcrypto.
997 elif test $withval = yes
999 # User wants to link with libcrypto but hasn't specified
1004 # User wants to link with libcrypto and has specified
1005 # a directory, so use the provided value.
1007 libcrypto_root=$withval
1008 AC_MSG_RESULT([yes, using the version installed in $withval])
1012 # Use libcrypto if it's present, otherwise don't; no directory
1015 want_libcrypto=ifavailable
1016 AC_MSG_RESULT([yes, if available])
1018 if test "$want_libcrypto" != "no"; then
1020 # Were we told where to look for libcrypto?
1022 if test -z "$libcrypto_root"; then
1026 # First, try looking for it with pkg-config, if we have it.
1028 # Homebrew's pkg-config does not, by default, look for
1029 # pkg-config files for packages it has installed.
1030 # Furthermore, at least for OpenSSL, they appear to be
1031 # dumped in package-specific directories whose paths are
1032 # not only package-specific but package-version-specific.
1034 # So the only way to find openssl is to get the value of
1035 # PKG_CONFIG_PATH from "brew --env openssl" and add that
1036 # to PKG_CONFIG_PATH. (No, we can't just assume it's under
1037 # /usr/local; Homebrew have conveniently chosen to put it
1038 # under /opt/homebrew on ARM.)
1040 # That's the nice thing about Homebrew - it makes things easier!
1043 save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
1044 if test -n "$BREW"; then
1045 openssl_pkgconfig_dir=`$BREW --env --plain openssl | sed -n 's/PKG_CONFIG_PATH: //p'`
1046 PKG_CONFIG_PATH="$openssl_pkgconfig_dir:$PKG_CONFIG_PATH"
1048 PKG_CHECK_MODULE(LIBCRYPTO, libcrypto,
1051 # We found OpenSSL/libressl libcrypto.
1055 PKG_CONFIG_PATH="$save_PKG_CONFIG_PATH"
1058 # If it wasn't found, and we have Homebrew installed, see
1059 # if it's in Homebrew.
1061 if test "x$HAVE_LIBCRYPTO" != "xyes" -a -n "$BREW"; then
1062 AC_MSG_CHECKING(for openssl in Homebrew)
1064 # The brew man page lies when it speaks of
1065 # $BREW --prefix --installed <formula>
1066 # outputting nothing. In Homebrew 3.3.16,
1067 # it produces output regardless of whether
1068 # the formula is installed or not, so we
1069 # send the standard output and error to
1072 # libcrypto isn't a formula, openssl is a formula.
1074 if $BREW --prefix --installed openssl >/dev/null 2>&1; then
1076 # Yes. Get the include directory and library
1077 # directory. (No, we can't just assume it's
1078 # under /usr/local; Homebrew have conveniently
1079 # chosen to put it under /opt/homebrew on ARM.)
1083 openssl_path=`$BREW --prefix openssl`
1084 LIBCRYPTO_CFLAGS="-I$openssl_path/include"
1085 LIBCRYPTO_LIBS="-L$openssl_path/lib -lcrypto"
1092 # If it wasn't found, and /usr/local/include and /usr/local/lib
1093 # exist, check if it's in /usr/local. (We check whether they
1094 # exist because, if they don't exist, the compiler will warn
1095 # about that and then ignore the argument, so they test
1096 # using just the system header files and libraries.)
1098 # We include the standard include file to 1) make sure that
1099 # it's installed (if it's just a shared library for the
1100 # benefit of existing programs, that's not useful) and 2)
1101 # because SSL_library_init() is a library routine in some
1102 # versions and a #defined wrapper around OPENSSL_init_ssl()
1105 if test "x$HAVE_LIBCRYPTO" != "xyes" -a -d "/usr/local/include" -a -d "/usr/local/lib"; then
1106 AC_LBL_SAVE_CHECK_STATE
1107 CFLAGS="$CFLAGS -I/usr/local/include"
1108 LIBS="$LIBS -L/usr/local/lib -lcrypto"
1109 AC_MSG_CHECKING(whether we have an OpenSSL/libressl libcrypto in /usr/local that we can use)
1110 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1112 #include <openssl/evp.h>
1115 EVP_CIPHER_CTX_block_size((EVP_CIPHER_CTX *)0);
1121 LIBCRYPTO_CFLAGS="-I/usr/local/include"
1122 LIBCRYPTO_LIBS="-L/usr/local/lib -lcrypto"
1125 AC_LBL_RESTORE_CHECK_STATE
1129 # If it wasn't found, check if it's a system library.
1131 # We include the standard include file to 1) make sure that
1132 # it's installed (if it's just a shared library for the
1133 # benefit of existing programs, that's not useful) and 2)
1134 # make sure this isn't a newer macOS that provides libcrypto
1135 # as a shared library but doesn't provide headers - Apple,
1136 # bless their pointy little heads, apparently ship libcrypto
1137 # as a library, but not the header files, in El Capitan and
1138 # later, probably because they don't want you writing nasty
1139 # portable code that could run on other UN*Xes, they want you
1140 # writing code that uses their Shiny New Crypto Library and
1141 # that thus only runs on macOS.
1143 if test "x$HAVE_LIBCRYPTO" != "xyes"; then
1144 AC_LBL_SAVE_CHECK_STATE
1145 LIBS="$LIBS -lcrypto"
1146 AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use)
1147 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1149 #include <openssl/evp.h>
1152 EVP_CIPHER_CTX_block_size((EVP_CIPHER_CTX *)0);
1158 LIBCRYPTO_LIBS="-lcrypto"
1161 AC_LBL_RESTORE_CHECK_STATE
1167 # Look for it there.
1169 AC_LBL_SAVE_CHECK_STATE
1170 CFLAGS="$CFLAGS -I$libcrypto_root/include"
1171 LIBS="$LIBS -L$libcrypto_root/lib -lcrypto"
1172 AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use)
1173 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1175 #include <openssl/evp.h>
1178 EVP_CIPHER_CTX_block_size((EVP_CIPHER_CTX *)0);
1184 LIBCRYPTO_CFLAGS="-I$libcrypto_root/include"
1185 LIBCRYPTO_LIBS="-L$libcrypto_root/lib -lcrypto"
1188 AC_LBL_RESTORE_CHECK_STATE
1192 # OK, did we find it?
1194 if test "x$HAVE_LIBCRYPTO" = "xyes"; then
1195 AC_DEFINE([HAVE_LIBCRYPTO], [1], [Define to 1 if you have a usable `crypto' library (-lcrypto).])
1198 # Put the subdirectories of the libcrypto root directory
1199 # at the end of the header and library search path, to
1200 # make sure they come after any -I or -L flags for
1201 # a local libpcap - those must take precedence of any
1202 # directory that might contain an installed version of
1205 V_INCLS="$V_INCLS $LIBCRYPTO_CFLAGS"
1206 LIBS="$LIBS $LIBCRYPTO_LIBS"
1211 # 1) do we have EVP_CIPHER_CTX_new?
1212 # If so, we use it to allocate an EVP_CIPHER_CTX, as
1213 # EVP_CIPHER_CTX may be opaque; otherwise, we allocate it
1216 # 2) do we have EVP_DecryptInit_ex()?
1217 # If so, we use it, because we need to be able to make
1218 # two "initialize the cipher" calls, one with the cipher
1219 # and key, and one with the IV, and, as of OpenSSL 1.1,
1220 # You Can't Do That with EVP_DecryptInit(), because a
1221 # call to EVP_DecryptInit() will unconditionally clear
1222 # the context, and if you don't supply a cipher, it'll
1223 # clear the cipher, rendering the context unusable and
1226 AC_CHECK_FUNCS(EVP_CIPHER_CTX_new EVP_DecryptInit_ex)
1228 AC_MSG_NOTICE(OpenSSL/libressl libcrypto not found)
1232 # Check for libcap-ng
1233 AC_MSG_CHECKING(whether to use libcap-ng)
1234 # Specify location for both includes and libraries.
1235 want_libcap_ng=ifavailable
1237 AS_HELP_STRING([--with-cap-ng],
1238 [use libcap-ng @<:@default=yes, if available@:>@]),
1240 if test $withval = no
1244 elif test $withval = yes
1251 # Use libcap-ng if it's present, otherwise don't.
1253 want_libcap_ng=ifavailable
1254 AC_MSG_RESULT([yes, if available])
1256 if test "$want_libcap_ng" != "no"; then
1257 AC_CHECK_LIB(cap-ng, capng_change_id)
1258 AC_CHECK_HEADERS(cap-ng.h)
1262 dnl set additional include path if necessary
1263 if test "$missing_includes" = "yes"; then
1264 CPPFLAGS="$CPPFLAGS -I$srcdir/missing"
1265 V_INCLS="$V_INCLS -I$srcdir/missing"
1273 AC_SUBST(MAN_FILE_FORMATS)
1274 AC_SUBST(MAN_MISC_INFO)
1278 AC_CONFIG_HEADER(config.h)
1280 AC_CONFIG_COMMANDS([.devel],[[if test -f .devel; then
1281 echo timestamp > stamp-h
1282 cat $srcdir/Makefile-devel-adds >> Makefile
1283 make depend || exit 1
1285 AC_CONFIG_FILES([Makefile tcpdump.1])