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)],[https://github.com/the-tcpdump-group/tcpdump/issues])
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)
33 AC_CHECK_HEADERS(rpc/rpc.h rpc/rpcent.h)
35 # Get the size of a void *, to know whether this is a 32-bit or 64-bit build.
37 AC_CHECK_SIZEOF([void *])
40 # Get the size of a time_t, to know whether it's 32-bit or 64-bit.
42 AC_CHECK_SIZEOF([time_t],,[#include <time.h>])
47 AC_ARG_ENABLE(universal,
48 AS_HELP_STRING([--disable-universal],[don't build universal on macOS]))
49 if test "$enable_universal" != "no"; then
54 # Leopard. Build for x86 and 32-bit PowerPC, with
55 # x86 first. (That's what Apple does.)
57 V_CCOPT="$V_CCOPT -arch i386 -arch ppc"
58 LDFLAGS="$LDFLAGS -arch i386 -arch ppc"
63 # Snow Leopard. Build for x86-64 and x86, with
64 # x86-64 first. (That's what Apple does.)
66 V_CCOPT="$V_CCOPT -arch x86_64 -arch i386"
67 LDFLAGS="$LDFLAGS -arch x86_64 -arch i386"
75 # Do we have pkg-config?
80 # Do we have the brew command from Homebrew?
82 AC_PATH_PROG([BREW], [brew])
85 [AS_HELP_STRING([--with-smi],
86 [link with libsmi (allows to load MIBs on the fly to decode SNMP packets) [default=yes, if available]])],
90 if test "x$with_smi" != "xno" ; then
91 AC_CHECK_HEADER(smi.h,
94 # OK, we found smi.h. Do we have libsmi with smiInit?
96 AC_CHECK_LIB(smi, smiInit,
99 # OK, we have libsmi with smiInit. Can we use it?
101 AC_MSG_CHECKING([whether to enable libsmi])
104 AC_RUN_IFELSE([AC_LANG_SOURCE([[
105 /* libsmi available check */
112 int current, revision, age, n;
113 const int required = 2;
116 if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
118 n = sscanf(smi_library_version, "%d:%d:%d", ¤t, &revision, &age);
121 if (required < current - age || required > current)
129 AC_DEFINE(USE_LIBSMI, 1,
130 [Define if you enable support for libsmi])
133 dnl autoconf documentation says that
134 dnl $? contains the exit value.
135 dnl reality is that it does not.
136 dnl We leave this in just in case
137 dnl autoconf ever comes back to
138 dnl match the documentation.
140 1) AC_MSG_RESULT(no - smiInit failed) ;;
141 2) AC_MSG_RESULT(no - header/library version mismatch) ;;
142 3) AC_MSG_RESULT(no - can't determine library version) ;;
143 4) AC_MSG_RESULT(no - too old) ;;
144 *) AC_MSG_RESULT(no) ;;
149 AC_MSG_RESULT(not when cross-compiling)
157 AC_MSG_CHECKING([whether to enable the instrument functions code])
158 AC_ARG_ENABLE([instrument-functions],
159 [AS_HELP_STRING([--enable-instrument-functions],
160 [enable instrument functions code [default=no]])],
164 yes) AC_MSG_RESULT(yes)
165 AC_CHECK_LIB([bfd], [bfd_init],
168 [--enable-instrument-functions was given, but test for library libbfd failed. Please install the 'binutils-dev' package.])],
170 AC_DEFINE(ENABLE_INSTRUMENT_FUNCTIONS, 1,
171 [define if you want to build the instrument functions code])
172 LOCALSRC="$LOCALSRC instrument-functions.c"
173 # Add '-finstrument-functions' instrumentation option to generate
174 # instrumentation calls for entry and exit to functions.
175 # Try to avoid Address Space Layout Randomization (ALSR).
176 CFLAGS="$CFLAGS -O0 -ggdb -finstrument-functions -fno-stack-protector -fno-pic"
177 LDFLAGS="$LDFLAGS -O0 -ggdb -fno-stack-protector -no-pie"
184 AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer])
186 [AS_HELP_STRING([--enable-smb],
187 [enable possibly-buggy SMB printer [default=no]])],
191 yes) AC_MSG_RESULT(yes)
192 AC_DEFINE(ENABLE_SMB, 1,
193 [define if you want to build the possibly-buggy SMB printer])
194 LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
200 AC_MSG_CHECKING([whether to drop root privileges by default])
203 [AS_HELP_STRING([--with-user=USERNAME],
204 [drop privileges by default to USERNAME]
208 AS_CASE(["$withval"],
209 [no], [AC_MSG_RESULT(no)],
210 [''|yes], [AC_MSG_ERROR([--with-user requires a username])],
212 AC_DEFINE_UNQUOTED(WITH_USER, "$withval",
213 [define if should drop privileges by default])
214 AC_MSG_RESULT([yes, to user "$withval"])
218 AC_MSG_CHECKING([whether to chroot])
221 [AS_HELP_STRING([--with-chroot=DIRECTORY],
222 [when dropping privileges, chroot to DIRECTORY]
227 AS_CASE(["$withval"],
228 [no], [AC_MSG_RESULT(no)],
229 [''|yes], [AC_MSG_ERROR([--with-chroot requires a directory])],
231 AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval",
232 [define if should chroot when dropping privileges])
233 AC_MSG_RESULT([yes, to directory "$withval"])
237 AC_ARG_WITH(sandbox-capsicum,
238 AS_HELP_STRING([--with-sandbox-capsicum],
239 [use Capsicum security functions @<:@default=yes, if available@:>@]))
241 # Check whether various functions are available. If any are, set
242 # ac_lbl_capsicum_function_seen to yes; if any are not, set
243 # ac_lbl_capsicum_function_not_seen to yes.
245 # We don't check cap_rights_init(), as it's a macro, wrapping another
246 # function, in at least some versions of FreeBSD, and AC_CHECK_FUNCS()
247 # doesn't handle that.
249 # All of the ones we check for must be available in order to enable
250 # capsicum sandboxing.
252 # XXX - do we need to check for all of them, or are there some that, if
253 # present, imply others are present?
255 if test -z "$with_sandbox_capsicum" || test "$with_sandbox_capsicum" != "no" ; then
257 # First, make sure we have the required header.
259 AC_CHECK_HEADER(sys/capsicum.h,
262 # We do; now make sure we have the required functions.
264 AC_CHECK_FUNCS(cap_enter cap_rights_limit cap_ioctls_limit openat,
265 ac_lbl_capsicum_function_seen=yes,
266 ac_lbl_capsicum_function_not_seen=yes)
268 AC_CHECK_LIB(casper, cap_init, LIBS="$LIBS -lcasper")
269 AC_CHECK_LIB(cap_dns, cap_gethostbyaddr, LIBS="$LIBS -lcap_dns")
271 AC_MSG_CHECKING([whether to sandbox using capsicum])
272 if test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then
273 AC_DEFINE(HAVE_CAPSICUM, 1, [capsicum support available])
278 AC_MSG_CHECKING([whether to sandbox using Casper library])
279 if test "x$ac_cv_lib_casper_cap_init" = "xyes" -a "x$ac_cv_lib_cap_dns_cap_gethostbyaddr" = "xyes"; then
280 AC_DEFINE(HAVE_CASPER, 1, [Casper support available])
287 # XXX - we used to check this before checking whether to check the OS's
288 # IPv6, support because, on some platforms (such as SunOS 5.x), the test
289 # program requires the extra networking libraries. We no longer
290 # test for IPv6 support, we just assume it's present with the
291 # standard API, so perhaps this can be moved.
295 AC_REPLACE_FUNCS(strlcat strlcpy strsep getservent getopt_long)
296 AC_CHECK_FUNCS(fork vfork)
299 # It became apparent at some point that using a suitable C99 compiler does not
300 # automatically mean snprintf(3) implementation in the libc supports all the
301 # modifiers and specifiers used in the project, so let's test that before the
304 # Testing the sizeof_t length modifier takes making an snprintf() call and
305 # comparing the actual result with the expected result. If this fails, it will
306 # most likely happen at run time, not compile time.
308 # Testing the 64-bit conversion specifiers in addition to that requires the
309 # <inttypes.h> header to be present and the macros to be defined, so if this
310 # fails, it will more likely happen at compile time.
312 AC_MSG_CHECKING([whether snprintf is suitable])
318 #include <inttypes.h>
319 #include <sys/types.h>
324 uint64_t t = (uint64_t)1 << 32;
326 snprintf(buf, sizeof(buf), "%zu", sizeof(buf));
327 if (strncmp(buf, "100", sizeof(buf)))
330 snprintf(buf, sizeof(buf), "%zd", -sizeof(buf));
331 if (strncmp(buf, "-100", sizeof(buf)))
334 snprintf(buf, sizeof(buf), "%" PRId64, -t);
335 if (strncmp(buf, "-4294967296", sizeof(buf)))
338 snprintf(buf, sizeof(buf), "0o%" PRIo64, t);
339 if (strncmp(buf, "0o40000000000", sizeof(buf)))
342 snprintf(buf, sizeof(buf), "0x%" PRIx64, t);
343 if (strncmp(buf, "0x100000000", sizeof(buf)))
346 snprintf(buf, sizeof(buf), "%" PRIu64, t);
347 if (strncmp(buf, "4294967296", sizeof(buf)))
360 [The snprintf(3) implementation in this libc is not suitable,
361 tcpdump would not work correctly even if it managed to compile.])
364 AC_MSG_RESULT(not while cross-compiling)
368 AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc
370 dnl Some platforms may need -lnsl for getrpcbynumber.
371 AC_SEARCH_LIBS(getrpcbynumber, nsl,
372 AC_DEFINE(HAVE_GETRPCBYNUMBER, 1, [define if you have getrpcbynumber()]))
374 AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
377 # Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
378 # libraries (e.g., "-lsocket -lnsl" on Solaris).
380 # You are in a twisty little maze of UN*Xes, all different.
381 # Some might not have ether_ntohost().
382 # Some might have it and declare it in <net/ethernet.h>.
383 # Some might have it and declare it in <netinet/ether.h>
384 # Some might have it and declare it in <sys/ethernet.h>.
385 # Some might have it and declare it in <arpa/inet.h>.
386 # Some might have it and declare it in <netinet/if_ether.h>.
387 # Some might have it and not declare it in any header file.
389 # Before you is a C compiler.
391 AC_CHECK_FUNCS(ether_ntohost, [
393 # OK, we have ether_ntohost(). Is it declared in <net/ethernet.h>?
395 # This test fails if we don't have <net/ethernet.h> or if we do
396 # but it doesn't declare ether_ntohost().
398 AC_CHECK_DECL(ether_ntohost,
400 AC_DEFINE(NET_ETHERNET_H_DECLARES_ETHER_NTOHOST,1,
401 [Define to 1 if net/ethernet.h declares `ether_ntohost'])
404 #include <net/ethernet.h>
409 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
411 # No, how about <netinet/ether.h>, as on Linux?
413 # This test fails if we don't have <netinet/ether.h>
414 # or if we do but it doesn't declare ether_ntohost().
416 # Unset ac_cv_have_decl_ether_ntohost so we don't
417 # treat the previous failure as a cached value and
418 # suppress the next test.
420 unset ac_cv_have_decl_ether_ntohost
421 AC_CHECK_DECL(ether_ntohost,
423 AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,1,
424 [Define to 1 if netinet/ether.h declares `ether_ntohost'])
427 #include <netinet/ether.h>
433 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
435 # No, how about <sys/ethernet.h>, as on Solaris 10
438 # This test fails if we don't have <sys/ethernet.h>
439 # or if we do but it doesn't declare ether_ntohost().
441 # Unset ac_cv_have_decl_ether_ntohost so we don't
442 # treat the previous failure as a cached value and
443 # suppress the next test.
445 unset ac_cv_have_decl_ether_ntohost
446 AC_CHECK_DECL(ether_ntohost,
448 AC_DEFINE(SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST,1,
449 [Define to 1 if sys/ethernet.h declares `ether_ntohost'])
452 #include <sys/ethernet.h>
458 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
460 # No, how about <arpa/inet.h>, as in AIX?
462 # This test fails if we don't have <arpa/inet.h>
463 # (if we have ether_ntohost(), we should have
464 # networking, and if we have networking, we should
465 # have <arpa/inet.h>) or if we do but it doesn't
466 # declare ether_ntohost().
468 # Unset ac_cv_have_decl_ether_ntohost so we don't
469 # treat the previous failure as a cached value and
470 # suppress the next test.
472 unset ac_cv_have_decl_ether_ntohost
473 AC_CHECK_DECL(ether_ntohost,
475 AC_DEFINE(ARPA_INET_H_DECLARES_ETHER_NTOHOST,1,
476 [Define to 1 if arpa/inet.h declares `ether_ntohost'])
479 #include <arpa/inet.h>
485 if test "$ac_cv_have_decl_ether_ntohost" != yes; then
487 # No, how about <netinet/if_ether.h>?
488 # On some platforms, it requires <net/if.h> and
489 # <netinet/in.h>, and we always include it with
490 # both of them, so test it with both of them.
492 # This test fails if we don't have <netinet/if_ether.h>
493 # and the headers we include before it, or if we do but
494 # <netinet/if_ether.h> doesn't declare ether_hostton().
496 # Unset ac_cv_have_decl_ether_ntohost so we don't
497 # treat the previous failure as a cached value and
498 # suppress the next test.
500 unset ac_cv_have_decl_ether_ntohost
501 AC_CHECK_DECL(ether_ntohost,
503 AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST,1,
504 [Define to 1 if netinet/if_ether.h declares `ether_ntohost'])
507 #include <sys/types.h>
508 #include <sys/socket.h>
510 #include <netinet/in.h>
511 #include <netinet/if_ether.h>
515 # After all that, is ether_ntohost() declared?
517 if test "$ac_cv_have_decl_ether_ntohost" = yes; then
521 AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 1,
522 [Define to 1 if you have the declaration of `ether_ntohost'])
525 # No, we'll have to declare it ourselves.
526 # Do we have "struct ether_addr" if we include
527 # <netinet/if_ether.h>?
529 AC_CHECK_TYPES(struct ether_addr,,,
531 #include <sys/types.h>
532 #include <sys/socket.h>
534 #include <netinet/in.h>
535 #include <netinet/if_ether.h>
538 AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [
539 AC_RUN_IFELSE([AC_LANG_SOURCE([[
541 #if defined(NET_ETHERNET_H_DECLARES_ETHER_NTOHOST)
543 * OK, just include <net/ethernet.h>.
545 #include <net/ethernet.h>
546 #elif defined(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST)
548 * OK, just include <netinet/ether.h>
550 #include <netinet/ether.h>
551 #elif defined(SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST)
553 * OK, just include <sys/ethernet.h>
555 #include <sys/ethernet.h>
556 #elif defined(ARPA_INET_H_DECLARES_ETHER_NTOHOST)
558 * OK, just include <arpa/inet.h>
560 #include <arpa/inet.h>
561 #elif defined(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST)
563 * OK, include <netinet/if_ether.h>, after all the other stuff we
564 * need to include or define for its benefit.
566 #define NEED_NETINET_IF_ETHER_H
569 * We'll have to declare it ourselves.
570 * If <netinet/if_ether.h> defines struct ether_addr, include
571 * it. Otherwise, define it ourselves.
573 #ifdef HAVE_STRUCT_ETHER_ADDR
574 #define NEED_NETINET_IF_ETHER_H
575 #else /* HAVE_STRUCT_ETHER_ADDR */
577 /* Beware FreeBSD calls this "octet". */
578 unsigned char ether_addr_octet[MAC_ADDR_LEN];
580 #endif /* HAVE_STRUCT_ETHER_ADDR */
581 #endif /* what declares ether_ntohost() */
583 #ifdef NEED_NETINET_IF_ETHER_H
585 * Include diag-control.h before <net/if.h>, which too defines a macro
586 * named ND_UNREACHABLE.
588 #include "diag-control.h"
589 #include <net/if.h> /* Needed on some platforms */
590 #include <netinet/in.h> /* Needed on some platforms */
591 #include <netinet/if_ether.h>
592 #endif /* NEED_NETINET_IF_ETHER_H */
594 #ifndef HAVE_DECL_ETHER_NTOHOST
596 * No header declares it, so declare it ourselves.
598 extern int ether_ntohost(char *, const struct ether_addr *);
599 #endif /* !defined(HAVE_DECL_ETHER_NTOHOST) */
601 #include <sys/types.h>
602 #include <sys/param.h>
603 #include <sys/socket.h>
606 main(int argc, char **argv)
608 u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff };
609 char name[MAXHOSTNAMELEN];
611 ether_ntohost(name, (struct ether_addr *)ea);
615 ], [ac_cv_buggy_ether_ntohost=no],
616 [ac_cv_buggy_ether_ntohost=yes],
617 [ac_cv_buggy_ether_ntohost="not while cross-compiling"])])
618 if test "$ac_cv_buggy_ether_ntohost" = "no"; then
619 AC_DEFINE(USE_ETHER_NTOHOST, 1,
620 [define if you have ether_ntohost() and it works])
625 # Do we have the new open API? Check for pcap_create, and assume that,
626 # if we do, we also have pcap_activate() and the other new routines
627 # introduced in libpcap 1.0.
629 # We require those routines, so fail if we don't find it.
631 AC_CHECK_FUNC(pcap_create,,
632 [AC_MSG_ERROR([libpcap is too old; 1.0 or later is required])])
635 # OK, do we have pcap_set_tstamp_type? If so, assume we have
636 # pcap_list_tstamp_types and pcap_free_tstamp_types as well.
638 AC_CHECK_FUNCS(pcap_set_tstamp_type)
640 # And do we have pcap_set_tstamp_precision? If so, we assume
641 # we also have pcap_open_offline_with_tstamp_precision.
643 AC_CHECK_FUNCS(pcap_set_tstamp_precision)
646 # Check for a miscellaneous collection of functions which we use
649 AC_CHECK_FUNCS(pcap_set_immediate_mode pcap_dump_ftell64)
651 # See the comment in AC_LBL_LIBPCAP in aclocal.m4 for the reason
652 # why we don't check for remote-capture APIs if we're building
653 # with the system libpcap on macOS.
655 if test "$_dont_check_for_remote_apis" != "yes"; then
656 AC_CHECK_FUNCS(pcap_open pcap_findalldevs_ex)
660 # Check for special debugging functions
662 AC_CHECK_FUNCS(pcap_set_parser_debug)
663 if test "$ac_cv_func_pcap_set_parser_debug" = "no" ; then
665 # OK, we don't have pcap_set_parser_debug() to set the libpcap
666 # filter expression parser debug flag; can we directly set the
668 AC_MSG_CHECKING(whether pcap_debug is defined by libpcap)
669 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
670 extern int pcap_debug;
675 [ac_lbl_cv_pcap_debug_defined=yes],
676 [ac_lbl_cv_pcap_debug_defined=no])
677 if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
679 AC_DEFINE(HAVE_PCAP_DEBUG, 1, [define if libpcap has pcap_debug])
683 # OK, what about "yydebug"?
685 AC_MSG_CHECKING(whether yydebug is defined by libpcap)
686 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
692 [ac_lbl_cv_yydebug_defined=yes],
693 [ac_lbl_cv_yydebug_defined=no])
694 if test "$ac_lbl_cv_yydebug_defined" = yes ; then
696 AC_DEFINE(HAVE_YYDEBUG, 1, [define if libpcap has yydebug])
702 AC_CHECK_FUNCS(pcap_set_optimizer_debug)
705 # bpf_dump() moved from tcpdump to libpcap in libpcap 0.6, but not all
706 # versions of libpcap didn't pick that change up; the OpenBSD libpcap
707 # picked up most of the new APIs from versions up to 1.0, but didn't
708 # pick up bpf_dump(), so we need to provide it if it's absent.
710 AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6
713 # Assume V7/BSD convention for man pages (file formats in section 5,
714 # miscellaneous info in section 7).
722 # Use System V conventions for man pages.
730 # Use System V conventions for man pages.
737 savedcppflags="$CPPFLAGS"
738 CPPFLAGS="$CPPFLAGS $V_INCLS"
741 # Check whether we have pcap/pcap-inttypes.h.
742 # If we do, we use that to get the C99 types defined.
744 AC_CHECK_HEADERS(pcap/pcap-inttypes.h)
746 CPPFLAGS="$savedcppflags"
749 # Define the old BSD specified-width types in terms of the C99 types;
750 # we may need them with libpcap include files.
752 AC_CHECK_TYPE([u_int8_t], ,
753 [AC_DEFINE([u_int8_t], [uint8_t],
754 [Define to `uint8_t' if u_int8_t not defined.])],
756 #include <sys/types.h>
758 AC_CHECK_TYPE([u_int16_t], ,
759 [AC_DEFINE([u_int16_t], [uint16_t],
760 [Define to `uint16_t' if u_int16_t not defined.])],
762 #include <sys/types.h>
764 AC_CHECK_TYPE([u_int32_t], ,
765 [AC_DEFINE([u_int32_t], [uint32_t],
766 [Define to `uint32_t' if u_int32_t not defined.])],
768 #include <sys/types.h>
770 AC_CHECK_TYPE([u_int64_t], ,
771 [AC_DEFINE([u_int64_t], [uint64_t],
772 [Define to `uint64_t' if u_int64_t not defined.])],
774 #include <sys/types.h>
778 AC_CHECK_TOOL([AR], [ar])
780 AC_LBL_DEVEL(V_CCOPT)
782 # Check for OpenSSL/libressl libcrypto
783 AC_MSG_CHECKING(whether to use OpenSSL/libressl libcrypto)
784 # Specify location for both includes and libraries.
785 want_libcrypto=ifavailable
787 AS_HELP_STRING([--with-crypto]@<:@=DIR@:>@,
788 [use OpenSSL/libressl libcrypto (located in directory DIR, if specified) @<:@default=yes, if available@:>@]),
790 if test $withval = no
792 # User doesn't want to link with libcrypto.
795 elif test $withval = yes
797 # User wants to link with libcrypto but hasn't specified
802 # User wants to link with libcrypto and has specified
803 # a directory, so use the provided value.
805 libcrypto_root=$withval
806 AC_MSG_RESULT([yes, using the version installed in $withval])
810 # Use libcrypto if it's present, otherwise don't; no directory
813 want_libcrypto=ifavailable
814 AC_MSG_RESULT([yes, if available])
816 if test "$want_libcrypto" != "no"; then
818 # Were we told where to look for libcrypto?
820 if test -z "$libcrypto_root"; then
824 # First, try looking for it with pkg-config, if we have it.
826 # Homebrew's pkg-config does not, by default, look for
827 # pkg-config files for packages it has installed.
828 # Furthermore, at least for OpenSSL, they appear to be
829 # dumped in package-specific directories whose paths are
830 # not only package-specific but package-version-specific.
832 # So the only way to find openssl is to get the value of
833 # PKG_CONFIG_PATH from "brew --env openssl" and add that
834 # to PKG_CONFIG_PATH. (No, we can't just assume it's under
835 # /usr/local; Homebrew have conveniently chosen to put it
836 # under /opt/homebrew on ARM.)
838 # That's the nice thing about Homebrew - it makes things easier!
841 save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
842 if test -n "$BREW"; then
843 openssl_pkgconfig_dir=`$BREW --env --plain openssl | sed -n 's/PKG_CONFIG_PATH: //p'`
844 PKG_CONFIG_PATH="$openssl_pkgconfig_dir:$PKG_CONFIG_PATH"
846 PKG_CHECK_MODULE(LIBCRYPTO, libcrypto,
849 # We found OpenSSL/libressl libcrypto.
853 PKG_CONFIG_PATH="$save_PKG_CONFIG_PATH"
856 # If it wasn't found, and we have Homebrew installed, see
857 # if it's in Homebrew.
859 if test "x$HAVE_LIBCRYPTO" != "xyes" -a -n "$BREW"; then
860 AC_MSG_CHECKING(for openssl in Homebrew)
862 # The brew man page lies when it speaks of
863 # $BREW --prefix --installed <formula>
864 # outputting nothing. In Homebrew 3.3.16,
865 # it produces output regardless of whether
866 # the formula is installed or not, so we
867 # send the standard output and error to
870 # libcrypto isn't a formula, openssl is a formula.
872 if $BREW --prefix --installed openssl >/dev/null 2>&1; then
874 # Yes. Get the include directory and library
875 # directory. (No, we can't just assume it's
876 # under /usr/local; Homebrew have conveniently
877 # chosen to put it under /opt/homebrew on ARM.)
881 openssl_path=`$BREW --prefix openssl`
882 LIBCRYPTO_CFLAGS="-I$openssl_path/include"
883 LIBCRYPTO_LIBS="-L$openssl_path/lib -lcrypto"
890 # If it wasn't found, and /usr/local/include and /usr/local/lib
891 # exist, check if it's in /usr/local. (We check whether they
892 # exist because, if they don't exist, the compiler will warn
893 # about that and then ignore the argument, so they test
894 # using just the system header files and libraries.)
896 # We include the standard include file to 1) make sure that
897 # it's installed (if it's just a shared library for the
898 # benefit of existing programs, that's not useful) and 2)
899 # because SSL_library_init() is a library routine in some
900 # versions and a #defined wrapper around OPENSSL_init_ssl()
903 if test "x$HAVE_LIBCRYPTO" != "xyes" -a -d "/usr/local/include" -a -d "/usr/local/lib"; then
904 AC_LBL_SAVE_CHECK_STATE
905 CFLAGS="$CFLAGS -I/usr/local/include"
906 LIBS="$LIBS -L/usr/local/lib -lcrypto"
907 AC_MSG_CHECKING(whether we have an OpenSSL/libressl libcrypto in /usr/local that we can use)
908 AC_LINK_IFELSE([AC_LANG_PROGRAM(
910 #include <openssl/evp.h>
913 EVP_CIPHER_CTX_block_size((EVP_CIPHER_CTX *)0);
919 LIBCRYPTO_CFLAGS="-I/usr/local/include"
920 LIBCRYPTO_LIBS="-L/usr/local/lib -lcrypto"
923 AC_LBL_RESTORE_CHECK_STATE
927 # If it wasn't found, check if it's a system library.
929 # We include the standard include file to 1) make sure that
930 # it's installed (if it's just a shared library for the
931 # benefit of existing programs, that's not useful) and 2)
932 # make sure this isn't a newer macOS that provides libcrypto
933 # as a shared library but doesn't provide headers - Apple,
934 # bless their pointy little heads, apparently ship libcrypto
935 # as a library, but not the header files, in El Capitan and
936 # later, probably because they don't want you writing nasty
937 # portable code that could run on other UN*Xes, they want you
938 # writing code that uses their Shiny New Crypto Library and
939 # that thus only runs on macOS.
941 if test "x$HAVE_LIBCRYPTO" != "xyes"; then
942 AC_LBL_SAVE_CHECK_STATE
943 LIBS="$LIBS -lcrypto"
944 AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use)
945 AC_LINK_IFELSE([AC_LANG_PROGRAM(
947 #include <openssl/evp.h>
950 EVP_CIPHER_CTX_block_size((EVP_CIPHER_CTX *)0);
956 LIBCRYPTO_LIBS="-lcrypto"
959 AC_LBL_RESTORE_CHECK_STATE
967 AC_LBL_SAVE_CHECK_STATE
968 CFLAGS="$CFLAGS -I$libcrypto_root/include"
969 LIBS="$LIBS -L$libcrypto_root/lib -lcrypto"
970 AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use)
971 AC_LINK_IFELSE([AC_LANG_PROGRAM(
973 #include <openssl/evp.h>
976 EVP_CIPHER_CTX_block_size((EVP_CIPHER_CTX *)0);
982 LIBCRYPTO_CFLAGS="-I$libcrypto_root/include"
983 LIBCRYPTO_LIBS="-L$libcrypto_root/lib -lcrypto"
986 AC_LBL_RESTORE_CHECK_STATE
990 # OK, did we find it?
992 if test "x$HAVE_LIBCRYPTO" = "xyes"; then
993 AC_DEFINE([HAVE_LIBCRYPTO], [1], [Define to 1 if you have a usable `crypto' library (-lcrypto).])
996 # Put the subdirectories of the libcrypto root directory
997 # at the end of the header and library search path, to
998 # make sure they come after any -I or -L flags for
999 # a local libpcap - those must take precedence of any
1000 # directory that might contain an installed version of
1003 V_INCLS="$V_INCLS $LIBCRYPTO_CFLAGS"
1004 LIBS="$LIBS $LIBCRYPTO_LIBS"
1009 # 1) do we have EVP_CIPHER_CTX_new?
1010 # If so, we use it to allocate an EVP_CIPHER_CTX, as
1011 # EVP_CIPHER_CTX may be opaque; otherwise, we allocate it
1014 # 2) do we have EVP_DecryptInit_ex()?
1015 # If so, we use it, because we need to be able to make
1016 # two "initialize the cipher" calls, one with the cipher
1017 # and key, and one with the IV, and, as of OpenSSL 1.1,
1018 # You Can't Do That with EVP_DecryptInit(), because a
1019 # call to EVP_DecryptInit() will unconditionally clear
1020 # the context, and if you don't supply a cipher, it'll
1021 # clear the cipher, rendering the context unusable and
1024 AC_CHECK_FUNCS(EVP_CIPHER_CTX_new EVP_DecryptInit_ex)
1026 AC_MSG_NOTICE(OpenSSL/libressl libcrypto not found)
1030 # Check for libcap-ng
1031 AC_MSG_CHECKING(whether to use libcap-ng)
1032 # Specify location for both includes and libraries.
1033 want_libcap_ng=ifavailable
1035 AS_HELP_STRING([--with-cap-ng],
1036 [use libcap-ng @<:@default=yes, if available@:>@]),
1038 if test $withval = no
1042 elif test $withval = yes
1049 # Use libcap-ng if it's present, otherwise don't.
1051 want_libcap_ng=ifavailable
1052 AC_MSG_RESULT([yes, if available])
1054 if test "$want_libcap_ng" != "no"; then
1055 AC_CHECK_LIB(cap-ng, capng_change_id)
1056 AC_CHECK_HEADERS(cap-ng.h)
1060 dnl set additional include path if necessary
1061 if test "$missing_includes" = "yes"; then
1062 CPPFLAGS="$CPPFLAGS -I$srcdir/missing"
1063 V_INCLS="$V_INCLS -I$srcdir/missing"
1071 AC_SUBST(MAN_FILE_FORMATS)
1072 AC_SUBST(MAN_MISC_INFO)
1076 AC_CONFIG_HEADERS([config.h])
1078 AC_CONFIG_COMMANDS([.devel],[[if test -f .devel; then
1079 echo timestamp > stamp-h
1080 cat $srcdir/Makefile-devel-adds >> Makefile
1081 make depend || exit 1
1083 AC_CONFIG_FILES([Makefile tcpdump.1])