139e421e8SCy Schubertdnl Copyright (c) 1994, 1995, 1996, 1997 239e421e8SCy Schubertdnl The Regents of the University of California. All rights reserved. 339e421e8SCy Schubertdnl 439e421e8SCy Schubertdnl Process this file with autoconf to produce a configure script. 539e421e8SCy Schubertdnl 639e421e8SCy Schubert 739e421e8SCy Schubert# 839e421e8SCy Schubert# See 939e421e8SCy Schubert# 10ee67461eSJoseph Mingrone# https://ftp.gnu.org/gnu/config/README 1139e421e8SCy Schubert# 1239e421e8SCy Schubert# for the URLs to use to fetch new versions of config.guess and 1339e421e8SCy Schubert# config.sub. 1439e421e8SCy Schubert# 1539e421e8SCy Schubert 16*0a7e5f1fSJoseph MingroneAC_PREREQ([2.69]) 17*0a7e5f1fSJoseph MingroneAC_INIT([tcpdump],[m4_esyscmd_s(cat VERSION)]) 18ee67461eSJoseph MingroneAC_CONFIG_SRCDIR(tcpdump.c) 1939e421e8SCy Schubert 2039e421e8SCy SchubertAC_CANONICAL_HOST 2139e421e8SCy Schubert 2239e421e8SCy SchubertAC_LBL_C_INIT_BEFORE_CC(V_INCLS) 23ee67461eSJoseph Mingrone# 24ee67461eSJoseph Mingrone# Try to enable as many C99 features as we can. 25ee67461eSJoseph Mingrone# At minimum, we want C++/C99-style // comments. 26ee67461eSJoseph Mingrone# 27ee67461eSJoseph MingroneAC_PROG_CC_C99 28ee67461eSJoseph Mingroneif test "$ac_cv_prog_cc_c99" = "no"; then 29ee67461eSJoseph Mingrone AC_MSG_WARN([The C compiler does not support C99; there may be compiler errors]) 30ee67461eSJoseph Mingronefi 3139e421e8SCy SchubertAC_LBL_C_INIT(V_CCOPT, V_INCLS) 3239e421e8SCy SchubertAC_LBL_C_INLINE 3339e421e8SCy Schubert 34*0a7e5f1fSJoseph MingroneAC_CHECK_HEADERS(rpc/rpc.h rpc/rpcent.h net/if.h) 35*0a7e5f1fSJoseph Mingrone# 36*0a7e5f1fSJoseph Mingrone# Get the size of a void *, to know whether this is a 32-bit or 64-bit build. 37*0a7e5f1fSJoseph Mingrone# 38*0a7e5f1fSJoseph MingroneAC_CHECK_SIZEOF([void *]) 39*0a7e5f1fSJoseph Mingrone 40*0a7e5f1fSJoseph Mingrone# 41*0a7e5f1fSJoseph Mingrone# Get the size of a time_t, to know whether it's 32-bit or 64-bit. 42*0a7e5f1fSJoseph Mingrone# 43*0a7e5f1fSJoseph MingroneAC_CHECK_SIZEOF([time_t],,[#include <time.h>]) 4439e421e8SCy Schubert 4539e421e8SCy Schubertcase "$host_os" in 4639e421e8SCy Schubert 4739e421e8SCy Schubertdarwin*) 4839e421e8SCy Schubert AC_ARG_ENABLE(universal, 49ee67461eSJoseph Mingrone AS_HELP_STRING([--disable-universal],[don't build universal on macOS])) 5039e421e8SCy Schubert if test "$enable_universal" != "no"; then 5139e421e8SCy Schubert case "$host_os" in 5239e421e8SCy Schubert 5339e421e8SCy Schubert darwin9.*) 5439e421e8SCy Schubert # 5539e421e8SCy Schubert # Leopard. Build for x86 and 32-bit PowerPC, with 5639e421e8SCy Schubert # x86 first. (That's what Apple does.) 5739e421e8SCy Schubert # 5839e421e8SCy Schubert V_CCOPT="$V_CCOPT -arch i386 -arch ppc" 5939e421e8SCy Schubert LDFLAGS="$LDFLAGS -arch i386 -arch ppc" 6039e421e8SCy Schubert ;; 6139e421e8SCy Schubert 6239e421e8SCy Schubert darwin10.*) 6339e421e8SCy Schubert # 6439e421e8SCy Schubert # Snow Leopard. Build for x86-64 and x86, with 6539e421e8SCy Schubert # x86-64 first. (That's what Apple does.) 6639e421e8SCy Schubert # 6739e421e8SCy Schubert V_CCOPT="$V_CCOPT -arch x86_64 -arch i386" 6839e421e8SCy Schubert LDFLAGS="$LDFLAGS -arch x86_64 -arch i386" 6939e421e8SCy Schubert ;; 7039e421e8SCy Schubert esac 7139e421e8SCy Schubert fi 7239e421e8SCy Schubert ;; 7339e421e8SCy Schubertesac 7439e421e8SCy Schubert 75*0a7e5f1fSJoseph Mingrone# 76*0a7e5f1fSJoseph Mingrone# Do we have pkg-config? 77*0a7e5f1fSJoseph Mingrone# 78*0a7e5f1fSJoseph MingronePKG_PROG_PKG_CONFIG 79*0a7e5f1fSJoseph Mingrone 80*0a7e5f1fSJoseph Mingrone# 81*0a7e5f1fSJoseph Mingrone# Do we have the brew command from Homebrew? 82*0a7e5f1fSJoseph Mingrone# 83*0a7e5f1fSJoseph MingroneAC_PATH_PROG([BREW], [brew]) 8439e421e8SCy Schubert 85ee67461eSJoseph MingroneAC_ARG_WITH([smi], 86ee67461eSJoseph Mingrone [AS_HELP_STRING([--with-smi], 87ee67461eSJoseph Mingrone [link with libsmi (allows to load MIBs on the fly to decode SNMP packets) [default=yes, if available]])], 88ee67461eSJoseph Mingrone [], 89ee67461eSJoseph Mingrone [with_smi=yes]) 9039e421e8SCy Schubert 9139e421e8SCy Schubertif test "x$with_smi" != "xno" ; then 9239e421e8SCy Schubert AC_CHECK_HEADER(smi.h, 9339e421e8SCy Schubert [ 9439e421e8SCy Schubert # 9539e421e8SCy Schubert # OK, we found smi.h. Do we have libsmi with smiInit? 9639e421e8SCy Schubert # 9739e421e8SCy Schubert AC_CHECK_LIB(smi, smiInit, 9839e421e8SCy Schubert [ 9939e421e8SCy Schubert # 10039e421e8SCy Schubert # OK, we have libsmi with smiInit. Can we use it? 10139e421e8SCy Schubert # 10239e421e8SCy Schubert AC_MSG_CHECKING([whether to enable libsmi]) 10339e421e8SCy Schubert savedlibs="$LIBS" 10439e421e8SCy Schubert LIBS="-lsmi $LIBS" 105*0a7e5f1fSJoseph Mingrone AC_RUN_IFELSE([AC_LANG_SOURCE([[ 10639e421e8SCy Schubert/* libsmi available check */ 107ee67461eSJoseph Mingrone#include <stdio.h> 108ee67461eSJoseph Mingrone#include <stdlib.h> 109ee67461eSJoseph Mingrone#include <string.h> 11039e421e8SCy Schubert#include <smi.h> 111ee67461eSJoseph Mingroneint main() 11239e421e8SCy Schubert{ 11339e421e8SCy Schubert int current, revision, age, n; 11439e421e8SCy Schubert const int required = 2; 11539e421e8SCy Schubert if (smiInit("")) 11639e421e8SCy Schubert exit(1); 11739e421e8SCy Schubert if (strcmp(SMI_LIBRARY_VERSION, smi_library_version)) 11839e421e8SCy Schubert exit(2); 11939e421e8SCy Schubert n = sscanf(smi_library_version, "%d:%d:%d", ¤t, &revision, &age); 12039e421e8SCy Schubert if (n != 3) 12139e421e8SCy Schubert exit(3); 12239e421e8SCy Schubert if (required < current - age || required > current) 12339e421e8SCy Schubert exit(4); 12439e421e8SCy Schubert exit(0); 12539e421e8SCy Schubert} 126*0a7e5f1fSJoseph Mingrone ]]) 12739e421e8SCy Schubert ], 12839e421e8SCy Schubert [ 12939e421e8SCy Schubert AC_MSG_RESULT(yes) 13039e421e8SCy Schubert AC_DEFINE(USE_LIBSMI, 1, 13139e421e8SCy Schubert [Define if you enable support for libsmi]) 13239e421e8SCy Schubert ], 13339e421e8SCy Schubert [ 13439e421e8SCy Schubert dnl autoconf documentation says that 13539e421e8SCy Schubert dnl $? contains the exit value. 13639e421e8SCy Schubert dnl reality is that it does not. 13739e421e8SCy Schubert dnl We leave this in just in case 13839e421e8SCy Schubert dnl autoconf ever comes back to 13939e421e8SCy Schubert dnl match the documentation. 14039e421e8SCy Schubert case $? in 14139e421e8SCy Schubert 1) AC_MSG_RESULT(no - smiInit failed) ;; 14239e421e8SCy Schubert 2) AC_MSG_RESULT(no - header/library version mismatch) ;; 14339e421e8SCy Schubert 3) AC_MSG_RESULT(no - can't determine library version) ;; 14439e421e8SCy Schubert 4) AC_MSG_RESULT(no - too old) ;; 14539e421e8SCy Schubert *) AC_MSG_RESULT(no) ;; 14639e421e8SCy Schubert esac 14739e421e8SCy Schubert LIBS="$savedlibs" 14839e421e8SCy Schubert ], 14939e421e8SCy Schubert [ 15039e421e8SCy Schubert AC_MSG_RESULT(not when cross-compiling) 15139e421e8SCy Schubert LIBS="$savedlibs" 15239e421e8SCy Schubert ] 15339e421e8SCy Schubert ) 15439e421e8SCy Schubert ]) 15539e421e8SCy Schubert ]) 15639e421e8SCy Schubertfi 15739e421e8SCy Schubert 158*0a7e5f1fSJoseph MingroneAC_MSG_CHECKING([whether to enable the instrument functions code]) 159*0a7e5f1fSJoseph MingroneAC_ARG_ENABLE([instrument-functions], 160*0a7e5f1fSJoseph Mingrone [AS_HELP_STRING([--enable-instrument-functions], 161*0a7e5f1fSJoseph Mingrone [enable instrument functions code [default=no]])], 162*0a7e5f1fSJoseph Mingrone [], 163*0a7e5f1fSJoseph Mingrone [enableval=no]) 164*0a7e5f1fSJoseph Mingronecase "$enableval" in 165*0a7e5f1fSJoseph Mingroneyes) AC_MSG_RESULT(yes) 166*0a7e5f1fSJoseph Mingrone AC_CHECK_LIB([bfd], [bfd_init], 167*0a7e5f1fSJoseph Mingrone [true], 168*0a7e5f1fSJoseph Mingrone [AC_MSG_ERROR( 169*0a7e5f1fSJoseph Mingrone [--enable-instrument-functions was given, but test for library libbfd failed. Please install the 'binutils-dev' package.])], 170*0a7e5f1fSJoseph Mingrone []) 171*0a7e5f1fSJoseph Mingrone AC_DEFINE(ENABLE_INSTRUMENT_FUNCTIONS, 1, 172*0a7e5f1fSJoseph Mingrone [define if you want to build the instrument functions code]) 173*0a7e5f1fSJoseph Mingrone LOCALSRC="$LOCALSRC instrument-functions.c" 174*0a7e5f1fSJoseph Mingrone # Add '-finstrument-functions' instrumentation option to generate 175*0a7e5f1fSJoseph Mingrone # instrumentation calls for entry and exit to functions. 176*0a7e5f1fSJoseph Mingrone # Try to avoid Address Space Layout Randomization (ALSR). 177*0a7e5f1fSJoseph Mingrone CFLAGS="$CFLAGS -O0 -ggdb -finstrument-functions -fno-stack-protector -fno-pic" 178*0a7e5f1fSJoseph Mingrone LDFLAGS="$LDFLAGS -O0 -ggdb -fno-stack-protector -no-pie" 179*0a7e5f1fSJoseph Mingrone LIBS="$LIBS -lbfd" 180*0a7e5f1fSJoseph Mingrone ;; 181*0a7e5f1fSJoseph Mingrone*) AC_MSG_RESULT(no) 182*0a7e5f1fSJoseph Mingrone ;; 183*0a7e5f1fSJoseph Mingroneesac 184*0a7e5f1fSJoseph Mingrone 18539e421e8SCy SchubertAC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer]) 186ee67461eSJoseph MingroneAC_ARG_ENABLE([smb], 187ee67461eSJoseph Mingrone [AS_HELP_STRING([--enable-smb], 188ee67461eSJoseph Mingrone [enable possibly-buggy SMB printer [default=no]])], 189ee67461eSJoseph Mingrone [], 190ee67461eSJoseph Mingrone [enableval=no]) 19139e421e8SCy Schubertcase "$enableval" in 19239e421e8SCy Schubertyes) AC_MSG_RESULT(yes) 19339e421e8SCy Schubert AC_DEFINE(ENABLE_SMB, 1, 19439e421e8SCy Schubert [define if you want to build the possibly-buggy SMB printer]) 19539e421e8SCy Schubert LOCALSRC="print-smb.c smbutil.c $LOCALSRC" 19639e421e8SCy Schubert ;; 19739e421e8SCy Schubert*) AC_MSG_RESULT(no) 19839e421e8SCy Schubert ;; 19939e421e8SCy Schubertesac 20039e421e8SCy Schubert 20139e421e8SCy SchubertAC_MSG_CHECKING([whether to drop root privileges by default]) 202*0a7e5f1fSJoseph MingroneAC_ARG_WITH( 203*0a7e5f1fSJoseph Mingrone [user], 204*0a7e5f1fSJoseph Mingrone [AS_HELP_STRING([--with-user=USERNAME], 205*0a7e5f1fSJoseph Mingrone [drop privileges by default to USERNAME] 206*0a7e5f1fSJoseph Mingrone )], 207*0a7e5f1fSJoseph Mingrone [], 208*0a7e5f1fSJoseph Mingrone [withval=no]) 209*0a7e5f1fSJoseph MingroneAS_CASE(["$withval"], 210*0a7e5f1fSJoseph Mingrone [no], [AC_MSG_RESULT(no)], 211*0a7e5f1fSJoseph Mingrone [''|yes], [AC_MSG_ERROR([--with-user requires a username])], 212*0a7e5f1fSJoseph Mingrone [ 21339e421e8SCy Schubert AC_DEFINE_UNQUOTED(WITH_USER, "$withval", 21439e421e8SCy Schubert [define if should drop privileges by default]) 215*0a7e5f1fSJoseph Mingrone AC_MSG_RESULT([yes, to user "$withval"]) 216*0a7e5f1fSJoseph Mingrone ] 217*0a7e5f1fSJoseph Mingrone) 21839e421e8SCy Schubert 21939e421e8SCy SchubertAC_MSG_CHECKING([whether to chroot]) 220*0a7e5f1fSJoseph MingroneAC_ARG_WITH( 221*0a7e5f1fSJoseph Mingrone [chroot], 222*0a7e5f1fSJoseph Mingrone [AS_HELP_STRING([--with-chroot=DIRECTORY], 223*0a7e5f1fSJoseph Mingrone [when dropping privileges, chroot to DIRECTORY] 224*0a7e5f1fSJoseph Mingrone )], 225*0a7e5f1fSJoseph Mingrone [], 226*0a7e5f1fSJoseph Mingrone [withval=no] 227*0a7e5f1fSJoseph Mingrone) 228*0a7e5f1fSJoseph MingroneAS_CASE(["$withval"], 229*0a7e5f1fSJoseph Mingrone [no], [AC_MSG_RESULT(no)], 230*0a7e5f1fSJoseph Mingrone [''|yes], [AC_MSG_ERROR([--with-chroot requires a directory])], 231*0a7e5f1fSJoseph Mingrone [ 23239e421e8SCy Schubert AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval", 23339e421e8SCy Schubert [define if should chroot when dropping privileges]) 234*0a7e5f1fSJoseph Mingrone AC_MSG_RESULT([yes, to directory "$withval"]) 235*0a7e5f1fSJoseph Mingrone ] 236*0a7e5f1fSJoseph Mingrone) 23739e421e8SCy Schubert 23839e421e8SCy SchubertAC_ARG_WITH(sandbox-capsicum, 23939e421e8SCy Schubert AS_HELP_STRING([--with-sandbox-capsicum], 24039e421e8SCy Schubert [use Capsicum security functions @<:@default=yes, if available@:>@])) 24139e421e8SCy Schubert# 24239e421e8SCy Schubert# Check whether various functions are available. If any are, set 24339e421e8SCy Schubert# ac_lbl_capsicum_function_seen to yes; if any are not, set 24439e421e8SCy Schubert# ac_lbl_capsicum_function_not_seen to yes. 24539e421e8SCy Schubert# 24639e421e8SCy Schubert# We don't check cap_rights_init(), as it's a macro, wrapping another 24739e421e8SCy Schubert# function, in at least some versions of FreeBSD, and AC_CHECK_FUNCS() 24839e421e8SCy Schubert# doesn't handle that. 24939e421e8SCy Schubert# 25039e421e8SCy Schubert# All of the ones we check for must be available in order to enable 25139e421e8SCy Schubert# capsicum sandboxing. 25239e421e8SCy Schubert# 25339e421e8SCy Schubert# XXX - do we need to check for all of them, or are there some that, if 25439e421e8SCy Schubert# present, imply others are present? 25539e421e8SCy Schubert# 256ee67461eSJoseph Mingroneif test -z "$with_sandbox_capsicum" || test "$with_sandbox_capsicum" != "no" ; then 257ee67461eSJoseph Mingrone # 258ee67461eSJoseph Mingrone # First, make sure we have the required header. 259ee67461eSJoseph Mingrone # 260ee67461eSJoseph Mingrone AC_CHECK_HEADER(sys/capsicum.h, 261ee67461eSJoseph Mingrone [ 262ee67461eSJoseph Mingrone # 263ee67461eSJoseph Mingrone # We do; now make sure we have the required functions. 264ee67461eSJoseph Mingrone # 26539e421e8SCy Schubert AC_CHECK_FUNCS(cap_enter cap_rights_limit cap_ioctls_limit openat, 26639e421e8SCy Schubert ac_lbl_capsicum_function_seen=yes, 26739e421e8SCy Schubert ac_lbl_capsicum_function_not_seen=yes) 268ee67461eSJoseph Mingrone ]) 269ee67461eSJoseph Mingrone AC_CHECK_LIB(casper, cap_init, LIBS="$LIBS -lcasper") 270ee67461eSJoseph Mingrone AC_CHECK_LIB(cap_dns, cap_gethostbyaddr, LIBS="$LIBS -lcap_dns") 27139e421e8SCy Schubertfi 27239e421e8SCy SchubertAC_MSG_CHECKING([whether to sandbox using capsicum]) 27339e421e8SCy Schubertif test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then 27439e421e8SCy Schubert AC_DEFINE(HAVE_CAPSICUM, 1, [capsicum support available]) 27539e421e8SCy Schubert AC_MSG_RESULT(yes) 27639e421e8SCy Schubertelse 27739e421e8SCy Schubert AC_MSG_RESULT(no) 27839e421e8SCy Schubertfi 279ee67461eSJoseph MingroneAC_MSG_CHECKING([whether to sandbox using Casper library]) 280ee67461eSJoseph Mingroneif test "x$ac_cv_lib_casper_cap_init" = "xyes" -a "x$ac_cv_lib_cap_dns_cap_gethostbyaddr" = "xyes"; then 281ee67461eSJoseph Mingrone AC_DEFINE(HAVE_CASPER, 1, [Casper support available]) 282ee67461eSJoseph Mingrone AC_MSG_RESULT(yes) 283ee67461eSJoseph Mingroneelse 284ee67461eSJoseph Mingrone AC_MSG_RESULT(no) 285ee67461eSJoseph Mingronefi 28639e421e8SCy Schubert 28739e421e8SCy Schubert# 28839e421e8SCy Schubert# We must check this before checking whether to check the OS's IPv6, 28939e421e8SCy Schubert# support because, on some platforms (such as SunOS 5.x), the test 29039e421e8SCy Schubert# program requires the extra networking libraries. 29139e421e8SCy Schubert# 29239e421e8SCy SchubertAC_LBL_LIBRARY_NET 29339e421e8SCy Schubert 29439e421e8SCy Schubert# 29539e421e8SCy Schubert# Check whether AF_INET6 and struct in6_addr are defined. 29639e421e8SCy Schubert# If they aren't both defined, we don't have sufficient OS 29739e421e8SCy Schubert# support for IPv6, so we don't look for IPv6 support libraries, 29839e421e8SCy Schubert# and we define AF_INET6 and struct in6_addr ourselves. 29939e421e8SCy Schubert# 30039e421e8SCy SchubertAC_MSG_CHECKING([whether the operating system supports IPv6]) 30139e421e8SCy SchubertAC_COMPILE_IFELSE( 30239e421e8SCy Schubert [ 30339e421e8SCy Schubert AC_LANG_SOURCE( 30439e421e8SCy Schubert [[ 305ee67461eSJoseph Mingrone#include <string.h> 30639e421e8SCy Schubert/* AF_INET6 available check */ 30739e421e8SCy Schubert#include <sys/types.h> 308ee67461eSJoseph Mingrone#ifdef _WIN32 309ee67461eSJoseph Mingrone#include <ws2tcpip.h> 310ee67461eSJoseph Mingrone#else 31139e421e8SCy Schubert#include <sys/socket.h> 31239e421e8SCy Schubert#include <netinet/in.h> 313ee67461eSJoseph Mingrone#endif 31439e421e8SCy Schubert#ifdef AF_INET6 31539e421e8SCy Schubertvoid 31639e421e8SCy Schubertfoo(struct in6_addr *addr) 31739e421e8SCy Schubert{ 31839e421e8SCy Schubert memset(addr, 0, sizeof (struct in6_addr)); 31939e421e8SCy Schubert} 32039e421e8SCy Schubert#else 32139e421e8SCy Schubert#error "AF_INET6 not defined" 32239e421e8SCy Schubert#endif 32339e421e8SCy Schubert ]]) 32439e421e8SCy Schubert ], 32539e421e8SCy Schubert [ 32639e421e8SCy Schubert AC_MSG_RESULT(yes) 32739e421e8SCy Schubert AC_DEFINE(HAVE_OS_IPV6_SUPPORT, 1, 32839e421e8SCy Schubert [define if the OS provides AF_INET6 and struct in6_addr]) 32939e421e8SCy Schubert ipv6=yes 33039e421e8SCy Schubert ], 33139e421e8SCy Schubert [ 33239e421e8SCy Schubert AC_MSG_RESULT(no) 33339e421e8SCy Schubert ipv6=no 33439e421e8SCy Schubert ] 33539e421e8SCy Schubert) 33639e421e8SCy Schubert 33739e421e8SCy Schubertipv6type=unknown 33839e421e8SCy Schubertipv6lib=none 33939e421e8SCy Schubertipv6trylibc=no 34039e421e8SCy Schubert 34139e421e8SCy Schubertif test "$ipv6" = "yes"; then 34239e421e8SCy Schubert AC_MSG_CHECKING([ipv6 stack type]) 34339e421e8SCy Schubert for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do 34439e421e8SCy Schubert case $i in 34539e421e8SCy Schubert inria) 34639e421e8SCy Schubert dnl http://www.kame.net/ 34739e421e8SCy Schubert AC_EGREP_CPP(yes, 34839e421e8SCy Schubert[#include <netinet/in.h> 34939e421e8SCy Schubert#ifdef IPV6_INRIA_VERSION 35039e421e8SCy Schubertyes 35139e421e8SCy Schubert#endif], 35239e421e8SCy Schubert [ipv6type=$i]) 35339e421e8SCy Schubert ;; 35439e421e8SCy Schubert kame) 35539e421e8SCy Schubert dnl http://www.kame.net/ 35639e421e8SCy Schubert AC_EGREP_CPP(yes, 35739e421e8SCy Schubert[#include <netinet/in.h> 35839e421e8SCy Schubert#ifdef __KAME__ 35939e421e8SCy Schubertyes 36039e421e8SCy Schubert#endif], 36139e421e8SCy Schubert [ipv6type=$i; 36239e421e8SCy Schubert ipv6lib=inet6; 36339e421e8SCy Schubert ipv6libdir=/usr/local/v6/lib; 36439e421e8SCy Schubert ipv6trylibc=yes]) 36539e421e8SCy Schubert ;; 36639e421e8SCy Schubert linux-glibc) 36739e421e8SCy Schubert dnl http://www.v6.linux.or.jp/ 36839e421e8SCy Schubert AC_EGREP_CPP(yes, 36939e421e8SCy Schubert[#include <features.h> 37039e421e8SCy Schubert#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1 37139e421e8SCy Schubertyes 37239e421e8SCy Schubert#endif], 37339e421e8SCy Schubert [ipv6type=$i]) 37439e421e8SCy Schubert ;; 37539e421e8SCy Schubert linux-libinet6) 37639e421e8SCy Schubert dnl http://www.v6.linux.or.jp/ 37739e421e8SCy Schubert dnl 37839e421e8SCy Schubert dnl This also matches Solaris 8 and Tru64 UNIX 5.1, 37939e421e8SCy Schubert dnl and possibly other versions of those OSes 38039e421e8SCy Schubert dnl 38139e421e8SCy Schubert if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then 38239e421e8SCy Schubert ipv6type=$i 38339e421e8SCy Schubert ipv6lib=inet6 38439e421e8SCy Schubert ipv6libdir=/usr/inet6/lib 38539e421e8SCy Schubert ipv6trylibc=yes; 38639e421e8SCy Schubert CFLAGS="-I/usr/inet6/include $CFLAGS" 38739e421e8SCy Schubert fi 38839e421e8SCy Schubert ;; 38939e421e8SCy Schubert toshiba) 39039e421e8SCy Schubert AC_EGREP_CPP(yes, 39139e421e8SCy Schubert[#include <sys/param.h> 39239e421e8SCy Schubert#ifdef _TOSHIBA_INET6 39339e421e8SCy Schubertyes 39439e421e8SCy Schubert#endif], 39539e421e8SCy Schubert [ipv6type=$i; 39639e421e8SCy Schubert ipv6lib=inet6; 39739e421e8SCy Schubert ipv6libdir=/usr/local/v6/lib]) 39839e421e8SCy Schubert ;; 39939e421e8SCy Schubert v6d) 40039e421e8SCy Schubert AC_EGREP_CPP(yes, 40139e421e8SCy Schubert[#include </usr/local/v6/include/sys/v6config.h> 40239e421e8SCy Schubert#ifdef __V6D__ 40339e421e8SCy Schubertyes 40439e421e8SCy Schubert#endif], 40539e421e8SCy Schubert [ipv6type=$i; 40639e421e8SCy Schubert ipv6lib=v6; 40739e421e8SCy Schubert ipv6libdir=/usr/local/v6/lib; 40839e421e8SCy Schubert CFLAGS="-I/usr/local/v6/include $CFLAGS"]) 40939e421e8SCy Schubert ;; 41039e421e8SCy Schubert zeta) 41139e421e8SCy Schubert AC_EGREP_CPP(yes, 41239e421e8SCy Schubert[#include <sys/param.h> 41339e421e8SCy Schubert#ifdef _ZETA_MINAMI_INET6 41439e421e8SCy Schubertyes 41539e421e8SCy Schubert#endif], 41639e421e8SCy Schubert [ipv6type=$i; 41739e421e8SCy Schubert ipv6lib=inet6; 41839e421e8SCy Schubert ipv6libdir=/usr/local/v6/lib]) 41939e421e8SCy Schubert ;; 42039e421e8SCy Schubert esac 42139e421e8SCy Schubert if test "$ipv6type" != "unknown"; then 42239e421e8SCy Schubert break 42339e421e8SCy Schubert fi 42439e421e8SCy Schubert done 42539e421e8SCy Schubert AC_MSG_RESULT($ipv6type) 42639e421e8SCy Schubertfi 42739e421e8SCy Schubert 42839e421e8SCy Schubertif test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then 42939e421e8SCy Schubert if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then 43039e421e8SCy Schubert LIBS="-L$ipv6libdir -l$ipv6lib $LIBS" 43139e421e8SCy Schubert echo "You have $ipv6lib library, using it" 43239e421e8SCy Schubert else 43339e421e8SCy Schubert if test "$ipv6trylibc" = "yes"; then 43439e421e8SCy Schubert echo "You do not have $ipv6lib library, using libc" 43539e421e8SCy Schubert else 43639e421e8SCy Schubert echo 'Fatal: no $ipv6lib library found. cannot continue.' 43739e421e8SCy Schubert echo "You need to fetch lib$ipv6lib.a from appropriate" 43839e421e8SCy Schubert echo 'ipv6 kit and compile beforehand.' 43939e421e8SCy Schubert exit 1 44039e421e8SCy Schubert fi 44139e421e8SCy Schubert fi 44239e421e8SCy Schubertfi 44339e421e8SCy Schubert 444ee67461eSJoseph MingroneAC_REPLACE_FUNCS(strlcat strlcpy strdup strsep getservent getopt_long) 445ee67461eSJoseph MingroneAC_CHECK_FUNCS(fork vfork) 446ee67461eSJoseph MingroneAC_CHECK_FUNCS(setlinebuf) 44739e421e8SCy Schubert 448ee67461eSJoseph Mingrone# 449*0a7e5f1fSJoseph Mingrone# Make sure we have snprintf(); we require it. 450ee67461eSJoseph Mingrone# 451ee67461eSJoseph MingroneAC_CHECK_FUNC(snprintf,, 452ee67461eSJoseph Mingrone AC_MSG_ERROR([snprintf() is required but wasn't found])) 45339e421e8SCy Schubert 454ee67461eSJoseph Mingrone# 455*0a7e5f1fSJoseph Mingrone# It became apparent at some point that using a suitable C99 compiler does not 456*0a7e5f1fSJoseph Mingrone# automatically mean snprintf(3) implementation in the libc supports all the 457*0a7e5f1fSJoseph Mingrone# modifiers and specifiers used in the project, so let's test that before the 458*0a7e5f1fSJoseph Mingrone# build, not after. 459ee67461eSJoseph Mingrone# 460*0a7e5f1fSJoseph Mingrone# Testing the sizeof_t length modifier takes making an snprintf() call and 461*0a7e5f1fSJoseph Mingrone# comparing the actual result with the expected result. If this fails, it will 462*0a7e5f1fSJoseph Mingrone# most likely happen at run time, not compile time. 463*0a7e5f1fSJoseph Mingrone# 464*0a7e5f1fSJoseph Mingrone# Testing the 64-bit conversion specifiers in addition to that requires the 465*0a7e5f1fSJoseph Mingrone# <inttypes.h> header to be present and the macros to be defined, so if this 466*0a7e5f1fSJoseph Mingrone# fails, it will more likely happen at compile time. 467*0a7e5f1fSJoseph Mingrone# 468*0a7e5f1fSJoseph MingroneAC_MSG_CHECKING([whether snprintf is suitable]) 469ee67461eSJoseph MingroneAC_RUN_IFELSE( 470ee67461eSJoseph Mingrone [ 471ee67461eSJoseph Mingrone AC_LANG_SOURCE([[ 472ee67461eSJoseph Mingrone#include <stdio.h> 473ee67461eSJoseph Mingrone#include <string.h> 474*0a7e5f1fSJoseph Mingrone#include <inttypes.h> 475*0a7e5f1fSJoseph Mingrone#include <sys/types.h> 476ee67461eSJoseph Mingrone 477ee67461eSJoseph Mingroneint main() 478ee67461eSJoseph Mingrone{ 479ee67461eSJoseph Mingrone char buf[100]; 480*0a7e5f1fSJoseph Mingrone uint64_t t = (uint64_t)1 << 32; 481*0a7e5f1fSJoseph Mingrone 482ee67461eSJoseph Mingrone snprintf(buf, sizeof(buf), "%zu", sizeof(buf)); 483*0a7e5f1fSJoseph Mingrone if (strncmp(buf, "100", sizeof(buf))) 484*0a7e5f1fSJoseph Mingrone return 1; 485*0a7e5f1fSJoseph Mingrone 486*0a7e5f1fSJoseph Mingrone snprintf(buf, sizeof(buf), "%zd", -sizeof(buf)); 487*0a7e5f1fSJoseph Mingrone if (strncmp(buf, "-100", sizeof(buf))) 488*0a7e5f1fSJoseph Mingrone return 2; 489*0a7e5f1fSJoseph Mingrone 490*0a7e5f1fSJoseph Mingrone snprintf(buf, sizeof(buf), "%" PRId64, -t); 491*0a7e5f1fSJoseph Mingrone if (strncmp(buf, "-4294967296", sizeof(buf))) 492*0a7e5f1fSJoseph Mingrone return 3; 493*0a7e5f1fSJoseph Mingrone 494*0a7e5f1fSJoseph Mingrone snprintf(buf, sizeof(buf), "0o%" PRIo64, t); 495*0a7e5f1fSJoseph Mingrone if (strncmp(buf, "0o40000000000", sizeof(buf))) 496*0a7e5f1fSJoseph Mingrone return 4; 497*0a7e5f1fSJoseph Mingrone 498*0a7e5f1fSJoseph Mingrone snprintf(buf, sizeof(buf), "0x%" PRIx64, t); 499*0a7e5f1fSJoseph Mingrone if (strncmp(buf, "0x100000000", sizeof(buf))) 500*0a7e5f1fSJoseph Mingrone return 5; 501*0a7e5f1fSJoseph Mingrone 502*0a7e5f1fSJoseph Mingrone snprintf(buf, sizeof(buf), "%" PRIu64, t); 503*0a7e5f1fSJoseph Mingrone if (strncmp(buf, "4294967296", sizeof(buf))) 504*0a7e5f1fSJoseph Mingrone return 6; 505*0a7e5f1fSJoseph Mingrone 506*0a7e5f1fSJoseph Mingrone return 0; 507ee67461eSJoseph Mingrone} 508ee67461eSJoseph Mingrone ]]) 509ee67461eSJoseph Mingrone ], 510ee67461eSJoseph Mingrone [ 511ee67461eSJoseph Mingrone AC_MSG_RESULT(yes) 512ee67461eSJoseph Mingrone ], 513ee67461eSJoseph Mingrone [ 514ee67461eSJoseph Mingrone AC_MSG_RESULT(no) 515*0a7e5f1fSJoseph Mingrone AC_MSG_ERROR( 516*0a7e5f1fSJoseph Mingrone[The snprintf(3) implementation in this libc is not suitable, 517*0a7e5f1fSJoseph Mingronetcpdump would not work correctly even if it managed to compile.]) 518ee67461eSJoseph Mingrone ], 519ee67461eSJoseph Mingrone [ 520ee67461eSJoseph Mingrone AC_MSG_RESULT(not while cross-compiling) 521ee67461eSJoseph Mingrone ] 522ee67461eSJoseph Mingrone) 52339e421e8SCy Schubert 52439e421e8SCy SchubertAC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc 52539e421e8SCy Schubert 52639e421e8SCy Schubertdnl Some platforms may need -lnsl for getrpcbynumber. 52739e421e8SCy SchubertAC_SEARCH_LIBS(getrpcbynumber, nsl, 52839e421e8SCy Schubert AC_DEFINE(HAVE_GETRPCBYNUMBER, 1, [define if you have getrpcbynumber()])) 52939e421e8SCy Schubert 53039e421e8SCy SchubertAC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS) 53139e421e8SCy Schubert 53239e421e8SCy Schubert# 53339e421e8SCy Schubert# Check for these after AC_LBL_LIBPCAP, so we link with the appropriate 53439e421e8SCy Schubert# libraries (e.g., "-lsocket -lnsl" on Solaris). 53539e421e8SCy Schubert# 53639e421e8SCy Schubert# You are in a twisty little maze of UN*Xes, all different. 53739e421e8SCy Schubert# Some might not have ether_ntohost(). 538ee67461eSJoseph Mingrone# Some might have it and declare it in <net/ethernet.h>. 539ee67461eSJoseph Mingrone# Some might have it and declare it in <netinet/ether.h> 540ee67461eSJoseph Mingrone# Some might have it and declare it in <sys/ethernet.h>. 541ee67461eSJoseph Mingrone# Some might have it and declare it in <arpa/inet.h>. 542ee67461eSJoseph Mingrone# Some might have it and declare it in <netinet/if_ether.h>. 543ee67461eSJoseph Mingrone# Some might have it and not declare it in any header file. 54439e421e8SCy Schubert# 54539e421e8SCy Schubert# Before you is a C compiler. 54639e421e8SCy Schubert# 54739e421e8SCy SchubertAC_CHECK_FUNCS(ether_ntohost, [ 54839e421e8SCy Schubert AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [ 549*0a7e5f1fSJoseph Mingrone AC_RUN_IFELSE([AC_LANG_SOURCE([[ 55039e421e8SCy Schubert #include <netdb.h> 551ee67461eSJoseph Mingrone #include <netinet/ether.h> 552ee67461eSJoseph Mingrone #include <stdlib.h> 55339e421e8SCy Schubert #include <sys/types.h> 55439e421e8SCy Schubert #include <sys/param.h> 55539e421e8SCy Schubert #include <sys/socket.h> 55639e421e8SCy Schubert 55739e421e8SCy Schubert int 55839e421e8SCy Schubert main(int argc, char **argv) 55939e421e8SCy Schubert { 56039e421e8SCy Schubert u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff }; 56139e421e8SCy Schubert char name[MAXHOSTNAMELEN]; 56239e421e8SCy Schubert 56339e421e8SCy Schubert ether_ntohost(name, (struct ether_addr *)ea); 56439e421e8SCy Schubert exit(0); 56539e421e8SCy Schubert } 566*0a7e5f1fSJoseph Mingrone ]]) 56739e421e8SCy Schubert ], [ac_cv_buggy_ether_ntohost=no], 56839e421e8SCy Schubert [ac_cv_buggy_ether_ntohost=yes], 56939e421e8SCy Schubert [ac_cv_buggy_ether_ntohost="not while cross-compiling"])]) 57039e421e8SCy Schubert if test "$ac_cv_buggy_ether_ntohost" = "no"; then 57139e421e8SCy Schubert AC_DEFINE(USE_ETHER_NTOHOST, 1, 57239e421e8SCy Schubert [define if you have ether_ntohost() and it works]) 57339e421e8SCy Schubert fi 57439e421e8SCy Schubert]) 57539e421e8SCy Schubertif test "$ac_cv_func_ether_ntohost" = yes -a \ 57639e421e8SCy Schubert "$ac_cv_buggy_ether_ntohost" = "no"; then 57739e421e8SCy Schubert # 578ee67461eSJoseph Mingrone # OK, we have ether_ntohost(). Is it declared in <net/ethernet.h>? 57939e421e8SCy Schubert # 580ee67461eSJoseph Mingrone # This test fails if we don't have <net/ethernet.h> or if we do 581ee67461eSJoseph Mingrone # but it doesn't declare ether_ntohost(). 58239e421e8SCy Schubert # 58339e421e8SCy Schubert AC_CHECK_DECL(ether_ntohost, 58439e421e8SCy Schubert [ 585ee67461eSJoseph Mingrone AC_DEFINE(NET_ETHERNET_H_DECLARES_ETHER_NTOHOST,, 586ee67461eSJoseph Mingrone [Define to 1 if net/ethernet.h declares `ether_ntohost']) 58739e421e8SCy Schubert ],, 58839e421e8SCy Schubert [ 589ee67461eSJoseph Mingrone#include <net/ethernet.h> 59039e421e8SCy Schubert ]) 59139e421e8SCy Schubert # 59239e421e8SCy Schubert # Did that succeed? 59339e421e8SCy Schubert # 59439e421e8SCy Schubert if test "$ac_cv_have_decl_ether_ntohost" != yes; then 59539e421e8SCy Schubert # 59639e421e8SCy Schubert # No, how about <netinet/ether.h>, as on Linux? 59739e421e8SCy Schubert # 598ee67461eSJoseph Mingrone # This test fails if we don't have <netinet/ether.h> 599ee67461eSJoseph Mingrone # or if we do but it doesn't declare ether_ntohost(). 60039e421e8SCy Schubert # 60139e421e8SCy Schubert # Unset ac_cv_have_decl_ether_ntohost so we don't 60239e421e8SCy Schubert # treat the previous failure as a cached value and 60339e421e8SCy Schubert # suppress the next test. 60439e421e8SCy Schubert # 60539e421e8SCy Schubert unset ac_cv_have_decl_ether_ntohost 60639e421e8SCy Schubert AC_CHECK_DECL(ether_ntohost, 60739e421e8SCy Schubert [ 608*0a7e5f1fSJoseph Mingrone AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,1, 60939e421e8SCy Schubert [Define to 1 if netinet/ether.h declares `ether_ntohost']) 61039e421e8SCy Schubert ],, 61139e421e8SCy Schubert [ 61239e421e8SCy Schubert#include <netinet/ether.h> 61339e421e8SCy Schubert ]) 61439e421e8SCy Schubert fi 61539e421e8SCy Schubert # 616ee67461eSJoseph Mingrone # Did that succeed? 61739e421e8SCy Schubert # 61839e421e8SCy Schubert if test "$ac_cv_have_decl_ether_ntohost" != yes; then 61939e421e8SCy Schubert # 620ee67461eSJoseph Mingrone # No, how about <sys/ethernet.h>, as on Solaris 10 621ee67461eSJoseph Mingrone # and later? 622ee67461eSJoseph Mingrone # 623ee67461eSJoseph Mingrone # This test fails if we don't have <sys/ethernet.h> 624ee67461eSJoseph Mingrone # or if we do but it doesn't declare ether_ntohost(). 625ee67461eSJoseph Mingrone # 626ee67461eSJoseph Mingrone # Unset ac_cv_have_decl_ether_ntohost so we don't 627ee67461eSJoseph Mingrone # treat the previous failure as a cached value and 628ee67461eSJoseph Mingrone # suppress the next test. 629ee67461eSJoseph Mingrone # 630ee67461eSJoseph Mingrone unset ac_cv_have_decl_ether_ntohost 631ee67461eSJoseph Mingrone AC_CHECK_DECL(ether_ntohost, 632ee67461eSJoseph Mingrone [ 633ee67461eSJoseph Mingrone AC_DEFINE(SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST,, 634ee67461eSJoseph Mingrone [Define to 1 if sys/ethernet.h declares `ether_ntohost']) 635ee67461eSJoseph Mingrone ],, 636ee67461eSJoseph Mingrone [ 637ee67461eSJoseph Mingrone#include <sys/ethernet.h> 638ee67461eSJoseph Mingrone ]) 639ee67461eSJoseph Mingrone fi 640ee67461eSJoseph Mingrone # 641ee67461eSJoseph Mingrone # Did that succeed? 642ee67461eSJoseph Mingrone # 643ee67461eSJoseph Mingrone if test "$ac_cv_have_decl_ether_ntohost" != yes; then 644ee67461eSJoseph Mingrone # 645ee67461eSJoseph Mingrone # No, how about <arpa/inet.h>, as in AIX? 646ee67461eSJoseph Mingrone # 647ee67461eSJoseph Mingrone # This test fails if we don't have <arpa/inet.h> 648ee67461eSJoseph Mingrone # (if we have ether_ntohost(), we should have 649ee67461eSJoseph Mingrone # networking, and if we have networking, we should 650ee67461eSJoseph Mingrone # have <arpa/inet.h>) or if we do but it doesn't 651ee67461eSJoseph Mingrone # declare ether_ntohost(). 652ee67461eSJoseph Mingrone # 653ee67461eSJoseph Mingrone # Unset ac_cv_have_decl_ether_ntohost so we don't 654ee67461eSJoseph Mingrone # treat the previous failure as a cached value and 655ee67461eSJoseph Mingrone # suppress the next test. 656ee67461eSJoseph Mingrone # 657ee67461eSJoseph Mingrone unset ac_cv_have_decl_ether_ntohost 658ee67461eSJoseph Mingrone AC_CHECK_DECL(ether_ntohost, 659ee67461eSJoseph Mingrone [ 660ee67461eSJoseph Mingrone AC_DEFINE(ARPA_INET_H_DECLARES_ETHER_NTOHOST,, 661ee67461eSJoseph Mingrone [Define to 1 if arpa/inet.h declares `ether_ntohost']) 662ee67461eSJoseph Mingrone ],, 663ee67461eSJoseph Mingrone [ 664ee67461eSJoseph Mingrone#include <arpa/inet.h> 665ee67461eSJoseph Mingrone ]) 666ee67461eSJoseph Mingrone fi 667ee67461eSJoseph Mingrone # 668ee67461eSJoseph Mingrone # Did that succeed? 669ee67461eSJoseph Mingrone # 670ee67461eSJoseph Mingrone if test "$ac_cv_have_decl_ether_ntohost" != yes; then 671ee67461eSJoseph Mingrone # 672ee67461eSJoseph Mingrone # No, how about <netinet/if_ether.h>? 673ee67461eSJoseph Mingrone # On some platforms, it requires <net/if.h> and 674ee67461eSJoseph Mingrone # <netinet/in.h>, and we always include it with 675ee67461eSJoseph Mingrone # both of them, so test it with both of them. 676ee67461eSJoseph Mingrone # 677ee67461eSJoseph Mingrone # This test fails if we don't have <netinet/if_ether.h> 678ee67461eSJoseph Mingrone # and the headers we include before it, or if we do but 679ee67461eSJoseph Mingrone # <netinet/if_ether.h> doesn't declare ether_hostton(). 680ee67461eSJoseph Mingrone # 681ee67461eSJoseph Mingrone # Unset ac_cv_have_decl_ether_ntohost so we don't 682ee67461eSJoseph Mingrone # treat the previous failure as a cached value and 683ee67461eSJoseph Mingrone # suppress the next test. 684ee67461eSJoseph Mingrone # 685ee67461eSJoseph Mingrone unset ac_cv_have_decl_ether_ntohost 686ee67461eSJoseph Mingrone AC_CHECK_DECL(ether_ntohost, 687ee67461eSJoseph Mingrone [ 688ee67461eSJoseph Mingrone AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST,, 689ee67461eSJoseph Mingrone [Define to 1 if netinet/if_ether.h declares `ether_ntohost']) 690ee67461eSJoseph Mingrone ],, 691ee67461eSJoseph Mingrone [ 692ee67461eSJoseph Mingrone#include <sys/types.h> 693ee67461eSJoseph Mingrone#include <sys/socket.h> 694ee67461eSJoseph Mingrone#include <net/if.h> 695ee67461eSJoseph Mingrone#include <netinet/in.h> 696ee67461eSJoseph Mingrone#include <netinet/if_ether.h> 697ee67461eSJoseph Mingrone ]) 698ee67461eSJoseph Mingrone fi 699ee67461eSJoseph Mingrone # 700ee67461eSJoseph Mingrone # After all that, is ether_ntohost() declared? 701ee67461eSJoseph Mingrone # 702ee67461eSJoseph Mingrone if test "$ac_cv_have_decl_ether_ntohost" = yes; then 703ee67461eSJoseph Mingrone # 704ee67461eSJoseph Mingrone # Yes. 705ee67461eSJoseph Mingrone # 706ee67461eSJoseph Mingrone AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 1, 707ee67461eSJoseph Mingrone [Define to 1 if you have the declaration of `ether_ntohost']) 708ee67461eSJoseph Mingrone else 709ee67461eSJoseph Mingrone # 71039e421e8SCy Schubert # No, we'll have to declare it ourselves. 711ee67461eSJoseph Mingrone # Do we have "struct ether_addr" if we include 712ee67461eSJoseph Mingrone # <netinet/if_ether.h>? 71339e421e8SCy Schubert # 71439e421e8SCy Schubert AC_CHECK_TYPES(struct ether_addr,,, 71539e421e8SCy Schubert [ 71639e421e8SCy Schubert #include <sys/types.h> 71739e421e8SCy Schubert #include <sys/socket.h> 71839e421e8SCy Schubert #include <net/if.h> 719ee67461eSJoseph Mingrone #include <netinet/in.h> 72039e421e8SCy Schubert #include <netinet/if_ether.h> 72139e421e8SCy Schubert ]) 72239e421e8SCy Schubert fi 72339e421e8SCy Schubertfi 72439e421e8SCy Schubert 72539e421e8SCy Schubertdnl 726ee67461eSJoseph Mingronednl Check for "pcap_list_datalinks()" and use a substitute version if 727ee67461eSJoseph Mingronednl it's not present. If it is present, check for "pcap_free_datalinks()"; 728ee67461eSJoseph Mingronednl if it's not present, we don't replace it for now. (We could do so 729ee67461eSJoseph Mingronednl on UN*X, but not on Windows, where hilarity ensues if a program 730ee67461eSJoseph Mingronednl built with one version of the MSVC support library tries to free 731ee67461eSJoseph Mingronednl something allocated by a library built with another version of 732ee67461eSJoseph Mingronednl the MSVC support library.) 73339e421e8SCy Schubertdnl 73439e421e8SCy SchubertAC_CHECK_FUNC(pcap_list_datalinks, 73539e421e8SCy Schubert [ 73639e421e8SCy Schubert AC_DEFINE(HAVE_PCAP_LIST_DATALINKS, 1, 73739e421e8SCy Schubert [define if libpcap has pcap_list_datalinks()]) 73839e421e8SCy Schubert AC_CHECK_FUNCS(pcap_free_datalinks) 73939e421e8SCy Schubert ], 74039e421e8SCy Schubert [ 74139e421e8SCy Schubert AC_LIBOBJ(datalinks) 74239e421e8SCy Schubert ]) 743ee67461eSJoseph Mingrone 744ee67461eSJoseph Mingronednl 745ee67461eSJoseph Mingronednl Check for "pcap_datalink_name_to_val()", and use a substitute 746ee67461eSJoseph Mingronednl version if it's not present. If it is present, check for 747ee67461eSJoseph Mingronednl "pcap_datalink_val_to_description()", and if we don't have it, 748ee67461eSJoseph Mingronednl use a substitute version. 749ee67461eSJoseph Mingronednl 75039e421e8SCy SchubertAC_CHECK_FUNC(pcap_datalink_name_to_val, 75139e421e8SCy Schubert [ 75239e421e8SCy Schubert AC_DEFINE(HAVE_PCAP_DATALINK_NAME_TO_VAL, 1, 75339e421e8SCy Schubert [define if libpcap has pcap_datalink_name_to_val()]) 75439e421e8SCy Schubert AC_CHECK_FUNC(pcap_datalink_val_to_description, 75539e421e8SCy Schubert AC_DEFINE(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION, 1, 75639e421e8SCy Schubert [define if libpcap has pcap_datalink_val_to_description()]), 75739e421e8SCy Schubert [ 75839e421e8SCy Schubert AC_LIBOBJ(dlnames) 75939e421e8SCy Schubert ]) 76039e421e8SCy Schubert ], 76139e421e8SCy Schubert [ 76239e421e8SCy Schubert AC_LIBOBJ(dlnames) 76339e421e8SCy Schubert ]) 76439e421e8SCy Schubert 76539e421e8SCy Schubertdnl 766ee67461eSJoseph Mingronednl Check for "pcap_set_datalink()"; you can't substitute for it if 767ee67461eSJoseph Mingronednl it's absent (it has hooks into libpcap), so just define the 768ee67461eSJoseph Mingronednl HAVE_ value if it's there. 769ee67461eSJoseph Mingronednl 770ee67461eSJoseph MingroneAC_CHECK_FUNCS(pcap_set_datalink) 771ee67461eSJoseph Mingrone 772ee67461eSJoseph Mingronednl 77339e421e8SCy Schubertdnl Check for "pcap_breakloop()"; you can't substitute for it if 77439e421e8SCy Schubertdnl it's absent (it has hooks into the live capture routines), 77539e421e8SCy Schubertdnl so just define the HAVE_ value if it's there. 77639e421e8SCy Schubertdnl 77739e421e8SCy SchubertAC_CHECK_FUNCS(pcap_breakloop) 77839e421e8SCy Schubert 77939e421e8SCy Schubert# 78039e421e8SCy Schubert# Do we have the new open API? Check for pcap_create, and assume that, 78139e421e8SCy Schubert# if we do, we also have pcap_activate() and the other new routines 78239e421e8SCy Schubert# introduced in libpcap 1.0.0. 78339e421e8SCy Schubert# 78439e421e8SCy SchubertAC_CHECK_FUNCS(pcap_create) 78539e421e8SCy Schubertif test $ac_cv_func_pcap_create = "yes" ; then 78639e421e8SCy Schubert # 78739e421e8SCy Schubert # OK, do we have pcap_set_tstamp_type? If so, assume we have 78839e421e8SCy Schubert # pcap_list_tstamp_types and pcap_free_tstamp_types as well. 78939e421e8SCy Schubert # 79039e421e8SCy Schubert AC_CHECK_FUNCS(pcap_set_tstamp_type) 79139e421e8SCy Schubert # 79239e421e8SCy Schubert # And do we have pcap_set_tstamp_precision? If so, we assume 79339e421e8SCy Schubert # we also have pcap_open_offline_with_tstamp_precision. 79439e421e8SCy Schubert # 79539e421e8SCy Schubert AC_CHECK_FUNCS(pcap_set_tstamp_precision) 79639e421e8SCy Schubertfi 79739e421e8SCy Schubert 79839e421e8SCy Schubert# 79939e421e8SCy Schubert# Check for a miscellaneous collection of functions which we use 80039e421e8SCy Schubert# if we have them. 80139e421e8SCy Schubert# 802ee67461eSJoseph MingroneAC_CHECK_FUNCS(pcap_findalldevs) 803ee67461eSJoseph MingroneAC_CHECK_FUNCS(pcap_dump_flush pcap_lib_version) 80439e421e8SCy Schubertif test $ac_cv_func_pcap_lib_version = "no" ; then 80539e421e8SCy Schubert AC_MSG_CHECKING(whether pcap_version is defined by libpcap) 806*0a7e5f1fSJoseph Mingrone AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ 80739e421e8SCy Schubert extern char pcap_version[]; 80839e421e8SCy Schubert 80939e421e8SCy Schubert return (int)pcap_version; 810*0a7e5f1fSJoseph Mingrone ]]) 81139e421e8SCy Schubert ], 812*0a7e5f1fSJoseph Mingrone [ac_lbl_cv_pcap_version_defined=yes], 813*0a7e5f1fSJoseph Mingrone [ac_lbl_cv_pcap_version_defined=no]) 81439e421e8SCy Schubert if test "$ac_lbl_cv_pcap_version_defined" = yes ; then 81539e421e8SCy Schubert AC_MSG_RESULT(yes) 81639e421e8SCy Schubert AC_DEFINE(HAVE_PCAP_VERSION, 1, [define if libpcap has pcap_version]) 81739e421e8SCy Schubert else 81839e421e8SCy Schubert AC_MSG_RESULT(no) 81939e421e8SCy Schubert fi 82039e421e8SCy Schubertfi 821ee67461eSJoseph MingroneAC_CHECK_FUNCS(pcap_setdirection pcap_set_immediate_mode pcap_dump_ftell64) 822*0a7e5f1fSJoseph Mingrone# 823*0a7e5f1fSJoseph Mingrone# See the comment in AC_LBL_LIBPCAP in aclocal.m4 for the reason 824*0a7e5f1fSJoseph Mingrone# why we don't check for remote-capture APIs if we're building 825*0a7e5f1fSJoseph Mingrone# with the system libpcap on macOS. 826*0a7e5f1fSJoseph Mingrone# 827*0a7e5f1fSJoseph Mingroneif test "$_dont_check_for_remote_apis" != "yes"; then 828ee67461eSJoseph Mingrone AC_CHECK_FUNCS(pcap_open pcap_findalldevs_ex) 829*0a7e5f1fSJoseph Mingronefi 830ee67461eSJoseph MingroneAC_REPLACE_FUNCS(pcap_dump_ftell) 83139e421e8SCy Schubert 83239e421e8SCy Schubert# 83339e421e8SCy Schubert# Check for special debugging functions 83439e421e8SCy Schubert# 83539e421e8SCy SchubertAC_CHECK_FUNCS(pcap_set_parser_debug) 83639e421e8SCy Schubertif test "$ac_cv_func_pcap_set_parser_debug" = "no" ; then 83739e421e8SCy Schubert # 83839e421e8SCy Schubert # OK, we don't have pcap_set_parser_debug() to set the libpcap 83939e421e8SCy Schubert # filter expression parser debug flag; can we directly set the 84039e421e8SCy Schubert # flag? 84139e421e8SCy Schubert AC_MSG_CHECKING(whether pcap_debug is defined by libpcap) 842*0a7e5f1fSJoseph Mingrone AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ 84339e421e8SCy Schubert extern int pcap_debug; 84439e421e8SCy Schubert 84539e421e8SCy Schubert return pcap_debug; 846*0a7e5f1fSJoseph Mingrone ]]) 84739e421e8SCy Schubert ], 848*0a7e5f1fSJoseph Mingrone [ac_lbl_cv_pcap_debug_defined=yes], 849*0a7e5f1fSJoseph Mingrone [ac_lbl_cv_pcap_debug_defined=no]) 85039e421e8SCy Schubert if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then 85139e421e8SCy Schubert AC_MSG_RESULT(yes) 85239e421e8SCy Schubert AC_DEFINE(HAVE_PCAP_DEBUG, 1, [define if libpcap has pcap_debug]) 85339e421e8SCy Schubert else 85439e421e8SCy Schubert AC_MSG_RESULT(no) 85539e421e8SCy Schubert # 85639e421e8SCy Schubert # OK, what about "yydebug"? 85739e421e8SCy Schubert # 85839e421e8SCy Schubert AC_MSG_CHECKING(whether yydebug is defined by libpcap) 859*0a7e5f1fSJoseph Mingrone AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ 86039e421e8SCy Schubert extern int yydebug; 86139e421e8SCy Schubert 86239e421e8SCy Schubert return yydebug; 863*0a7e5f1fSJoseph Mingrone ]]) 86439e421e8SCy Schubert ], 865*0a7e5f1fSJoseph Mingrone [ac_lbl_cv_yydebug_defined=yes], 866*0a7e5f1fSJoseph Mingrone [ac_lbl_cv_yydebug_defined=no]) 86739e421e8SCy Schubert if test "$ac_lbl_cv_yydebug_defined" = yes ; then 86839e421e8SCy Schubert AC_MSG_RESULT(yes) 86939e421e8SCy Schubert AC_DEFINE(HAVE_YYDEBUG, 1, [define if libpcap has yydebug]) 87039e421e8SCy Schubert else 87139e421e8SCy Schubert AC_MSG_RESULT(no) 87239e421e8SCy Schubert fi 87339e421e8SCy Schubert fi 87439e421e8SCy Schubertfi 87539e421e8SCy SchubertAC_CHECK_FUNCS(pcap_set_optimizer_debug) 87639e421e8SCy SchubertAC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6 87739e421e8SCy Schubert 87839e421e8SCy Schubert# 87939e421e8SCy Schubert# Assume V7/BSD convention for man pages (file formats in section 5, 88039e421e8SCy Schubert# miscellaneous info in section 7). 88139e421e8SCy Schubert# 88239e421e8SCy SchubertMAN_FILE_FORMATS=5 88339e421e8SCy SchubertMAN_MISC_INFO=7 88439e421e8SCy Schubertcase "$host_os" in 88539e421e8SCy Schubert 88639e421e8SCy Schubertaix*) 88739e421e8SCy Schubert dnl Workaround to enable certain features 88839e421e8SCy Schubert AC_DEFINE(_SUN,1,[define on AIX to get certain functions]) 88939e421e8SCy Schubert ;; 89039e421e8SCy Schubert 89139e421e8SCy Schuberthpux*) 89239e421e8SCy Schubert # 89339e421e8SCy Schubert # Use System V conventions for man pages. 89439e421e8SCy Schubert # 89539e421e8SCy Schubert MAN_FILE_FORMATS=4 89639e421e8SCy Schubert MAN_MISC_INFO=5 89739e421e8SCy Schubert ;; 89839e421e8SCy Schubert 89939e421e8SCy Schubertirix*) 90039e421e8SCy Schubert V_GROUP=sys 90139e421e8SCy Schubert 90239e421e8SCy Schubert # 90339e421e8SCy Schubert # Use System V conventions for man pages. 90439e421e8SCy Schubert # 90539e421e8SCy Schubert MAN_FILE_FORMATS=4 90639e421e8SCy Schubert MAN_MISC_INFO=5 90739e421e8SCy Schubert ;; 90839e421e8SCy Schubert 90939e421e8SCy Schubertosf*) 91039e421e8SCy Schubert V_GROUP=system 91139e421e8SCy Schubert 91239e421e8SCy Schubert # 91339e421e8SCy Schubert # Use System V conventions for man pages. 91439e421e8SCy Schubert # 91539e421e8SCy Schubert MAN_FILE_FORMATS=4 91639e421e8SCy Schubert MAN_MISC_INFO=5 91739e421e8SCy Schubert ;; 91839e421e8SCy Schubert 91939e421e8SCy Schubertsolaris*) 92039e421e8SCy Schubert # 92139e421e8SCy Schubert # Use System V conventions for man pages. 92239e421e8SCy Schubert # 92339e421e8SCy Schubert MAN_FILE_FORMATS=4 92439e421e8SCy Schubert MAN_MISC_INFO=5 92539e421e8SCy Schubert ;; 92639e421e8SCy Schubertesac 92739e421e8SCy Schubert 92839e421e8SCy Schubert# 92939e421e8SCy Schubert# Make sure we have a definition for C99's uintptr_t (regardless of 93039e421e8SCy Schubert# whether the environment is a C99 environment or not). 93139e421e8SCy Schubert# 93239e421e8SCy SchubertAC_TYPE_UINTPTR_T 93339e421e8SCy Schubert 934*0a7e5f1fSJoseph Mingronesavedcppflags="$CPPFLAGS" 935*0a7e5f1fSJoseph MingroneCPPFLAGS="$CPPFLAGS $V_INCLS" 936*0a7e5f1fSJoseph Mingrone 93739e421e8SCy Schubert# 938ee67461eSJoseph Mingrone# Check whether we have pcap/pcap-inttypes.h. 939ee67461eSJoseph Mingrone# If we do, we use that to get the C99 types defined. 940ee67461eSJoseph Mingrone# 941ee67461eSJoseph MingroneAC_CHECK_HEADERS(pcap/pcap-inttypes.h) 942*0a7e5f1fSJoseph Mingrone 943*0a7e5f1fSJoseph Mingrone# 944*0a7e5f1fSJoseph Mingrone# At compile time HAVE_PCAP_FINDALLDEVS depends on HAVE_PCAP_IF_T. 945*0a7e5f1fSJoseph Mingrone# 946*0a7e5f1fSJoseph MingroneAC_CHECK_TYPES(pcap_if_t, , , [#include <pcap.h>]) 947*0a7e5f1fSJoseph Mingrone 948ee67461eSJoseph MingroneCPPFLAGS="$savedcppflags" 949ee67461eSJoseph Mingrone 950ee67461eSJoseph Mingrone# 95139e421e8SCy Schubert# Define the old BSD specified-width types in terms of the C99 types; 95239e421e8SCy Schubert# we may need them with libpcap include files. 95339e421e8SCy Schubert# 95439e421e8SCy SchubertAC_CHECK_TYPE([u_int8_t], , 95539e421e8SCy Schubert [AC_DEFINE([u_int8_t], [uint8_t], 95639e421e8SCy Schubert [Define to `uint8_t' if u_int8_t not defined.])], 95739e421e8SCy Schubert [AC_INCLUDES_DEFAULT 95839e421e8SCy Schubert#include <sys/types.h> 95939e421e8SCy Schubert]) 96039e421e8SCy SchubertAC_CHECK_TYPE([u_int16_t], , 96139e421e8SCy Schubert [AC_DEFINE([u_int16_t], [uint16_t], 96239e421e8SCy Schubert [Define to `uint16_t' if u_int16_t not defined.])], 96339e421e8SCy Schubert [AC_INCLUDES_DEFAULT 96439e421e8SCy Schubert#include <sys/types.h> 96539e421e8SCy Schubert]) 96639e421e8SCy SchubertAC_CHECK_TYPE([u_int32_t], , 96739e421e8SCy Schubert [AC_DEFINE([u_int32_t], [uint32_t], 96839e421e8SCy Schubert [Define to `uint32_t' if u_int32_t not defined.])], 96939e421e8SCy Schubert [AC_INCLUDES_DEFAULT 97039e421e8SCy Schubert#include <sys/types.h> 97139e421e8SCy Schubert]) 97239e421e8SCy SchubertAC_CHECK_TYPE([u_int64_t], , 97339e421e8SCy Schubert [AC_DEFINE([u_int64_t], [uint64_t], 97439e421e8SCy Schubert [Define to `uint64_t' if u_int64_t not defined.])], 97539e421e8SCy Schubert [AC_INCLUDES_DEFAULT 97639e421e8SCy Schubert#include <sys/types.h> 97739e421e8SCy Schubert]) 97839e421e8SCy Schubert 97939e421e8SCy SchubertAC_PROG_RANLIB 98039e421e8SCy SchubertAC_CHECK_TOOL([AR], [ar]) 98139e421e8SCy Schubert 98239e421e8SCy SchubertAC_LBL_DEVEL(V_CCOPT) 98339e421e8SCy Schubert 98439e421e8SCy Schubert# Check for OpenSSL/libressl libcrypto 98539e421e8SCy SchubertAC_MSG_CHECKING(whether to use OpenSSL/libressl libcrypto) 98639e421e8SCy Schubert# Specify location for both includes and libraries. 98739e421e8SCy Schubertwant_libcrypto=ifavailable 98839e421e8SCy SchubertAC_ARG_WITH(crypto, 98939e421e8SCy Schubert AS_HELP_STRING([--with-crypto]@<:@=DIR@:>@, 99039e421e8SCy Schubert [use OpenSSL/libressl libcrypto (located in directory DIR, if specified) @<:@default=yes, if available@:>@]), 99139e421e8SCy Schubert[ 99239e421e8SCy Schubert if test $withval = no 99339e421e8SCy Schubert then 99439e421e8SCy Schubert # User doesn't want to link with libcrypto. 99539e421e8SCy Schubert want_libcrypto=no 99639e421e8SCy Schubert AC_MSG_RESULT(no) 99739e421e8SCy Schubert elif test $withval = yes 99839e421e8SCy Schubert then 99939e421e8SCy Schubert # User wants to link with libcrypto but hasn't specified 100039e421e8SCy Schubert # a directory. 100139e421e8SCy Schubert want_libcrypto=yes 100239e421e8SCy Schubert AC_MSG_RESULT(yes) 100339e421e8SCy Schubert else 100439e421e8SCy Schubert # User wants to link with libcrypto and has specified 100539e421e8SCy Schubert # a directory, so use the provided value. 100639e421e8SCy Schubert want_libcrypto=yes 100739e421e8SCy Schubert libcrypto_root=$withval 100839e421e8SCy Schubert AC_MSG_RESULT([yes, using the version installed in $withval]) 100939e421e8SCy Schubert fi 101039e421e8SCy Schubert],[ 101139e421e8SCy Schubert # 101239e421e8SCy Schubert # Use libcrypto if it's present, otherwise don't; no directory 101339e421e8SCy Schubert # was specified. 101439e421e8SCy Schubert # 101539e421e8SCy Schubert want_libcrypto=ifavailable 101639e421e8SCy Schubert AC_MSG_RESULT([yes, if available]) 101739e421e8SCy Schubert]) 101839e421e8SCy Schubertif test "$want_libcrypto" != "no"; then 101939e421e8SCy Schubert # 1020*0a7e5f1fSJoseph Mingrone # Were we told where to look for libcrypto? 102139e421e8SCy Schubert # 1022*0a7e5f1fSJoseph Mingrone if test -z "$libcrypto_root"; then 1023*0a7e5f1fSJoseph Mingrone # 1024*0a7e5f1fSJoseph Mingrone # No. 1025*0a7e5f1fSJoseph Mingrone # 1026*0a7e5f1fSJoseph Mingrone # First, try looking for it with pkg-config, if we have it. 1027*0a7e5f1fSJoseph Mingrone # 1028*0a7e5f1fSJoseph Mingrone # Homebrew's pkg-config does not, by default, look for 1029*0a7e5f1fSJoseph Mingrone # pkg-config files for packages it has installed. 1030*0a7e5f1fSJoseph Mingrone # Furthermore, at least for OpenSSL, they appear to be 1031*0a7e5f1fSJoseph Mingrone # dumped in package-specific directories whose paths are 1032*0a7e5f1fSJoseph Mingrone # not only package-specific but package-version-specific. 1033*0a7e5f1fSJoseph Mingrone # 1034*0a7e5f1fSJoseph Mingrone # So the only way to find openssl is to get the value of 1035*0a7e5f1fSJoseph Mingrone # PKG_CONFIG_PATH from "brew --env openssl" and add that 1036*0a7e5f1fSJoseph Mingrone # to PKG_CONFIG_PATH. (No, we can't just assume it's under 1037*0a7e5f1fSJoseph Mingrone # /usr/local; Homebrew have conveniently chosen to put it 1038*0a7e5f1fSJoseph Mingrone # under /opt/homebrew on ARM.) 1039*0a7e5f1fSJoseph Mingrone # 1040*0a7e5f1fSJoseph Mingrone # That's the nice thing about Homebrew - it makes things easier! 1041*0a7e5f1fSJoseph Mingrone # Thanks! 1042*0a7e5f1fSJoseph Mingrone # 1043*0a7e5f1fSJoseph Mingrone save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH" 1044*0a7e5f1fSJoseph Mingrone if test -n "$BREW"; then 1045*0a7e5f1fSJoseph Mingrone openssl_pkgconfig_dir=`$BREW --env --plain openssl | sed -n 's/PKG_CONFIG_PATH: //p'` 1046*0a7e5f1fSJoseph Mingrone PKG_CONFIG_PATH="$openssl_pkgconfig_dir:$PKG_CONFIG_PATH" 1047*0a7e5f1fSJoseph Mingrone fi 1048*0a7e5f1fSJoseph Mingrone PKG_CHECK_MODULE(LIBCRYPTO, libcrypto, 104939e421e8SCy Schubert [ 1050*0a7e5f1fSJoseph Mingrone # 1051*0a7e5f1fSJoseph Mingrone # We found OpenSSL/libressl libcrypto. 1052*0a7e5f1fSJoseph Mingrone # 1053*0a7e5f1fSJoseph Mingrone HAVE_LIBCRYPTO=yes 1054*0a7e5f1fSJoseph Mingrone ]) 1055*0a7e5f1fSJoseph Mingrone PKG_CONFIG_PATH="$save_PKG_CONFIG_PATH" 1056*0a7e5f1fSJoseph Mingrone 1057*0a7e5f1fSJoseph Mingrone # 1058*0a7e5f1fSJoseph Mingrone # If it wasn't found, and we have Homebrew installed, see 1059*0a7e5f1fSJoseph Mingrone # if it's in Homebrew. 1060*0a7e5f1fSJoseph Mingrone # 1061*0a7e5f1fSJoseph Mingrone if test "x$HAVE_LIBCRYPTO" != "xyes" -a -n "$BREW"; then 1062*0a7e5f1fSJoseph Mingrone AC_MSG_CHECKING(for openssl in Homebrew) 1063*0a7e5f1fSJoseph Mingrone # 1064*0a7e5f1fSJoseph Mingrone # The brew man page lies when it speaks of 1065*0a7e5f1fSJoseph Mingrone # $BREW --prefix --installed <formula> 1066*0a7e5f1fSJoseph Mingrone # outputting nothing. In Homebrew 3.3.16, 1067*0a7e5f1fSJoseph Mingrone # it produces output regardless of whether 1068*0a7e5f1fSJoseph Mingrone # the formula is installed or not, so we 1069*0a7e5f1fSJoseph Mingrone # send the standard output and error to 1070*0a7e5f1fSJoseph Mingrone # the bit bucket. 1071*0a7e5f1fSJoseph Mingrone # 1072*0a7e5f1fSJoseph Mingrone # libcrypto isn't a formula, openssl is a formula. 1073*0a7e5f1fSJoseph Mingrone # 1074*0a7e5f1fSJoseph Mingrone if $BREW --prefix --installed openssl >/dev/null 2>&1; then 1075*0a7e5f1fSJoseph Mingrone # 1076*0a7e5f1fSJoseph Mingrone # Yes. Get the include directory and library 1077*0a7e5f1fSJoseph Mingrone # directory. (No, we can't just assume it's 1078*0a7e5f1fSJoseph Mingrone # under /usr/local; Homebrew have conveniently 1079*0a7e5f1fSJoseph Mingrone # chosen to put it under /opt/homebrew on ARM.) 1080*0a7e5f1fSJoseph Mingrone # 1081*0a7e5f1fSJoseph Mingrone AC_MSG_RESULT(yes) 1082*0a7e5f1fSJoseph Mingrone HAVE_LIBCRYPTO=yes 1083*0a7e5f1fSJoseph Mingrone openssl_path=`$BREW --prefix openssl` 1084*0a7e5f1fSJoseph Mingrone LIBCRYPTO_CFLAGS="-I$openssl_path/include" 1085*0a7e5f1fSJoseph Mingrone LIBCRYPTO_LIBS="-L$openssl_path/lib -lcrypto" 1086*0a7e5f1fSJoseph Mingrone else 1087*0a7e5f1fSJoseph Mingrone AC_MSG_RESULT(no) 1088*0a7e5f1fSJoseph Mingrone fi 1089*0a7e5f1fSJoseph Mingrone fi 1090*0a7e5f1fSJoseph Mingrone 1091*0a7e5f1fSJoseph Mingrone # 1092*0a7e5f1fSJoseph Mingrone # If it wasn't found, and /usr/local/include and /usr/local/lib 1093*0a7e5f1fSJoseph Mingrone # exist, check if it's in /usr/local. (We check whether they 1094*0a7e5f1fSJoseph Mingrone # exist because, if they don't exist, the compiler will warn 1095*0a7e5f1fSJoseph Mingrone # about that and then ignore the argument, so they test 1096*0a7e5f1fSJoseph Mingrone # using just the system header files and libraries.) 1097*0a7e5f1fSJoseph Mingrone # 1098*0a7e5f1fSJoseph Mingrone # We include the standard include file to 1) make sure that 1099*0a7e5f1fSJoseph Mingrone # it's installed (if it's just a shared library for the 1100*0a7e5f1fSJoseph Mingrone # benefit of existing programs, that's not useful) and 2) 1101*0a7e5f1fSJoseph Mingrone # because SSL_library_init() is a library routine in some 1102*0a7e5f1fSJoseph Mingrone # versions and a #defined wrapper around OPENSSL_init_ssl() 1103*0a7e5f1fSJoseph Mingrone # in others. 1104*0a7e5f1fSJoseph Mingrone # 1105*0a7e5f1fSJoseph Mingrone if test "x$HAVE_LIBCRYPTO" != "xyes" -a -d "/usr/local/include" -a -d "/usr/local/lib"; then 1106*0a7e5f1fSJoseph Mingrone AC_LBL_SAVE_CHECK_STATE 1107*0a7e5f1fSJoseph Mingrone CFLAGS="$CFLAGS -I/usr/local/include" 1108*0a7e5f1fSJoseph Mingrone LIBS="$LIBS -L/usr/local/lib -lcrypto" 1109*0a7e5f1fSJoseph Mingrone AC_MSG_CHECKING(whether we have an OpenSSL/libressl libcrypto in /usr/local that we can use) 1110*0a7e5f1fSJoseph Mingrone AC_LINK_IFELSE([AC_LANG_PROGRAM( 1111*0a7e5f1fSJoseph Mingrone [[ 1112*0a7e5f1fSJoseph Mingrone#include <openssl/evp.h> 1113*0a7e5f1fSJoseph Mingrone ]], 1114*0a7e5f1fSJoseph Mingrone [[ 1115*0a7e5f1fSJoseph MingroneEVP_CIPHER_CTX_block_size((EVP_CIPHER_CTX *)0); 1116*0a7e5f1fSJoseph Mingronereturn 0; 1117*0a7e5f1fSJoseph Mingrone ]])], 1118*0a7e5f1fSJoseph Mingrone [ 1119*0a7e5f1fSJoseph Mingrone AC_MSG_RESULT(yes) 1120*0a7e5f1fSJoseph Mingrone HAVE_LIBCRYPTO=yes 1121*0a7e5f1fSJoseph Mingrone LIBCRYPTO_CFLAGS="-I/usr/local/include" 1122*0a7e5f1fSJoseph Mingrone LIBCRYPTO_LIBS="-L/usr/local/lib -lcrypto" 1123*0a7e5f1fSJoseph Mingrone ], 1124*0a7e5f1fSJoseph Mingrone AC_MSG_RESULT(no)) 1125*0a7e5f1fSJoseph Mingrone AC_LBL_RESTORE_CHECK_STATE 1126*0a7e5f1fSJoseph Mingrone fi 1127*0a7e5f1fSJoseph Mingrone 1128*0a7e5f1fSJoseph Mingrone # 1129*0a7e5f1fSJoseph Mingrone # If it wasn't found, check if it's a system library. 1130*0a7e5f1fSJoseph Mingrone # 1131*0a7e5f1fSJoseph Mingrone # We include the standard include file to 1) make sure that 1132*0a7e5f1fSJoseph Mingrone # it's installed (if it's just a shared library for the 1133*0a7e5f1fSJoseph Mingrone # benefit of existing programs, that's not useful) and 2) 1134*0a7e5f1fSJoseph Mingrone # make sure this isn't a newer macOS that provides libcrypto 1135*0a7e5f1fSJoseph Mingrone # as a shared library but doesn't provide headers - Apple, 1136*0a7e5f1fSJoseph Mingrone # bless their pointy little heads, apparently ship libcrypto 1137*0a7e5f1fSJoseph Mingrone # as a library, but not the header files, in El Capitan and 1138*0a7e5f1fSJoseph Mingrone # later, probably because they don't want you writing nasty 1139*0a7e5f1fSJoseph Mingrone # portable code that could run on other UN*Xes, they want you 1140*0a7e5f1fSJoseph Mingrone # writing code that uses their Shiny New Crypto Library and 1141*0a7e5f1fSJoseph Mingrone # that thus only runs on macOS. 1142*0a7e5f1fSJoseph Mingrone # 1143*0a7e5f1fSJoseph Mingrone if test "x$HAVE_LIBCRYPTO" != "xyes"; then 1144*0a7e5f1fSJoseph Mingrone AC_LBL_SAVE_CHECK_STATE 1145*0a7e5f1fSJoseph Mingrone LIBS="$LIBS -lcrypto" 1146*0a7e5f1fSJoseph Mingrone AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use) 1147*0a7e5f1fSJoseph Mingrone AC_LINK_IFELSE([AC_LANG_PROGRAM( 1148*0a7e5f1fSJoseph Mingrone [[ 1149*0a7e5f1fSJoseph Mingrone#include <openssl/evp.h> 1150*0a7e5f1fSJoseph Mingrone ]], 1151*0a7e5f1fSJoseph Mingrone [[ 1152*0a7e5f1fSJoseph MingroneEVP_CIPHER_CTX_block_size((EVP_CIPHER_CTX *)0); 1153*0a7e5f1fSJoseph Mingronereturn 0; 1154*0a7e5f1fSJoseph Mingrone ]])], 1155*0a7e5f1fSJoseph Mingrone [ 1156*0a7e5f1fSJoseph Mingrone AC_MSG_RESULT(yes) 1157*0a7e5f1fSJoseph Mingrone HAVE_LIBCRYPTO=yes 1158*0a7e5f1fSJoseph Mingrone LIBCRYPTO_LIBS="-lcrypto" 1159*0a7e5f1fSJoseph Mingrone ], 1160*0a7e5f1fSJoseph Mingrone AC_MSG_RESULT(no)) 1161*0a7e5f1fSJoseph Mingrone AC_LBL_RESTORE_CHECK_STATE 1162*0a7e5f1fSJoseph Mingrone fi 1163*0a7e5f1fSJoseph Mingrone else 1164*0a7e5f1fSJoseph Mingrone # 1165*0a7e5f1fSJoseph Mingrone # Yes. 1166*0a7e5f1fSJoseph Mingrone # 1167*0a7e5f1fSJoseph Mingrone # Look for it there. 1168*0a7e5f1fSJoseph Mingrone # 1169*0a7e5f1fSJoseph Mingrone AC_LBL_SAVE_CHECK_STATE 1170*0a7e5f1fSJoseph Mingrone CFLAGS="$CFLAGS -I$libcrypto_root/include" 1171*0a7e5f1fSJoseph Mingrone LIBS="$LIBS -L$libcrypto_root/lib -lcrypto" 1172*0a7e5f1fSJoseph Mingrone AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use) 1173*0a7e5f1fSJoseph Mingrone AC_LINK_IFELSE([AC_LANG_PROGRAM( 1174*0a7e5f1fSJoseph Mingrone [[ 1175*0a7e5f1fSJoseph Mingrone#include <openssl/evp.h> 1176*0a7e5f1fSJoseph Mingrone ]], 1177*0a7e5f1fSJoseph Mingrone [[ 1178*0a7e5f1fSJoseph MingroneEVP_CIPHER_CTX_block_size((EVP_CIPHER_CTX *)0); 1179*0a7e5f1fSJoseph Mingronereturn 0; 1180*0a7e5f1fSJoseph Mingrone ]])], 1181*0a7e5f1fSJoseph Mingrone [ 1182*0a7e5f1fSJoseph Mingrone AC_MSG_RESULT(yes) 1183*0a7e5f1fSJoseph Mingrone HAVE_LIBCRYPTO=yes 1184*0a7e5f1fSJoseph Mingrone LIBCRYPTO_CFLAGS="-I$libcrypto_root/include" 1185*0a7e5f1fSJoseph Mingrone LIBCRYPTO_LIBS="-L$libcrypto_root/lib -lcrypto" 1186*0a7e5f1fSJoseph Mingrone ], 1187*0a7e5f1fSJoseph Mingrone AC_MSG_RESULT(no)) 1188*0a7e5f1fSJoseph Mingrone AC_LBL_RESTORE_CHECK_STATE 1189*0a7e5f1fSJoseph Mingrone fi 1190*0a7e5f1fSJoseph Mingrone 1191*0a7e5f1fSJoseph Mingrone # 1192*0a7e5f1fSJoseph Mingrone # OK, did we find it? 1193*0a7e5f1fSJoseph Mingrone # 1194*0a7e5f1fSJoseph Mingrone if test "x$HAVE_LIBCRYPTO" = "xyes"; then 1195*0a7e5f1fSJoseph Mingrone AC_DEFINE([HAVE_LIBCRYPTO], [1], [Define to 1 if you have a usable `crypto' library (-lcrypto).]) 1196*0a7e5f1fSJoseph Mingrone 1197*0a7e5f1fSJoseph Mingrone # 1198*0a7e5f1fSJoseph Mingrone # Put the subdirectories of the libcrypto root directory 1199*0a7e5f1fSJoseph Mingrone # at the end of the header and library search path, to 1200*0a7e5f1fSJoseph Mingrone # make sure they come after any -I or -L flags for 1201*0a7e5f1fSJoseph Mingrone # a local libpcap - those must take precedence of any 1202*0a7e5f1fSJoseph Mingrone # directory that might contain an installed version of 1203*0a7e5f1fSJoseph Mingrone # libpcap. 1204*0a7e5f1fSJoseph Mingrone # 1205*0a7e5f1fSJoseph Mingrone V_INCLS="$V_INCLS $LIBCRYPTO_CFLAGS" 1206*0a7e5f1fSJoseph Mingrone LIBS="$LIBS $LIBCRYPTO_LIBS" 1207*0a7e5f1fSJoseph Mingrone 120839e421e8SCy Schubert # 120939e421e8SCy Schubert # OK, then: 121039e421e8SCy Schubert # 121139e421e8SCy Schubert # 1) do we have EVP_CIPHER_CTX_new? 1212*0a7e5f1fSJoseph Mingrone # If so, we use it to allocate an EVP_CIPHER_CTX, as 1213*0a7e5f1fSJoseph Mingrone # EVP_CIPHER_CTX may be opaque; otherwise, we allocate it 1214*0a7e5f1fSJoseph Mingrone # ourselves. 121539e421e8SCy Schubert # 1216ee67461eSJoseph Mingrone # 2) do we have EVP_DecryptInit_ex()? 1217*0a7e5f1fSJoseph Mingrone # If so, we use it, because we need to be able to make 1218*0a7e5f1fSJoseph Mingrone # two "initialize the cipher" calls, one with the cipher 1219*0a7e5f1fSJoseph Mingrone # and key, and one with the IV, and, as of OpenSSL 1.1, 1220*0a7e5f1fSJoseph Mingrone # You Can't Do That with EVP_DecryptInit(), because a 1221*0a7e5f1fSJoseph Mingrone # call to EVP_DecryptInit() will unconditionally clear 1222*0a7e5f1fSJoseph Mingrone # the context, and if you don't supply a cipher, it'll 1223*0a7e5f1fSJoseph Mingrone # clear the cipher, rendering the context unusable and 1224*0a7e5f1fSJoseph Mingrone # causing a crash. 122539e421e8SCy Schubert # 1226ee67461eSJoseph Mingrone AC_CHECK_FUNCS(EVP_CIPHER_CTX_new EVP_DecryptInit_ex) 1227*0a7e5f1fSJoseph Mingrone else 1228*0a7e5f1fSJoseph Mingrone AC_MSG_NOTICE(OpenSSL/libressl libcrypto not found) 122939e421e8SCy Schubert fi 123039e421e8SCy Schubertfi 123139e421e8SCy Schubert 123239e421e8SCy Schubert# Check for libcap-ng 123339e421e8SCy SchubertAC_MSG_CHECKING(whether to use libcap-ng) 123439e421e8SCy Schubert# Specify location for both includes and libraries. 123539e421e8SCy Schubertwant_libcap_ng=ifavailable 123639e421e8SCy SchubertAC_ARG_WITH(cap_ng, 123739e421e8SCy Schubert AS_HELP_STRING([--with-cap-ng], 123839e421e8SCy Schubert [use libcap-ng @<:@default=yes, if available@:>@]), 123939e421e8SCy Schubert[ 124039e421e8SCy Schubert if test $withval = no 124139e421e8SCy Schubert then 124239e421e8SCy Schubert want_libcap_ng=no 124339e421e8SCy Schubert AC_MSG_RESULT(no) 124439e421e8SCy Schubert elif test $withval = yes 124539e421e8SCy Schubert then 124639e421e8SCy Schubert want_libcap_ng=yes 124739e421e8SCy Schubert AC_MSG_RESULT(yes) 124839e421e8SCy Schubert fi 124939e421e8SCy Schubert],[ 125039e421e8SCy Schubert # 125139e421e8SCy Schubert # Use libcap-ng if it's present, otherwise don't. 125239e421e8SCy Schubert # 125339e421e8SCy Schubert want_libcap_ng=ifavailable 125439e421e8SCy Schubert AC_MSG_RESULT([yes, if available]) 125539e421e8SCy Schubert]) 125639e421e8SCy Schubertif test "$want_libcap_ng" != "no"; then 125739e421e8SCy Schubert AC_CHECK_LIB(cap-ng, capng_change_id) 125839e421e8SCy Schubert AC_CHECK_HEADERS(cap-ng.h) 125939e421e8SCy Schubertfi 126039e421e8SCy Schubert 126139e421e8SCy Schubertdnl 126239e421e8SCy Schubertdnl set additional include path if necessary 126339e421e8SCy Schubertif test "$missing_includes" = "yes"; then 126439e421e8SCy Schubert CPPFLAGS="$CPPFLAGS -I$srcdir/missing" 126539e421e8SCy Schubert V_INCLS="$V_INCLS -I$srcdir/missing" 126639e421e8SCy Schubertfi 126739e421e8SCy Schubert 126839e421e8SCy SchubertAC_SUBST(V_CCOPT) 126939e421e8SCy SchubertAC_SUBST(V_DEFS) 127039e421e8SCy SchubertAC_SUBST(V_INCLS) 127139e421e8SCy SchubertAC_SUBST(V_PCAPDEP) 127239e421e8SCy SchubertAC_SUBST(LOCALSRC) 127339e421e8SCy SchubertAC_SUBST(MAN_FILE_FORMATS) 127439e421e8SCy SchubertAC_SUBST(MAN_MISC_INFO) 127539e421e8SCy Schubert 127639e421e8SCy SchubertAC_PROG_INSTALL 127739e421e8SCy Schubert 127839e421e8SCy SchubertAC_CONFIG_HEADER(config.h) 127939e421e8SCy Schubert 1280*0a7e5f1fSJoseph MingroneAC_CONFIG_COMMANDS([.devel],[[if test -f .devel; then 128139e421e8SCy Schubert echo timestamp > stamp-h 1282ee67461eSJoseph Mingrone cat $srcdir/Makefile-devel-adds >> Makefile 1283ee67461eSJoseph Mingrone make depend || exit 1 1284*0a7e5f1fSJoseph Mingronefi]],[[]]) 1285*0a7e5f1fSJoseph MingroneAC_CONFIG_FILES([Makefile tcpdump.1]) 1286*0a7e5f1fSJoseph MingroneAC_OUTPUT 128739e421e8SCy Schubertexit 0 1288