X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/1af79d4adf40a736340e9f5fd87b93c9bc847191..refs/pull/1036/head:/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index c1178427..fa865703 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,41 +1,127 @@ -cmake_minimum_required(VERSION 2.8.6) +if(WIN32) + # + # We need 3.12 or later, so that we can set policy CMP0074; see + # below. + # + cmake_minimum_required(VERSION 3.12) +else(WIN32) + # + # For now, require only 2.8.12, just in case somebody is + # configuring with CMake on a "long-term support" version + # of some OS and that version supplies an older version of + # CMake. + # + # If this is ever updated to CMake 3.1 or later, remove the + # stuff in cmake/Modules/FindPCAP.cmake that appends subdirectories + # of directories from CMAKE_PREFIX_PATH to the PKG_CONFIG_PATH + # environment variable when running pkg-config, to make sure + # it finds any .pc file from there. + # + cmake_minimum_required(VERSION 2.8.12) +endif(WIN32) -set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) +# +# We want find_path() and find_library() to honor {packagename}_ROOT, +# as that appears to be the standard way to say "hey, look here for +# this package" from the command line. +# +if(POLICY CMP0074) + cmake_policy(SET CMP0074 NEW) +endif() -project(tcpdump) +# +# OK, this is a pain. +# +# When building on NetBSD, with a libpcap installed from pkgsrc, +# a -Wl,-rpath,/usr/pkg/lib option is added to the options when +# linking tcpdump. This puts /usr/pkg/lib into the run-time path. +# +# However, by default, CMake adds a rule to the install CMake script +# a CMake command (using an undocumented subcommand of file()) that +# strips /usr/pkg/lib *out* of the run-time path; the message in the +# output for the "install" target is +# +# -- Set runtime path of "{target-directory}/tcpdump" to "" +# +# I am not certain what the rationale is for doing this, but a +# *consequence* of this is that, when you run the installed tcpdump, +# it fails to find libpcap.so: +# +# $ {target-directory}/tcpdump -h +# {target-directory}/tcpdump: Shared object "libpcap.so.0" not found +# +# It also appears to be the case that, on Ubuntu 22.04, FreeBSD 12, +# DragonFly BSD 5.8, OpenBSD 6.6, and Solaris 11.4, +# +# On Ubuntu and Solaris, even if you have a libpcap in /usr/local, you +# have to provide not only -I/usr/local/include and -L/usr/local/lib, +# you also must provide -Wl,-rpath,/usr/local/lib in order to have +# the run-time linker look in /usr/local/lib for libpcap. If it's not +# specified, then, if the shared library major version number of the +# libpcap in /usr/lib is the same as the shared major version number +# of the libpcap in /usr/local/lib, the run-time linker will find the +# libpcap in /usr/lib; if the versions are different, the run-time +# linker will fail to find the libpcap in /usr/lib, so the program will +# fail to run. +# +# We suppress this by setting CMAKE_INSTALL_RPATH_USE_LINK_PATH to TRUE; +# as the documentation for that variable says: +# +# Add paths to linker search and installed rpath. +# +# CMAKE_INSTALL_RPATH_USE_LINK_PATH is a boolean that if set to True +# will append to the runtime search path (rpath) of installed +# binaries any directories outside the project that are in the linker +# search path or contain linked library files. The directories are +# appended after the value of the INSTALL_RPATH target property. +# +# If, for whatever reason, directories in which we search for external +# libraries, other than the standard system library directories, are +# added to the executable's rpath in the build process, we most +# defintely want them in the installed image's rpath if they are +# necessary in order to find the libraries at run time. +# +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + +set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) # -# Try to enable as many C99 features as we can. -# At minimum, we want C++/C99-style // comments. +# We explicitly indicate what languages are used in tcpdump to avoid +# checking for a C++ compiler. +# +# One reason to avoid that check is that there's no need to waste +# configuration time performing it. # -# Newer versions of compilers might default to supporting C99, but older -# versions may require a special flag. +# Another reason is that: # -# Prior to CMake 3.1, setting CMAKE_C_STANDARD will not have any effect, -# so, unless and until we require CMake 3.1 or later, we have to do it -# ourselves on pre-3.1 CMake, so we just do it ourselves on all versions -# of CMake. +# CMake will try to determine the sizes of some data types, including +# void *, early in the process of configuration; apparently, it's done +# as part of processing the project() command. # -# Note: with CMake 3.1 through 3.5, the only compilers for which CMake -# handles CMAKE_C_STANDARD are GCC and Clang. 3.6 adds support only -# for Intel C; 3.9 adds support for PGI C, Sun C, and IBM XL C, and -# 3.10 adds support for Cray C and IAR C, but no version of CMake has -# support for HP C. Therefore, even if we use CMAKE_C_STANDARD with -# compilers for which CMake supports it, we may still have to do it -# ourselves on other compilers. +# At least as of CMake 2.8.6, it does so by checking the size of +# "void *" in C, setting CMAKE_C_SIZEOF_DATA_PTR based on that, +# setting CMAKE_SIZEOF_VOID_P to that, and then checking the size +# of "void *" in C++, setting CMAKE_CXX_SIZEOF_DATA_PTR based on +# that, and then setting CMAKE_SIZEOF_VOID_P to *that*. # -# See the CMake documentation for the CMAKE__COMPILER_ID variables -# for a list of compiler IDs. +# The compile tests include whatever C flags may have been provided +# to CMake in the CFLAGS and CXXFLAGS environment variables. # -# We don't worry about MSVC; it doesn't have such a flag - either it -# doesn't support the C99 features we need at all, or it supports them -# regardless of the compiler flag. +# If you set an architecture flag such as -m32 or -m64 in CFLAGS +# but *not* in CXXFLAGS, the size for C++ will win, and hilarity +# will ensue. +# +# Or if, at least on Solaris, you have a newer version of GCC +# installed, but *not* a newer version of G++, and you have Oracle +# Studio installed, it will find GCC, which will default to building +# 64-bit, and Oracle Studio's C++ compiler, which will default to +# building 32-bit, the size for C++ will win, and, again, hilarity +# will ensue. +# +project(tcpdump C) + # -# XXX - this just tests whether the option works and adds it if it does. -# We don't test whether it's necessary in order to get the C99 features -# that we use; if we ever have a user who tries to compile with a compiler -# that can't be made to support those features, we can add a test to make -# sure we actually *have* C99 support. +# For checking if a compiler flag works and adding it if it does. # include(CheckCCompilerFlag) macro(check_and_add_compiler_option _option) @@ -48,23 +134,75 @@ macro(check_and_add_compiler_option _option) endif() endmacro() +# +# If we're building with Visual Studio, we require Visual Studio 2015, +# in order to get sufficient C99 compatibility. Check for that. +# +# If not, try the appropriate flag for the compiler to enable C99 +# features. +# set(C_ADDITIONAL_FLAGS "") -if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR - CMAKE_C_COMPILER_ID MATCHES "Clang") - check_and_add_compiler_option("-std=gnu99") -elseif(CMAKE_C_COMPILER_ID MATCHES "XL") +if(MSVC) + if(MSVC_VERSION LESS 1900) + message(FATAL_ERROR "Visual Studio 2015 or later is required") + endif() + # - # We want support for extensions picked up for GNU C compatibility, - # so we use -qlanglvl=extc99. + # Treat source files as being in UTF-8 with MSVC if it's not using + # the Clang front end. + # We assume that UTF-8 source is OK with other compilers and with + # MSVC if it's using the Clang front end. # - check_and_add_compiler_option("-qlanglvl=extc99") -elseif(CMAKE_C_COMPILER_ID MATCHES "HP") - check_and_add_compiler_option("-AC99") -elseif(CMAKE_C_COMPILER_ID MATCHES "Sun") - check_and_add_compiler_option("-xc99") -elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") - check_and_add_compiler_option("-c99") -endif() + if(NOT ${CMAKE_C_COMPILER} MATCHES "clang*") + set(C_ADDITIONAL_FLAGS "${C_ADDITIONAL_FLAGS} /utf-8") + endif(NOT ${CMAKE_C_COMPILER} MATCHES "clang*") +else(MSVC) + # + # Try to enable as many C99 features as we can. + # At minimum, we want C++/C99-style // comments. + # + # Newer versions of compilers might default to supporting C99, but + # older versions may require a special flag. + # + # Prior to CMake 3.1, setting CMAKE_C_STANDARD will not have any effect, + # so, unless and until we require CMake 3.1 or later, we have to do it + # ourselves on pre-3.1 CMake, so we just do it ourselves on all versions + # of CMake. + # + # Note: with CMake 3.1 through 3.5, the only compilers for which CMake + # handles CMAKE_C_STANDARD are GCC and Clang. 3.6 adds support only + # for Intel C; 3.9 adds support for PGI C, Sun C, and IBM XL C, and + # 3.10 adds support for Cray C and IAR C, but no version of CMake has + # support for HP C. Therefore, even if we use CMAKE_C_STANDARD with + # compilers for which CMake supports it, we may still have to do it + # ourselves on other compilers. + # + # See the CMake documentation for the CMAKE__COMPILER_ID variables + # for a list of compiler IDs. + # + # XXX - this just tests whether the option works and adds it if it does. + # We don't test whether it's necessary in order to get the C99 features + # that we use; if we ever have a user who tries to compile with a compiler + # that can't be made to support those features, we can add a test to make + # sure we actually *have* C99 support. + # + if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR + CMAKE_C_COMPILER_ID MATCHES "Clang") + check_and_add_compiler_option("-std=gnu99") + elseif(CMAKE_C_COMPILER_ID MATCHES "XL") + # + # We want support for extensions picked up for GNU C compatibility, + # so we use -qlanglvl=extc99. + # + check_and_add_compiler_option("-qlanglvl=extc99") + elseif(CMAKE_C_COMPILER_ID MATCHES "HP") + check_and_add_compiler_option("-AC99") + elseif(CMAKE_C_COMPILER_ID MATCHES "Sun") + check_and_add_compiler_option("-xc99") + elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") + check_and_add_compiler_option("-c99") + endif() +endif(MSVC) set(LIBRARY_NAME netdissect) @@ -76,7 +214,7 @@ option(WITH_SMI "Build with libsmi, if available" ON) option(WITH_CRYPTO "Build with OpenSSL/libressl libcrypto, if available" ON) option(WITH_CAPSICUM "Build with Capsicum security functions, if available" ON) option(WITH_CAP_NG "Use libcap-ng, if available" ON) -option(ENABLE_SMB "Build with the SMB dissector" ON) +option(ENABLE_SMB "Build with the SMB dissector" OFF) # # String parameters. Neither of them are set, initially; only if the @@ -195,22 +333,12 @@ check_include_file(net/if.h HAVE_NET_IF_H) if(HAVE_RPC_RPC_H) check_include_files("rpc/rpc.h;rpc/rpcent.h" HAVE_RPC_RPCENT_H) endif(HAVE_RPC_RPC_H) -if(NOT WIN32) - check_include_files("sys/types.h;sys/socket.h;net/if.h;net/pfvar.h" HAVE_NET_PFVAR_H) - if(HAVE_NET_PFVAR_H) - check_include_files("sys/types.h;sys/socket.h;net/if.h;net/pfvar.h;net/if_pflog.h" HAVE_NET_IF_PFLOG_H) - if(HAVE_NET_IF_PFLOG_H) - set(LOCALSRC print-pflog.c ${LOCALSRC}) - endif(HAVE_NET_IF_PFLOG_H) - endif(HAVE_NET_PFVAR_H) -endif(NOT WIN32) # # Functions. # check_function_exists(strlcat HAVE_STRLCAT) check_function_exists(strlcpy HAVE_STRLCPY) -check_function_exists(strdup HAVE_STRDUP) check_function_exists(strsep HAVE_STRSEP) # @@ -243,7 +371,12 @@ else(WIN32) if(LIBNSL_HAS_GETHOSTBYADDR) set(TCPDUMP_LINK_LIBRARIES ${TCPDUMP_LINK_LIBRARIES} nsl) else(LIBNSL_HAS_GETHOSTBYADDR) - message(FATAL_ERROR "gethostbyaddr is required, but wasn't found") + check_library_exists(network gethostbyaddr "" LIBNETWORK_HAS_GETHOSTBYADDR) + if(LIBNETWORK_HAS_GETHOSTBYADDR) + set(TCPDUMP_LINK_LIBRARIES ${TCPDUMP_LINK_LIBRARIES} network) + else(LIBNETWORK_HAS_GETHOSTBYADDR) + message(FATAL_ERROR "gethostbyaddr is required, but wasn't found") + endif(LIBNETWORK_HAS_GETHOSTBYADDR) endif(LIBNSL_HAS_GETHOSTBYADDR) endif(LIBSOCKET_HAS_GETHOSTBYADDR) endif(NOT STDLIBS_HAVE_GETHOSTBYADDR) @@ -270,37 +403,78 @@ else(STDLIBS_HAVE_GETSERVENT) endif(STDLIBS_HAVE_GETSERVENT) cmake_pop_check_state() -check_function_exists(getopt_long HAVE_GETOPT_LONG) -# -# For Windows, either -# -# 1) we're using VS 2015, in which case we have both snprintf() -# and vsnprintf(), and they behave in a C99-compliant fashion, -# so we use them # -# or +# Make sure we have snprintf(); we require it. +# We use check_symbol_exists(), as it isn't necessarily an external +# function - in Visual Studio, for example, it is an inline function +# calling an external function. # -# 2) we're not, and we don't have snprintf(), and we either don't -# have vsnprintf() or we have one that *doesn't* behave in a -# C99-compliant fashion, but we *do* have _snprintf_s() and -# _vsnprintf_s(), so we wrap them with #defines +check_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF) +if(NOT HAVE_SNPRINTF) + message(FATAL_ERROR "snprintf() is required but wasn't found") +endif() + # -# and we test for both of them at compile time, so we don't need to -# check for snprintf() or vsnprintf() here. +# Require a proof of suitable snprintf(3), same as in Autoconf. # -# XXX - do we need to care about UN*Xes that don't have snprintf() -# or vsnprintf() any more? +include(CheckCSourceRuns) +check_c_source_runs(" +#include +#include +#include +#include + +int main() +{ + char buf[100]; + uint64_t t = (uint64_t)1 << 32; + + snprintf(buf, sizeof(buf), \"%zu\", sizeof(buf)); + if (strncmp(buf, \"100\", sizeof(buf))) + return 1; + + snprintf(buf, sizeof(buf), \"%zd\", -sizeof(buf)); + if (strncmp(buf, \"-100\", sizeof(buf))) + return 2; + + snprintf(buf, sizeof(buf), \"%\" PRId64, -t); + if (strncmp(buf, \"-4294967296\", sizeof(buf))) + return 3; + + snprintf(buf, sizeof(buf), \"0o%\" PRIo64, t); + if (strncmp(buf, \"0o40000000000\", sizeof(buf))) + return 4; + + snprintf(buf, sizeof(buf), \"0x%\" PRIx64, t); + if (strncmp(buf, \"0x100000000\", sizeof(buf))) + return 5; + + snprintf(buf, sizeof(buf), \"%\" PRIu64, t); + if (strncmp(buf, \"4294967296\", sizeof(buf))) + return 6; + + return 0; +} + +" + SUITABLE_SNPRINTF +) +if(NOT SUITABLE_SNPRINTF) + message(FATAL_ERROR +"The snprintf(3) implementation in this libc is not suitable, +tcpdump would not work correctly even if it managed to compile." + ) +endif() + +check_function_exists(getopt_long HAVE_GETOPT_LONG) +check_function_exists(setlinebuf HAVE_SETLINEBUF) # -# We also don't need to waste time checking for fork() or vfork(). +# For Windows, don't need to waste time checking for fork() or vfork(). # if(NOT WIN32) - check_function_exists(vsnprintf HAVE_VSNPRINTF) - check_function_exists(snprintf HAVE_SNPRINTF) - check_function_exists(fork HAVE_FORK) - check_function_exists(vfork HAVE_VFORK) + check_function_exists(fork HAVE_FORK) + check_function_exists(vfork HAVE_VFORK) endif(NOT WIN32) -check_function_exists(strftime HAVE_STRFTIME) -check_function_exists(setlinebuf HAVE_SETLINEBUF) # # Some platforms may need -lnsl for getrpcbynumber. @@ -450,45 +624,6 @@ if(HAVE_ETHER_NTOHOST) endif() cmake_pop_check_state() -check_function_exists(dnet_htoa STDLIBS_HAVE_DNET_HTOA) -if(STDLIBS_HAVE_DNET_HTOA) - set(HAVE_DNET_HTOA TRUE) -else(STDLIBS_HAVE_DNET_HTOA) - check_library_exists(dnet dnet_htoa "" HAVE_DNET_HTOA) - if(HAVE_DNET_HTOA) - set(TCPDUMP_LINK_LIBRARIES dnet ${TCPDUMP_LINK_LIBRARIES}) - endif(HAVE_DNET_HTOA) -endif(STDLIBS_HAVE_DNET_HTOA) -if(HAVE_DNET_HTOA) - # - # OK, we have dnet_htoa(). Do we have netdnet/dnetdb.h? - # - check_include_files("sys/types.h;netdnet/dnetdb.h" HAVE_NETDNET_DNETDB_H) - if(HAVE_NETDNET_DNETDB_H) - # - # Yes. Does it declare dnet_htoa()? - # - cmake_push_check_state() - set(CMAKE_REQUIRED_LIBRARIES dnet) - check_symbol_exists(dnet_htoa "sys/types.h;netdnet/dnetdb.h" NETDNET_DNETDB_H_DECLARES_DNET_HTOA) - cmake_pop_check_state() - endif(HAVE_NETDNET_DNETDB_H) - - # - # Do we have netdnet/dn.h? - # - check_include_file(netdnet/dn.h HAVE_NETDNET_DN_H) - if(HAVE_NETDNET_DN_H) - # - # Yes. Does it declare struct dn_naddr? - # - cmake_push_check_state() - set(CMAKE_EXTRA_INCLUDE_FILES netdnet/dn.h) - check_type_size("struct dn_naddr" STRUCT_DN_NADDR) - cmake_pop_check_state() - endif(HAVE_NETDNET_DN_H) -endif(HAVE_DNET_HTOA) - # # Data types. # @@ -498,29 +633,17 @@ endif(HAVE_DNET_HTOA) # # -# Check for IPv6 support. -# We just check for AF_INET6 and struct in6_addr. +# FIXME: This check does not influence the build logic, but without it CMake +# 3.18.4 fails trying to make the next check_type_size() check later on. # -cmake_push_check_state() -if(WIN32) - set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h ws2tcpip.h) - check_symbol_exists(AF_INET6 "sys/types.h;ws2tcpip.h" HAVE_AF_INET6) -else(WIN32) - set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h sys/socket.h netinet/in.h) - check_symbol_exists(AF_INET6 "sys/types.h;sys/socket.h;netinet/in.h" HAVE_AF_INET6) -endif(WIN32) check_type_size("struct in6_addr" HAVE_STRUCT_IN6_ADDR) -cmake_pop_check_state() -if(HAVE_AF_INET6 AND HAVE_STRUCT_IN6_ADDR) - set(HAVE_OS_IPV6_SUPPORT TRUE) -endif(HAVE_AF_INET6 AND HAVE_STRUCT_IN6_ADDR) ###################################### # External dependencies ###################################### # -# libpcap/WinPcap. +# libpcap/WinPcap/Npcap. # First, find it. # find_package(PCAP REQUIRED) @@ -540,7 +663,7 @@ set(CMAKE_REQUIRED_INCLUDES ${PCAP_INCLUDE_DIRS}) check_include_file(pcap/pcap-inttypes.h HAVE_PCAP_PCAP_INTTYPES_H) # -# Check for various functions in libpcap/WinPcap. +# Check for various functions in libpcap/WinPcap/Npcap. # cmake_push_check_state() set(CMAKE_REQUIRED_LIBRARIES ${PCAP_LIBRARIES}) @@ -709,30 +832,32 @@ if(WITH_CRYPTO) find_package(CRYPTO) if(CRYPTO_FOUND) # - # Check for some functions. + # Check for some headers and functions. # - cmake_push_check_state() - set(CMAKE_REQUIRED_LIBRARIES crypto) + check_include_file(openssl/evp.h HAVE_OPENSSL_EVP_H) # - # 1) do we have EVP_CIPHER_CTX_new? + # 1) do we have EVP_CIPHER_CTX_new? # If so, we use it to allocate an EVP_CIPHER_CTX, as # EVP_CIPHER_CTX may be opaque; otherwise, we allocate # it ourselves. # + cmake_push_check_state() + set(CMAKE_REQUIRED_LIBRARIES "${CRYPTO_LIBRARIES}") + check_function_exists(EVP_CIPHER_CTX_new HAVE_EVP_CIPHER_CTX_NEW) # - # 2) do we have EVP_CipherInit_ex()? + # 2) do we have EVP_DecryptInit_ex()? # If so, we use it, because we need to be able to make two # "initialize the cipher" calls, one with the cipher and key, # and one with the IV, and, as of OpenSSL 1.1, You Can't Do That - # with EVP_CipherInit(), because a call to EVP_CipherInit() will + # with EVP_DecryptInit(), because a call to EVP_DecryptInit() will # unconditionally clear the context, and if you don't supply a # cipher, it'll clear the cipher, rendering the context unusable # and causing a crash. # - check_function_exists(EVP_CipherInit_ex HAVE_EVP_CIPHERINIT_EX) + check_function_exists(EVP_DecryptInit_ex HAVE_EVP_DECRYPTINIT_EX) cmake_pop_check_state() @@ -873,6 +998,18 @@ if(EXISTS ${CMAKE_SOURCE_DIR}/.devel OR EXISTS ${CMAKE_BINARY_DIR}/.devel) # XXX - add /Qspectre if that is really worth doing. # check_and_add_compiler_option(-wd5045) + # + # We do *not* care whether a structure had padding added at + # the end because of __declspec(align) - *we* don't use + # __declspec(align), because the only structures whose layout + # we precisely specify are those that get overlayed on packet + # data, and in those every element is an array of octets so + # that we have full control over the size and aligmnet, and, + # apparently, jmp_buf has such a declaration on x86, meaning + # that everything that includes netdissect.h, i.e. almost every + # file in tcpdump, gets a warning. + # + check_and_add_compiler_option(-wd4324) else() # # Other compilers, including MSVC with a Clang front end and @@ -884,9 +1021,11 @@ if(EXISTS ${CMAKE_SOURCE_DIR}/.devel OR EXISTS ${CMAKE_BINARY_DIR}/.devel) check_and_add_compiler_option(-Wassign-enum) check_and_add_compiler_option(-Wcast-qual) check_and_add_compiler_option(-Wmissing-prototypes) + check_and_add_compiler_option(-Wmissing-variable-declarations) check_and_add_compiler_option(-Wold-style-definition) check_and_add_compiler_option(-Wpedantic) check_and_add_compiler_option(-Wpointer-arith) + check_and_add_compiler_option(-Wpointer-sign) check_and_add_compiler_option(-Wshadow) check_and_add_compiler_option(-Wsign-compare) check_and_add_compiler_option(-Wstrict-prototypes) @@ -896,6 +1035,19 @@ if(EXISTS ${CMAKE_SOURCE_DIR}/.devel OR EXISTS ${CMAKE_BINARY_DIR}/.devel) endif() endif() +# +# Extra compiler options for the build matrix scripts to request -Werror or +# its equivalent if required. The CMake variable name cannot be CFLAGS +# because that is already used for a different purpose in CMake. Example +# usage: cmake -DEXTRA_CFLAGS='-Wall -Wextra -Werror' ... +# +if(NOT "${EXTRA_CFLAGS}" STREQUAL "") + foreach(_extra_cflag ${EXTRA_CFLAGS}) + check_and_add_compiler_option("${_extra_cflag}") + endforeach(_extra_cflag) + message(STATUS "Added extra compile options (${EXTRA_CFLAGS})") +endif() + ###################################### # Input files ###################################### @@ -925,6 +1077,7 @@ set(NETDISSECT_SOURCE_LIST_C netdissect-alloc.c nlpid.c oui.c + ntp.c parsenfsfh.c print.c print-802_11.c @@ -935,15 +1088,18 @@ set(NETDISSECT_SOURCE_LIST_C print-aoe.c print-ap1394.c print-arcnet.c + print-arista.c print-arp.c print-ascii.c print-atalk.c print-atm.c print-babel.c + print-bcm-li.c print-beep.c print-bfd.c print-bgp.c print-bootp.c + print-brcmtag.c print-bt.c print-calm-fast.c print-carp.c @@ -956,6 +1112,7 @@ set(NETDISSECT_SOURCE_LIST_C print-decnet.c print-dhcp6.c print-domain.c + print-dsa.c print-dtp.c print-dvmrp.c print-eap.c @@ -979,12 +1136,14 @@ set(NETDISSECT_SOURCE_LIST_C print-icmp6.c print-igmp.c print-igrp.c + print-ip-demux.c print-ip.c print-ip6.c print-ip6opts.c print-ipcomp.c print-ipfc.c print-ipnet.c + print-ipoib.c print-ipx.c print-isakmp.c print-isoclns.c @@ -1002,7 +1161,7 @@ set(NETDISSECT_SOURCE_LIST_C print-lwapp.c print-lwres.c print-m3ua.c - print-medsa.c + print-macsec.c print-mobile.c print-mobility.c print-mpcp.c @@ -1017,10 +1176,12 @@ set(NETDISSECT_SOURCE_LIST_C print-null.c print-olsr.c print-openflow-1.0.c + print-openflow-1.3.c print-openflow.c print-ospf.c print-ospf6.c print-otv.c + print-pflog.c print-pgm.c print-pim.c print-pktap.c @@ -1028,13 +1189,15 @@ set(NETDISSECT_SOURCE_LIST_C print-ppp.c print-pppoe.c print-pptp.c + print-ptp.c + print-quic.c print-radius.c print-raw.c + print-realtek.c print-resp.c print-rip.c print-ripng.c print-rpki-rtr.c - print-rrcp.c print-rsvp.c print-rt6.c print-rtsp.c @@ -1047,6 +1210,8 @@ set(NETDISSECT_SOURCE_LIST_C print-slow.c print-smtp.c print-snmp.c + print-someip.c + print-ssh.c print-stp.c print-sunatm.c print-sunrpc.c @@ -1060,14 +1225,18 @@ set(NETDISSECT_SOURCE_LIST_C print-token.c print-udld.c print-udp.c + print-unsupported.c print-usb.c print-vjc.c print-vqp.c print-vrrp.c + print-vsock.c print-vtp.c - print-vxlan.c print-vxlan-gpe.c + print-vxlan.c print-wb.c + print-whois.c + print-zep.c print-zephyr.c print-zeromq.c ${LOCALSRC} @@ -1079,18 +1248,13 @@ set(NETDISSECT_SOURCE_LIST_C # # Replace missing functions # -foreach(FUNC strlcat strlcpy strdup strsep getservent getopt_long) +foreach(FUNC strlcat strlcpy strsep getservent getopt_long) string(TOUPPER ${FUNC} FUNC_UPPERCASE) set(HAVE_FUNC_UPPERCASE HAVE_${FUNC_UPPERCASE}) if(NOT ${HAVE_FUNC_UPPERCASE}) set(NETDISSECT_SOURCE_LIST_C ${NETDISSECT_SOURCE_LIST_C} missing/${FUNC}.c) endif() endforeach() -if(NOT WIN32) - if(NOT HAVE_VSNPRINTF OR NOT HAVE_SNPRINTF) - set(NETDISSECT_SOURCE_LIST_C ${NETDISSECT_SOURCE_LIST_C} missing/snprintf.c) - endif(NOT HAVE_VSNPRINTF OR NOT HAVE_SNPRINTF) -endif(NOT WIN32) add_library(netdissect STATIC ${NETDISSECT_SOURCE_LIST_C} @@ -1099,7 +1263,7 @@ if(NOT C_ADDITIONAL_FLAGS STREQUAL "") set_target_properties(netdissect PROPERTIES COMPILE_FLAGS ${C_ADDITIONAL_FLAGS}) endif() -set(TCPDUMP_SOURCE_LIST_C tcpdump.c) +set(TCPDUMP_SOURCE_LIST_C fptype.c tcpdump.c) if(NOT HAVE_BPF_DUMP) set(TCPDUMP_SOURCE_LIST_C ${TCPDUMP_SOURCE_LIST_C} bpf_dump.c) @@ -1122,6 +1286,55 @@ file(GLOB PROJECT_SOURCE_LIST_H *.h ) +# +# Assume, by default, no support for shared libraries and V7/BSD +# convention for man pages (devices in section 4, file formats in +# section 5, miscellaneous info in section 7, administrative commands +# and daemons in section 8). Individual cases can override this. +# Individual cases can override this. +# +set(MAN_FILE_FORMATS 5) +set(MAN_MISC_INFO 7) +if(CMAKE_SYSTEM_NAME STREQUAL "AIX") + # Workaround to enable certain features + set(_SUN TRUE) +elseif(CMAKE_SYSTEM_NAME STREQUAL "HP-UX") + # + # Use System V conventions for man pages. + # + set(MAN_FILE_FORMATS 4) + set(MAN_MISC_INFO 5) +elseif(CMAKE_SYSTEM_NAME STREQUAL "IRIX" OR CMAKE_SYSTEM_NAME STREQUAL "IRIX64") + # + # Use IRIX conventions for man pages; they're the same as the + # System V conventions, except that they use section 8 for + # administrative commands and daemons. + # + set(MAN_FILE_FORMATS 4) + set(MAN_MISC_INFO 5) +elseif(CMAKE_SYSTEM_NAME STREQUAL "OSF1") + # + # DEC OSF/1, a/k/a Digital UNIX, a/k/a Tru64 UNIX. + # Use Tru64 UNIX conventions for man pages; they're the same as the + # System V conventions except that they use section 8 for + # administrative commands and daemons. + # + set(MAN_FILE_FORMATS 4) + set(MAN_MISC_INFO 5) +elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.][0-9.]*") + # + # SunOS 5.x. + # + if(CMAKE_SYSTEM_VERSION STREQUAL "5.12") + else() + # + # Use System V conventions for man pages. + # + set(MAN_FILE_FORMATS 4) + set(MAN_MISC_INFO 5) + endif() +endif() + source_group("Source Files" FILES ${PROJECT_SOURCE_LIST_C}) source_group("Header Files" FILES ${PROJECT_SOURCE_LIST_H}) @@ -1157,7 +1370,7 @@ set(MAN1_EXPAND tcpdump.1.in) if(WIN32) # XXX TODO where to install on Windows? else(WIN32) - install(TARGETS tcpdump DESTINATION sbin) + install(TARGETS tcpdump DESTINATION bin) endif(WIN32) # On UN*X, and on Windows when not using MSVC, process man pages and @@ -1189,7 +1402,15 @@ add_custom_target(uninstall # # Tcpdump tests -# -add_custom_target(check - COMMAND ./TESTrun.sh - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests) +# We try to find the Perl interpreter and, if we do, we have the check +# rule run tests/TESTrun with it, because just trying to run the TESTrun +# script as a command won't work on Windows. +# +find_program(PERL perl) +if(PERL) + message(STATUS "Found perl at ${PERL}") + add_custom_target(check + COMMAND ${PERL} ${CMAKE_SOURCE_DIR}/tests/TESTrun) +else() + message(STATUS "Didn't find perl") +endif()