]> The Tcpdump Group git mirrors - tcpdump/blobdiff - configure.ac
Add '-Wunreachable-code-return' warning option in devel mode for cmake
[tcpdump] / configure.ac
index af501dbac8457aa47df80e5cd7c3231c789c2a61..0202f0399e47e720efa22f711749b311ee59b67a 100644 (file)
@@ -20,16 +20,11 @@ AC_CONFIG_SRCDIR(tcpdump.c)
 AC_CANONICAL_HOST
 
 AC_LBL_C_INIT_BEFORE_CC(V_INCLS)
-AC_PROG_CC
+AC_PROG_CC_C99
 AC_LBL_C_INIT(V_CCOPT, V_INCLS)
 AC_LBL_C_INLINE
-AC_C___ATTRIBUTE__
-if test "$ac_cv___attribute__" = "yes"; then
-       AC_C___ATTRIBUTE___UNUSED
-       AC_C___ATTRIBUTE___FALLTHROUGH
-fi
 
-AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h netdnet/dnetdb.h)
+AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h net/if.h)
 AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
 #include <sys/socket.h>
 #include <net/if.h>])
@@ -42,31 +37,12 @@ if test "$ac_cv_header_net_pfvar_h" = yes; then
                LOCALSRC="print-pflog.c $LOCALSRC"
        fi
 fi
-AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
-#include <sys/socket.h>])
-if test "$ac_cv_header_netinet_if_ether_h" != yes; then
-       #
-       # The simple test didn't work.
-       # Do we need to include <net/if.h> first?
-       # Unset ac_cv_header_netinet_if_ether_h so we don't
-       # treat the previous failure as a cached value and
-       # suppress the next test.
-       #
-       AC_MSG_NOTICE([Rechecking with some additional includes])
-       unset ac_cv_header_netinet_if_ether_h
-       AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-struct mbuf;
-struct rtentry;
-#include <net/if.h>])
-fi
 
 case "$host_os" in
 
 darwin*)
        AC_ARG_ENABLE(universal,
-       AC_HELP_STRING([--disable-universal],[don't build universal on OS X]))
+       AC_HELP_STRING([--disable-universal],[don't build universal on macOS]))
        if test "$enable_universal" != "no"; then
                case "$host_os" in
 
@@ -169,7 +145,6 @@ AC_ARG_ENABLE(smb,
    enableval=yes)
 case "$enableval" in
 yes)   AC_MSG_RESULT(yes)
-       AC_WARN([The SMB printer may have exploitable buffer overflows!!!])
        AC_DEFINE(ENABLE_SMB, 1,
            [define if you want to build the possibly-buggy SMB printer])
        LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
@@ -394,17 +369,46 @@ if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
        fi
 fi
 
-AC_CACHE_CHECK([for dnet_htoa declaration in netdnet/dnetdb.h],
-[td_cv_decl_netdnet_dnetdb_h_dnet_htoa],
-[AC_EGREP_HEADER(dnet_htoa, netdnet/dnetdb.h,
-       td_cv_decl_netdnet_dnetdb_h_dnet_htoa=yes,
-       td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no)])
-if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then
-       AC_DEFINE(HAVE_NETDNET_DNETDB_H_DNET_HTOA, 1,
-           [define if you have a dnet_htoa declaration in <netdnet/dnetdb.h>])
-fi
+AC_SEARCH_LIBS(dnet_htoa, dnet,
+[
+       AC_DEFINE(HAVE_DNET_HTOA, 1,
+           [define if you have the dnet_htoa function])
+       #
+       # OK, we have dnet_htoa().  Do we have netdnet/dnetdb.h?
+       #
+       AC_CHECK_HEADERS(netdnet/dnetdb.h)
+       if test "$ac_cv_header_netdnet_dnetdb_h" = "yes"; then
+               #
+               # Yes.  Does it declare dnet_htoa()?
+               #
+               AC_CHECK_DECL(dnet_htoa,
+               [
+                       # Yes.
+                       AC_DEFINE(NETDNET_DNETDB_H_DECLARES_DNET_HTOA,,
+                           [Define to 1 if netenet/dnetdb.h declares `dnet_htoa'])
+               ],,
+               [
+AC_INCLUDES_DEFAULT
+#include <netdnet/dnetdb.h>
+               ])
+       fi
 
-AC_REPLACE_FUNCS(vfprintf strlcat strlcpy strdup strsep getservent getopt_long)
+       #
+       # Do we have netdnet/dn.h?
+       #
+       AC_CHECK_HEADERS(netdnet/dn.h)
+       if test "$ac_cv_header_netdnet_dn_h" = "yes"; then
+               #
+               # Yes.  Does it declare struct dn_naddr?
+               #
+               AC_CHECK_TYPES(struct dn_naddr,,,
+               [
+#include <netdnet/dn.h>
+               ])
+       fi
+])
+
+AC_REPLACE_FUNCS(strlcat strlcpy strdup strsep getservent getopt_long)
 AC_CHECK_FUNCS(fork vfork strftime)
 AC_CHECK_FUNCS(setlinebuf)
 
@@ -415,9 +419,6 @@ if test $needsnprintf = yes; then
        AC_LIBOBJ(snprintf)
 fi
 
-AC_SEARCH_LIBS(dnet_htoa, dnet,
-    AC_DEFINE(HAVE_DNET_HTOA, 1, [define if you have the dnet_htoa function]))
-
 AC_CHECK_LIB(rpc, main)                dnl It's unclear why we might need -lrpc
 
 dnl Some platforms may need -lnsl for getrpcbynumber.
@@ -432,11 +433,12 @@ AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
 #
 # You are in a twisty little maze of UN*Xes, all different.
 # Some might not have ether_ntohost().
-# Some might have it, but not declare it in any header file.
-# Some might have it, but declare it in <netinet/if_ether.h>.
-# Some might have it, but declare it in <netinet/ether.h>
-# (And some might have it but document it as something declared in
-# <netinet/ethernet.h>, although <netinet/if_ether.h> appears to work.)
+# Some might have it and declare it in <net/ethernet.h>.
+# Some might have it and declare it in <netinet/ether.h>
+# Some might have it and declare it in <sys/ethernet.h>.
+# Some might have it and declare it in <arpa/inet.h>.
+# Some might have it and declare it in <netinet/if_ether.h>.
+# Some might have it and not declare it in any header file.
 #
 # Before you is a C compiler.
 #
@@ -468,26 +470,41 @@ AC_CHECK_FUNCS(ether_ntohost, [
 if test "$ac_cv_func_ether_ntohost" = yes -a \
     "$ac_cv_buggy_ether_ntohost" = "no"; then
        #
-       # OK, we have ether_ntohost().  Do we have <netinet/if_ether.h>?
+       # OK, we have ether_ntohost().  Is it declared in <net/ethernet.h>?
        #
-       if test "$ac_cv_header_netinet_if_ether_h" = yes; then
+       # This test fails if we don't have <net/ethernet.h> or if we do
+       # but it doesn't declare ether_ntohost().
+       #
+       AC_CHECK_DECL(ether_ntohost,
+           [
+               AC_DEFINE(NET_ETHERNET_H_DECLARES_ETHER_NTOHOST,,
+                   [Define to 1 if net/ethernet.h declares `ether_ntohost'])
+           ],,
+           [
+#include <net/ethernet.h>
+           ])
+       #
+       # Did that succeed?
+       #
+       if test "$ac_cv_have_decl_ether_ntohost" != yes; then
+               #
+               # No, how about <netinet/ether.h>, as on Linux?
                #
-               # Yes.  Does it declare ether_ntohost()?
+               # This test fails if we don't have <netinet/ether.h>
+               # or if we do but it doesn't declare ether_ntohost().
                #
+               # Unset ac_cv_have_decl_ether_ntohost so we don't
+               # treat the previous failure as a cached value and
+               # suppress the next test.
+               #
+               unset ac_cv_have_decl_ether_ntohost
                AC_CHECK_DECL(ether_ntohost,
                    [
-                       AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST,,
-                           [Define to 1 if netinet/if_ether.h declares `ether_ntohost'])
+                       AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,,
+                           [Define to 1 if netinet/ether.h declares `ether_ntohost'])
                    ],,
                    [
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-struct mbuf;
-struct rtentry;
-#include <net/if.h>
-#include <netinet/if_ether.h>
+#include <netinet/ether.h>
                    ])
        fi
        #
@@ -495,60 +512,119 @@ struct rtentry;
        #
        if test "$ac_cv_have_decl_ether_ntohost" != yes; then
                #
-               # No, how about <netinet/ether.h>, as on Linux?
+               # No, how about <sys/ethernet.h>, as on Solaris 10
+               # and later?
                #
-               AC_CHECK_HEADERS(netinet/ether.h)
-               if test "$ac_cv_header_netinet_ether_h" = yes; then
-                       #
-                       # We have it - does it declare ether_ntohost()?
-                       # Unset ac_cv_have_decl_ether_ntohost so we don't
-                       # treat the previous failure as a cached value and
-                       # suppress the next test.
-                       #
-                       unset ac_cv_have_decl_ether_ntohost
-                       AC_CHECK_DECL(ether_ntohost,
-                           [
-                               AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,,
-                                   [Define to 1 if netinet/ether.h declares `ether_ntohost'])
-                           ],,
-                           [
-#include <netinet/ether.h>
-                           ])
-               fi
+               # This test fails if we don't have <sys/ethernet.h>
+               # or if we do but it doesn't declare ether_ntohost().
+               #
+               # Unset ac_cv_have_decl_ether_ntohost so we don't
+               # treat the previous failure as a cached value and
+               # suppress the next test.
+               #
+               unset ac_cv_have_decl_ether_ntohost
+               AC_CHECK_DECL(ether_ntohost,
+                   [
+                       AC_DEFINE(SYS_ETHERNET_H_DECLARES_ETHER_NTOHOST,,
+                           [Define to 1 if sys/ethernet.h declares `ether_ntohost'])
+                   ],,
+                   [
+#include <sys/ethernet.h>
+                   ])
        fi
        #
-       # Is ether_ntohost() declared?
+       # Did that succeed?
        #
        if test "$ac_cv_have_decl_ether_ntohost" != yes; then
                #
-               # No, we'll have to declare it ourselves.
-               # Do we have "struct ether_addr"?
+               # No, how about <arpa/inet.h>, as in AIX?
                #
-               AC_CHECK_TYPES(struct ether_addr,,,
+               # This test fails if we don't have <arpa/inet.h>
+               # (if we have ether_ntohost(), we should have
+               # networking, and if we have networking, we should
+               # have <arpa/inet.h>) or if we do but it doesn't
+               # declare ether_ntohost().
+               #
+               # Unset ac_cv_have_decl_ether_ntohost so we don't
+               # treat the previous failure as a cached value and
+               # suppress the next test.
+               #
+               unset ac_cv_have_decl_ether_ntohost
+               AC_CHECK_DECL(ether_ntohost,
+                   [
+                       AC_DEFINE(ARPA_INET_H_DECLARES_ETHER_NTOHOST,,
+                           [Define to 1 if arpa/inet.h declares `ether_ntohost'])
+                   ],,
+                   [
+#include <arpa/inet.h>
+                   ])
+       fi
+       #
+       # Did that succeed?
+       #
+       if test "$ac_cv_have_decl_ether_ntohost" != yes; then
+               #
+               # No, how about <netinet/if_ether.h>?
+               # On some platforms, it requires <net/if.h> and
+               # <netinet/in.h>, and we always include it with
+               # both of them, so test it with both of them.
+               #
+               # This test fails if we don't have <netinet/if_ether.h>
+               # and the headers we include before it, or if we do but
+               # <netinet/if_ether.h> doesn't declare ether_hostton().
+               #
+               # Unset ac_cv_have_decl_ether_ntohost so we don't
+               # treat the previous failure as a cached value and
+               # suppress the next test.
+               #
+               unset ac_cv_have_decl_ether_ntohost
+               AC_CHECK_DECL(ether_ntohost,
+                   [
+                       AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST,,
+                           [Define to 1 if netinet/if_ether.h declares `ether_ntohost'])
+                   ],,
                    [
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-struct mbuf;
-struct rtentry;
 #include <net/if.h>
+#include <netinet/in.h>
 #include <netinet/if_ether.h>
                    ])
-               AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 0,
-                   [Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
-don't.])
-       else
+       fi
+       #
+       # After all that, is ether_ntohost() declared?
+       #
+       if test "$ac_cv_have_decl_ether_ntohost" = yes; then
+               #
+               # Yes.
+               #
                AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 1,
-                   [Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
-don't.])
+                   [Define to 1 if you have the declaration of `ether_ntohost'])
+       else
+               #
+               # No, we'll have to declare it ourselves.
+               # Do we have "struct ether_addr" if we include
+               # <netinet/if_ether.h>?
+               #
+               AC_CHECK_TYPES(struct ether_addr,,,
+                   [
+                       #include <sys/types.h>
+                       #include <sys/socket.h>
+                       #include <net/if.h>
+                       #include <netinet/in.h>
+                       #include <netinet/if_ether.h>
+                   ])
        fi
 fi
 
 dnl
-dnl Check for "pcap_list_datalinks()", "pcap_set_datalink()",
-dnl and "pcap_datalink_name_to_val()", and use substitute versions
-dnl if they're not present.
+dnl Check for "pcap_list_datalinks()" and use a substitute version if
+dnl it's not present.  If it is present, check for "pcap_free_datalinks()";
+dnl if it's not present, we don't replace it for now.  (We could do so
+dnl on UN*X, but not on Windows, where hilarity ensues if a program
+dnl built with one version of the MSVC support library tries to free
+dnl something allocated by a library built with another version of
+dnl the MSVC support library.)
 dnl
 AC_CHECK_FUNC(pcap_list_datalinks,
        [
@@ -559,7 +635,13 @@ AC_CHECK_FUNC(pcap_list_datalinks,
        [
            AC_LIBOBJ(datalinks)
        ])
-AC_CHECK_FUNCS(pcap_set_datalink)
+
+dnl
+dnl Check for "pcap_datalink_name_to_val()", and use a substitute
+dnl version if it's not present.  If it is present, check for
+dnl "pcap_datalink_val_to_description()", and if we don't have it,
+dnl use a substitute version.
+dnl
 AC_CHECK_FUNC(pcap_datalink_name_to_val,
        [
            AC_DEFINE(HAVE_PCAP_DATALINK_NAME_TO_VAL, 1,
@@ -575,6 +657,13 @@ AC_CHECK_FUNC(pcap_datalink_name_to_val,
            AC_LIBOBJ(dlnames)
        ])
 
+dnl
+dnl Check for "pcap_set_datalink()"; you can't substitute for it if
+dnl it's absent (it has hooks into libpcap), so just define the
+dnl HAVE_ value if it's there.
+dnl
+AC_CHECK_FUNCS(pcap_set_datalink)
+
 dnl
 dnl Check for "pcap_breakloop()"; you can't substitute for it if
 dnl it's absent (it has hooks into the live capture routines),
@@ -582,17 +671,6 @@ dnl so just define the HAVE_ value if it's there.
 dnl
 AC_CHECK_FUNCS(pcap_breakloop)
 
-dnl
-dnl Check for "pcap_dump_ftell()" and use a substitute version
-dnl if it's not present.
-dnl
-AC_CHECK_FUNC(pcap_dump_ftell,
-       AC_DEFINE(HAVE_PCAP_DUMP_FTELL, 1,
-           [define if libpcap has pcap_dump_ftell()]),
-       [
-           AC_LIBOBJ(pcap_dump_ftell)
-       ])
-
 #
 # Do we have the new open API?  Check for pcap_create, and assume that,
 # if we do, we also have pcap_activate() and the other new routines
@@ -618,9 +696,10 @@ fi
 #
 AC_CHECK_FUNCS(pcap_findalldevs)
 if test $ac_cv_func_pcap_findalldevs = "yes" ; then
-dnl Check for Mac OS X, which may ship pcap.h from 0.6 but libpcap may
-dnl be 0.8; this means that lib has pcap_findalldevs but header doesn't
-dnl have pcap_if_t.
+dnl Check for libpcap having pcap_findalldevs() but the pcap.h header
+dnl not having pcap_if_t; some versions of Mac OS X shipped with pcap.h
+dnl from 0.6 and libpcap 0.8, so that libpcap had pcap_findalldevs but
+dnl pcap.h didn't have pcap_if_t.
     savedcppflags="$CPPFLAGS"
     CPPFLAGS="$CPPFLAGS $V_INCLS"
     AC_CHECK_TYPES(pcap_if_t, , , [#include <pcap.h>])
@@ -646,6 +725,7 @@ if test $ac_cv_func_pcap_lib_version = "no" ; then
 fi
 AC_CHECK_FUNCS(pcap_setdirection pcap_set_immediate_mode pcap_dump_ftell64)
 AC_CHECK_FUNCS(pcap_open pcap_findalldevs_ex)
+AC_REPLACE_FUNCS(pcap_dump_ftell)
 
 #
 # Check for special debugging functions
@@ -797,20 +877,6 @@ AC_CHECK_TYPE([u_int64_t], ,
 #include <sys/types.h>
 ])
 
-#
-# Check for some headers introduced in later versions of libpcap
-# and used by some printers.
-#
-# Those headers might use the {u_}intN_t types, so we must do this
-# after we check for what's needed to get them defined.
-#
-savedcppflags="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $V_INCLS"
-AC_CHECK_HEADERS(pcap/bluetooth.h,,,[#include "netdissect-stdinc.h"])
-AC_CHECK_HEADERS(pcap/nflog.h,,,[#include "netdissect-stdinc.h"])
-AC_CHECK_HEADERS(pcap/usb.h,,,[#include "netdissect-stdinc.h"])
-CPPFLAGS="$savedcppflags"
-
 AC_PROG_RANLIB
 AC_CHECK_TOOL([AR], [ar])
 
@@ -865,7 +931,7 @@ if test "$want_libcrypto" != "no"; then
        # El Capitan, probably because they don't want you writing
        # nasty portable code that could run on other UN*Xes, they
        # want you writing code that uses their Shiny New Crypto
-       # Library and that only runs on OS X.
+       # Library and that only runs on macOS.
        #
        AC_CHECK_HEADER(openssl/crypto.h,
        [