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
19 [m4_esyscmd_s(cat VERSION)],
20 [https://github.com/the-tcpdump-group/tcpdump/issues],
22 [https://www.tcpdump.org/])
23 AC_CONFIG_SRCDIR(tcpdump.c)
27 AC_LBL_C_INIT_BEFORE_CC(V_INCLS)
29 # Try to enable as many C99 features as we can.
30 # At minimum, we want C++/C99-style // comments.
33 if test "$ac_cv_prog_cc_c99" = "no"; then
34 AC_MSG_WARN([The C compiler does not support C99; there may be compiler errors])
36 AC_LBL_C_INIT(V_CCOPT, V_INCLS)
39 # Test for ONC RPC headers.
41 # XXX - we should supply copies of these, as I think Sun released them
42 # under a sufficiently permissive license, and that would be one less
43 # place where we rely on OS headers, rather than our own headers, for
44 # a protocol that is specified independent of any particular OS.
46 AC_CHECK_HEADERS(rpc/rpc.h rpc/rpcent.h)
48 # On Linux, if Autoconf version >= 2.72 and GNU C Library version >= 2.34,
49 # uncomment AC_SYS_YEAR2038_RECOMMENDED to ensure time_t is Y2038-safe.
50 # (Can be done by autogen.sh)
51 # AC_SYS_YEAR2038_RECOMMENDED
53 # Get the size of a void *, to know whether this is a 32-bit or 64-bit build.
55 AC_CHECK_SIZEOF([void *])
58 # Get the size of a time_t, to know whether it's 32-bit or 64-bit.
60 AC_CHECK_SIZEOF([time_t],,[#include <time.h>])
65 AC_ARG_ENABLE(universal,
66 AS_HELP_STRING([--disable-universal],[don't build universal on macOS]))
67 if test "$enable_universal" != "no"; then
72 # Leopard. Build for x86 and 32-bit PowerPC, with
73 # x86 first. (That's what Apple does.)
75 V_CCOPT="$V_CCOPT -arch i386 -arch ppc"
76 LDFLAGS="$LDFLAGS -arch i386 -arch ppc"
81 # Snow Leopard. Build for x86-64 and x86, with
82 # x86-64 first. (That's what Apple does.)
84 V_CCOPT="$V_CCOPT -arch x86_64 -arch i386"
85 LDFLAGS="$LDFLAGS -arch x86_64 -arch i386"
93 # Do we have pkg-config?
98 # Do we have the brew command from Homebrew?
102 AC_PATH_PROG([BREW], [brew])
107 [AS_HELP_STRING([--with-smi],
108 [link with libsmi (allows to load MIBs on the fly to decode SNMP packets) [default=yes, if available]])],
112 if test "x$with_smi" != "xno" ; then
113 AC_CHECK_HEADER(smi.h,
116 # OK, we found smi.h. Do we have libsmi with smiInit?
118 AC_CHECK_LIB(smi, smiInit,
121 # OK, we have libsmi with smiInit. Can we use it?
123 AC_MSG_CHECKING([whether to enable libsmi])
126 AC_RUN_IFELSE([AC_LANG_SOURCE([[
127 /* libsmi available check */
134 int current, revision, age, n;
135 const int required = 2;
138 if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
140 n = sscanf(smi_library_version, "%d:%d:%d", ¤t, &revision, &age);
143 if (required < current - age || required > current)
151 AC_DEFINE(USE_LIBSMI, 1,
152 [Define if you enable support for libsmi])
155 dnl autoconf documentation says that
156 dnl $? contains the exit value.
157 dnl reality is that it does not.
158 dnl We leave this in just in case
159 dnl autoconf ever comes back to
160 dnl match the documentation.
162 1) AC_MSG_RESULT(no - smiInit failed) ;;
163 2) AC_MSG_RESULT(no - header/library version mismatch) ;;
164 3) AC_MSG_RESULT(no - can't determine library version) ;;
165 4) AC_MSG_RESULT(no - too old) ;;
166 *) AC_MSG_RESULT(no) ;;
171 AC_MSG_RESULT(not when cross-compiling)
179 AC_MSG_CHECKING([whether to enable the instrument functions code])
180 AC_ARG_ENABLE([instrument-functions],
181 [AS_HELP_STRING([--enable-instrument-functions],
182 [enable instrument functions code [default=no]])],
186 yes) AC_MSG_RESULT(yes)
187 AC_CHECK_LIB([bfd], [bfd_init],
190 [--enable-instrument-functions was given, but test for library libbfd failed. Please install the 'binutils-dev' package.])],
192 AC_DEFINE(ENABLE_INSTRUMENT_FUNCTIONS, 1,
193 [define if you want to build the instrument functions code])
194 LOCALSRC="$LOCALSRC instrument-functions.c"
195 # Add '-finstrument-functions' instrumentation option to generate
196 # instrumentation calls for entry and exit to functions.
197 # Try to avoid Address Space Layout Randomization (ALSR).
198 CFLAGS="$CFLAGS -O0 -ggdb -finstrument-functions -fno-stack-protector -fno-pic"
199 LDFLAGS="$LDFLAGS -O0 -ggdb -fno-stack-protector -no-pie"
206 AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer])
208 [AS_HELP_STRING([--enable-smb],
209 [enable possibly-buggy SMB printer [default=no]])],
213 yes) AC_MSG_RESULT(yes)
214 AC_DEFINE(ENABLE_SMB, 1,
215 [define if you want to build the possibly-buggy SMB printer])
216 LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
222 AC_MSG_CHECKING([whether to drop root privileges by default])
225 [AS_HELP_STRING([--with-user=USERNAME],
226 [drop privileges by default to USERNAME]
230 AS_CASE(["$withval"],
231 [no], [AC_MSG_RESULT(no)],
232 [''|yes], [AC_MSG_ERROR([--with-user requires a username])],
234 AC_DEFINE_UNQUOTED(WITH_USER, "$withval",
235 [define if should drop privileges by default])
236 AC_MSG_RESULT([yes, to user "$withval"])
240 AC_MSG_CHECKING([whether to chroot])
243 [AS_HELP_STRING([--with-chroot=DIRECTORY],
244 [when dropping privileges, chroot to DIRECTORY]
249 AS_CASE(["$withval"],
250 [no], [AC_MSG_RESULT(no)],
251 [''|yes], [AC_MSG_ERROR([--with-chroot requires a directory])],
253 AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval",
254 [define if should chroot when dropping privileges])
255 AC_MSG_RESULT([yes, to directory "$withval"])
259 AC_ARG_WITH(sandbox-capsicum,
260 AS_HELP_STRING([--with-sandbox-capsicum],
261 [use Capsicum security functions @<:@default=yes, if available@:>@]))
263 # Capsicum is available on FreeBSD only.
264 expr "$host_os" : freebsd >/dev/null || with_sandbox_capsicum=no
267 # Check whether various functions are available. If any are, set
268 # ac_lbl_capsicum_function_seen to yes; if any are not, set
269 # ac_lbl_capsicum_function_not_seen to yes.
271 # We don't check cap_rights_init(), as it's a macro, wrapping another
272 # function, in at least some versions of FreeBSD, and AC_CHECK_FUNCS()
273 # doesn't handle that.
275 # All of the ones we check for must be available in order to enable
276 # capsicum sandboxing.
278 # XXX - do we need to check for all of them, or are there some that, if
279 # present, imply others are present?
281 if test -z "$with_sandbox_capsicum" || test "$with_sandbox_capsicum" != "no" ; then
283 # First, make sure we have the required header.
285 AC_CHECK_HEADER(sys/capsicum.h,
288 # We do; now make sure we have the required functions.
290 AC_CHECK_FUNCS(cap_enter cap_rights_limit cap_ioctls_limit openat,
291 ac_lbl_capsicum_function_seen=yes,
292 ac_lbl_capsicum_function_not_seen=yes)
294 AC_CHECK_LIB(casper, cap_init, LIBS="$LIBS -lcasper")
295 AC_CHECK_LIB(cap_dns, cap_gethostbyaddr, LIBS="$LIBS -lcap_dns")
297 AC_MSG_CHECKING([whether to sandbox using capsicum])
298 if test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then
299 AC_DEFINE(HAVE_CAPSICUM, 1, [capsicum support available])
304 AC_MSG_CHECKING([whether to sandbox using Casper library])
305 if test "x$ac_cv_lib_casper_cap_init" = "xyes" -a "x$ac_cv_lib_cap_dns_cap_gethostbyaddr" = "xyes"; then
306 AC_DEFINE(HAVE_CASPER, 1, [Casper support available])
313 # XXX - we used to check this before checking whether to check the OS's
314 # IPv6, support because, on some platforms (such as SunOS 5.x), the test
315 # program requires the extra networking libraries. We no longer
316 # test for IPv6 support, we just assume it's present with the
317 # standard API, so perhaps this can be moved.
321 AC_REPLACE_FUNCS(strlcat strlcpy strsep getservent getopt_long)
322 AC_CHECK_FUNCS(fork vfork)
325 # It became apparent at some point that using a suitable C99 compiler does not
326 # automatically mean snprintf(3) implementation in the libc supports all the
327 # modifiers and specifiers used in the project, so let's test that before the
330 # Testing the sizeof_t length modifier takes making an snprintf() call and
331 # comparing the actual result with the expected result. If this fails, it will
332 # most likely happen at run time, not compile time.
334 # Testing the 64-bit conversion specifiers in addition to that requires the
335 # <inttypes.h> header to be present and the macros to be defined, so if this
336 # fails, it will more likely happen at compile time.
338 AC_MSG_CHECKING([whether snprintf is suitable])
344 #include <inttypes.h>
345 #include <sys/types.h>
347 #if defined(_WIN32) && !defined(_SSIZE_T_DEFINED)
349 * On UN*Xes, this is a signed integer type of the same size as size_t.
351 * It's not defined by Visual Studio; we assume that ptrdiff_t will
352 * be a type that is a signed integer type of the same size as size_t.
354 typedef ptrdiff_t ssize_t;
358 * Avoid trying to cast negative values to unsigned types, or doing
359 * shifts of signed types, in order not to have the test program fail
360 * if we're building with undefined-behavior sanitizers enabled.
365 unsigned int ui = sizeof(buf);
367 int64_t i64 = INT64_C(0x100000000);
368 uint64_t ui64 = UINT64_C(0x100000000);
370 snprintf(buf, sizeof(buf), "%zu", (size_t)ui);
371 if (strncmp(buf, "100", sizeof(buf)))
374 snprintf(buf, sizeof(buf), "%zd", (ssize_t)(-i));
375 if (strncmp(buf, "-100", sizeof(buf)))
378 snprintf(buf, sizeof(buf), "%" PRId64, -i64);
379 if (strncmp(buf, "-4294967296", sizeof(buf)))
382 snprintf(buf, sizeof(buf), "0o%" PRIo64, ui64);
383 if (strncmp(buf, "0o40000000000", sizeof(buf)))
386 snprintf(buf, sizeof(buf), "0x%" PRIx64, ui64);
387 if (strncmp(buf, "0x100000000", sizeof(buf)))
390 snprintf(buf, sizeof(buf), "%" PRIu64, ui64);
391 if (strncmp(buf, "4294967296", sizeof(buf)))
404 [The snprintf(3) implementation in this libc is not suitable,
405 tcpdump would not work correctly even if it managed to compile.])
408 AC_MSG_RESULT(not while cross-compiling)
412 AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc
414 dnl Some platforms may need -lnsl for getrpcbynumber.
415 AC_SEARCH_LIBS(getrpcbynumber, nsl,
416 AC_DEFINE(HAVE_GETRPCBYNUMBER, 1, [define if you have getrpcbynumber()]))
418 AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
421 # Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
422 # libraries (e.g., "-lsocket -lnsl" on Solaris).
424 # You are in a twisty little maze of UN*Xes, all different.
425 # Some might not have ether_ntohost().
426 # Some might have it and declare it in <net/ethernet.h>.
427 # Some might have it and declare it in <netinet/ether.h>
428 # Some might have it and declare it in <sys/ethernet.h>.
429 # Some might have it and declare it in <arpa/inet.h>.
430 # Some might have it and declare it in <netinet/if_ether.h>.
431 # Some might have it and not declare it in any header file.
433 # Before you is a C compiler.
435 AC_CHECK_FUNCS(ether_ntohost, [
437 # OK, we have ether_ntohost(). Is it declared in <net/ethernet.h>?
439 # This test fails if we don't have <net/ethernet.h> or if we do
440 # but it doesn't declare ether_ntohost().
442 AC_CHECK_DECL(ether_ntohost,
444 AC_DEFINE(NET_ETHERNET_H_DECLARES_ETHER_NTOHOST,1,
445 [Define to 1 if net/ethernet.h declares `ether_ntohost'])
448 #include <net/ethernet.h>
453 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
455 # No, how about <netinet/ether.h>, as on Linux?
457 # This test fails if we don't have <netinet/ether.h>
458 # or if we do but it doesn't declare ether_ntohost().
460 # Unset ac_cv_have_decl_ether_ntohost so we don't
461 # treat the previous failure as a cached value and
462 # suppress the next test.
464 unset ac_cv_have_decl_ether_ntohost
465 AC_CHECK_DECL(ether_ntohost,
467 AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,1,
468 [Define to 1 if netinet/ether.h declares `ether_ntohost'])
471 #include <netinet/ether.h>
477 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
479 # No, how about <sys/ethernet.h>, as on Solaris 10
482 # This test fails if we don't have <sys/ethernet.h>
483 # or if we do but it doesn't declare ether_ntohost().
485 # Unset ac_cv_have_decl_ether_ntohost so we don't
486 # treat the previous failure as a cached value and
487 # suppress the next test.
489 unset ac_cv_have_decl_ether_ntohost
490 AC_CHECK_DECL(ether_ntohost,
492 AC_DEFINE(SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST,1,
493 [Define to 1 if sys/ethernet.h declares `ether_ntohost'])
496 #include <sys/ethernet.h>
502 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
504 # No, how about <arpa/inet.h>, as in AIX?
506 # This test fails if we don't have <arpa/inet.h>
507 # (if we have ether_ntohost(), we should have
508 # networking, and if we have networking, we should
509 # have <arpa/inet.h>) or if we do but it doesn't
510 # declare ether_ntohost().
512 # Unset ac_cv_have_decl_ether_ntohost so we don't
513 # treat the previous failure as a cached value and
514 # suppress the next test.
516 unset ac_cv_have_decl_ether_ntohost
517 AC_CHECK_DECL(ether_ntohost,
519 AC_DEFINE(ARPA_INET_H_DECLARES_ETHER_NTOHOST,1,
520 [Define to 1 if arpa/inet.h declares `ether_ntohost'])
523 #include <arpa/inet.h>
529 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
531 # No, how about <netinet/if_ether.h>?
532 # On some platforms, it requires <net/if.h> and
533 # <netinet/in.h>, and we always include it with
534 # both of them, so test it with both of them.
536 # This test fails if we don't have <netinet/if_ether.h>
537 # and the headers we include before it, or if we do but
538 # <netinet/if_ether.h> doesn't declare ether_hostton().
540 # Unset ac_cv_have_decl_ether_ntohost so we don't
541 # treat the previous failure as a cached value and
542 # suppress the next test.
544 unset ac_cv_have_decl_ether_ntohost
545 AC_CHECK_DECL(ether_ntohost,
547 AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST,1,
548 [Define to 1 if netinet/if_ether.h declares `ether_ntohost'])
551 #include <sys/types.h>
552 #include <sys/socket.h>
554 #include <netinet/in.h>
555 #include <netinet/if_ether.h>
559 # After all that, is ether_ntohost() declared?
561 if test "$ac_cv_have_decl_ether_ntohost" = yes; then
565 AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 1,
566 [Define to 1 if you have the declaration of `ether_ntohost'])
569 # No, we'll have to declare it ourselves.
570 # Do we have "struct ether_addr" if we include
571 # <netinet/if_ether.h>?
573 AC_CHECK_TYPES(struct ether_addr,,,
575 #include <sys/types.h>
576 #include <sys/socket.h>
578 #include <netinet/in.h>
579 #include <netinet/if_ether.h>
582 AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [
583 AC_RUN_IFELSE([AC_LANG_SOURCE([[
585 #if defined(NET_ETHERNET_H_DECLARES_ETHER_NTOHOST)
587 * OK, just include <net/ethernet.h>.
589 #include <net/ethernet.h>
590 #elif defined(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST)
592 * OK, just include <netinet/ether.h>
594 #include <netinet/ether.h>
595 #elif defined(SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST)
597 * OK, just include <sys/ethernet.h>
599 #include <sys/ethernet.h>
600 #elif defined(ARPA_INET_H_DECLARES_ETHER_NTOHOST)
602 * OK, just include <arpa/inet.h>
604 #include <arpa/inet.h>
605 #elif defined(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST)
607 * OK, include <netinet/if_ether.h>, after all the other stuff we
608 * need to include or define for its benefit.
610 #define NEED_NETINET_IF_ETHER_H
613 * We'll have to declare it ourselves.
614 * If <netinet/if_ether.h> defines struct ether_addr, include
615 * it. Otherwise, define it ourselves.
617 #ifdef HAVE_STRUCT_ETHER_ADDR
618 #define NEED_NETINET_IF_ETHER_H
619 #else /* HAVE_STRUCT_ETHER_ADDR */
621 /* Beware FreeBSD calls this "octet". */
622 unsigned char ether_addr_octet[MAC_ADDR_LEN];
624 #endif /* HAVE_STRUCT_ETHER_ADDR */
625 #endif /* what declares ether_ntohost() */
627 #ifdef NEED_NETINET_IF_ETHER_H
629 * Include diag-control.h before <net/if.h>, which too defines a macro
630 * named ND_UNREACHABLE.
632 #include "diag-control.h"
633 #include <net/if.h> /* Needed on some platforms */
634 #include <netinet/in.h> /* Needed on some platforms */
635 #include <netinet/if_ether.h>
636 #endif /* NEED_NETINET_IF_ETHER_H */
638 #ifndef HAVE_DECL_ETHER_NTOHOST
640 * No header declares it, so declare it ourselves.
642 extern int ether_ntohost(char *, const struct ether_addr *);
643 #endif /* !defined(HAVE_DECL_ETHER_NTOHOST) */
645 #include <sys/types.h>
646 #include <sys/param.h>
647 #include <sys/socket.h>
650 main(int argc, char **argv)
652 u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff };
653 char name[MAXHOSTNAMELEN];
655 ether_ntohost(name, (struct ether_addr *)ea);
659 ], [ac_cv_buggy_ether_ntohost=no],
660 [ac_cv_buggy_ether_ntohost=yes],
661 [ac_cv_buggy_ether_ntohost="not while cross-compiling"])])
662 if test "$ac_cv_buggy_ether_ntohost" = "no"; then
663 AC_DEFINE(USE_ETHER_NTOHOST, 1,
664 [define if you have ether_ntohost() and it works])
669 # Do we have the new open API? Check for pcap_create, and assume that,
670 # if we do, we also have pcap_activate() and the other new routines
671 # introduced in libpcap 1.0.
673 # We require those routines, so fail if we don't find it.
675 AC_CHECK_FUNC(pcap_create,,
676 [AC_MSG_ERROR([libpcap is too old; 1.0 or later is required])])
679 # OK, do we have pcap_set_tstamp_type? If so, assume we have
680 # pcap_list_tstamp_types and pcap_free_tstamp_types as well.
682 AC_CHECK_FUNCS(pcap_set_tstamp_type)
684 # And do we have pcap_set_tstamp_precision? If so, we assume
685 # we also have pcap_open_offline_with_tstamp_precision.
687 AC_CHECK_FUNCS(pcap_set_tstamp_precision)
690 # Check for a miscellaneous collection of functions which we use
693 AC_CHECK_FUNCS(pcap_set_immediate_mode pcap_dump_ftell64)
695 # See the comment in AC_LBL_LIBPCAP in aclocal.m4 for the reason
696 # why we don't check for remote-capture APIs if we're building
697 # with the system libpcap on macOS.
699 if test "$_dont_check_for_remote_apis" != "yes"; then
700 AC_CHECK_FUNCS(pcap_open pcap_findalldevs_ex)
704 # Check for special debugging functions
706 AC_CHECK_FUNCS(pcap_set_parser_debug)
707 if test "$ac_cv_func_pcap_set_parser_debug" = "no" ; then
709 # OK, we don't have pcap_set_parser_debug() to set the libpcap
710 # filter expression parser debug flag; can we directly set the
712 AC_MSG_CHECKING(whether pcap_debug is defined by libpcap)
713 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
714 extern int pcap_debug;
719 [ac_lbl_cv_pcap_debug_defined=yes],
720 [ac_lbl_cv_pcap_debug_defined=no])
721 if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
723 AC_DEFINE(HAVE_PCAP_DEBUG, 1, [define if libpcap has pcap_debug])
727 # OK, what about "yydebug"?
729 AC_MSG_CHECKING(whether yydebug is defined by libpcap)
730 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
736 [ac_lbl_cv_yydebug_defined=yes],
737 [ac_lbl_cv_yydebug_defined=no])
738 if test "$ac_lbl_cv_yydebug_defined" = yes ; then
740 AC_DEFINE(HAVE_YYDEBUG, 1, [define if libpcap has yydebug])
746 AC_CHECK_FUNCS(pcap_set_optimizer_debug)
749 # bpf_dump() moved from tcpdump to libpcap in libpcap 0.6, but some
750 # versions of libpcap didn't pick that change up; the OpenBSD libpcap
751 # picked up most of the new APIs from versions up to 1.0, but didn't
752 # pick up bpf_dump(), so we need to provide it if it's absent.
754 AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6
757 # Assume V7/BSD convention for man pages (file formats in section 5,
758 # miscellaneous info in section 7).
766 # Use System V conventions for man pages.
774 # Use System V conventions for man pages.
781 savedcppflags="$CPPFLAGS"
782 CPPFLAGS="$CPPFLAGS $V_INCLS"
785 # Check whether we have pcap/pcap-inttypes.h.
786 # If we do, we use that to get the C99 types defined.
788 AC_CHECK_HEADERS(pcap/pcap-inttypes.h)
790 CPPFLAGS="$savedcppflags"
793 # Define the old BSD specified-width types in terms of the C99 types;
794 # we may need them with libpcap include files.
796 AC_CHECK_TYPE([u_int8_t], ,
797 [AC_DEFINE([u_int8_t], [uint8_t],
798 [Define to `uint8_t' if u_int8_t not defined.])],
800 #include <sys/types.h>
802 AC_CHECK_TYPE([u_int16_t], ,
803 [AC_DEFINE([u_int16_t], [uint16_t],
804 [Define to `uint16_t' if u_int16_t not defined.])],
806 #include <sys/types.h>
808 AC_CHECK_TYPE([u_int32_t], ,
809 [AC_DEFINE([u_int32_t], [uint32_t],
810 [Define to `uint32_t' if u_int32_t not defined.])],
812 #include <sys/types.h>
814 AC_CHECK_TYPE([u_int64_t], ,
815 [AC_DEFINE([u_int64_t], [uint64_t],
816 [Define to `uint64_t' if u_int64_t not defined.])],
818 #include <sys/types.h>
822 AC_CHECK_TOOL([AR], [ar])
824 AC_LBL_DEVEL(V_CCOPT)
826 # Check for OpenSSL/libressl libcrypto
827 AC_MSG_CHECKING(whether to use OpenSSL/libressl libcrypto)
828 # Specify location for both includes and libraries.
829 want_libcrypto=ifavailable
831 AS_HELP_STRING([--with-crypto]@<:@=DIR@:>@,
832 [use OpenSSL/libressl libcrypto (located in directory DIR, if specified) @<:@default=yes, if available@:>@]),
834 if test $withval = no
836 # User doesn't want to link with libcrypto.
839 elif test $withval = yes
841 # User wants to link with libcrypto but hasn't specified
846 # User wants to link with libcrypto and has specified
847 # a directory, so use the provided value.
849 libcrypto_root=$withval
850 AC_MSG_RESULT([yes, using the version installed in $withval])
854 # Use libcrypto if it's present, otherwise don't; no directory
857 want_libcrypto=ifavailable
858 AC_MSG_RESULT([yes, if available])
860 if test "$want_libcrypto" != "no"; then
862 # Were we told where to look for libcrypto?
864 if test -z "$libcrypto_root"; then
868 # First, try looking for it with pkg-config, if we have it.
870 # Homebrew's pkg-config does not, by default, look for
871 # pkg-config files for packages it has installed.
872 # Furthermore, at least for OpenSSL, they appear to be
873 # dumped in package-specific directories whose paths are
874 # not only package-specific but package-version-specific.
876 # So the only way to find openssl is to get the value of
877 # PKG_CONFIG_PATH from "brew --env openssl" and add that
878 # to PKG_CONFIG_PATH. (No, we can't just assume it's under
879 # /usr/local; Homebrew have conveniently chosen to put it
880 # under /opt/homebrew on ARM.)
882 # That's the nice thing about Homebrew - it makes things easier!
885 save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
886 if test -n "$BREW"; then
887 openssl_pkgconfig_dir=`$BREW --env --plain openssl | sed -n 's/PKG_CONFIG_PATH: //p'`
888 PKG_CONFIG_PATH="$openssl_pkgconfig_dir:$PKG_CONFIG_PATH"
890 PKG_CHECK_MODULE(LIBCRYPTO, libcrypto,
893 # We found OpenSSL/libressl libcrypto.
897 PKG_CONFIG_PATH="$save_PKG_CONFIG_PATH"
900 # If it wasn't found, and we have Homebrew installed, see
901 # if it's in Homebrew.
903 if test "x$HAVE_LIBCRYPTO" != "xyes" -a -n "$BREW"; then
904 AC_MSG_CHECKING(for openssl in Homebrew)
906 # The brew man page lies when it speaks of
907 # $BREW --prefix --installed <formula>
908 # outputting nothing. In Homebrew 3.3.16,
909 # it produces output regardless of whether
910 # the formula is installed or not, so we
911 # send the standard output and error to
914 # libcrypto isn't a formula, openssl is a formula.
916 if $BREW --prefix --installed openssl >/dev/null 2>&1; then
918 # Yes. Get the include directory and library
919 # directory. (No, we can't just assume it's
920 # under /usr/local; Homebrew have conveniently
921 # chosen to put it under /opt/homebrew on ARM.)
925 openssl_path=`$BREW --prefix openssl`
926 LIBCRYPTO_CFLAGS="-I$openssl_path/include"
927 LIBCRYPTO_LIBS="-L$openssl_path/lib -lcrypto"
934 # If it wasn't found, and /usr/local/include and /usr/local/lib
935 # exist, check if it's in /usr/local. (We check whether they
936 # exist because, if they don't exist, the compiler will warn
937 # about that and then ignore the argument, so they test
938 # using just the system header files and libraries.)
940 # We include the standard include file to 1) make sure that
941 # it's installed (if it's just a shared library for the
942 # benefit of existing programs, that's not useful) and 2)
943 # because SSL_library_init() is a library routine in some
944 # versions and a #defined wrapper around OPENSSL_init_ssl()
947 if test "x$HAVE_LIBCRYPTO" != "xyes" -a -d "/usr/local/include" -a -d "/usr/local/lib"; then
948 AC_LBL_SAVE_CHECK_STATE
949 CFLAGS="$CFLAGS -I/usr/local/include"
950 LIBS="$LIBS -L/usr/local/lib -lcrypto"
951 AC_MSG_CHECKING(whether we have an OpenSSL/libressl libcrypto in /usr/local that we can use)
952 AC_LINK_IFELSE([AC_LANG_PROGRAM(
954 #include <openssl/evp.h>
957 EVP_CIPHER_CTX_block_size((EVP_CIPHER_CTX *)0);
963 LIBCRYPTO_CFLAGS="-I/usr/local/include"
964 LIBCRYPTO_LIBS="-L/usr/local/lib -lcrypto"
967 AC_LBL_RESTORE_CHECK_STATE
971 # If it wasn't found, check if it's a system library.
973 # We include the standard include file to 1) make sure that
974 # it's installed (if it's just a shared library for the
975 # benefit of existing programs, that's not useful) and 2)
976 # make sure this isn't a newer macOS that provides libcrypto
977 # as a shared library but doesn't provide headers - Apple,
978 # bless their pointy little heads, apparently ship libcrypto
979 # as a library, but not the header files, in El Capitan and
980 # later, probably because they don't want you writing nasty
981 # portable code that could run on other UN*Xes, they want you
982 # writing code that uses their Shiny New Crypto Library and
983 # that thus only runs on macOS.
985 if test "x$HAVE_LIBCRYPTO" != "xyes"; then
986 AC_LBL_SAVE_CHECK_STATE
987 LIBS="$LIBS -lcrypto"
988 AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use)
989 AC_LINK_IFELSE([AC_LANG_PROGRAM(
991 #include <openssl/evp.h>
994 EVP_CIPHER_CTX_block_size((EVP_CIPHER_CTX *)0);
1000 LIBCRYPTO_LIBS="-lcrypto"
1003 AC_LBL_RESTORE_CHECK_STATE
1009 # Look for it there.
1011 AC_LBL_SAVE_CHECK_STATE
1012 CFLAGS="$CFLAGS -I$libcrypto_root/include"
1013 LIBS="$LIBS -L$libcrypto_root/lib -lcrypto"
1014 AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use)
1015 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1017 #include <openssl/evp.h>
1020 EVP_CIPHER_CTX_block_size((EVP_CIPHER_CTX *)0);
1026 LIBCRYPTO_CFLAGS="-I$libcrypto_root/include"
1027 LIBCRYPTO_LIBS="-L$libcrypto_root/lib -lcrypto"
1030 AC_LBL_RESTORE_CHECK_STATE
1034 # OK, did we find it?
1036 if test "x$HAVE_LIBCRYPTO" = "xyes"; then
1037 AC_DEFINE([HAVE_LIBCRYPTO], [1], [Define to 1 if you have a usable `crypto' library (-lcrypto).])
1040 # Put the subdirectories of the libcrypto root directory
1041 # at the end of the header and library search path, to
1042 # make sure they come after any -I or -L flags for
1043 # a local libpcap - those must take precedence of any
1044 # directory that might contain an installed version of
1047 V_INCLS="$V_INCLS $LIBCRYPTO_CFLAGS"
1048 LIBS="$LIBS $LIBCRYPTO_LIBS"
1053 # 1) do we have EVP_CIPHER_CTX_new?
1054 # If so, we use it to allocate an EVP_CIPHER_CTX, as
1055 # EVP_CIPHER_CTX may be opaque; otherwise, we allocate it
1058 # 2) do we have EVP_DecryptInit_ex()?
1059 # If so, we use it, because we need to be able to make
1060 # two "initialize the cipher" calls, one with the cipher
1061 # and key, and one with the IV, and, as of OpenSSL 1.1,
1062 # You Can't Do That with EVP_DecryptInit(), because a
1063 # call to EVP_DecryptInit() will unconditionally clear
1064 # the context, and if you don't supply a cipher, it'll
1065 # clear the cipher, rendering the context unusable and
1068 AC_CHECK_FUNCS(EVP_CIPHER_CTX_new EVP_DecryptInit_ex)
1070 AC_MSG_NOTICE(OpenSSL/libressl libcrypto not found)
1074 # Check for libcap-ng
1075 AC_MSG_CHECKING(whether to use libcap-ng)
1076 # Specify location for both includes and libraries.
1078 AS_HELP_STRING([--with-cap-ng],
1079 [use libcap-ng @<:@default=yes, if available@:>@]),
1081 if test $withval = no
1085 elif test $withval = yes
1092 # Use libcap-ng if it's present, otherwise don't.
1094 want_libcap_ng=ifavailable
1095 AC_MSG_RESULT([yes, if available])
1098 # libcap-ng is available on Linux only.
1099 expr "$host_os" : linux >/dev/null || want_libcap_ng=no
1101 if test "$want_libcap_ng" != "no"; then
1102 AC_CHECK_LIB(cap-ng, capng_change_id)
1103 AC_CHECK_HEADERS(cap-ng.h)
1107 dnl set additional include path if necessary
1108 if test "$missing_includes" = "yes"; then
1109 CPPFLAGS="$CPPFLAGS -I$srcdir/missing"
1110 V_INCLS="$V_INCLS -I$srcdir/missing"
1118 AC_SUBST(MAN_FILE_FORMATS)
1119 AC_SUBST(MAN_MISC_INFO)
1123 AC_CONFIG_HEADERS([config.h])
1125 #ifndef TCPDUMP_CONFIG_H_
1126 #define TCPDUMP_CONFIG_H_
1129 #endif // TCPDUMP_CONFIG_H_
1132 AC_CONFIG_COMMANDS([.devel],[[if test -f .devel; then
1133 echo timestamp > stamp-h
1134 cat $srcdir/Makefile-devel-adds >> Makefile
1135 make depend || exit 1
1137 AC_CONFIG_FILES([Makefile tcpdump.1])