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)
49 # Get the size of a void *, to know whether this is a 32-bit or 64-bit build.
51 AC_CHECK_SIZEOF([void *])
54 # Get the size of a time_t, to know whether it's 32-bit or 64-bit.
56 AC_CHECK_SIZEOF([time_t],,[#include <time.h>])
61 AC_ARG_ENABLE(universal,
62 AS_HELP_STRING([--disable-universal],[don't build universal on macOS]))
63 if test "$enable_universal" != "no"; then
68 # Leopard. Build for x86 and 32-bit PowerPC, with
69 # x86 first. (That's what Apple does.)
71 V_CCOPT="$V_CCOPT -arch i386 -arch ppc"
72 LDFLAGS="$LDFLAGS -arch i386 -arch ppc"
77 # Snow Leopard. Build for x86-64 and x86, with
78 # x86-64 first. (That's what Apple does.)
80 V_CCOPT="$V_CCOPT -arch x86_64 -arch i386"
81 LDFLAGS="$LDFLAGS -arch x86_64 -arch i386"
89 # Do we have pkg-config?
94 # Do we have the brew command from Homebrew?
96 AC_PATH_PROG([BREW], [brew])
99 [AS_HELP_STRING([--with-smi],
100 [link with libsmi (allows to load MIBs on the fly to decode SNMP packets) [default=yes, if available]])],
104 if test "x$with_smi" != "xno" ; then
105 AC_CHECK_HEADER(smi.h,
108 # OK, we found smi.h. Do we have libsmi with smiInit?
110 AC_CHECK_LIB(smi, smiInit,
113 # OK, we have libsmi with smiInit. Can we use it?
115 AC_MSG_CHECKING([whether to enable libsmi])
118 AC_RUN_IFELSE([AC_LANG_SOURCE([[
119 /* libsmi available check */
126 int current, revision, age, n;
127 const int required = 2;
130 if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
132 n = sscanf(smi_library_version, "%d:%d:%d", ¤t, &revision, &age);
135 if (required < current - age || required > current)
143 AC_DEFINE(USE_LIBSMI, 1,
144 [Define if you enable support for libsmi])
147 dnl autoconf documentation says that
148 dnl $? contains the exit value.
149 dnl reality is that it does not.
150 dnl We leave this in just in case
151 dnl autoconf ever comes back to
152 dnl match the documentation.
154 1) AC_MSG_RESULT(no - smiInit failed) ;;
155 2) AC_MSG_RESULT(no - header/library version mismatch) ;;
156 3) AC_MSG_RESULT(no - can't determine library version) ;;
157 4) AC_MSG_RESULT(no - too old) ;;
158 *) AC_MSG_RESULT(no) ;;
163 AC_MSG_RESULT(not when cross-compiling)
171 AC_MSG_CHECKING([whether to enable the instrument functions code])
172 AC_ARG_ENABLE([instrument-functions],
173 [AS_HELP_STRING([--enable-instrument-functions],
174 [enable instrument functions code [default=no]])],
178 yes) AC_MSG_RESULT(yes)
179 AC_CHECK_LIB([bfd], [bfd_init],
182 [--enable-instrument-functions was given, but test for library libbfd failed. Please install the 'binutils-dev' package.])],
184 AC_DEFINE(ENABLE_INSTRUMENT_FUNCTIONS, 1,
185 [define if you want to build the instrument functions code])
186 LOCALSRC="$LOCALSRC instrument-functions.c"
187 # Add '-finstrument-functions' instrumentation option to generate
188 # instrumentation calls for entry and exit to functions.
189 # Try to avoid Address Space Layout Randomization (ALSR).
190 CFLAGS="$CFLAGS -O0 -ggdb -finstrument-functions -fno-stack-protector -fno-pic"
191 LDFLAGS="$LDFLAGS -O0 -ggdb -fno-stack-protector -no-pie"
198 AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer])
200 [AS_HELP_STRING([--enable-smb],
201 [enable possibly-buggy SMB printer [default=no]])],
205 yes) AC_MSG_RESULT(yes)
206 AC_DEFINE(ENABLE_SMB, 1,
207 [define if you want to build the possibly-buggy SMB printer])
208 LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
214 AC_MSG_CHECKING([whether to drop root privileges by default])
217 [AS_HELP_STRING([--with-user=USERNAME],
218 [drop privileges by default to USERNAME]
222 AS_CASE(["$withval"],
223 [no], [AC_MSG_RESULT(no)],
224 [''|yes], [AC_MSG_ERROR([--with-user requires a username])],
226 AC_DEFINE_UNQUOTED(WITH_USER, "$withval",
227 [define if should drop privileges by default])
228 AC_MSG_RESULT([yes, to user "$withval"])
232 AC_MSG_CHECKING([whether to chroot])
235 [AS_HELP_STRING([--with-chroot=DIRECTORY],
236 [when dropping privileges, chroot to DIRECTORY]
241 AS_CASE(["$withval"],
242 [no], [AC_MSG_RESULT(no)],
243 [''|yes], [AC_MSG_ERROR([--with-chroot requires a directory])],
245 AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval",
246 [define if should chroot when dropping privileges])
247 AC_MSG_RESULT([yes, to directory "$withval"])
251 AC_ARG_WITH(sandbox-capsicum,
252 AS_HELP_STRING([--with-sandbox-capsicum],
253 [use Capsicum security functions @<:@default=yes, if available@:>@]))
255 # Check whether various functions are available. If any are, set
256 # ac_lbl_capsicum_function_seen to yes; if any are not, set
257 # ac_lbl_capsicum_function_not_seen to yes.
259 # We don't check cap_rights_init(), as it's a macro, wrapping another
260 # function, in at least some versions of FreeBSD, and AC_CHECK_FUNCS()
261 # doesn't handle that.
263 # All of the ones we check for must be available in order to enable
264 # capsicum sandboxing.
266 # XXX - do we need to check for all of them, or are there some that, if
267 # present, imply others are present?
269 if test -z "$with_sandbox_capsicum" || test "$with_sandbox_capsicum" != "no" ; then
271 # First, make sure we have the required header.
273 AC_CHECK_HEADER(sys/capsicum.h,
276 # We do; now make sure we have the required functions.
278 AC_CHECK_FUNCS(cap_enter cap_rights_limit cap_ioctls_limit openat,
279 ac_lbl_capsicum_function_seen=yes,
280 ac_lbl_capsicum_function_not_seen=yes)
282 AC_CHECK_LIB(casper, cap_init, LIBS="$LIBS -lcasper")
283 AC_CHECK_LIB(cap_dns, cap_gethostbyaddr, LIBS="$LIBS -lcap_dns")
285 AC_MSG_CHECKING([whether to sandbox using capsicum])
286 if test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then
287 AC_DEFINE(HAVE_CAPSICUM, 1, [capsicum support available])
292 AC_MSG_CHECKING([whether to sandbox using Casper library])
293 if test "x$ac_cv_lib_casper_cap_init" = "xyes" -a "x$ac_cv_lib_cap_dns_cap_gethostbyaddr" = "xyes"; then
294 AC_DEFINE(HAVE_CASPER, 1, [Casper support available])
301 # XXX - we used to check this before checking whether to check the OS's
302 # IPv6, support because, on some platforms (such as SunOS 5.x), the test
303 # program requires the extra networking libraries. We no longer
304 # test for IPv6 support, we just assume it's present with the
305 # standard API, so perhaps this can be moved.
309 AC_REPLACE_FUNCS(strlcat strlcpy strsep getservent getopt_long)
310 AC_CHECK_FUNCS(fork vfork)
313 # It became apparent at some point that using a suitable C99 compiler does not
314 # automatically mean snprintf(3) implementation in the libc supports all the
315 # modifiers and specifiers used in the project, so let's test that before the
318 # Testing the sizeof_t length modifier takes making an snprintf() call and
319 # comparing the actual result with the expected result. If this fails, it will
320 # most likely happen at run time, not compile time.
322 # Testing the 64-bit conversion specifiers in addition to that requires the
323 # <inttypes.h> header to be present and the macros to be defined, so if this
324 # fails, it will more likely happen at compile time.
326 AC_MSG_CHECKING([whether snprintf is suitable])
332 #include <inttypes.h>
333 #include <sys/types.h>
335 #if defined(_WIN32) && !defined(_SSIZE_T_DEFINED)
337 * On UN*Xes, this is a signed integer type of the same size as size_t.
339 * It's not defined by Visual Studio; we assume that ptrdiff_t will
340 * be a type that is a signed integer type of the same size as size_t.
342 typedef ptrdiff_t ssize_t;
346 * Avoid trying to cast negative values to unsigned types, or doing
347 * shifts of signed types, in order not to have the test program fail
348 * if we're building with undefined-behavior sanitizers enabled.
353 unsigned int ui = sizeof(buf);
355 int64_t i64 = INT64_C(0x100000000);
356 uint64_t ui64 = UINT64_C(0x100000000);
358 snprintf(buf, sizeof(buf), "%zu", (size_t)ui);
359 if (strncmp(buf, "100", sizeof(buf)))
362 snprintf(buf, sizeof(buf), "%zd", (ssize_t)(-i));
363 if (strncmp(buf, "-100", sizeof(buf)))
366 snprintf(buf, sizeof(buf), "%" PRId64, -i64);
367 if (strncmp(buf, "-4294967296", sizeof(buf)))
370 snprintf(buf, sizeof(buf), "0o%" PRIo64, ui64);
371 if (strncmp(buf, "0o40000000000", sizeof(buf)))
374 snprintf(buf, sizeof(buf), "0x%" PRIx64, ui64);
375 if (strncmp(buf, "0x100000000", sizeof(buf)))
378 snprintf(buf, sizeof(buf), "%" PRIu64, ui64);
379 if (strncmp(buf, "4294967296", sizeof(buf)))
392 [The snprintf(3) implementation in this libc is not suitable,
393 tcpdump would not work correctly even if it managed to compile.])
396 AC_MSG_RESULT(not while cross-compiling)
400 AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc
402 dnl Some platforms may need -lnsl for getrpcbynumber.
403 AC_SEARCH_LIBS(getrpcbynumber, nsl,
404 AC_DEFINE(HAVE_GETRPCBYNUMBER, 1, [define if you have getrpcbynumber()]))
406 AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
409 # Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
410 # libraries (e.g., "-lsocket -lnsl" on Solaris).
412 # You are in a twisty little maze of UN*Xes, all different.
413 # Some might not have ether_ntohost().
414 # Some might have it and declare it in <net/ethernet.h>.
415 # Some might have it and declare it in <netinet/ether.h>
416 # Some might have it and declare it in <sys/ethernet.h>.
417 # Some might have it and declare it in <arpa/inet.h>.
418 # Some might have it and declare it in <netinet/if_ether.h>.
419 # Some might have it and not declare it in any header file.
421 # Before you is a C compiler.
423 AC_CHECK_FUNCS(ether_ntohost, [
425 # OK, we have ether_ntohost(). Is it declared in <net/ethernet.h>?
427 # This test fails if we don't have <net/ethernet.h> or if we do
428 # but it doesn't declare ether_ntohost().
430 AC_CHECK_DECL(ether_ntohost,
432 AC_DEFINE(NET_ETHERNET_H_DECLARES_ETHER_NTOHOST,1,
433 [Define to 1 if net/ethernet.h declares `ether_ntohost'])
436 #include <net/ethernet.h>
441 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
443 # No, how about <netinet/ether.h>, as on Linux?
445 # This test fails if we don't have <netinet/ether.h>
446 # or if we do but it doesn't declare ether_ntohost().
448 # Unset ac_cv_have_decl_ether_ntohost so we don't
449 # treat the previous failure as a cached value and
450 # suppress the next test.
452 unset ac_cv_have_decl_ether_ntohost
453 AC_CHECK_DECL(ether_ntohost,
455 AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,1,
456 [Define to 1 if netinet/ether.h declares `ether_ntohost'])
459 #include <netinet/ether.h>
465 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
467 # No, how about <sys/ethernet.h>, as on Solaris 10
470 # This test fails if we don't have <sys/ethernet.h>
471 # or if we do but it doesn't declare ether_ntohost().
473 # Unset ac_cv_have_decl_ether_ntohost so we don't
474 # treat the previous failure as a cached value and
475 # suppress the next test.
477 unset ac_cv_have_decl_ether_ntohost
478 AC_CHECK_DECL(ether_ntohost,
480 AC_DEFINE(SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST,1,
481 [Define to 1 if sys/ethernet.h declares `ether_ntohost'])
484 #include <sys/ethernet.h>
490 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
492 # No, how about <arpa/inet.h>, as in AIX?
494 # This test fails if we don't have <arpa/inet.h>
495 # (if we have ether_ntohost(), we should have
496 # networking, and if we have networking, we should
497 # have <arpa/inet.h>) or if we do but it doesn't
498 # declare ether_ntohost().
500 # Unset ac_cv_have_decl_ether_ntohost so we don't
501 # treat the previous failure as a cached value and
502 # suppress the next test.
504 unset ac_cv_have_decl_ether_ntohost
505 AC_CHECK_DECL(ether_ntohost,
507 AC_DEFINE(ARPA_INET_H_DECLARES_ETHER_NTOHOST,1,
508 [Define to 1 if arpa/inet.h declares `ether_ntohost'])
511 #include <arpa/inet.h>
517 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
519 # No, how about <netinet/if_ether.h>?
520 # On some platforms, it requires <net/if.h> and
521 # <netinet/in.h>, and we always include it with
522 # both of them, so test it with both of them.
524 # This test fails if we don't have <netinet/if_ether.h>
525 # and the headers we include before it, or if we do but
526 # <netinet/if_ether.h> doesn't declare ether_hostton().
528 # Unset ac_cv_have_decl_ether_ntohost so we don't
529 # treat the previous failure as a cached value and
530 # suppress the next test.
532 unset ac_cv_have_decl_ether_ntohost
533 AC_CHECK_DECL(ether_ntohost,
535 AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST,1,
536 [Define to 1 if netinet/if_ether.h declares `ether_ntohost'])
539 #include <sys/types.h>
540 #include <sys/socket.h>
542 #include <netinet/in.h>
543 #include <netinet/if_ether.h>
547 # After all that, is ether_ntohost() declared?
549 if test "$ac_cv_have_decl_ether_ntohost" = yes; then
553 AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 1,
554 [Define to 1 if you have the declaration of `ether_ntohost'])
557 # No, we'll have to declare it ourselves.
558 # Do we have "struct ether_addr" if we include
559 # <netinet/if_ether.h>?
561 AC_CHECK_TYPES(struct ether_addr,,,
563 #include <sys/types.h>
564 #include <sys/socket.h>
566 #include <netinet/in.h>
567 #include <netinet/if_ether.h>
570 AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [
571 AC_RUN_IFELSE([AC_LANG_SOURCE([[
573 #if defined(NET_ETHERNET_H_DECLARES_ETHER_NTOHOST)
575 * OK, just include <net/ethernet.h>.
577 #include <net/ethernet.h>
578 #elif defined(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST)
580 * OK, just include <netinet/ether.h>
582 #include <netinet/ether.h>
583 #elif defined(SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST)
585 * OK, just include <sys/ethernet.h>
587 #include <sys/ethernet.h>
588 #elif defined(ARPA_INET_H_DECLARES_ETHER_NTOHOST)
590 * OK, just include <arpa/inet.h>
592 #include <arpa/inet.h>
593 #elif defined(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST)
595 * OK, include <netinet/if_ether.h>, after all the other stuff we
596 * need to include or define for its benefit.
598 #define NEED_NETINET_IF_ETHER_H
601 * We'll have to declare it ourselves.
602 * If <netinet/if_ether.h> defines struct ether_addr, include
603 * it. Otherwise, define it ourselves.
605 #ifdef HAVE_STRUCT_ETHER_ADDR
606 #define NEED_NETINET_IF_ETHER_H
607 #else /* HAVE_STRUCT_ETHER_ADDR */
609 /* Beware FreeBSD calls this "octet". */
610 unsigned char ether_addr_octet[MAC_ADDR_LEN];
612 #endif /* HAVE_STRUCT_ETHER_ADDR */
613 #endif /* what declares ether_ntohost() */
615 #ifdef NEED_NETINET_IF_ETHER_H
617 * Include diag-control.h before <net/if.h>, which too defines a macro
618 * named ND_UNREACHABLE.
620 #include "diag-control.h"
621 #include <net/if.h> /* Needed on some platforms */
622 #include <netinet/in.h> /* Needed on some platforms */
623 #include <netinet/if_ether.h>
624 #endif /* NEED_NETINET_IF_ETHER_H */
626 #ifndef HAVE_DECL_ETHER_NTOHOST
628 * No header declares it, so declare it ourselves.
630 extern int ether_ntohost(char *, const struct ether_addr *);
631 #endif /* !defined(HAVE_DECL_ETHER_NTOHOST) */
633 #include <sys/types.h>
634 #include <sys/param.h>
635 #include <sys/socket.h>
638 main(int argc, char **argv)
640 u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff };
641 char name[MAXHOSTNAMELEN];
643 ether_ntohost(name, (struct ether_addr *)ea);
647 ], [ac_cv_buggy_ether_ntohost=no],
648 [ac_cv_buggy_ether_ntohost=yes],
649 [ac_cv_buggy_ether_ntohost="not while cross-compiling"])])
650 if test "$ac_cv_buggy_ether_ntohost" = "no"; then
651 AC_DEFINE(USE_ETHER_NTOHOST, 1,
652 [define if you have ether_ntohost() and it works])
657 # Do we have the new open API? Check for pcap_create, and assume that,
658 # if we do, we also have pcap_activate() and the other new routines
659 # introduced in libpcap 1.0.
661 # We require those routines, so fail if we don't find it.
663 AC_CHECK_FUNC(pcap_create,,
664 [AC_MSG_ERROR([libpcap is too old; 1.0 or later is required])])
667 # OK, do we have pcap_set_tstamp_type? If so, assume we have
668 # pcap_list_tstamp_types and pcap_free_tstamp_types as well.
670 AC_CHECK_FUNCS(pcap_set_tstamp_type)
672 # And do we have pcap_set_tstamp_precision? If so, we assume
673 # we also have pcap_open_offline_with_tstamp_precision.
675 AC_CHECK_FUNCS(pcap_set_tstamp_precision)
678 # Check for a miscellaneous collection of functions which we use
681 AC_CHECK_FUNCS(pcap_set_immediate_mode pcap_dump_ftell64)
683 # See the comment in AC_LBL_LIBPCAP in aclocal.m4 for the reason
684 # why we don't check for remote-capture APIs if we're building
685 # with the system libpcap on macOS.
687 if test "$_dont_check_for_remote_apis" != "yes"; then
688 AC_CHECK_FUNCS(pcap_open pcap_findalldevs_ex)
692 # Check for special debugging functions
694 AC_CHECK_FUNCS(pcap_set_parser_debug)
695 if test "$ac_cv_func_pcap_set_parser_debug" = "no" ; then
697 # OK, we don't have pcap_set_parser_debug() to set the libpcap
698 # filter expression parser debug flag; can we directly set the
700 AC_MSG_CHECKING(whether pcap_debug is defined by libpcap)
701 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
702 extern int pcap_debug;
707 [ac_lbl_cv_pcap_debug_defined=yes],
708 [ac_lbl_cv_pcap_debug_defined=no])
709 if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
711 AC_DEFINE(HAVE_PCAP_DEBUG, 1, [define if libpcap has pcap_debug])
715 # OK, what about "yydebug"?
717 AC_MSG_CHECKING(whether yydebug is defined by libpcap)
718 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
724 [ac_lbl_cv_yydebug_defined=yes],
725 [ac_lbl_cv_yydebug_defined=no])
726 if test "$ac_lbl_cv_yydebug_defined" = yes ; then
728 AC_DEFINE(HAVE_YYDEBUG, 1, [define if libpcap has yydebug])
734 AC_CHECK_FUNCS(pcap_set_optimizer_debug)
737 # bpf_dump() moved from tcpdump to libpcap in libpcap 0.6, but some
738 # versions of libpcap didn't pick that change up; the OpenBSD libpcap
739 # picked up most of the new APIs from versions up to 1.0, but didn't
740 # pick up bpf_dump(), so we need to provide it if it's absent.
742 AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6
745 # Assume V7/BSD convention for man pages (file formats in section 5,
746 # miscellaneous info in section 7).
754 # Use System V conventions for man pages.
762 # Use System V conventions for man pages.
769 savedcppflags="$CPPFLAGS"
770 CPPFLAGS="$CPPFLAGS $V_INCLS"
773 # Check whether we have pcap/pcap-inttypes.h.
774 # If we do, we use that to get the C99 types defined.
776 AC_CHECK_HEADERS(pcap/pcap-inttypes.h)
778 CPPFLAGS="$savedcppflags"
781 # Define the old BSD specified-width types in terms of the C99 types;
782 # we may need them with libpcap include files.
784 AC_CHECK_TYPE([u_int8_t], ,
785 [AC_DEFINE([u_int8_t], [uint8_t],
786 [Define to `uint8_t' if u_int8_t not defined.])],
788 #include <sys/types.h>
790 AC_CHECK_TYPE([u_int16_t], ,
791 [AC_DEFINE([u_int16_t], [uint16_t],
792 [Define to `uint16_t' if u_int16_t not defined.])],
794 #include <sys/types.h>
796 AC_CHECK_TYPE([u_int32_t], ,
797 [AC_DEFINE([u_int32_t], [uint32_t],
798 [Define to `uint32_t' if u_int32_t not defined.])],
800 #include <sys/types.h>
802 AC_CHECK_TYPE([u_int64_t], ,
803 [AC_DEFINE([u_int64_t], [uint64_t],
804 [Define to `uint64_t' if u_int64_t not defined.])],
806 #include <sys/types.h>
810 AC_CHECK_TOOL([AR], [ar])
812 AC_LBL_DEVEL(V_CCOPT)
814 # Check for OpenSSL/libressl libcrypto
815 AC_MSG_CHECKING(whether to use OpenSSL/libressl libcrypto)
816 # Specify location for both includes and libraries.
817 want_libcrypto=ifavailable
819 AS_HELP_STRING([--with-crypto]@<:@=DIR@:>@,
820 [use OpenSSL/libressl libcrypto (located in directory DIR, if specified) @<:@default=yes, if available@:>@]),
822 if test $withval = no
824 # User doesn't want to link with libcrypto.
827 elif test $withval = yes
829 # User wants to link with libcrypto but hasn't specified
834 # User wants to link with libcrypto and has specified
835 # a directory, so use the provided value.
837 libcrypto_root=$withval
838 AC_MSG_RESULT([yes, using the version installed in $withval])
842 # Use libcrypto if it's present, otherwise don't; no directory
845 want_libcrypto=ifavailable
846 AC_MSG_RESULT([yes, if available])
848 if test "$want_libcrypto" != "no"; then
850 # Were we told where to look for libcrypto?
852 if test -z "$libcrypto_root"; then
856 # First, try looking for it with pkg-config, if we have it.
858 # Homebrew's pkg-config does not, by default, look for
859 # pkg-config files for packages it has installed.
860 # Furthermore, at least for OpenSSL, they appear to be
861 # dumped in package-specific directories whose paths are
862 # not only package-specific but package-version-specific.
864 # So the only way to find openssl is to get the value of
865 # PKG_CONFIG_PATH from "brew --env openssl" and add that
866 # to PKG_CONFIG_PATH. (No, we can't just assume it's under
867 # /usr/local; Homebrew have conveniently chosen to put it
868 # under /opt/homebrew on ARM.)
870 # That's the nice thing about Homebrew - it makes things easier!
873 save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
874 if test -n "$BREW"; then
875 openssl_pkgconfig_dir=`$BREW --env --plain openssl | sed -n 's/PKG_CONFIG_PATH: //p'`
876 PKG_CONFIG_PATH="$openssl_pkgconfig_dir:$PKG_CONFIG_PATH"
878 PKG_CHECK_MODULE(LIBCRYPTO, libcrypto,
881 # We found OpenSSL/libressl libcrypto.
885 PKG_CONFIG_PATH="$save_PKG_CONFIG_PATH"
888 # If it wasn't found, and we have Homebrew installed, see
889 # if it's in Homebrew.
891 if test "x$HAVE_LIBCRYPTO" != "xyes" -a -n "$BREW"; then
892 AC_MSG_CHECKING(for openssl in Homebrew)
894 # The brew man page lies when it speaks of
895 # $BREW --prefix --installed <formula>
896 # outputting nothing. In Homebrew 3.3.16,
897 # it produces output regardless of whether
898 # the formula is installed or not, so we
899 # send the standard output and error to
902 # libcrypto isn't a formula, openssl is a formula.
904 if $BREW --prefix --installed openssl >/dev/null 2>&1; then
906 # Yes. Get the include directory and library
907 # directory. (No, we can't just assume it's
908 # under /usr/local; Homebrew have conveniently
909 # chosen to put it under /opt/homebrew on ARM.)
913 openssl_path=`$BREW --prefix openssl`
914 LIBCRYPTO_CFLAGS="-I$openssl_path/include"
915 LIBCRYPTO_LIBS="-L$openssl_path/lib -lcrypto"
922 # If it wasn't found, and /usr/local/include and /usr/local/lib
923 # exist, check if it's in /usr/local. (We check whether they
924 # exist because, if they don't exist, the compiler will warn
925 # about that and then ignore the argument, so they test
926 # using just the system header files and libraries.)
928 # We include the standard include file to 1) make sure that
929 # it's installed (if it's just a shared library for the
930 # benefit of existing programs, that's not useful) and 2)
931 # because SSL_library_init() is a library routine in some
932 # versions and a #defined wrapper around OPENSSL_init_ssl()
935 if test "x$HAVE_LIBCRYPTO" != "xyes" -a -d "/usr/local/include" -a -d "/usr/local/lib"; then
936 AC_LBL_SAVE_CHECK_STATE
937 CFLAGS="$CFLAGS -I/usr/local/include"
938 LIBS="$LIBS -L/usr/local/lib -lcrypto"
939 AC_MSG_CHECKING(whether we have an OpenSSL/libressl libcrypto in /usr/local that we can use)
940 AC_LINK_IFELSE([AC_LANG_PROGRAM(
942 #include <openssl/evp.h>
945 EVP_CIPHER_CTX_block_size((EVP_CIPHER_CTX *)0);
951 LIBCRYPTO_CFLAGS="-I/usr/local/include"
952 LIBCRYPTO_LIBS="-L/usr/local/lib -lcrypto"
955 AC_LBL_RESTORE_CHECK_STATE
959 # If it wasn't found, check if it's a system library.
961 # We include the standard include file to 1) make sure that
962 # it's installed (if it's just a shared library for the
963 # benefit of existing programs, that's not useful) and 2)
964 # make sure this isn't a newer macOS that provides libcrypto
965 # as a shared library but doesn't provide headers - Apple,
966 # bless their pointy little heads, apparently ship libcrypto
967 # as a library, but not the header files, in El Capitan and
968 # later, probably because they don't want you writing nasty
969 # portable code that could run on other UN*Xes, they want you
970 # writing code that uses their Shiny New Crypto Library and
971 # that thus only runs on macOS.
973 if test "x$HAVE_LIBCRYPTO" != "xyes"; then
974 AC_LBL_SAVE_CHECK_STATE
975 LIBS="$LIBS -lcrypto"
976 AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use)
977 AC_LINK_IFELSE([AC_LANG_PROGRAM(
979 #include <openssl/evp.h>
982 EVP_CIPHER_CTX_block_size((EVP_CIPHER_CTX *)0);
988 LIBCRYPTO_LIBS="-lcrypto"
991 AC_LBL_RESTORE_CHECK_STATE
999 AC_LBL_SAVE_CHECK_STATE
1000 CFLAGS="$CFLAGS -I$libcrypto_root/include"
1001 LIBS="$LIBS -L$libcrypto_root/lib -lcrypto"
1002 AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use)
1003 AC_LINK_IFELSE([AC_LANG_PROGRAM(
1005 #include <openssl/evp.h>
1008 EVP_CIPHER_CTX_block_size((EVP_CIPHER_CTX *)0);
1014 LIBCRYPTO_CFLAGS="-I$libcrypto_root/include"
1015 LIBCRYPTO_LIBS="-L$libcrypto_root/lib -lcrypto"
1018 AC_LBL_RESTORE_CHECK_STATE
1022 # OK, did we find it?
1024 if test "x$HAVE_LIBCRYPTO" = "xyes"; then
1025 AC_DEFINE([HAVE_LIBCRYPTO], [1], [Define to 1 if you have a usable `crypto' library (-lcrypto).])
1028 # Put the subdirectories of the libcrypto root directory
1029 # at the end of the header and library search path, to
1030 # make sure they come after any -I or -L flags for
1031 # a local libpcap - those must take precedence of any
1032 # directory that might contain an installed version of
1035 V_INCLS="$V_INCLS $LIBCRYPTO_CFLAGS"
1036 LIBS="$LIBS $LIBCRYPTO_LIBS"
1041 # 1) do we have EVP_CIPHER_CTX_new?
1042 # If so, we use it to allocate an EVP_CIPHER_CTX, as
1043 # EVP_CIPHER_CTX may be opaque; otherwise, we allocate it
1046 # 2) do we have EVP_DecryptInit_ex()?
1047 # If so, we use it, because we need to be able to make
1048 # two "initialize the cipher" calls, one with the cipher
1049 # and key, and one with the IV, and, as of OpenSSL 1.1,
1050 # You Can't Do That with EVP_DecryptInit(), because a
1051 # call to EVP_DecryptInit() will unconditionally clear
1052 # the context, and if you don't supply a cipher, it'll
1053 # clear the cipher, rendering the context unusable and
1056 AC_CHECK_FUNCS(EVP_CIPHER_CTX_new EVP_DecryptInit_ex)
1058 AC_MSG_NOTICE(OpenSSL/libressl libcrypto not found)
1062 # Check for libcap-ng
1063 AC_MSG_CHECKING(whether to use libcap-ng)
1064 # Specify location for both includes and libraries.
1065 want_libcap_ng=ifavailable
1067 AS_HELP_STRING([--with-cap-ng],
1068 [use libcap-ng @<:@default=yes, if available@:>@]),
1070 if test $withval = no
1074 elif test $withval = yes
1081 # Use libcap-ng if it's present, otherwise don't.
1083 want_libcap_ng=ifavailable
1084 AC_MSG_RESULT([yes, if available])
1086 if test "$want_libcap_ng" != "no"; then
1087 AC_CHECK_LIB(cap-ng, capng_change_id)
1088 AC_CHECK_HEADERS(cap-ng.h)
1092 dnl set additional include path if necessary
1093 if test "$missing_includes" = "yes"; then
1094 CPPFLAGS="$CPPFLAGS -I$srcdir/missing"
1095 V_INCLS="$V_INCLS -I$srcdir/missing"
1103 AC_SUBST(MAN_FILE_FORMATS)
1104 AC_SUBST(MAN_MISC_INFO)
1108 AC_CONFIG_HEADERS([config.h])
1110 AC_CONFIG_COMMANDS([.devel],[[if test -f .devel; then
1111 echo timestamp > stamp-h
1112 cat $srcdir/Makefile-devel-adds >> Makefile
1113 make depend || exit 1
1115 AC_CONFIG_FILES([Makefile tcpdump.1])