diff options
author | Joseph Mingrone <jrm@FreeBSD.org> | 2023-03-31 19:01:44 +0000 |
---|---|---|
committer | Joseph Mingrone <jrm@FreeBSD.org> | 2023-03-31 19:02:22 +0000 |
commit | 6f9cba8f8b5efd16249633e52483ea351876b67b (patch) | |
tree | 544c9dc831f12dad8ce0bf0af943eb68d07a845f | |
parent | d860991a7289c673d19467ea7faae46df7681db1 (diff) | |
parent | 35af88c96350eb786f1198dfb6b29a171016e6bf (diff) | |
download | src-6f9cba8f8b5e.tar.gz src-6f9cba8f8b5e.zip |
libpcap: Update to 1.10.3
Local changes:
- In contrib/libpcap/pcap/bpf.h, do not include pcap/dlt.h. Our system
net/dlt.h is pulled in from net/bpf.h.
- sys/net/dlt.h: Incorporate changes from libpcap 1.10.3.
- lib/libpcap/Makefile: Update for libpcap 1.10.3.
Changelog: https://git.tcpdump.org/libpcap/blob/95691ebe7564afa3faa5c6ba0dbd17e351be455a:/CHANGES
Reviewed by: emaste
Obtained from: https://www.tcpdump.org/release/libpcap-1.10.3.tar.gz
Sponsored by: The FreeBSD Foundation
239 files changed, 28583 insertions, 14757 deletions
diff --git a/contrib/libpcap/CHANGES b/contrib/libpcap/CHANGES index 89e739c46fa2..d174cd5e1a9c 100644 --- a/contrib/libpcap/CHANGES +++ b/contrib/libpcap/CHANGES @@ -1,3 +1,432 @@ +Thursday, January 12, 2023 / The Tcpdump Group + Summary for 1.10.3 libpcap release + Source code: + Sort the PUBHDR variable in Makefile.in in "ls" order. + Fix typo in comment in pflog.h. + Remove two no-longer-present files from .gitignore. + Update code and comments for handling failure to set promiscuous + mode based on new information. + Building and testing: + install: Fixed not to install the non-public pcap-util.h header. + pcap-config: add a --version flag. + Makefile.in: Add some missing files in the distclean target. + +Saturday, December 31, 2022 / The Tcpdump Group + Summary for 1.10.2 libpcap release + Source code: + Use __builtin_unreachable() in PCAP_UNREACHABLE. + Use AS_HELP_STRING macro instead of AC_HELP_STRING in the + configure scripts, to avoid deprecation warnings. + Change availability tags in pcap.h to make it easier to + arrange for it to be used in Darwin releases. + Use AS_HELP_STRING for --enable-remote. + Fix some formatting string issues found by cppcheck. + Various small code and comment cleanups. + Use PCAP_ERROR (defined as -1) rather than explicit -1 for + functions the documentation says return PCAP_ERROR. + Remove unused code from the filter compiler. + Use _declspec(deprecated(msg)) rather than __pragma(deprecated) + for Windows deprecation warnings, so the message that was + specified shows up. + diag-control.h: define PCAP_DO_PRAGMA() iff we're going to use it. + Use "%d" to print some signed ints. + Use the Wayback Machine for a removed document in a comment. + Add some const qualifiers. + RDMA: Use PRIu64 to print a uint64_t. + "Dead" pcap_ts from pcap_open_dead() and ..._with_tstamp_precision(): + Don't crash if pcap_breakloop() is called. + Savefiles: + Fix pcap_dispatch() to return number of packets processed, rather + than 0, even at EOF. + If we get an error writing the packet header, don't write the + packet data. + Put PFLOG UID and PID values in the header into host byte order + when reading a LINKTYPE_PFLOG file. + Put CAN ID field in CAN pseudo-headers for LINUX_SLL2, as we do + for LINUX_SLL. + Fix inorrectly-computed "real" length for isochronous USB + transfers when reading savefiles. + Don't crash if pcap_can_set_rfmon() is called. + Fix pcap_offline_read() loop. + Capture: + Never process more than INT_MAX packets in a pcap_dispatch() call, + to avoid integer overflow (issue #1087). + Improve error messages for "no such device" and "permission + denied" errors. + SITA: Fix a typo in a variable name. + Packet filtering: + Get PFLOG header length from the length value in the header. + Support all the direction, reason, and action types supported by + all systems that support PFLOG. + Don't require PFLOG support on the target machine in order to + support PFLOG filtering (also fixes issue #1076). + Expand abbreviations into "proto X" properly. + gencode.c: Update a comment about the VLAN TPID test. + Add the minimum and maximum matching DLTs to an error message. + Linux: + Fix memory leak in capture device open (pull request #1038). + Fix detection of CAN/CAN FD packets in direction check (issue + #1051). + Fix double-free crashes on errors such as running on a kernel with + CONFIG_PACKET_MMAP not configured (issue #1054). + Use DLT_CAN_SOCKETCAN for CANbus interfaces (issue #1052; includes + changes from pull request #1035). + Make sure the CANFD_FDF can be relied on to indicate whether a + CANbus packet is a CAN frame or a CAN FD frame + Improve error message for "out of memory" errors for kernel + filters (see issue #1089). + Fix pcap_findalldevs() to find usbmon devices. + Fix handling of VLAN tagged packets if the link-layer type is + changed from DLT_LINUX_SLL to DLT_LINUX_SLL2 (see issue #1105). + Always turn on PACKET_AUXDATA (see issue #1105). + We require 2.6.27 or later, so PACKET_RESERVE is available. + Make sure there's reserved space for a DLT_LINUX_SLL2 header + when capturing. + Correctly compute the "real" length for isochronous USB transfers. + Don't have an eventfd descriptor open in non-blocking mode, so as + not to waste descriptors. + netfilter: Squelch a narrowing warning (To be look at before 2038). + BPF capture (*BSD, macOS, AIX, Solaris 11): + Fix case where a device open might fail, rather than falling back + to a smaller buffer size, when the initial buffer size is too + big. + Use an unsigned device number to iterate over BPF devices, to + squelch a compiler warning. + NetBSD: + Fix handling of LINKTYPE_HDLC/DLT_HDLC. + rpcap: + Fix unaligned accesses in rpcapd (pull request #1037). + Fix code to process port number. + Clean up findalldevs code in rpcapd. + Clean up bufferizing code. + Fix a file descriptor/handle leak in pcap_findalldevs_ex() + (Coverity CID 1507240). + Improve error messages for host and port resolution errors. + Fix connect code not to fail if both IPv4 and IPv6 addresses are + tried. + Improve connect failure error message. + Provide an error message for a bad authentication reply size. + For link-layer types with host-endian fields in the header, fix + those fields if capturing from a server with a different byte + order. + Suppress temporarily the warnings with "enable remote packet capture". + Windows: + Add support for NdisMediumIP (pull request #1027). + Don't require applications using pcap to be built with VS 2015 or + later. + Use the correct string for the DLL VersionInfo. + Remove unnecessary DllMain() function. + Correctly handle ERROR_INVALID_FUNCTION from + PacketGetTimestampModes() (indicate that WinPcap or an older + version of Npcap is probably installed). + Fix use-after-free in some cases when a pcap_t is closed. + Make sure an error is returned by pcap_create_interface() if + PacketOpenAdapter() fails. + Return an error if the driver reports 0 timestamp modes supported. + Close the ADAPTER handle for some errors in + pcap_create_interface(). + Get rid of old umaintained VS project files. + Fix deprecation warning for pcap_handle(). + Npcap is now at npcap.com, not npcap.org. + Make sure "no such device" and "no permission to open device" + errors show up in pcap_activate(), not pcap_create() (fixes, + among other things, tcpdump -i <interface-number>). + npcap: squelch deprecation warnings for kernel dump mode. + Haiku: + Implement pcap_lib_version(), as now required. + Handle negative or too-large snaplen values. + Fix various build issues and warnings. + Building and testing: + Update configure-time universal build checks for macOS. + Update config.guess and config.sub. + If we look for an SSL library with pkg-config in configure script, + try pkg-config first. + If we have pkg-config and Homebrew, try to set pkg-config up to + find Homebrew packages. + Handle some Autoconf/make errors better. + Use "git archive" for the "make releasetar" process. + Remove the release candidate rcX targets. + Fix compiling on Solaris 9/SPARC and 11/AMD64. + Address assorted compiler warnings. + Fix cross-building on Linux for Windows with mingw32 for Win64 + (pull request #1031). + Properly set installation directory on Windows when not compiling + with MSVC. + Fix configure script checks for compiler flags. + Give more details if check for usable (F)Lex fails. + Fix compiling with GCC 4.6.4. + Don't use add_compile_options() with CMake, as we currently don't + require 2.8.12, where it first appeared. + Don't provide -L/usr/lib for pkg-config --libs in pkg-config. + Fix error message for inadequate Bison/Berkeley YACC. + configure: correctly do some DPDK checks. + Only use pkg-config when checking for DPDK. + Allow the path in which DPDK is installed to be specified. + Use pkg-config first when checking for libibverbs. + CMake: fix check for libibverbs with Sun's C compiler. + Have CMake warn if no capture mechanism can be found. + Don't do stuff requiring 3.19 or later on earlier CMakes. + Squelch some CMake warnings. + Fix diag-control.h to handle compiling with clang-cl (issues + #1101 and #1115). + Cleanup various leftover cruft in the configure script. + Fix building without protochain support. (GH #852) + Check for a usable YACC (or Bison) and {F}lex in CMake, as we do + in autotools. + Only check for a C++ compiler on Haiku, as that's the only + platform with C++ code, and make sure they generate code for + the same instruction set bit-width (both 32-bit or both 64-bit) + (issue #1112). + On Solaris, check the target bit-width and set PKG_CONFIG_PATH + appropriately, to handle the mess that is the D-Bus library + package (issue #1112). + Fix generation of pcap-config and libpcap.pc files (issue #1062). + pcap-config: don't assume the system library directory is /usr/lib. + pcap-config: add a --static-pcap-only flag. + Cirrus CI: Use the same configuration as for the main branch. + Add four libpcap test files. + Update Npcap SDK to 1.13. + Makefile.in: Use TEST_DIST, like for tcpdump. + Remove awk code from mkdep. + Cirrus CI: Add the libssl-dev package in the Linux task. + Cirrus CI: Add the openssl@3 brew package in the macOS task. + Get "make shellcheck" to pass again. + CMake: Build valgrindtest only if Autoconf would. + CMake: use ${CMAKE_INSTALL_SBINDIR} rather than just sbin. + CMake: use NUL: as the null device on Windows. + autoconf: fix typo in test of macOS version. + Makefile.in: Add two missing files in EXTRA_DIST. + autotools, cmake: provide an rpath option if necessary. + configure: get rid of the attempt to auto-run PKG_PROG_PKG_CONFIG. + configure: use PKG_CHECK_MODULES to run pkg-config. + Documentation: + Add README.solaris.md. + Add SCTP to pcap-filter(7). + Note that = and == are the same operator in filters (issue #1044). + Update INSTALL.md, README.md, and README.solaris.md. + Update and clean up CONTRIBUTING.md. + Trim documentation of support for now-dead UN*Xe and older + versions of other UN*Xes. + Move the "how to allocate a LINKTYPE_/DLT_ value" documentation to + the web site. + Clean up man pages. + Move README.capture-module to the web site. + Improve some protocol details in pcap-filter(7). + Refine "relop" notes in pcap-filter(7). + In pcap-filter(7) "domain" is an id. + Discuss backward compatibility in pcap-filter(7). + Other improvements to pcap-filter(7). + Document pcap_breakloop(3PCAP) interaction with threads better. + Document PCAP_ERROR_NOT_ACTIVATED for more routines. + +Wednesday, June 9, 2021: + Summary for 1.10.1 libpcap release: + Packet filtering: + Fix "type XXX subtype YYY" giving a parse error + Source code: + Add PCAP_AVAILABLE_1_11. + Building and testing: + Rename struct bpf_aux_data to avoid NetBSD compile errors + Squelch some compiler warnings + Squelch some Bison warnings + Fix cross-builds with older kernels lacking BPF_MOD and BPF_XOR + Fix Bison detection for minor version 0. + Fix parallel build with FreeBSD make. + Get DLT_MATCHING_MAX right in gencode.c on NetBSD. + Define timeradd() and timersub() if necessary. + Fix Cygwin/MSYS target directories. + Fix symlinking with DESTDIR. + Fix generation of libpcap.pc with CMake when not building a shared + library. + Check for Arm64 as well as x86-64 when looking for packet.lib on + Windows. + Documentation: + Refine Markdown in README.md. + Improve the description of portrange in filters. + README.linux.md isn't Markdown, rename it just README.linux. + pcapng: + Support reading version 1.2, which some writers produce, and which + is the same as 1.0 (some new block types were added, but + that's not sufficient reason to bump the minor version number, + as code that understands those new block types can handle them + in a 1.0 file) + Linux: + Drop support for text-mode USB captures, as we require a 2.6.27 + or later kernel (credit to Chaoyuan Peng for noting the + sscanf vulnerabilities in the text-mode code that got me to + realize that we didn't need this code any more) + Bluetooth: fix non-blocking mode. + Don't assume that all compilers used to build for Linux support + the __atomic builtins + Windows: + Add more information in "interface disappeared" error messages, in + the hopes of trying to figure out the cause. + Treat ERROR_DEVICE_REMOVED as "device was removed". + Indicate in the error message which "device was removed" error + occurred. + Report the Windows error status if PacketSendPacket() fails. + Use %lu for ULONGs in error message formats. + Don't treat the inability to find airpcap.dll as an error. + Ignore spurious error reports by Microsoft Surface mobile + telephony modem driver + rpcap: + Clean up error checking and error messages for server address + lookup. + +Tuesday, December 29, 2020 + Summary for 1.10.0 libpcap release + Add support for capturing on DPDK devices + Label most APIs by the first release in which they're available + Fix some memory leaks, including in pcap_compile() + Add pcap_datalink_val_to_description_or_dlt() + Handle the pcap private data in a fashion that makes fewer + assumptions about memory layouts (might fix GitHub issue #940 + on ARM) + Fix some thread safety issues + pcap_findalldevs(): don't sort interfaces by unit number + Always return a list of supported time-stamp types, even if only + host time stamps are supported + Increase the maximum snaplen for LINKTYPE_USBPCAP/DLT_USBPCAP + Report the DLT description in error messages + Add pcap_init() for first-time initialization and global option + setting; it's not required, but may be used + Remove (unused) SITA support + Capture file reading: + Correctly handle pcapng captures with more than one IDB with a + snspshot length greater than the supported maximum + Capture file writing: + Create the file in pcap_dump_open_append() if it doesn't exist + Packet filtering: + Fix "unknown ether proto 'aarp'" + Add a new filter "ifindex" for DLT_LINUX_SLL2 files on all + platforms and live Linux captures + Add a hack to the optimizer to try to catch certain optimizer + loops (should prevent GitHub issue #112) + Show special Linux BPF offsets symbolically in bpf_image() and + bpf_dump() + Added support for ICMPv6 types 1-4 as tokens with names + Remove undocumented and rather old "ether proto" protocols + Catch invalid IPv4 addresses in filters + Don't assume ARM supports unaligned accesses + Security and other issues found by analysis: + Fix various security issues reported by Charles Smith at Tangible + Security + Fix various security issues reported by Include Security + Fix some issues found by cppcheck. + Add some overflow checks in the optimizer + rpcap: + Support rpcap-over-TLS + Redo protocol version negotiation to avoid problems with old + servers (it still works with servers using the old negotiation, + as well as servers not supporting negotiation) + Error handling cleanups + Add some new authentication libpcap error codes for specific + errors + Fix some inetd issues in rpcapd + Fix rpcapd core dumps with invalid configuration file + On UN*X, don't have rpcapd tell the client why authentication + failed, so a brute-force attacker can't distinguish between + "unknown user name" and "known user name, wrong password" + Allow rpcapd to rebind more rapidly (GitHub issue #765) + Documentation: + Improve man pages, including adding backward compatibility notes + Building and testing: + Require, and assume, some level of C99 support in the C compiler + Require Visual Studio 2015 or later if using Visual Studio + Fix configure script issues, including with libnl on Linux + Fix CMake issues + Squelch complaints from Bison about "%define api.pure" being + deprecated + Fix compilation of pcap-tc.c + Linux: + Require PF_PACKET support, and kernel 2.6.27 or later + Handle systems without AF_INET or AF_UNIX socket support + Get rid of Wireless Extensions for turning monitor mode on + Proper memory sync for PACKET_MMAP (may prevent GitHub issue + #898) + Drop support for libnl 1 and 2. + Return error on interface going away, but not if it just went + down but is still present + Set socket protocol only after packet ring configured, + reducing bogus packet drop reports + Get ifdrop stats from sysfs. + When adjusting BPF programs, do not subtract the + SLL[2]_HDR_LEN if the location is negative (special metadata + offset), to preserve references to metadata; see + https://github.com/the-tcpdump-group/tcpdump/issues/480#issuecomment-486827278 + Report a warning for unknown ARPHRD types + Have pcap_breakloop() forcibly break out of a sleeping + capture loop + Add support for DSA data link types + For raw USB bus capture, use the snapshot length to set the + buffer size, and set the len field to reflect the length + in the URB (GitHub issue #808) + With a timeout of zero, wait indefinitely + Clean up support for some non-GNU libc C libraries + Add DLT_LINUX_SLL2 for cooked-mode captures + Probe CONFIGURATION descriptor of connected USB devices + Treat EPERM on ethtool ioctls as meaning "not supported", as + permissions checks are done before checking whether the + ioctl is supported at all + macOS: + Cope with getting EPWROFF from SIOCGIFMEDIA + Treat EPERM on SIOCGIFMEDIA as meaning "not supported", as + permissions checks are done before checking whether the + ioctl is supported at all + Treat ENXIO when reading packets as meaning "the interface + was removed" + Report "the interface disappeared", not "the interface went + down", if the interface was removed during a capture + FreeBSD: + Treat ENXIO as meaning "the interface was removed" + Report "the interface disappeared", not "the interface went + down", if the interface was removed during a capture + NetBSD: + Treat ENXIO as meaning "the interface was removed" + Report "the interface disappeared", not "the interface went + down", if the interface was removed during a capture + OpenBSD: + Treat EIO as meaning "the interface was removed" + Report "the interface disappeared", not "the interface went + down", if the interface was removed during a capture + DragonFly BSD: + Treat ENXIO as meaning "the interface was removed" + Report "the interface disappeared", not "the interface went + down", if the interface was removed during a capture + Solaris: + Treat ENXIO as meaning "the interface was removed" + Report "the interface disappeared", not "the interface went + down", if the interface was removed during a capture + AIX: + Fix loading of BPF kernel extension + Treat ENXIO as meaning "the interface was removed" + Report "the interface disappeared", not "the interface went + down", if the interface was removed during a capture + Windows: + Make the snapshot length work even if pcap_setfilter() + isn't called + Fix compilation on Cygwin/MSYS + Add pcap_handle(), and deprecate pcap_fileno() + Report PCAP_ERROR_NO_SUCH_DEVICE for a non-existent device + Return an appropriate error message for device removed or + device unusable due to a suspend/resume + Report a warning for unknown NdisMedium types + Have pcap_breakloop() forcibly break out of a sleeping + capture loop + Clean up building DLL + Handle CRT mismatch for pcap_dump_fopen() + Map NdisMediumWirelessWan to DLT_RAW + Add AirPcap support in a module, rather than using + WinPcap/Npcap's support for it + Report the system error for PacketSetHwFilter() failures + Add support for getting and setting packet time stamp types + with Npcap + Have pcap_init() allow selecting whether the API should use + local code page strings or UTF-8 strings (including error + messages) + Haiku: + Add capture support + Sunday, July 22, 2018 Summary for 1.9.1 libpcap release Mention pcap_get_required_select_timeout() in the main pcap man page @@ -26,7 +455,7 @@ Sunday, July 22, 2018 need to be Fix reading of capture statistics for Linux USB Fix packet size values for Linux USB packets (GitHub issue #808) - Check only VID in VLAN test in filterss (GitHub issue #461) + Check only VID in VLAN test in filters (GitHub issue #461) Fix pcap_list_datalinks on 802.11 devices on macOS Fix overflows with very large snapshot length in pcap file Improve parsing of rpcapd configuration file (GitHub issue #767) @@ -67,7 +496,6 @@ Sunday, July 22, 2018 Boost the TPACKET_V3 timeout to the maximum if a timeout of 0 was specified Five CVE-2019-15161, CVE-2019-15162, CVE-2019-15163, CVE-2019-15164, CVE-2019-15165 - Fixes for CVE-2018-16301, errors in pcapng reading. PCAPNG reader applies some sanity checks before doing malloc(). Sunday, June 24, 2018, by mcr@sandelman.ca @@ -75,7 +503,7 @@ Sunday, June 24, 2018, by mcr@sandelman.ca Added testing system to libpcap, independent of tcpdump Changes to how pcap_t is activated Adding support for Large stream buffers on Endace DAG cards - Changes to BSD 3-clause license to 2-clause licence + Changes to BSD 3-clause license to 2-clause license Additions to TCP header parsing, per RFC3168 Add CMake build process (extensive number of changes) Assign a value for OpenBSD DLT_OPENFLOW. @@ -93,7 +521,7 @@ Sunday, June 24, 2018, by mcr@sandelman.ca Make VLAN filter handle both metadata and inline tags D-Bus captures can now be up to 128MB in size Added LORATAP DLT value - Added DLT_VSOCK for http://qemu-project.org/Features/VirtioVsock + Added DLT_VSOCK for https://qemu-project.org/Features/VirtioVsock probe_devices() fixes not to overrun buffer for name of device Add linux-specific pcap_set_protocol_linux() to allow specifying a specific capture protocol. RDMA sniffing support for pcap @@ -275,7 +703,7 @@ Summary for 1.5.0 libpcap release than the mcr repository Checks added for malloc()/realloc()/etc. failures Fixed build on Solaris 11 - Support filtering filtering E1 SS7 traffic on MTP2 layer Annex A + Support filtering E1 SS7 traffic on MTP2 layer Annex A Use "ln -s" to link man pages by default Add support for getting nanosecond-resolution time stamps when capturing and reading capture files @@ -336,7 +764,7 @@ Summary for 1.3.0 libpcap release Friday December 9, 2011. guy@alum.mit.edu. Summary for 1.2.1 libpcap release Update README file. - Fix typoes in README.linux file. + Fix typos in README.linux file. Clean up some compiler warnings. Fix Linux compile problems and tests for ethtool.h. Treat Debian/kFreeBSD and GNU/Hurd as systems with GNU @@ -369,7 +797,7 @@ Summary for 1.2 libpcap release Noted real nature of LINKTYPE_ARCNET. Add a link-layer type for DVB-CI. Fix configure-script discovery of VLAN acceleration support. - see http://netoptimizer.blogspot.com/2010/09/tcpdump-vs-vlan-tags.html + see https://netoptimizer.blogspot.com/2010/09/tcpdump-vs-vlan-tags.html Linux, HP-UX, AIX, NetBSD and OpenBSD compilation/conflict fixes. Protect against including AIX 5.x's <net/bpf.h> having been included. Add DLT_DBUS, for raw D-Bus messages. @@ -568,7 +996,7 @@ Tue. September 19, 2006. ken@xelerance.com. Summary for 0.9.5 libpcap release beginning+link-layer Add DLT/LINKTYPE for carrying FRF.16 Multi-link Frame Relay Fix allocation of buffer for list of link-layer types - Added a new DLT and LINKTYPE value for ARINC 653 Interpartition Communcation Messages + Added a new DLT and LINKTYPE value for ARINC 653 Interpartition Communication Messages Fixed a typo in a DLT value: it should start with DLT_ and not LINKTYPE_ Redefined DLT_CAN20B and LINKTYPE_CAN20B as #190 (as this is the right value for CAN). Added definition for DLT_A429 and LINKTYPE_A429 as #184. @@ -682,7 +1110,7 @@ Tuesday January 9, 2001. guy@alum.mit.edu. Summary for 0.6 release Header files fixed to allow use in C++ programs. - Removed dependancy on native headers for packet layout. + Removed dependency on native headers for packet layout. Removed Linux specific headers that were shipped. Security fixes: Strcpy replaced with strlcpy, sprintf replaced @@ -820,7 +1248,7 @@ v0.3 Sat Nov 30 20:56:27 PST 1996 v0.2.1 Sun Jul 14 03:02:26 PDT 1996 -- Fixes for HP-UX 10. Thanks in part to to Thomas Wolfram +- Fixes for HP-UX 10. Thanks in part to Thomas Wolfram (wolf@prz.tu-berlin.de) and Rick Jones (raj@hpisrdq.cup.hp.com) - Added support for SINIX. Thanks to Andrej Borsenkow diff --git a/contrib/libpcap/CMakeLists.txt b/contrib/libpcap/CMakeLists.txt index 55b93f14d74c..58c5159905d0 100644 --- a/contrib/libpcap/CMakeLists.txt +++ b/contrib/libpcap/CMakeLists.txt @@ -1,4 +1,11 @@ -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) + cmake_minimum_required(VERSION 2.8.6) +endif(WIN32) # # Apple doesn't build with an install_name starting with @rpath, and @@ -9,44 +16,308 @@ if(POLICY CMP0042) cmake_policy(SET CMP0042 OLD) endif() +# +# Squelch noise about quoted strings in if() statements. +# WE KNOW WHAT WE'RE DOING, WE'RE DOING EVERYTHING THE WAY THAT NEWER +# VERSIONS OF CMAKE EXPECT BY DEFAULT, DON'T WASTE OUR TIME WITH NOISE. +# +if(POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) +endif() + +# +# We want find_file() and find_library() to honor {packagename}_ROOT, +# as that appears to be the only way, with the Visual Studio 2019 IDE +# and its CMake support, to tell CMake where to look for the Npcap +# or WinPcap SDK. +# +if(POLICY CMP0074) + cmake_policy(SET CMP0074 NEW) +endif() + +# +# We want check_include_file() to honor CMAKE_REQUIRED_LIBRARIES; see +# the big comment before the check_include_file() test for +# infiniband/verbs.h for the reason. +# +if(POLICY CMP0075) + cmake_policy(SET CMP0075 NEW) +endif() + set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules) -project(pcap) +# +# We only need a C++ compiler for Haiku; all code except for its +# pcap module is in C. +# +# We do that by specifying just C in the project() call and, after +# that finishes, checking for Haiku and, if we're building for +# Haiku, use enable_language() to check for C++. This means that +# we don't require a C++ compiler on platforms other than Haiku. +# +# CMAKE_SYSTEM_NAME is set by project(), so we can't do this by +# testing CMAKE_SYSTEM_NAME and then passing different language +# lists to project() based on the system. +# +project(pcap C) # -# Try to enable as many C99 features as we can. -# At minimum, we want C++/C99-style // comments. +# For getting raw lists of --libs and --libs --static information from a +# pkg-config module. # -# Newer versions of compilers might default to supporting C99, but older -# versions may require a special flag. +# In CMake up to 2.8.12, pkg_check_modules() sets: # -# 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. +# <XPREFIX>_LIBRARIES, which is a list of library names to which, on +# a UN*X, -l can be prefixed - i.e., names, without extensions, +# rather than full paths to the file. +# <XPREFIX>_LIBRARY_DIRS, which is a list of paths to directories +# containing the libraries, to which, on a UN*X, -L can be +# prefixed. +# <XPREFIX>_LDFLAGS, which is a list of *all* required linker flags +# <XPREFIX>_LDFLAGS_OTHER, which is a list of all linker flags other +# than -l and -L flags # -# 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. +# In 3.0 (at least as of 3.0.2), it also sets: # -# See the CMake documentation for the CMAKE_<LANG>_COMPILER_ID variables -# for a list of compiler IDs. +# <XPREFIX>_LINK_LIBRARIES, which is a list of full paths to the +# library files. # -# 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. +# but if <XPREFIX> is <PREFIX>_STATIC, <XPREFIX>_LINK_LIBRARIES is +# currently not set by CMake. # -# 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. +# Unfortunately, pkg_check_modules() sets the +# PKG_CONFIG_ALLOW_SYSTEM_LIBS environment variable when running +# pkg-config, so the output of --libs, etc. may include a -L for the +# system library, which we do *NOT* want to put in our libpcap.pc and +# pcap-config files. # +# So we just run pkg-config ourselves, so that we get its output +# directly without any processing by CMake. +# +macro(pkg_get_link_info _prefix _package) + if (PKG_CONFIG_EXECUTABLE) + # + # Get the --libs information. + # + # We force PKG_CONFIG_ALLOW_SYSTEM_LIBS to be undefined, as + # at least some versions of CMake appear to define it in + # pkg_check_modules() before running pkg-config and *not* undefine + # it after running it. + # + unset(ENV{PKG_CONFIG_ALLOW_SYSTEM_LIBS}) + set(_pkg_config_result "") + execute_process( + COMMAND ${PKG_CONFIG_EXECUTABLE} "--libs" ${_package} + OUTPUT_VARIABLE _pkg_config_result + RESULT_VARIABLE _pkg_config_failed + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if (_pkg_config_failed) + # + # pkg-config failed; assume that means that there is no such + # package for it to find. XXX - what do we do here? + # + set(${_prefix}_FOUND_WITH_PKG_CONFIG FALSE) + else() + # + # pkg-config succeeded; replace CR and LF with spaces. + # + string(REGEX REPLACE "[\r\n]" " " ${_prefix}_LIBS "${_pkg_config_result}") + + # + # Now get the --libs --static information. + # + set(_pkg_config_result "") + execute_process( + COMMAND ${PKG_CONFIG_EXECUTABLE} "--libs" "--static" ${_package} + OUTPUT_VARIABLE _pkg_config_result + RESULT_VARIABLE _pkg_config_failed + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if (_pkg_config_failed) + # + # pkg-config failed; assume that means that there is no such + # package for it to find. XXX - what do we do here? + # + set(${_prefix}_FOUND_WITH_PKG_CONFIG FALSE) + else() + # + # pkg-config succeeded; replace CR and LF with spaces. + # + string(REGEX REPLACE "[\r\n]" " " ${_prefix}_LIBS_STATIC "${_pkg_config_result}") + + # + # List this package in its PACKAGE_NAME variable. + # + set(${_prefix}_PACKAGE_NAME "${_package}") + + # + # It worked. + # + set(${_prefix}_FOUND_WITH_PKG_CONFIG TRUE) + endif() + endif() + endif() +endmacro() + +macro(get_link_info_from_library_path _library_prefix _library_name) + if(NOT ${_library_prefix}_LIBRARY STREQUAL "${_library_prefix}_LIBRARY-NOTFOUND") + get_filename_component(_lib_directory "${${_library_prefix}_LIBRARY}}" DIRECTORY) + + # + # The closest thing to a list of "system library directories" in + # which the linker will, by default, search for libraries appears to + # be CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES, so that's what we use + # when we're trying to construct a -L argument, for insertion into + # pcap-config and libpcap.pc, for a library upon which we depend. + # + # In some versions of CMake it appears to have duplicate entries, + # but that shouldn't affect a search for a directory in that list. + # + list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${_lib_directory}" _lib_index) + if(_lib_index EQUAL -1) + # + # No, so add a -L flag to get the linker to search in that + # directory. + # + set(${_library_prefix}_LIBS "-L${_lib_directory}") + set(${_library_prefix}_LIBS_STATIC "-L${_lib_directory}") + set(${_libraryprefix}_LIBS_PRIVATE "-L${_lib_directory}") + endif() + set(${_library_prefix}_LIBS "${${_library_prefix}_LIBS} -l${_library_name}") + set(${_library_prefix}_LIBS_STATIC "${${_library_prefix}_LIBS} -l${_library_name}") + set(${_library_prefix}_LIBS_PRIVATE "${${_library_prefix}_LIBS} -l${_library_name}") + endif() +endmacro() + +if(CMAKE_SYSTEM_NAME STREQUAL "Haiku") + enable_language(CXX) + + # + # OK, this is a royal pain. + # + # 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. + # + # 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*. + # + # The compile tests include whatever C flags may have been provided + # to CMake in the CFLAGS and CXXFLAGS environment variables. + # + # 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. + # + # So we make sure both languages have the same pointer sizes with + # the flags they're given; if they don't, it means that the + # compilers for the languages will, with those flags, not produce + # code that can be linked together. + # + # This is unlikely to happen on Haiku, but it *has* happened on + # Solaris; we do this for future-proofing, in case we ever need + # C++ on a platform where that can happen. + # + if(NOT ${CMAKE_C_SIZEOF_DATA_PTR} EQUAL ${CMAKE_CXX_SIZEOF_DATA_PTR}) + message(FATAL_ERROR +"C compiler ${CMAKE_C_COMPILER} produces code with \ +${CMAKE_C_SIZEOF_DATA_PTR}-byte pointers while C++ compiler \ +${CMAKE_CXX_COMPILER} produces code with \ +${CMAKE_CXX_SIZEOF_DATA_PTR}-byte pointers. \ +This prevents code in these languages from being combined.") + endif() +endif() + +# +# Show the bit width for which we're compiling. +# This can help debug problems if you're dealing with a compiler that +# defaults to generating 32-bit code even when running on a 64-bit +# platform, and where that platform may provide only 64-bit versions of +# libraries that we might use (looking at *you*, Oracle Studio!). +# +if(CMAKE_SIZEOF_VOID_P EQUAL 4) + message(STATUS "Building 32-bit") +elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) + message(STATUS "Building 64-bit") +endif() + +# +# Solaris pkg-config is annoying. For at least one package (D-Bus, I'm +# looking at *you*!), there are separate include files for 32-bit and +# 64-bit builds (I guess using "unsigned long long" as a 64-bit integer +# type on a 64-bit build is like crossing the beams or soething), and +# there are two separate .pc files, so if we're doing a 32-bit build we +# should make sure we look in /usr/lib/pkgconfig for .pc files and if +# we're doing a 64-bit build we should make sure we look in +# /usr/lib/amd64/pkgconfig for .pc files. +# +if(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.][0-9.]*") + # + # Note: string(REPLACE) does not appear to support using ENV{...} + # as an argument, so we set a variable and then use set() to set + # the environment variable. + # + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + # + # 64-bit build. If /usr/lib/pkgconfig appears in the path, + # prepend /usr/lib/amd64/pkgconfig to it; otherwise, + # put /usr/lib/amd64 at the end. + # + if((NOT DEFINED ENV{PKG_CONFIG_PATH}) OR "$ENV{PKG_CONFIG_PATH}" EQUAL "") + # + # Not set, or empty. Set it to /usr/lib/amd64/pkgconfig. + # + set(fixed_path "/usr/lib/amd64/pkgconfig") + elseif("$ENV{PKG_CONFIG_PATH}" MATCHES "/usr/lib/pkgconfig") + # + # It contains /usr/lib/pkgconfig. Prepend + # /usr/lib/amd64/pkgconfig to /usr/lib/pkgconfig. + # + string(REPLACE "/usr/lib/pkgconfig" + "/usr/lib/amd64/pkgconfig:/usr/lib/pkgconfig" + fixed_path "$ENV{PKG_CONFIG_PATH}") + else() + # + # Not empty, but doesn't contain /usr/lib/pkgconfig. + # Append /usr/lib/amd64/pkgconfig to it. + # + set(fixed_path "$ENV{PKG_CONFIG_PATH}:/usr/lib/amd64/pkgconfig") + endif() + set(ENV{PKG_CONFIG_PATH} "${fixed_path}") + elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) + # + # 32-bit build. If /usr/amd64/lib/pkgconfig appears in the path, + # prepend /usr/lib/pkgconfig to it. + # + if("$ENV{PKG_CONFIG_PATH}" MATCHES "/usr/lib/amd64/pkgconfig") + # + # It contains /usr/lib/amd64/pkgconfig. Prepend + # /usr/lib/pkgconfig to /usr/lib/amd64/pkgconfig. + # + string(REPLACE "/usr/lib/amd64/pkgconfig" + "/usr/lib/pkgconfig:/usr/lib/amd64/pkgconfig" + fixed_path "$ENV{PKG_CONFIG_PATH}") + set(ENV{PKG_CONFIG_PATH} "${fixed_path}") + endif() + endif() +endif() + include(CheckCCompilerFlag) + +# +# For checking if a compiler flag works and adding it if it does. +# macro(check_and_add_compiler_option _option) message(STATUS "Checking C compiler flag ${_option}") string(REPLACE "=" "-" _temp_option_variable ${_option}) @@ -57,23 +328,105 @@ 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") - # - # 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() +if(MSVC) + if(MSVC_VERSION LESS 1900) + message(FATAL_ERROR "Visual Studio 2015 or later is required") + endif() + + # + # 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. + # + 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) + # + # For checking if a compiler flag works, failing if it doesn't, + # and adding it otherwise. + # + macro(require_and_add_compiler_option _option) + message(STATUS "Checking C compiler flag ${_option}") + string(REPLACE "=" "-" _temp_option_variable ${_option}) + string(REGEX REPLACE "^-" "" _option_variable ${_temp_option_variable}) + check_c_compiler_flag("${_option}" ${_option_variable}) + if(${${_option_variable}}) + set(C_ADDITIONAL_FLAGS "${C_ADDITIONAL_FLAGS} ${_option}") + else() + message(FATAL_ERROR "C99 support is required, but the compiler doesn't support a compiler flag to enable it") + endif() + endmacro() + + # + # 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_<LANG>_COMPILER_ID variables + # for a list of compiler IDs. + # + # XXX - this just tests whether the option works, fails if it doesn't, + # and adds it if it does. We don't test whether it's necessary in order + # to get the C99 features that we use, or whether, if it's used, it + # enables all the features that we require. + # + if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR + CMAKE_C_COMPILER_ID MATCHES "Clang") + require_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. + # + require_and_add_compiler_option("-qlanglvl=extc99") + elseif(CMAKE_C_COMPILER_ID MATCHES "HP") + require_and_add_compiler_option("-AC99") + elseif(CMAKE_C_COMPILER_ID MATCHES "Sun") + require_and_add_compiler_option("-xc99") + elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") + require_and_add_compiler_option("-c99") + endif() +endif(MSVC) + +# +# If we're building with MinGW, we need to specify _WIN32_WINNT as +# 0x0600 ("NT 6.0", a/k/a Vista/Windows Server 2008) or higher +# in order to get the full IPv6 API, including inet_ntop(), and we +# need to specify it as 0x0601 ("NT 6.1", a/k/a Windows 7) or higher +# in order to get NdisMediumIP. +# +# NOTE: pcap does *NOT* work with msvcrt.dll; it must link with +# a newer version of the C library, i.e. Visual Studio 2015 or +# later, as it depends on C99 features introduced in VS 2015. +# +if(MINGW) + add_definitions(-D_WIN32_WINNT=0x0601) +endif(MINGW) # # Build all runtimes in the top-level binary directory; that way, @@ -106,10 +459,14 @@ if(WIN32) option(USE_STATIC_RT "Use static Runtime" ON) endif(WIN32) option(BUILD_SHARED_LIBS "Build shared libraries" ON) +set(dpdk_ROOT "" CACHE PATH "Path to directory with include and lib subdirectories for DPDK") if(WIN32) - set(PACKET_DLL_DIR "" CACHE PATH "Path to directory with include and lib subdirectories for packet.dll") + set(Packet_ROOT "" CACHE PATH "Path to directory with include and lib subdirectories for packet.dll") + set(AirPcap_ROOT "" CACHE PATH "Path to directory with include and lib subdirectories for airpcap.dll") endif(WIN32) +option(ENABLE_PROFILING "Enable code profiling" OFF) + # To pacify those who hate the protochain instruction option(NO_PROTOCHAIN "Disable protochain instruction" OFF) @@ -131,16 +488,19 @@ else() endif(WIN32) if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - option(PCAP_SUPPORT_PACKET_RING "Enable Linux packet ring support" ON) option(BUILD_WITH_LIBNL "Build with libnl" ON) endif() # # Additional capture modules. # -option(DISABLE_USB "Disable USB sniffing support" OFF) +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + option(DISABLE_LINUX_USBMON "Disable Linux usbmon USB sniffing support" OFF) +endif() option(DISABLE_BLUETOOTH "Disable Bluetooth sniffing support" OFF) option(DISABLE_NETMAP "Disable netmap support" OFF) +option(DISABLE_DPDK "Disable DPDK support" OFF) + # # We don't support D-Bus sniffing on macOS; see # @@ -221,25 +581,26 @@ if(WIN32) endif(IS_DIRECTORY ${CMAKE_HOME_DIRECTORY}/../../Common) find_package(Packet) - if(PACKET_FOUND) + if(Packet_FOUND) set(HAVE_PACKET32 TRUE) - include_directories(${PACKET_INCLUDE_DIRS}) + include_directories(${Packet_INCLUDE_DIRS}) # # Check whether we have the NPcap PacketIsLoopbackAdapter() # function. # cmake_push_check_state() - set(CMAKE_REQUIRED_LIBRARIES ${PACKET_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES ${Packet_LIBRARIES}) check_function_exists(PacketIsLoopbackAdapter HAVE_PACKET_IS_LOOPBACK_ADAPTER) + check_function_exists(PacketGetTimestampModes HAVE_PACKET_GET_TIMESTAMP_MODES) cmake_pop_check_state() - endif(PACKET_FOUND) + endif(Packet_FOUND) message(STATUS "checking for Npcap's version.h") - check_symbol_exists(WINPCAP_PRODUCT_NAME "../../version.h" HAVE_VERSION_H) + check_symbol_exists(WINPCAP_PRODUCT_NAME "${CMAKE_SOURCE_DIR}/../../version.h" HAVE_VERSION_H) if(HAVE_VERSION_H) - message(STATUS "HAVE version.h") + message(STATUS "HAVE version.h") else(HAVE_VERSION_H) - message(STATUS "MISSING version.h") + message(STATUS "MISSING version.h") endif(HAVE_VERSION_H) endif(WIN32) @@ -294,41 +655,49 @@ if(NOT WIN32) check_include_file(sys/ioccom.h HAVE_SYS_IOCCOM_H) check_include_file(sys/sockio.h HAVE_SYS_SOCKIO_H) check_include_file(sys/select.h HAVE_SYS_SELECT_H) -endif(NOT WIN32) -check_include_file(limits.h HAVE_LIMITS_H) -if(NOT WIN32) + check_include_file(netpacket/packet.h HAVE_NETPACKET_PACKET_H) - 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 for various PF actions. - # - check_c_source_compiles( -"#include <sys/types.h> -#include <sys/socket.h> -#include <net/if.h> -#include <net/pfvar.h> + check_include_file(netinet/if_ether.h HAVE_NETINET_IF_ETHER_H) +endif(NOT WIN32) -int +# +# Functions. +# +# First, check for the __atomic_load_n() and __atomic_store_n() +# builtins. +# +# We can't use check_function_exists(), as it tries to declare +# the function, and attempting to declare a compiler builtin +# can produce an error. +# +# We don't use check_symbol_exists(), as it expects a header +# file to be specified to declare the function, but there isn't +# such a header file. +# +# So we use check_c_source_compiles(). +# +check_c_source_compiles( +"int main(void) { - return PF_NAT+PF_NONAT+PF_BINAT+PF_NOBINAT+PF_RDR+PF_NORDR; + int i = 17; + return __atomic_load_n(&i, __ATOMIC_RELAXED); } " - HAVE_PF_NAT_THROUGH_PF_NORDR) - endif(HAVE_NET_PFVAR_H) - check_include_file(netinet/if_ether.h HAVE_NETINET_IF_ETHER_H) - if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - check_include_file(linux/sockios.h HAVE_LINUX_SOCKIOS_H) - # - # linux/if_bonding.h requires sys/socket.h. - # - check_include_files("sys/socket.h;linux/if_bonding.h" HAVE_LINUX_IF_BONDING_H) - endif() -endif(NOT WIN32) + HAVE___ATOMIC_LOAD_N) +check_c_source_compiles( +"int +main(void) +{ + int i; + __atomic_store_n(&i, 17, __ATOMIC_RELAXED); + return 0; +} +" + HAVE___ATOMIC_STORE_N) # -# Functions. +# Now check for various system functions. # check_function_exists(strerror HAVE_STRERROR) check_function_exists(strerror_r HAVE_STRERROR_R) @@ -356,14 +725,28 @@ main(void) endif(NOT HAVE_GNU_STRERROR_R) else(HAVE_STRERROR_R) # - # We don't have strerror_r; do we have strerror_s? + # We don't have strerror_r; do we have _wcserror_s? # - check_function_exists(strerror_s HAVE_STRERROR_S) + check_function_exists(_wcserror_s HAVE__WCSERROR_S) endif(HAVE_STRERROR_R) + +# +# Make sure we have vsnprintf() and snprintf(); we require them. +# We use check_symbol_exists(), as they aren't necessarily external +# functions - in Visual Studio, for example, they're inline functions +# calling a common external function. +# +check_symbol_exists(vsnprintf "stdio.h" HAVE_VSNPRINTF) +if(NOT HAVE_VSNPRINTF) + message(FATAL_ERROR "vsnprintf() is required but wasn't found") +endif(NOT HAVE_VSNPRINTF) +check_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF) +if(NOT HAVE_SNPRINTF) + message(FATAL_ERROR "snprintf() is required but wasn't found") +endif() + check_function_exists(strlcpy HAVE_STRLCPY) check_function_exists(strlcat HAVE_STRLCAT) -check_function_exists(snprintf HAVE_SNPRINTF) -check_function_exists(vsnprintf HAVE_VSNPRINTF) check_function_exists(asprintf HAVE_ASPRINTF) check_function_exists(vasprintf HAVE_VASPRINTF) check_function_exists(strtok_r HAVE_STRTOK_R) @@ -397,6 +780,10 @@ endif() # that's been set, it skips the test, so we need different variables. # set(PCAP_LINK_LIBRARIES "") +set(LIBS "") +set(LIBS_STATIC "") +set(REQUIRES_PRIVATE "") +set(LIBS_PRIVATE "") include(CheckLibraryExists) if(WIN32) # @@ -432,11 +819,25 @@ else(WIN32) # OK, we found it in libsocket. # set(PCAP_LINK_LIBRARIES socket nsl ${PCAP_LINK_LIBRARIES}) + set(LIBS "-lsocket -lnsl ${LIBS}") + set(LIBS_STATIC "-lsocket -lnsl ${LIBS_STATIC}") + set(LIBS_PRIVATE "-lsocket -lnsl ${LIBS_PRIVATE}") else(LIBSOCKET_HAS_GETADDRINFO) - # - # We didn't find it. - # - message(FATAL_ERROR "getaddrinfo is required, but wasn't found") + check_library_exists(network getaddrinfo "" LIBNETWORK_HAS_GETADDRINFO) + if(LIBNETWORK_HAS_GETADDRINFO) + # + # OK, we found it in libnetwork (Haiku). + # + set(PCAP_LINK_LIBRARIES network ${PCAP_LINK_LIBRARIES}) + set(LIBS "-lnetwork ${LIBS}") + set(LIBS_STATIC "-lnetwork ${LIBS_STATIC}") + set(LIBS_PRIVATE "-lnetwork ${LIBS_PRIVATE}") + else(LIBNETWORK_HAS_GETADDRINFO) + # + # We didn't find it. + # + message(FATAL_ERROR "getaddrinfo is required, but wasn't found") + endif(LIBNETWORK_HAS_GETADDRINFO) endif(LIBSOCKET_HAS_GETADDRINFO) # @@ -452,6 +853,9 @@ else(WIN32) # Yes - link with it as well. # set(PCAP_LINK_LIBRARIES xnet ${PCAP_LINK_LIBRARIES}) + set(LIBSC "-lxnet ${LIBS_LIBS}") + set(LIBS_STATIC "-lxnet ${LIBS_STATIC}") + set(LIBS_PRIVATE "-lxnet ${LIBS_PRIVATE}") endif(LIBXNET_HAS_RECVMSG) endif(NOT STDLIBS_HAVE_GETADDRINFO) @@ -461,8 +865,20 @@ else(WIN32) check_library_exists(str putmsg "" LIBSTR_HAS_PUTMSG) if(LIBSTR_HAS_PUTMSG) set(PCAP_LINK_LIBRARIES str ${PCAP_LINK_LIBRARIES}) + set(LIBS "-lstr ${LIBS}") + set(LIBS_STATIC "-lstr ${LIBS_STATIC}") + set(LIBS_PRIVATE "-lstr ${LIBS_PRIVATE}") endif(LIBSTR_HAS_PUTMSG) endif(NOT STDLIBS_HAVE_PUTMSG) + + # Haiku has getpass in libbsd + check_function_exists(getpass STDLIBS_HAVE_GETPASS) + if(NOT STDLIBS_HAVE_GETPASS) + check_library_exists(bsd getpass "" LIBBSD_HAS_GETPASS) + if(LIBBSD_HAS_GETPASS) + set(PCAP_LINK_LIBRARIES bsd ${PCAP_LINK_LIBRARIES}) + endif(LIBBSD_HAS_GETPASS) + endif(NOT STDLIBS_HAVE_GETPASS) endif(WIN32) # @@ -812,6 +1228,195 @@ if(NOT WIN32) endif(NOT CMAKE_USE_PTHREADS_INIT) endif(NOT WIN32) +if(ENABLE_PROFILING) + if(NOT MSVC) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") + endif() +endif() + +# +# Based on +# +# https://github.com/commonmark/cmark/blob/master/FindAsan.cmake +# +# The MIT License (MIT) +# +# Copyright (c) 2013 Matthew Arsenault +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# +# Test if the each of the sanitizers in the ENABLE_SANITIZERS list are +# supported by the compiler, and, if so, adds the appropriate flags to +# CMAKE_C_FLAGS, CMAKE_CXX_FLAGS, and SANITIZER_FLAGS. If not, it fails. +# +# Do this last, in the hope that it will prevent configuration on Linux +# from somehow deciding it doesn't need -lpthread when building rpcapd +# (it does require it, but somehow, in some mysterious fashion that no +# obvious CMake debugging flag reveals, it doesn't realize that if we +# turn sanitizer stuff on). +# +set(SANITIZER_FLAGS "") +foreach(sanitizer IN LISTS ENABLE_SANITIZERS) + # Set -Werror to catch "argument unused during compilation" warnings + + message(STATUS "Checking sanitizer ${sanitizer}") + set(sanitizer_variable "sanitize_${sanitizer}") + set(CMAKE_REQUIRED_FLAGS "-Werror -fsanitize=${sanitizer}") + check_c_compiler_flag("-fsanitize=${sanitizer}" ${sanitizer_variable}) + if(${${sanitizer_variable}}) + set(SANITIZER_FLAGS "${SANITIZER_FLAGS} -fsanitize=${sanitizer}") + message(STATUS "${sanitizer} sanitizer supported using -fsanitizer=${sanitizer}") + else() + # + # Try the versions supported prior to Clang 3.2. + # If the sanitizer is "address", try -fsanitize-address. + # If it's "undefined", try -fcatch-undefined-behavior. + # Otherwise, give up. + # + set(sanitizer_variable "OLD_${sanitizer_variable}") + if ("${sanitizer}" STREQUAL "address") + set(CMAKE_REQUIRED_FLAGS "-Werror -fsanitize-address") + check_c_compiler_flag("-fsanitize-address" ${sanitizer_variable}) + if(${${sanitizer_variable}}) + set(SANITIZER_FLAGS "${SANITIZER_FLAGS} -fsanitize-address") + message(STATUS "${sanitizer} sanitizer supported using -fsanitize-address") + else() + message(FATAL_ERROR "${sanitizer} isn't a supported sanitizer") + endif() + elseif("${sanitizer}" STREQUAL "undefined") + set(CMAKE_REQUIRED_FLAGS "-Werror -fcatch-undefined-behavior") + check_c_compiler_flag("-fcatch-undefined-behavior" ${sanitizer_variable}) + if(${${sanitizer_variable}}) + set(SANITIZER_FLAGS "${SANITIZER_FLAGS} -fcatch-undefined-behavior") + message(STATUS "${sanitizer} sanitizer supported using catch-undefined-behavior") + else() + message(FATAL_ERROR "${sanitizer} isn't a supported sanitizer") + endif() + else() + message(FATAL_ERROR "${sanitizer} isn't a supported sanitizer") + endif() + endif() + + unset(CMAKE_REQUIRED_FLAGS) +endforeach() + +if(NOT "${SANITIZER_FLAGS}" STREQUAL "") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O1 -g ${SANITIZER_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O1 -g ${SANITIZER_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls") +endif() + +# +# OpenSSL/libressl. +# +find_package(OpenSSL) +if(OPENSSL_FOUND) + # + # We have OpenSSL. + # + include_directories(SYSTEM ${OPENSSL_INCLUDE_DIR}) + set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${OPENSSL_LIBRARIES}) + + # + # The find_package() module CMake provides for OpenSSL uses does not + # give us a defined indication of whether it found OpenSSL with + # pkg-config or not. We need to know that as, if it was found with + # pkg-config, we should set the Requires.private value in libpcap.pc + # to include its package name, openssl, otherwise we should add the + # names for the static libraries to Libs.private. + # + # On UN*X, FindOpenSSL happens to use pkg-config to find OpenSSL, but + # it doesn't appear to be documented as doing so; therefore, we don't + # assume that, if we got here, we have pkg-config. + # + # So we use pkg_get_link_info() to run pkg-config ourselves, both + # because FindOpenSSL doesn't set the OPENSSL_LDFLAGS or + # OPENSSL_STATIC_LDFLAGS variables and because, for reasons explained + # in the comment before the pkg_get_link_info() macro, even if it did, + # it wouldn't be what we want anyway. + # + if (PKG_CONFIG_EXECUTABLE) + pkg_get_link_info(OPENSSL openssl) + if (OPENSSL_FOUND_WITH_PKG_CONFIG) + # + # pkg-config failed; assume that means that there is no openssl + # package for it to find. Just add OPENSSL_LIBRARIES to + # LIBS_PRIVATE AND LIBS_STATIC, as that's the + # best we can do. XXX - need list of -l and -L flags to add.... + # + set(LIBS "${LIBS} ${OPENSSL_LIBS}") + set(LIBS_STATIC "${LIBS_STATIC} ${OPENSSL_LIBS_STATIC}") + set(REQUIRES_PRIVATE "${REQUIRES_PRIVATE} ${OPENSSL_PACKAGE_NAME}") + endif() + else() + # Get it from OPENSSL_LIBRARIES + foreach(_lib IN LISTS OPENSSL_LIBRARIES) + # + # Get the directory in which the library resides. + # + get_filename_component(_lib_directory "${_lib}" DIRECTORY) + + # + # Is the library directory in CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES? + # (See comment above on why we use that.) + # + list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${_lib_directory}" _lib_index) + if(_lib_index EQUAL -1) + # + # No, so add a -L flag to get the linker to search in that + # directory. + # + set(LIBS "${LIBS} -L${_lib_directory}") + set(LIBS_STATIC "${LIBS_STATIC} -L${_lib_directory}") + set(LIBS_PRIVATE "${LIBS_PRIVATE} -L${_lib_directory}") + endif() + + # + # Get the file name of the library, without the extension. + # + get_filename_component(_lib_filename "${_lib}" NAME_WE) + + # + # Strip off the "lib" prefix to get the library name, and + # add a -l flag based on that. + # + string(REGEX REPLACE "^lib" "" _library_name "${_lib_filename}") + set(LIBS "${LIBS} -l${_library_name}") + set(LIBS_STATIC "${LIBS_STATIC} -l${_library_name}") + set(LIBS_PRIVATE "${LIBS_PRIVATE} -l${_library_name}") + endforeach() + endif() + set(HAVE_OPENSSL YES) +endif(OPENSSL_FOUND) + +# +# Additional linker flags. +# +set(LINKER_FLAGS "${SANITIZER_FLAGS}") +if(ENABLE_PROFILING) + if(MSVC) + set(LINKER_FLAGS " /PROFILE") + else() + set(LINKER_FLAGS " -pg") + endif() +endif() + ###################################### # Input files ###################################### @@ -826,6 +1431,8 @@ set(PROJECT_SOURCE_LIST_C nametoaddr.c optimize.c pcap-common.c + pcap-usb-linux-common.c + pcap-util.c pcap.c savefile.c sf-pcapng.c @@ -834,52 +1441,16 @@ set(PROJECT_SOURCE_LIST_C if(WIN32) # - # For now, we assume we don't have snprintf() or that it's not one - # that behaves enough like C99's snprintf() for our purposes (i.e., - # it doesn't null-terminate the string if it truncates it to fit in - # the buffer), so we have to provide our own (a wrapper around - # _snprintf() that null-terminates the buffer). + # We add the character set conversion routines; they're Windows-only + # for now. # - # We also assume we don't have asprintf(), and provide an implementation + # We assume we don't have asprintf(), and provide an implementation # that uses _vscprintf() to determine how big the string needs to be. # set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} - missing/win_snprintf.c missing/win_asprintf.c) + charconv.c missing/win_asprintf.c) else() - # - # Either: - # - # we have snprintf() and vsnprintf(), and have asprintf() and - # vasprintf(); - # - # we have snprintf() and vsnprintf(), but don't have asprintf() - # or vasprintf(); - # - # we have neither snprintf() nor vsnprintf(), and don't have - # asprintf() or vasprintf(), either. - # - # We assume that if we have asprintf() we have vasprintf(), as well - # as snprintf() and vsnprintf(), and that if we have snprintf() we - # have vsnprintf(). - # - # For the first case, we don't need any replacement routines. - # For the second case, we need replacement asprintf()/vasprintf() - # routines. - # For the third case, we need replacement snprintf()/vsnprintf() and - # asprintf()/vasprintf() routines. - # - if(NOT HAVE_SNPRINTF) - # - # We assume we have none of them; missing/snprintf.c supplies - # all of them. - # - set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/snprintf.c) - elif(NOT HAVE_ASPRINTF) - # - # We assume we have snprintf()/vsnprintf() but lack - # asprintf()/vasprintf(); missing/asprintf.c supplies - # the latter (using vsnprintf()). - # + if(NOT HAVE_ASPRINTF) set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} missing/asprintf.c) endif() if(NOT HAVE_STRLCAT) @@ -985,6 +1556,7 @@ else() check_include_file(linux/socket.h HAVE_LINUX_SOCKET_H) check_include_file(net/raw.h HAVE_NET_RAW_H) check_include_file(sys/dlpi.h HAVE_SYS_DLPI_H) + check_include_file(config/HaikuConfig.h HAVE_CONFIG_HAIKUCONFIG_H) if(BPF_H_DEFINES_BIOCSETIF) # @@ -1028,28 +1600,38 @@ else() # DLPI on pre-Solaris 11 SunOS 5, HP-UX, possibly others. # set(PCAP_TYPE dlpi) + elseif(HAVE_CONFIG_HAIKUCONFIG_H) + # + # Haiku. + # + set(PCAP_TYPE haiku) else() # # Nothing we support. # set(PCAP_TYPE null) + message(WARNING +"cannot determine packet capture interface +(see the INSTALL.md file for more info)") endif() endif() endif(WIN32) message(STATUS "Packet capture mechanism type: ${PCAP_TYPE}") +find_package(PkgConfig QUIET) + # # Do capture-mechanism-dependent tests. # if(WIN32) if(PCAP_TYPE STREQUAL "npf") # - # Link with packet.dll before WinSock2. + # Link with packet.dll before Winsock2. # - set(PCAP_LINK_LIBRARIES ${PACKET_LIBRARIES} ${PCAP_LINK_LIBRARIES}) + set(PCAP_LINK_LIBRARIES ${Packet_LIBRARIES} ${PCAP_LINK_LIBRARIES}) elseif(PCAP_TYPE STREQUAL "null") else() - message(ERROR "${PCAP_TYPE} is not a valid pcap type") + message(FATAL_ERROR "${PCAP_TYPE} is not a valid pcap type") endif() else(WIN32) if(PCAP_TYPE STREQUAL "dlpi") @@ -1085,6 +1667,9 @@ else(WIN32) # XXX - add -L/lib # set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} dlpi) + set(LIBS "${LIBS} -ldlpi") + set(LIBS_STATIC "${LIBS_STATIC} -ldlpi") + set(LIBS_PRIVATE "${LIBS_PRIVATE} -ldlpi") set(PCAP_TYPE libdlpi) endif() @@ -1109,70 +1694,45 @@ else(WIN32) # # Do we have libnl? + # We only want version 3. Version 2 was, apparently, + # short-lived, and version 1 is source and binary + # incompatible with version 3, and it appears that, + # these days, everybody's using version 3. We're + # not supporting older versions of the Linux kernel; + # let's drop support for older versions of libnl, too. # if(BUILD_WITH_LIBNL) - # - # Try libnl 3.x first. - # - cmake_push_check_state() - set(CMAKE_REQUIRED_LIBRARIES nl-3) - check_function_exists(nl_socket_alloc HAVE_LIBNL) - cmake_pop_check_state() - if(HAVE_LIBNL) + pkg_check_modules(LIBNL libnl-genl-3.0) + if(LIBNL_FOUND) + set(PCAP_LINK_LIBRARIES ${LIBNL_LIBRARIES} ${PCAP_LINK_LIBRARIES}) + # - # Yes, we have libnl 3.x. + # Get raw link flags from pkg-config. # - set(PCAP_LINK_LIBRARIES nl-genl-3 nl-3 ${PCAP_LINK_LIBRARIES}) - set(HAVE_LIBNL_3_x ON) - set(HAVE_LIBNL_NLE ON) - set(HAVE_LIBNL_SOCKETS ON) - include_directories("/usr/include/libnl3") + pkg_get_link_info(LIBNL libnl-genl-3.0) + set(LIBS "${LIBNL_LIBS} ${LIBS}") + set(LIBS_STATIC "${LIBNL_LIBS_STATIC} ${LIBS_STATIC}") + set(REQUIRES_PRIVATE "${LIBNL_PACKAGE_NAME} ${REQUIRES_PRIVATE}") else() - # - # Try libnl 2.x. - # cmake_push_check_state() - set(CMAKE_REQUIRED_LIBRARIES nl) + set(CMAKE_REQUIRED_LIBRARIES nl-3) check_function_exists(nl_socket_alloc HAVE_LIBNL) cmake_pop_check_state() if(HAVE_LIBNL) # - # Yes, we have libnl 2.x. - # - set(PCAP_LINK_LIBRARIES nl-genl nl ${PCAP_LINK_LIBRARIES}) - set(HAVE_LIBNL_2_x ON) - set(HAVE_LIBNL_NLE ON) - set(HAVE_LIBNL_SOCKETS ON) - else() - # - # No, we don't; do we have libnl 1.x? + # Yes, we have libnl 3.x. # - cmake_push_check_state() - set(CMAKE_REQUIRED_LIBRARIES nl) - check_function_exists(nl_handle_alloc HAVE_LIBNL) - cmake_pop_check_state() - if(HAVE_LIBNL) - set(PCAP_LINK_LIBRARIES nl ${PCAP_LINK_LIBRARIES}) - endif() + set(PCAP_LINK_LIBRARIES nl-genl-3 nl-3 ${PCAP_LINK_LIBRARIES}) + include_directories("/usr/include/libnl3") + set(LIBS "-lnl-genl-3 -lnl-3 ${LIBS}") + set(LIBS_STATIC "-lnl-genl-3 -lnl-3 ${LIBS_STATIC}") + set(LIBS_PRIVATE "-lnl-genl-3 -lnl-3 ${LIBS_PRIVATE}") endif() endif() + else() + unset(HAVE_LIBNL CACHE) # check_function_exists stores results in cache endif() - check_include_file(linux/ethtool.h HAVE_LINUX_ETHTOOL_H) - - # - # Checks to see if tpacket_stats is defined in linux/if_packet.h - # If so then pcap-linux.c can use this to report proper statistics. - # - # XXX - there's no check_type() macro that's like check_type_size() - # except that it only checks for the existence of the structure type, - # so we use check_type_size() and ignore the size. - # - cmake_push_check_state() - set(CMAKE_EXTRA_INCLUDE_FILES linux/if_packet.h) - check_type_size("struct tpacket_stats" STRUCT_TPACKET_STATS) - cmake_pop_check_state() - check_struct_has_member("struct tpacket_auxdata" tp_vlan_tci linux/if_packet.h HAVE_STRUCT_TPACKET_AUXDATA_TP_VLAN_TCI) elseif(PCAP_TYPE STREQUAL "bpf") # @@ -1196,13 +1756,23 @@ else(WIN32) check_type_size("struct BPF_TIMEVAL" STRUCT_BPF_TIMEVAL) endif() cmake_pop_check_state() + elseif(PCAP_TYPE STREQUAL "haiku") + # + # Check for some headers just in case. + # + check_include_files("net/if.h;net/if_dl.h;net/if_types.h" HAVE_NET_IF_TYPES_H) + set(PCAP_SRC pcap-${PCAP_TYPE}.cpp) elseif(PCAP_TYPE STREQUAL "null") else() message(FATAL_ERROR "${PCAP_TYPE} is not a valid pcap type") endif() endif(WIN32) -set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-${PCAP_TYPE}.c) +if(NOT DEFINED PCAP_SRC) +set(PCAP_SRC pcap-${PCAP_TYPE}.c) +endif() + +set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} ${PCAP_SRC}) # # Now figure out how we get a list of interfaces and addresses, @@ -1239,6 +1809,9 @@ if(NOT WIN32) check_library_exists(socket getifaddrs "" SOCKET_HAS_GETIFADDRS) if(SOCKET_HAS_GETIFADDRS) set(PCAP_LINK_LIBRARIES socket ${PCAP_LINK_LIBRARIES}) + set(LIBS "-lsocket ${LIBS}") + set(LIBS_STATIC "-lsocket ${LIBS_STATIC}") + set(LIBS_PRIVATE "-lsocket ${LIBS_PRIVATE}") set(HAVE_GETIFADDRS TRUE) endif() endif() @@ -1308,13 +1881,14 @@ endif() # Check for additional native sniffing capabilities. # -# Check for USB sniffing support on Linux. -# On FreeBSD, it uses BPF, so we don't need to do anything special here. -if(NOT DISABLE_USB) - if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - set(PCAP_SUPPORT_USB TRUE) +# +# Various Linux-specific mechanisms. +# +if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + # Check for usbmon USB sniffing support. + if(NOT DISABLE_LINUX_USBMON) + set(PCAP_SUPPORT_LINUX_USBMON TRUE) set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-usb-linux.c) - set(LINUX_USB_MON_DEV /dev/usbmon) # # Do we have a version of <linux/compiler.h> available? # If so, we might need it for <linux/usbdevice_fs.h>. @@ -1342,10 +1916,9 @@ if(NOT DISABLE_USB) endif(HAVE_LINUX_COMPILER_H) endif() endif() -endif() -# Check for netfilter sniffing support. -if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + # + # Check for netfilter sniffing support. # # Life's too short to deal with trying to get this to compile # if you don't get the right types defined with @@ -1401,6 +1974,51 @@ main(void) endif(PCAP_SUPPORT_NETMAP) endif() +# Check for DPDK sniffing support +if(NOT DISABLE_DPDK) + find_package(dpdk) + if(dpdk_FOUND) + # + # We call rte_eth_dev_count_avail(), and older versions of DPDK + # didn't have it, so check for it. + # + cmake_push_check_state() + set(CMAKE_REQUIRED_INCLUDES ${dpdk_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES ${dpdk_LIBRARIES}) + check_function_exists(rte_eth_dev_count_avail HAVE_RTE_ETH_DEV_COUNT_AVAIL) + cmake_pop_check_state() + if(HAVE_RTE_ETH_DEV_COUNT_AVAIL) + set(DPDK_C_FLAGS "-march=native") + set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} ${DPDK_C_FLAGS}) + include_directories(AFTER ${dpdk_INCLUDE_DIRS}) + link_directories(AFTER ${dpdk_LIBRARIES}) + set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${dpdk_LIBRARIES}) + set(LIBS "${LIBS} ${dpdk_LIBS}") + set(LIBS_STATIC "${LIBS_STATIC} ${dpdk_LIBS_STATIC}") + set(REQUIRES_PRIVATE "${REQUIRES_PRIVATE} ${dpdk_PACKAGE_NAME}") + set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-dpdk.c) + set(PCAP_SUPPORT_DPDK TRUE) + + # + # Check whether the rte_ether.h file defines + # struct ether_addr or struct rte_ether_addr. + # + # ("API compatibility? That's for losers!") + # + cmake_push_check_state() + set(CMAKE_REQUIRED_INCLUDES ${dpdk_INCLUDE_DIRS}) + set(CMAKE_EXTRA_INCLUDE_FILES rte_ether.h) + check_type_size("struct rte_ether_addr" STRUCT_RTE_ETHER_ADDR) + cmake_pop_check_state() + endif() + else() + message(WARNING, +"We couldn't find DPDK with pkg-config. If you want DPDK support, +make sure that pkg-config is installed, that DPDK 18.02.2 or later is +installed, and that DPDK provides a .pc file.") + endif() +endif() + # Check for Bluetooth sniffing support if(NOT DISABLE_BLUETOOTH) if(CMAKE_SYSTEM_NAME STREQUAL "Linux") @@ -1439,9 +2057,11 @@ main(void) endif(HAVE_STRUCT_SOCKADDR_HCI_HCI_CHANNEL) endif(HAVE_BLUETOOTH_BLUETOOTH_H) endif() +else() + unset(PCAP_SUPPORT_BT_MONITOR CACHE) endif() -# Check for Bluetooth sniffing support +# Check for D-Bus sniffing support if(NOT DISABLE_DBUS) # # We don't support D-Bus sniffing on macOS; see @@ -1451,7 +2071,6 @@ if(NOT DISABLE_DBUS) if(APPLE) message(FATAL_ERROR "Due to freedesktop.org bug 74029, D-Bus capture support is not available on macOS") endif(APPLE) - include(FindPkgConfig) pkg_check_modules(DBUS dbus-1) if(DBUS_FOUND) set(PCAP_SUPPORT_DBUS TRUE) @@ -1479,22 +2098,80 @@ if(NOT DISABLE_DBUS) list(APPEND DBUS_LIBRARY_FULLPATHS ${_libfullpath}) endforeach() set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${DBUS_LIBRARY_FULLPATHS}) + + # + # Get library information for DPDK. + # + pkg_get_link_info(DBUS dbus-1) + set(LIBS "${LIBS} ${DBUS_LIBS}") + set(LIBS_STATIC "${LIBS_STATIC} ${DBUS_LIBS_STATIC}") + set(REQUIRES_PRIVATE "${REQUIRES_PRIVATE} ${DBUS_PACKAGE_NAME}") endif(DBUS_FOUND) endif(NOT DISABLE_DBUS) # Check for RDMA sniffing support if(NOT DISABLE_RDMA) - check_library_exists(ibverbs ibv_get_device_list "" LIBIBVERBS_HAS_IBV_GET_DEVICE_LIST) - if(LIBIBVERBS_HAS_IBV_GET_DEVICE_LIST) + pkg_check_modules(LIBIBVERBS libibverbs) + if(LIBIBVERBS_FOUND) + # + # pkg-config found it; remember its pkg-config name. + # + set(LIBIBVERBS_REQUIRES_PRIVATE ${LIBIBVERBS_PACKAGE_NAME}) + + # + # Get static linking information for it. + # + pkg_get_link_info(LIBIBVERBS libibverbs) + else() + # + # pkg-config didn't find it; try to look for it ourselves + # + check_library_exists(ibverbs ibv_get_device_list "" LIBIBVERBS_HAS_IBV_GET_DEVICE_LIST) + if(LIBIBVERBS_HAS_IBV_GET_DEVICE_LIST) + set(LIBIBVERBS_FOUND TRUE) + set(LIBIBVERBS_LIBRARIES ibverbs) + # XXX - at least on Ubuntu 20.04, there are many more + # libraries needed; is there any platform where + # libibverbs is available but where pkg-config + # isn't available or libibverbs doesn't use it? + # If not, we should only use pkg-config for it. + set(LIBIBVERBS_STATIC_LIBRARIES ibverbs) + set(LIBIBVERBS_LIBS -libverbs) + set(LIBIBVERBS_LIBS_STATIC -libverbs) + set(LIBIBVERBS_LIBS_PRIVATE -libverbs) + endif() + endif() + if(LIBIBVERBS_FOUND) + # + # For unknown reasons, check_include_file() doesn't just attempt + # to compile a test program that includes the header in + # question, it also attempts to link it. + # + # For unknown reasons, at least some of the static inline + # functions defined in infiniband/verbs.h are not inlined by the + # Sun^WOracle Studio C compiler, so the compiler generates code + # for them as part of the object code resulting from compiling + # the test program. At lest some of those functions call + # routines in -libverbs, so, in order to keep the compile and + # link from failing, even though the header file exists and is + # usable, we need to link with -libverbs. + # + cmake_push_check_state() + set(CMAKE_REQUIRED_LIBRARIES ${LIBIBVERBS_LIBRARIES}) check_include_file(infiniband/verbs.h HAVE_INFINIBAND_VERBS_H) if(HAVE_INFINIBAND_VERBS_H) check_symbol_exists(ibv_create_flow infiniband/verbs.h PCAP_SUPPORT_RDMASNIFF) if(PCAP_SUPPORT_RDMASNIFF) set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-rdmasniff.c) - set(PCAP_LINK_LIBRARIES ibverbs ${PCAP_LINK_LIBRARIES}) + set(PCAP_LINK_LIBRARIES ${LIBIBVERBS_LIBRARIES} ${PCAP_LINK_LIBRARIES}) + set(LIBS "${LIBIBVERBS_LIBS} ${LIBS}") + set(LIBS_STATIC "${LIBIBVERBS_LIBS_STATIC} ${LIBS_STATIC}") + set(LIBS_PRIVATE "${LIBIBVERBS_LIBS_PRIVATE} ${LIBS_PRIVATE}") + set(REQUIRES_PRIVATE "${REQUIRES_PRIVATE} ${LIBIBVERBS_PACKAGE_NAME}") endif(PCAP_SUPPORT_RDMASNIFF) endif(HAVE_INFINIBAND_VERBS_H) - endif(LIBIBVERBS_HAS_IBV_GET_DEVICE_LIST) + cmake_pop_check_state() + endif(LIBIBVERBS_FOUND) endif(NOT DISABLE_RDMA) # @@ -1532,12 +2209,18 @@ if(NOT DISABLE_DAG) set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-dag.c) set(HAVE_DAG_API TRUE) set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${DAG_LIBRARIES}) + set(LIBS "${LIBS} ${DAG_LIBS}") + set(LIBS_STATIC "${LIBS_STATIC} ${DAG_LIBS_STATIC}") + set(LIBS_PRIVATE "${LIBS_PRIVATE} ${DAG_LIBS_PRIVATE}") if(HAVE_DAG_LARGE_STREAMS_API) get_filename_component(DAG_LIBRARY_DIR ${DAG_LIBRARY} PATH) check_library_exists(vdag vdag_set_device_info ${DAG_LIBRARY_DIR} HAVE_DAG_VDAG) if(HAVE_DAG_VDAG) set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) + set(LIBS "${LIBS} ${CMAKE_THREAD_LIBS_INIT}") + set(LIBS_STATIC "${LIBS_STATIC} ${CMAKE_THREAD_LIBS_INIT}") + set(LIBS_PRIVATE "${LIBS_PRIVATE} ${CMAKE_THREAD_LIBS_INIT}") endif() endif() endif() @@ -1583,6 +2266,30 @@ if(NOT DISABLE_SNF) set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-snf.c) set(HAVE_SNF_API TRUE) set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${SNF_LIBRARIES}) + set(LIBS "${LIBS_STATIC} ${SNF_LIBS}") + set(LIBS_STATIC "${LIBS_STATIC} ${SNF_LIBS_STATIC}") + set(LIBS_PRIVATE "${LIBS_PRIVATE} ${SNF_LIBS_PRIVATE}") + endif() +endif() + +# Check for Riverbed AirPcap support. +if(NOT DISABLE_AIRPCAP) + # + # Try to find the AirPcap header file and library. + # + find_package(AirPcap) + + # + # Did we succeed? + # + if(AirPcap_FOUND) + # + # Yes. + # + include_directories(AFTER ${AirPcap_INCLUDE_DIRS}) + set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-airpcap.c) + set(HAVE_AIRPCAP_API TRUE) + set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${AirPcap_LIBRARIES}) endif() endif() @@ -1603,7 +2310,7 @@ if(NOT DISABLE_TC) include_directories(AFTER ${TC_INCLUDE_DIRS}) set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-tc.c) set(HAVE_TC_API TRUE) - set(PCAP_LINK_LIBRARIES "${PCAP_LINK_LIBRARIES} ${TC_LIBRARIES} ${CMAKE_USE_PTHREADS_INIT} stdc++") + set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${TC_LIBRARIES} ${CMAKE_USE_PTHREADS_INIT} stdc++) endif() endif() @@ -1629,7 +2336,7 @@ if(ENABLE_REMOTE) check_struct_has_member("struct msghdr" msg_flags "ftmacros.h;sys/socket.h" HAVE_STRUCT_MSGHDR_MSG_FLAGS) cmake_pop_check_state() set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} - pcap-new.c pcap-rpcap.c rpcap-protocol.c sockutils.c) + pcap-new.c pcap-rpcap.c rpcap-protocol.c sockutils.c sslutils.c) endif(ENABLE_REMOTE) ################################################################### @@ -1698,6 +2405,20 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.devel OR EXISTS ${CMAKE_BINARY_DIR}/.deve # structure members. # check_and_add_compiler_option(-wd4820) + # + # We do *not* care about every single place the compiler would + # have inserted Spectre mitigation if only we had told it to + # do so with /Qspectre. Maybe it's worth it, as that's in + # Bison-generated code that we don't control. + # + # XXX - add /Qspectre if that is really worth doing. + # + check_and_add_compiler_option(-wd5045) + + # + # Treat all (remaining) warnings as errors. + # + check_and_add_compiler_option(-WX) else() # # Other compilers, including MSVC with a Clang front end and @@ -1705,21 +2426,23 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.devel OR EXISTS ${CMAKE_BINARY_DIR}/.deve # they might support GCC-style -W options. # check_and_add_compiler_option(-Wall) - check_and_add_compiler_option(-Wsign-compare) - check_and_add_compiler_option(-Wmissing-prototypes) - check_and_add_compiler_option(-Wstrict-prototypes) - check_and_add_compiler_option(-Wshadow) - check_and_add_compiler_option(-Wdeclaration-after-statement) - check_and_add_compiler_option(-Wused-but-marked-unused) - check_and_add_compiler_option(-Wdocumentation) check_and_add_compiler_option(-Wcomma) - check_and_add_compiler_option(-Wmissing-noreturn) # Warns about safeguards added in case the enums are extended # check_and_add_compiler_option(-Wcovered-switch-default) - check_and_add_compiler_option(-Wmissing-variable-declarations) - check_and_add_compiler_option(-Wunused-parameter) + check_and_add_compiler_option(-Wdocumentation) check_and_add_compiler_option(-Wformat-nonliteral) + check_and_add_compiler_option(-Wmissing-noreturn) + check_and_add_compiler_option(-Wmissing-prototypes) + check_and_add_compiler_option(-Wmissing-variable-declarations) + 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(-Wshorten-64-to-32) + check_and_add_compiler_option(-Wstrict-prototypes) check_and_add_compiler_option(-Wunreachable-code) + check_and_add_compiler_option(-Wunused-parameter) + check_and_add_compiler_option(-Wused-but-marked-unused) endif() endif() @@ -1772,6 +2495,19 @@ if(NOT MSVC) endif(NOT MSVC) # +# 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() + +# # Flex/Lex and YACC/Berkeley YACC/Bison. # From a mail message to the CMake mailing list by Andy Cedilnik of # Kitware. @@ -1786,6 +2522,28 @@ if(LEX_EXECUTABLE STREQUAL "LEX_EXECUTABLE-NOTFOUND") endif() message(STATUS "Lexical analyzer generator: ${LEX_EXECUTABLE}") +# +# Make sure {f}lex supports the -P, --header-file, and --nounput flags +# and supports processing our scanner.l. +# +if(WIN32) + set(NULL_DEVICE "NUL:") +else() + set(NULL_DEVICE "/dev/null") +endif() +execute_process(COMMAND ${LEX_EXECUTABLE} -P pcap_ --header-file=${NULL_DEVICE} --nounput -t ${pcap_SOURCE_DIR}/scanner.l + OUTPUT_QUIET RESULT_VARIABLE EXIT_STATUS) +if(NOT EXIT_STATUS EQUAL 0) + message(FATAL_ERROR "${LEX_EXECUTABLE} is insufficient to compile libpcap. +libpcap requires Flex 2.5.31 or later, or a compatible version of lex. +If a suitable version of Lex/Flex is available as a non-standard command +and/or not in the PATH, you can specify it using the LEX environment +variable. That said, on some systems the error can mean that Flex/Lex is +actually acceptable, but m4 is not. Likewise, if a suitable version of +m4 (such as GNU M4) is available but has not been detected, you can +specify it using the M4 environment variable.") +endif() + add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/scanner.c ${CMAKE_CURRENT_BINARY_DIR}/scanner.h SOURCE ${pcap_SOURCE_DIR}/scanner.l @@ -1816,22 +2574,56 @@ find_program(YACC_EXECUTABLE NAMES bison win_bison byacc yacc) if(YACC_EXECUTABLE STREQUAL "YACC_EXECUTABLE-NOTFOUND") message(FATAL_ERROR "Neither bison nor win_bison nor byacc nor yacc was found.") endif() + +if(YACC_EXECUTABLE MATCHES "byacc" OR YACC_EXECUTABLE MATCHES "yacc") + # + # Make sure this is Berkeley YACC, not AT&T YACC; + # the latter doesn't support reentrant parsers. + # Run it with "-V"; that succeeds and reports the + # version number with Berkeley YACC, but will + # (probably) fail with various vendor flavors + # of AT&T YACC. + # + # Hopefully this also eliminates any versions + # of Berkeley YACC that don't support reentrant + # parsers, if there are any. + # + execute_process(COMMAND ${YACC_EXECUTABLE} -V OUTPUT_QUIET + RESULT_VARIABLE EXIT_STATUS) + if(NOT EXIT_STATUS EQUAL 0) + message(FATAL_ERROR "${YACC_EXECUTABLE} is insufficient to compile libpcap. +libpcap requires Bison, a newer version of Berkeley YACC with support +for reentrant parsers, or another YACC compatible with them.") + endif() + # + # Berkeley YACC doesn't support "%define api.pure", so use + # "%pure-parser". + # + set(REENTRANT_PARSER "%pure-parser") +else() + # + # Bison prior to 2.4(.1) doesn't support "%define api.pure", so use + # "%pure-parser". + # + execute_process(COMMAND ${YACC_EXECUTABLE} -V OUTPUT_VARIABLE bison_full_version) + string(REGEX MATCH "[1-9][0-9]*[.][0-9]+" bison_major_minor ${bison_full_version}) + if (bison_major_minor VERSION_LESS "2.4") + set(REENTRANT_PARSER "%pure-parser") + else() + set(REENTRANT_PARSER "%define api.pure") + endif() +endif() + message(STATUS "Parser generator: ${YACC_EXECUTABLE}") # # Create custom command for the scanner. -# Find out whether it's Bison or not by looking at the last component -# of the path (without a .exe extension, if this is Windows). # -get_filename_component(YACC_NAME ${YACC_EXECUTABLE} NAME_WE) -if("${YACC_NAME}" STREQUAL "bison" OR "${YACC_NAME}" STREQUAL "win_bison") - set(YACC_COMPATIBILITY_FLAG "-y") -endif() add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/grammar.c ${CMAKE_CURRENT_BINARY_DIR}/grammar.h - SOURCE ${pcap_SOURCE_DIR}/grammar.y - COMMAND ${YACC_EXECUTABLE} ${YACC_COMPATIBILITY_FLAG} -p pcap_ -o ${CMAKE_CURRENT_BINARY_DIR}/grammar.c -d ${pcap_SOURCE_DIR}/grammar.y - DEPENDS ${pcap_SOURCE_DIR}/grammar.y + SOURCE ${pcap_BINARY_DIR}/grammar.y + COMMAND ${YACC_EXECUTABLE} -p pcap_ -o ${CMAKE_CURRENT_BINARY_DIR}/grammar.c -d ${pcap_BINARY_DIR}/grammar.y + DEPENDS ${pcap_BINARY_DIR}/grammar.y ) # @@ -1868,6 +2660,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL "AIX") # we use them to load the BPF module. # set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} odm cfg) + set(LIBS "${LIBS} -lodm -lcfg") + set(LIBS_STATIC "${LIBS_STATIC} -lodm -lcfg") + set(LIBS_PRIVATE "${LIBS_PRIVATE} -lodm -lcfg") endif() elseif(CMAKE_SYSTEM_NAME STREQUAL "HP-UX") if(CMAKE_SYSTEM_VERSION MATCHES "[A-Z.]*9\.[0-9]*") @@ -1906,7 +2701,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "IRIX" OR CMAKE_SYSTEM_NAME STREQUAL "IRIX64") set(MAN_MISC_INFO 5) elseif(CMAKE_SYSTEM_NAME STREQUAL "OSF1") # - # DEC OSF/1, a/k/a Digial UNIX, a/k/a Tru64 UNIX. + # 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. @@ -1939,6 +2734,11 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.] set(MAN_MISC_INFO 5) set(MAN_DEVICES 7D) endif() +elseif(CMAKE_SYSTEM_NAME STREQUAL "Haiku") + # + # Haiku needs _BSD_SOURCE for the _IO* macros because it doesn't use them. + # + add_definitions(-D_BSD_SOURCE) endif() source_group("Source Files" FILES ${PROJECT_SOURCE_LIST_C}) @@ -1969,7 +2769,7 @@ add_subdirectory(testprogs) # # See # -# http://public.kitware.com/pipermail/cmake/2013-August/055510.html +# https://public.kitware.com/pipermail/cmake/2013-August/055510.html # add_custom_target(SerializeTarget DEPENDS @@ -2000,6 +2800,10 @@ if(BUILD_SHARED_LIBS) # set_target_properties(${LIBRARY_NAME} PROPERTIES DEFINE_SYMBOL pcap_EXPORTS) + if(NOT "${LINKER_FLAGS}" STREQUAL "") + set_target_properties(${LIBRARY_NAME} PROPERTIES + LINK_FLAGS "${LINKER_FLAGS}") + endif() endif(BUILD_SHARED_LIBS) add_library(${LIBRARY_NAME}_static STATIC @@ -2142,21 +2946,25 @@ if(APPLE AND "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "") # captures.) # set(OSX_LIBRARY_ARCHITECTURES "x86_64;i386;ppc") - else() + elseif(SYSTEM_VERSION_MAJOR GREATER 10 AND SYSTEM_VERSION_MAJOR LESS 19) # - # Post-Snow Leopard. Build for x86-64 and 32-bit x86, - # with x86-64 first. (That's what Apple does) - # XXX - update if and when Apple drops support - # for 32-bit x86 code and if and when Apple adds - # ARM-based Macs. (You're on your own for iOS etc.) + # Post-Snow Leopard, pre-Catalina. Build for x86-64 + # and 32-bit x86, with x86-64 first. (That's what Apple does) # - # XXX - check whether we *can* build for i386 and, if not, - # suggest that the user install the /usr/include headers if - # they want to build fat. + # First, check whether we're building with OpenSSL. + # If so, don't bother trying to build fat. # - cmake_push_check_state() - set(CMAKE_REQUIRED_FLAGS "-arch i386") - check_c_source_compiles( + if(HAVE_OPENSSL) + set(X86_32_BIT_SUPPORTED NO) + set(OSX_LIBRARY_ARCHITECTURES "x86_64") + message(WARNING "We're assuming the OpenSSL libraries are 64-bit only, so we're not compiling for 32-bit x86") + else() + # + # Now, check whether we *can* build for i386. + # + cmake_push_check_state() + set(CMAKE_REQUIRED_FLAGS "-arch i386") + check_c_source_compiles( "int main(void) { @@ -2164,20 +2972,80 @@ main(void) } " X86_32_BIT_SUPPORTED) - cmake_pop_check_state() - if(X86_32_BIT_SUPPORTED) - set(OSX_LIBRARY_ARCHITECTURES "x86_64;i386") + cmake_pop_check_state() + if(X86_32_BIT_SUPPORTED) + set(OSX_LIBRARY_ARCHITECTURES "x86_64;i386") + else() + set(OSX_LIBRARY_ARCHITECTURES "x86_64") + # + # We can't build fat; suggest that the user install the + # /usr/include headers if they want to build fat. + # + if(SYSTEM_VERSION_MAJOR LESS 18) + # + # Pre-Mojave; the command-line tools should be sufficient to + # enable 32-bit x86 builds. + # + message(WARNING "Compiling for 32-bit x86 gives an error; try installing the command-line tools") + else() + message(WARNING "Compiling for 32-bit x86 gives an error; try installing the command-line tools and, after that, installing the /usr/include headers from the /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg package") + endif() + endif() + endif() + elseif(SYSTEM_VERSION_MAJOR EQUAL 19) + # + # Catalina. Build libraries and executables + # only for x86-64. (That's what Apple does; + # 32-bit x86 binaries are not supported on + # Catalina.) + # + set(OSX_LIBRARY_ARCHITECTURES "x86_64") + else() + # + # Post-Catalina. Build libraries and + # executables for x86-64 and ARM64. + # (That's what Apple does, except they + # build for arm64e, which may include + # some of the pointer-checking extensions.) + # + # If we're building with libssl, make sure + # we can build fat with it (i.e., that it + # was built fat); if we can't, don't set + # the target architectures, and just + # build for the host we're on. + # + # Otherwise, just add both of them. + # + if(HAVE_OPENSSL) + cmake_push_check_state() + set(CMAKE_REQUIRED_FLAGS "-arch x86_64 -arch arm64") + set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) + # + # We must test whether this compiles and links, so + # check_symbol_exists() isn't sufficient. + # + # SSL_library_init() may be a macro that's #defined + # to be the real function to call, so we have to + # include <openssl/ssl.h>, and check_function_exists() + # isn't sufficient. + # + check_c_source_compiles( +"#include <openssl/ssl.h> +int +main(void) +{ + SSL_library_init(); + return 0; +} +" + FAT_SSL_BUILDS_SUPPORTED) + cmake_pop_check_state() + if(FAT_SSL_BUILDS_SUPPORTED) + set(OSX_LIBRARY_ARCHITECTURES "x86_64;arm64") + endif() else() - set(OSX_LIBRARY_ARCHITECTURES "x86_64") - if(SYSTEM_VERSION_MAJOR LESS 18) - # - # Pre-Mojave; the command-line tools should be sufficient to - # enable 32-bit x86 builds. - # - message(WARNING "Compiling for 32-bit x86 gives an error; try installing the command-line tools") - else() - message(WARNING "Compiling for 32-bit x86 gives an error; try installing the command-line tools and, after that, installing the /usr/include headers from the /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg package") - endif() + set(OSX_LIBRARY_ARCHITECTURES "x86_64;arm64") endif() endif() if(BUILD_SHARED_LIBS) @@ -2195,6 +3063,12 @@ endif() configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) ###################################### +# Write out the grammar.y file +###################################### + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/grammar.y.in ${CMAKE_CURRENT_BINARY_DIR}/grammar.y @ONLY) + +###################################### # Install pcap library, include files, and man pages ###################################### @@ -2209,25 +3083,24 @@ set(LIBRARY_NAME_STATIC ${LIBRARY_NAME}_static) function(install_manpage_symlink SOURCE TARGET MANDIR) if(MINGW) - find_program(LINK_EXECUTABLE ln) - if(LINK_EXECUTABLE) - set(LINK_COMMAND "\"${LINK_EXECUTABLE}\" \"-s\" \"${SOURCE}\" \"${TARGET}\"") - else(LINK_EXECUTABLE) - message(FATAL_ERROR "ln (http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ln.html) not found.") - endif(LINK_EXECUTABLE) + # + # If we haven't found an ln executable with MinGW, we don't try + # generating and installing the man pages, so if we get here, + # we've found that executable. + set(LINK_COMMAND "\"${LINK_EXECUTABLE}\" \"-s\" \"${SOURCE}\" \"${TARGET}\"") else(MINGW) set(LINK_COMMAND "\"${CMAKE_COMMAND}\" \"-E\" \"create_symlink\" \"${SOURCE}\" \"${TARGET}\"") endif(MINGW) install(CODE - "message(STATUS \"Symlinking: ${CMAKE_INSTALL_PREFIX}/${MANDIR}/${SOURCE} to ${TARGET}\") + "message(STATUS \"Symlinking: \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${MANDIR}/${SOURCE} to ${TARGET}\") execute_process( COMMAND \"${CMAKE_COMMAND}\" \"-E\" \"remove\" \"${TARGET}\" - WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${MANDIR} + WORKING_DIRECTORY \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${MANDIR} ) execute_process( COMMAND ${LINK_COMMAND} - WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${MANDIR} + WORKING_DIRECTORY \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${MANDIR} RESULT_VARIABLE EXIT_STATUS ) if(NOT EXIT_STATUS EQUAL 0) @@ -2271,6 +3144,7 @@ set(MAN3PCAP_NOEXPAND pcap_get_required_select_timeout.3pcap pcap_get_selectable_fd.3pcap pcap_geterr.3pcap + pcap_init.3pcap pcap_inject.3pcap pcap_is_swapped.3pcap pcap_lib_version.3pcap @@ -2298,33 +3172,42 @@ set(MAN3PCAP_NOEXPAND pcap_tstamp_type_name_to_val.3pcap pcap_tstamp_type_val_to_name.3pcap ) -set(MANFILE_EXPAND pcap-savefile.manfile.in) +set(MANFILE_EXPAND + pcap-savefile.manfile.in +) set(MANMISC_EXPAND pcap-filter.manmisc.in pcap-linktype.manmisc.in pcap-tstamp.manmisc.in ) -if(NOT BUILD_SHARED_LIBS) - unset(LIBRARY_NAME) -endif(NOT BUILD_SHARED_LIBS) +if(BUILD_SHARED_LIBS) + set(LIBRARIES_TO_INSTALL "${LIBRARY_NAME}" "${LIBRARY_NAME_STATIC}") +else(BUILD_SHARED_LIBS) + set(LIBRARIES_TO_INSTALL "${LIBRARY_NAME_STATIC}") +endif(BUILD_SHARED_LIBS) -if(WIN32) +if(WIN32 OR CYGWIN OR MSYS) + # + # XXX - according to the CMake documentation, WIN32 is set if + # the target is Windows; would there ever be a case where + # CYGWIN or MSYS are set but WIN32 *isn't* set? + # if(MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8) # - # Install 64-bit code built with MSVC in the amd64 subdirectories, + # Install 64-bit code built with MSVC in the x64 subdirectories, # as that's where it expects it to be. # - install(TARGETS ${LIBRARY_NAME} ${LIBRARY_NAME_STATIC} - RUNTIME DESTINATION bin/amd64 - LIBRARY DESTINATION lib/amd64 - ARCHIVE DESTINATION lib/amd64) + install(TARGETS ${LIBRARIES_TO_INSTALL} + RUNTIME DESTINATION bin/x64 + LIBRARY DESTINATION lib/x64 + ARCHIVE DESTINATION lib/x64) if(NOT MINGW) install(FILES $<TARGET_FILE_DIR:${LIBRARY_NAME_STATIC}>/${LIBRARY_NAME_STATIC}.pdb - DESTINATION bin/amd64 OPTIONAL) + DESTINATION bin/x64 OPTIONAL) if(BUILD_SHARED_LIBS) install(FILES $<TARGET_PDB_FILE:${LIBRARY_NAME}> - DESTINATION bin/amd64 OPTIONAL) + DESTINATION bin/x64 OPTIONAL) endif(BUILD_SHARED_LIBS) endif(NOT MINGW) else(MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8) @@ -2333,22 +3216,22 @@ if(WIN32) # in the top-level directories, as those are where they # expect it to be. # - install(TARGETS ${LIBRARY_NAME} ${LIBRARY_NAME_STATIC} + install(TARGETS ${LIBRARIES_TO_INSTALL} RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) - if(NOT MINGW) + if(MSVC) install(FILES $<TARGET_FILE_DIR:${LIBRARY_NAME_STATIC}>/${LIBRARY_NAME_STATIC}.pdb DESTINATION bin OPTIONAL) if(BUILD_SHARED_LIBS) install(FILES $<TARGET_PDB_FILE:${LIBRARY_NAME}> DESTINATION bin OPTIONAL) endif(BUILD_SHARED_LIBS) - endif(NOT MINGW) + endif(MSVC) endif(MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8) -else(WIN32) - install(TARGETS ${LIBRARY_NAME} ${LIBRARY_NAME_STATIC} DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) -endif(WIN32) +else(WIN32 OR CYGWIN OR MSYS) + install(TARGETS ${LIBRARIES_TO_INSTALL} DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) +endif(WIN32 OR CYGWIN OR MSYS) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/pcap/ DESTINATION include/pcap) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pcap.h DESTINATION include) @@ -2358,41 +3241,73 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/pcap-namedb.h DESTINATION include) # On UN*X, and on Windows when not using MSVC, generate libpcap.pc and # pcap-config and process man pages and arrange that they be installed. if(NOT MSVC) - set(PACKAGE_NAME ${LIBRARY_NAME}) set(prefix ${CMAKE_INSTALL_PREFIX}) set(exec_prefix "\${prefix}") set(includedir "\${prefix}/include") - set(libdir "\${exec_prefix}/lib") - if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR - CMAKE_SYSTEM_NAME STREQUAL "NetBSD" OR - CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" OR - CMAKE_SYSTEM_NAME STREQUAL "DragonFly BSD" OR - CMAKE_SYSTEM_NAME STREQUAL "Linux" OR - CMAKE_SYSTEM_NAME STREQUAL "OSF1") - # - # Platforms where the linker is the GNU linker - # or accepts command-line arguments like - # those the GNU linker accepts. - # - set(V_RPATH_OPT "-Wl,-rpath,") - elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.][0-9.]*") - # - # SunOS 5.x. - # - # XXX - this assumes GCC is using the Sun linker, - # rather than the GNU linker. - # - set(V_RPATH_OPT "-Wl,-R,") - else() - # - # No option needed to set the RPATH. - # - set(V_RPATH_OPT "") + set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") + + # + # If this is a platform where we need to have the .pc file and + # pcap-config script supply an rpath option to specify the directory + # in which the libpcap shared library is installed, and the install + # prefix /usr (meaning we're not installing a system library), + # provide the rpath option. + # + # (We must check CMAKE_INSTALL_PREFIX, as the library directory + # isn't necessarily /usr/lib in this case - for example, Linux + # distributions for 64-bit platforms that also provide support for + # binaries for a 32-bit version of the platform may put the 64-bit + # libraries, the 32-bit libraries, or both in directories other than + # /usr/lib.) + # + # In AIX, do we have to do this? + # + # In Darwin-based OSes, the full paths of the shared libraries with + # which the program was linked are stored in the executable, so we + # don't need to provide an rpath option. + # + # With the HP-UX linker, directories specified with -L are, by + # default, added to the run-time search path, so we don't need to + # supply them. + # + # For Tru64 UNIX, "-rpath" works with DEC's^WCompaq's^WHP's C + # compiler for Alpha, but isn't documented as working with GCC, and + # no GCC-compatible option is documented as working with the DEC + # compiler. If anybody needs this on Tru64/Alpha, they're welcome + # to figure out a way to make it work. + # + # This must *not* depend on the compiler, as, on platforms where + # there's a GCC-compatible compiler and a vendor compiler, we need + # to work with both. + # + if(NOT CMAKE_INSTALL_PREFIX STREQUAL "/usr") + if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR + CMAKE_SYSTEM_NAME STREQUAL "NetBSD" OR + CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" OR + CMAKE_SYSTEM_NAME STREQUAL "DragonFly BSD" OR + CMAKE_SYSTEM_NAME STREQUAL "Linux") + # + # Platforms where the "native" C compiler is GCC or accepts + # compatible command-line arguments, and the "native" linker + # is the GNU linker or accepts compatible command-line + # arguments. + # + set(RPATH "-Wl,-rpath,\${libdir}") + elseif(CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND CMAKE_SYSTEM_VERSION MATCHES "5[.][0-9.]*") + # + # SunOS 5.x. + # + # Sun/Oracle's linker, the GNU linker, and GNU-compatible + # linkers all support -R. + # + set(RPATH "-Wl,-R,\${libdir}") + else() + # + # No option needed to set the RPATH. + # + set(RPATH "") + endif() endif() - set(LIBS "") - foreach(LIB ${PCAP_LINK_LIBRARIES}) - set(LIBS "${LIBS} -l${LIB}") - endforeach(LIB) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pcap-config.in ${CMAKE_CURRENT_BINARY_DIR}/pcap-config @ONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpcap.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libpcap.pc @ONLY) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/pcap-config DESTINATION bin) @@ -2404,54 +3319,64 @@ if(NOT MSVC) # For each section of the manual for which we have man pages # that require macro expansion, do the expansion. # - set(MAN1 "") - foreach(MANPAGE ${MAN1_NOEXPAND}) - set(MAN1 ${MAN1} ${CMAKE_CURRENT_SOURCE_DIR}/${MANPAGE}) - endforeach(MANPAGE) - install(FILES ${MAN1} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) - - set(MAN3PCAP "") - foreach(MANPAGE ${MAN3PCAP_NOEXPAND}) - set(MAN3PCAP ${MAN3PCAP} ${CMAKE_CURRENT_SOURCE_DIR}/${MANPAGE}) - endforeach(MANPAGE) - foreach(TEMPLATE_MANPAGE ${MAN3PCAP_EXPAND}) - string(REPLACE ".in" "" MANPAGE ${TEMPLATE_MANPAGE}) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY) - set(MAN3PCAP ${MAN3PCAP} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE}) - endforeach(TEMPLATE_MANPAGE) - install(FILES ${MAN3PCAP} DESTINATION ${CMAKE_INSTALL_MANDIR}/man3) - install_manpage_symlink(pcap_datalink_val_to_name.3pcap pcap_datalink_val_to_description.3pcap ${CMAKE_INSTALL_MANDIR}/man3) - install_manpage_symlink(pcap_dump_open.3pcap pcap_dump_fopen.3pcap ${CMAKE_INSTALL_MANDIR}/man3) - install_manpage_symlink(pcap_findalldevs.3pcap pcap_freealldevs.3pcap ${CMAKE_INSTALL_MANDIR}/man3) - install_manpage_symlink(pcap_geterr.3pcap pcap_perror.3pcap ${CMAKE_INSTALL_MANDIR}/man3) - install_manpage_symlink(pcap_inject.3pcap pcap_sendpacket.3pcap ${CMAKE_INSTALL_MANDIR}/man3) - install_manpage_symlink(pcap_list_datalinks.3pcap pcap_free_datalinks.3pcap ${CMAKE_INSTALL_MANDIR}/man3) - install_manpage_symlink(pcap_list_tstamp_types.3pcap pcap_free_tstamp_types.3pcap ${CMAKE_INSTALL_MANDIR}/man3) - install_manpage_symlink(pcap_loop.3pcap pcap_dispatch.3pcap ${CMAKE_INSTALL_MANDIR}/man3) - install_manpage_symlink(pcap_major_version.3pcap pcap_minor_version.3pcap ${CMAKE_INSTALL_MANDIR}/man3) - install_manpage_symlink(pcap_next_ex.3pcap pcap_next.3pcap ${CMAKE_INSTALL_MANDIR}/man3) - install_manpage_symlink(pcap_open_dead.3pcap pcap_open_dead_with_tstamp_precision.3pcap ${CMAKE_INSTALL_MANDIR}/man3) - install_manpage_symlink(pcap_open_offline.3pcap pcap_open_offline_with_tstamp_precision.3pcap ${CMAKE_INSTALL_MANDIR}/man3) - install_manpage_symlink(pcap_open_offline.3pcap pcap_fopen_offline.3pcap ${CMAKE_INSTALL_MANDIR}/man3) - install_manpage_symlink(pcap_open_offline.3pcap pcap_fopen_offline_with_tstamp_precision.3pcap ${CMAKE_INSTALL_MANDIR}/man3) - install_manpage_symlink(pcap_tstamp_type_val_to_name.3pcap pcap_tstamp_type_val_to_description.3pcap ${CMAKE_INSTALL_MANDIR}/man3) - install_manpage_symlink(pcap_setnonblock.3pcap pcap_getnonblock.3pcap ${CMAKE_INSTALL_MANDIR}/man3) - - set(MANFILE "") - foreach(TEMPLATE_MANPAGE ${MANFILE_EXPAND}) - string(REPLACE ".manfile.in" ".${MAN_FILE_FORMATS}" MANPAGE ${TEMPLATE_MANPAGE}) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY) - set(MANFILE ${MANFILE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE}) - endforeach(TEMPLATE_MANPAGE) - install(FILES ${MANFILE} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${MAN_FILE_FORMATS}) - - set(MANMISC "") - foreach(TEMPLATE_MANPAGE ${MANMISC_EXPAND}) - string(REPLACE ".manmisc.in" ".${MAN_MISC_INFO}" MANPAGE ${TEMPLATE_MANPAGE}) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY) - set(MANMISC ${MANMISC} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE}) - endforeach(TEMPLATE_MANPAGE) - install(FILES ${MANMISC} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${MAN_MISC_INFO}) + # If this is MinGW, maybe we have a UN*X-style ln command and + # maybe we don't. (No, we do *NOT* require MSYS!) If we don't + # have it, don't do the man pages. + # + if(MINGW) + find_program(LINK_EXECUTABLE ln) + endif(MINGW) + if(UNIX OR (MINGW AND LINK_EXECUTABLE)) + set(MAN1 "") + foreach(MANPAGE ${MAN1_NOEXPAND}) + set(MAN1 ${MAN1} ${CMAKE_CURRENT_SOURCE_DIR}/${MANPAGE}) + endforeach(MANPAGE) + install(FILES ${MAN1} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) + + set(MAN3PCAP "") + foreach(MANPAGE ${MAN3PCAP_NOEXPAND}) + set(MAN3PCAP ${MAN3PCAP} ${CMAKE_CURRENT_SOURCE_DIR}/${MANPAGE}) + endforeach(MANPAGE) + foreach(TEMPLATE_MANPAGE ${MAN3PCAP_EXPAND}) + string(REPLACE ".in" "" MANPAGE ${TEMPLATE_MANPAGE}) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY) + set(MAN3PCAP ${MAN3PCAP} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE}) + endforeach(TEMPLATE_MANPAGE) + install(FILES ${MAN3PCAP} DESTINATION ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_datalink_val_to_name.3pcap pcap_datalink_val_to_description.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_datalink_val_to_name.3pcap pcap_datalink_val_to_description_or_dlt.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_dump_open.3pcap pcap_dump_fopen.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_findalldevs.3pcap pcap_freealldevs.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_geterr.3pcap pcap_perror.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_inject.3pcap pcap_sendpacket.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_list_datalinks.3pcap pcap_free_datalinks.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_list_tstamp_types.3pcap pcap_free_tstamp_types.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_loop.3pcap pcap_dispatch.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_major_version.3pcap pcap_minor_version.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_next_ex.3pcap pcap_next.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_open_dead.3pcap pcap_open_dead_with_tstamp_precision.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_open_offline.3pcap pcap_open_offline_with_tstamp_precision.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_open_offline.3pcap pcap_fopen_offline.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_open_offline.3pcap pcap_fopen_offline_with_tstamp_precision.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_tstamp_type_val_to_name.3pcap pcap_tstamp_type_val_to_description.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + install_manpage_symlink(pcap_setnonblock.3pcap pcap_getnonblock.3pcap ${CMAKE_INSTALL_MANDIR}/man3) + + set(MANFILE "") + foreach(TEMPLATE_MANPAGE ${MANFILE_EXPAND}) + string(REPLACE ".manfile.in" ".${MAN_FILE_FORMATS}" MANPAGE ${TEMPLATE_MANPAGE}) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY) + set(MANFILE ${MANFILE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE}) + endforeach(TEMPLATE_MANPAGE) + install(FILES ${MANFILE} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${MAN_FILE_FORMATS}) + + set(MANMISC "") + foreach(TEMPLATE_MANPAGE ${MANMISC_EXPAND}) + string(REPLACE ".manmisc.in" ".${MAN_MISC_INFO}" MANPAGE ${TEMPLATE_MANPAGE}) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY) + set(MANMISC ${MANMISC} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE}) + endforeach(TEMPLATE_MANPAGE) + install(FILES ${MANMISC} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${MAN_MISC_INFO}) + endif(UNIX OR (MINGW AND LINK_EXECUTABLE)) endif(NOT MSVC) # uninstall target diff --git a/contrib/libpcap/CONTRIBUTING.md b/contrib/libpcap/CONTRIBUTING.md index 69b597260f79..fb22c5e38159 100644 --- a/contrib/libpcap/CONTRIBUTING.md +++ b/contrib/libpcap/CONTRIBUTING.md @@ -14,10 +14,10 @@ above), please navigate to https://github.com/the-tcpdump-group/libpcap/issues and check if the problem has already been reported. If it has not, please open a new issue and provide the following details: -* libpcap version (e.g. from tcpdump --version) +* libpcap version (e.g. from `tcpdump --version`) * operating system name and version and any other details that may be relevant - (uname -a, compiler name and version, CPU type etc.) -* configure flags if any were used + (`uname -a`, compiler name and version, CPU type etc.) +* `configure` or `cmake` flags if any were used * statement of the problem * steps to reproduce diff --git a/contrib/libpcap/CREDITS b/contrib/libpcap/CREDITS index f7abc1f3222e..4b820ee7b9ac 100644 --- a/contrib/libpcap/CREDITS +++ b/contrib/libpcap/CREDITS @@ -3,29 +3,43 @@ This file lists people who have contributed to libpcap. The current maintainers (in alphabetical order): Denis Ovsienko <denis at ovsienko dot info> Francois-Xavier Le Bail <devel dot fx dot lebail at orange dot fr> - Guy Harris <guy at alum dot mit dot edu> + Guy Harris <gharris at sonic dot net> Michael Richardson <mcr at sandelman dot ottawa dot on dot ca> Additional people who have contributed patches (in alphabetical order): + Adrian Budau <adbudau at bitdefender dot com> Akos Vandra <axos88 at gmail dot com> Alan Bawden <Alan at LCS dot MIT dot EDU> Albert Chin <china at thewrittenword dot com> + Alexander Galanin <al at galanin dot nnov dot ru> Alexander 'Leo' Bergolth <Leo dot Bergolth at wu-wien dot ac dot at> Alexey Kuznetsov <kuznet at ms2 dot inr dot ac dot ru> + Alex Smith <44322503+MadAlexUK at users dot noreply dot github dot com> + Alfredo Alvarez Fernandez <alfredoalvarezernandez at gmail dot com> Ali Abdulkadir <autostart dot ini at gmail dot com> Alon Bar-Lev <alonbl at sourceforge dot net> + Anders Broman <anders dot broman at ericsson dot com> Andres Perera <andres dot p at zoho dot com> Andrew Brown <atatat at atatdot dot net> <andy-1 at sourceforge dot net> Ani Sinha <ani at aristanetworks dot com> + Anthony Kirby <Anthony dot Kirby at nominet dot uk> Antti Kantee <pooka at netbsd dot org> Arien Vijn <arienvijn at sourceforge dot net> Arkadiusz Miskiewicz <misiek at pld dot org dot pl> Armando L. Caro Jr. <acaro at mail dot eecis dot udel dot edu> Assar Westerlund <assar at sics dot se> + Atzm Watanabe <atzm at atzm dot org> + Baptiste Peugnez <baptiste dot peugnez at cea dot fr> + Baruch Siach <baruch at tkos dot co dot il> Bill Parker <wp02855 at gmail dot com> + Biswapriyo Nath <nathbappai at gmail dot com> + blazeable <blazeable at blazeable dot eu> + bleader <bleader at ratonland dot org> Brent Cook <brent at boundary dot com> Brian Ginsbach <ginsbach at cray dot com> + B. Scott Michel <scooter dot phd at gmail dot com> + Cedric Cellier <rixed at happyleptic dot org> Charles M. Hannum <mycroft at netbsd dot org> Chris G. Demetriou <cgd at netbsd dot org> Chris Lightfoot <cwrl at users dot sourceforge dot net> @@ -34,24 +48,38 @@ Additional people who have contributed patches (in alphabetical order): Christian Bell <csbell at myri dot com> Christian Peron <csjp at freebsd dot org> Christian Svensson <blue at cmd dot nu> + Christopher K Lee <christopher dot lee at cspi dot com> + Daniel Borkmann <dborkman at redhat dot com> Daniele Orlandi <daniele at orlandi dot com> + Daniel Lublin <daniel at lublin dot se> + Daniel Miller <dmiller at nmap dot org> + Dario Lombardo <lomato at gmail dot com> Darren Lim <darren dot lim at endace dot com> Darren Reed <darrenr at sun dot com> + Dave Barach <dave at barachs dot net> David Clark <david dot clark at datasoft dot com> David Kaelbling <drk at sgi dot com> + David Karoly <david dot karoly at outlook dot com> David Ward <david dot ward at ll dot mit dot edu> David Young <dyoung at ojctech dot com> Dean Gaudet <dean at arctic dot org> dhruv <rsrivat at sourceforge dot net> + Dmytro Ovdiienko <dmitriy dot ovdienko at gmail dot com> Don Ebright <Don dot Ebright at compuware dot com> Dug Song <dugsong at monkey dot org> Dustin Spicuzza <dustin at virtualroadside dot com> dzejarczech <dzejarczech at sourceforge dot net> Edward Sheldrake <ejs1920 at sourceforge dot net> + Eli Schwartz <eschwartz93 at gmail dot com> Eric Anderson <anderse at hpl dot hp dot com> Erik de Castro Lopo <erik dot de dot castro dot lopo at sensorynetworks dot com> + Fedor Sakharov <fedor dot sakharov at gmail dot com> + Felix Janda <felix dot janda at posteo dot de> Felix Obenhuber <felix at obenhuber dot de> + fghzxm <fghzxm at outlook dot com> Florent Drouin <Florent dot Drouin at alcatel-lucent dot fr> + Florian Fainelli <f dot fainelli at gmail dot com> + François Revol <revol at free dot fr> Franz Schaefer <schaefer at mond dot at> frederich <frederich at sourceforge dot net> Fulko Hew <fulko dot hew at gmail dot com> @@ -59,6 +87,7 @@ Additional people who have contributed patches (in alphabetical order): Gabor Tatarka <gabor dot tatarka at ericsson dot com> Garrett Cooper <yaberauneya at sourceforge dot net> George Neville-Neil <gnn at freebsd dot org> + Gerald Combs <gerald at zing dot org> Gerard Garcia <nouboh at gmail dot com> Gianluca Varenni <gianluca dot varenni at gmail dot com> Gilbert Hoyek <gil_hoyek at hotmail dot com> @@ -71,83 +100,115 @@ Additional people who have contributed patches (in alphabetical order): Gustavo Zacarias <gustavo at zacarias dot com dot ar> Hagen Paul Pfeifer <hagen at jauu dot net> Henri Doreau <hdoreau at sourceforge dot net> + Hiroaki KAWAI <kawai at stratosphere dot co dot jp> Hyung Sik Yoon <hsyn at kr dot ibm dot com> Igor Khristophorov <igor at atdot dot org> + Jakub Sitnicki <jsitnicki at gmail dot com> Jakub Zawadzki <darkjames at darkjames dot pl> + James Ko <jck at exegin dot com> Jan-Philip Velders <jpv at veldersjes dot net> Jason R. Thorpe <thorpej at netbsd dot org> Javier Achirica <achirica at ttd dot net> Jean-Louis Charton <Jean-Louis dot CHARTON at oikialog dot com> Jean Tourrilhes <jt at hpl dot hp dot com> Jefferson Ogata <jogata at nodc dot noaa dot gov> + Jerome Duval <jerome dot duval at gmail dot com> Jesper Dangaard Brouer <hawk at comx dot dk> Jesper Peterson <jesper at endace dot com> Jesse Gross <jesse at nicira dot com> + JHA <jon dot anderson at oracle dot com> + jingyu yang <jingleyang at users dot noreply dot github dot com> Jiri Slaby <jirislaby at gmail dot com> + João Valverde <joao dot valverde at tecnico dot ulisboa dot pt> Joerg Mayer <jmayer at loplof dot de> John Bankier <jbankier at rainfinity dot com> Jon Lindgren <jonl at yubyub dot net> Jon Smirl <jonsmirl at gmail dot com> Jorge Boncompte [DTI2] <jorge at dti2 dot net> + jromanr <jromanr at hotmail dot com> Juergen Schoenwaelder <schoenw at ibr dot cs dot tu-bs dot de> Julien Moutinho <julm at savines dot alpes dot fr dot eu dot org> Jung-uk Kim <jkim at FreeBSD dot org> Kazushi Sugyo <sugyo at pb dot jp dot nec dot com> + Kevin Boulain <kevin dot boulain at securactive dot net> Klaus Klein <kleink at netbsd dot org> Koryn Grant <koryn at endace dot com> Kris Katterjohn <katterjohn at gmail dot com> Krzysztof Halasa <khc at pm dot waw dot pl> Lennert Buytenhek <buytenh at wantstofly dot org> + Li kunyu <kunyu at nfschina dot com> + lixiaoyan <lixiaoyan at google dot com> Lorenzo Cavallaro <sullivan at sikurezza dot org> Loris Degioanni <loris at netgroup-serv dot polito dot it> Love Hörnquist-Åstrand <lha at stacken dot kth dot se> Luis MartinGarcia <luis dot mgarc at gmail dot com> + lxy <391861737 at qq dot com> Maciej W. Rozycki <macro at ds2 dot pg dot gda dot pl> Mansour Behabadi <mansour at oxplot dot com> Marcus Felipe Pereira <marcus at task dot com dot br> + Mario J. Rugiero <mrugiero at gmail dot com> Mark C. Brown <mbrown at hp dot com> Mark Johnston <markjdb at gmail dot com> + Mark Marshall <mark dot marshall at omicronenergy dot com> Mark Pizzolato <List-tcpdump-workers at subscriptions dot pizzolato dot net> Markus Mayer <markus_mayer at sourceforge dot net> Martin Husemann <martin at netbsd dot org> Márton Németh <nm127 at freemail dot hu> + Matt Eaton <agnosticdev at gmail dot com> Matthew Luckie <mjl at luckie dot org dot nz> + Matthias Hannig <matthias at hannig dot cc> + Matwey V. Kornilov <matwey dot kornilov at gmail dot com> + maxice8 <thinkabit dot ukim at gmail dot com> Max Laier <max at love2party dot net> Michal Kubecek <mkubecek at suse dot cz> Michal Labedzki <michal dot labedzki at tieto dot com> + Michal Ruprich <michalruprich at gmail dot com> Michal Sekletar <msekleta at redhat dot com> Mike Frysinger <vapier at gmail dot com> Mike Kershaw <dragorn at kismetwireless dot net> Mike Wiacek <mike at iroot dot net> + Milosz Kaniewski <milosz dot kaniewski at gmail dot com> Miroslav Lichvar <mlichvar at redhat dot com> Monroe Williams <monroe at pobox dot com> + Myricom Help <myri at users dot noreply dot github dot com> + Nan Xiao <nan at chinadtrace dot org> + nic-kaczinsky <68271784+nic-kaczinsky at users dot noreply dot github dot com> + Nick Kelsey <nickk at silicondust dot com> Nicolas Dade <ndade at nsd dot dyndns dot org> Niko Delarich <niko dot delarich at gmail dot com> N. Leiten <nleiten at sourceforge dot net> + nnposter <nnposter at users dot noreply dot github dot com> <nvercamm at sourceforge dot net> Octavian Cerna <tavy at ylabs dot com> Olaf Kirch <okir at caldera dot de> Ollie Wild <aaw at users dot sourceforge dot net> + Ondřej Hošek <ondra dot hosek at gmail dot com> Onno van der Linden <onno at simplex dot nl> + Orgad Shaneh <orgad dot shaneh at audiocodes dot com> + Ørjan Malde <red at foxi dot me> Paolo Abeni <pabeni at redhat dot com> Patrick Marie <mycroft at virgaria dot org> - Patrick McHardy <kaber at trash not net> + Patrick McHardy <kaber at trash dot net> Paul Mundt <lethal at linux-sh dot org> Pavel Kankovsky <kan at dcit dot cz> + Pawel Brzezinski <pawel dot brzezinski at harman dot com> Pawel Pokrywka <publicpp at gmail dot com> Peter Fales <peter at fales-lorenz dot net> Peter Jeremy <peter dot jeremy at alcatel dot com dot au> Peter Volkov <pva at gentoo dot org> + Petr Vorel <pvorel at suse dot cz> + Philippe Antoine <contact at catenacyber dot fr> Phil Wood <cpw at lanl dot gov> Rafal Maszkowski <rzm at icm dot edu dot pl> + ramin <lordrasmus at gmail dot com> <rcb-isis at users dot sourceforge dot net> Richard Stearn <richard at rns-stearn dot demon dot co dot uk> Rick Jones <raj at cup dot hp dot com> Robert Edmonds <stu-42 at sourceforge dot net> Roberto Mariani <jelot-tcpdump at jelot dot it> - Rongxi Li <rongxi dot li at chaitin dot com> Roland Dreier <roland at purestorage dot com> Romain Francoise <rfrancoise at debian dot org> + Rongxi Li <rongxi dot li at chaitin dot com> Sagun Shakya <sagun dot shakya at sun dot com> Scott Barron <sb125499 at ohiou dot edu> Scott Gifford <sgifford at tir dot com> @@ -155,23 +216,39 @@ Additional people who have contributed patches (in alphabetical order): Sebastian Krahmer <krahmer at cs dot uni-potsdam dot de> Sebastien Roy <Sebastien dot Roy at Sun dot COM> Sepherosa Ziehau <sepherosa at gmail dot com> + Shane Kerr <shane at time-travellers dot org> Shaun Clowes <delius at progsoc dot uts dot edu dot au> + solofox <wensg100 at sina dot com> Solomon Peachy <pizza at shaftnet dot org> Stefan Hudson <hudson at mbay dot net> Stephen Donnelly <stephen at endace dot com> + Steve Karg <skarg at users dot sourceforge dot net> + stubbfel <stubbfel at gmail dot com> Takashi Yamamoto <yamt at mwd dot biglobe dot ne dot jp> Tanaka Shin-ya <zstanaka at archer dot livedoor dot com> + Thomas Habets <habets at google dot com> + Thomas Petazzoni <thomas dot petazzoni at free-electrons dot com> Tobias Poschwatta <posch at sourceforge dot net> + Tomasz Moń <desowin at gmail dot com> + Tommy Beadle <tbeadle at arbor dot net> Tony Li <tli at procket dot com> Torsten Landschoff <torsten at debian dot org> + Tymoteusz Blazejczyk <tymoteusz dot blazejczyk at intel dot com> Uns Lider <unslider at miranda dot org> Uwe Girlich <Uwe dot Girlich at philosys dot de> + Vitaly Lavrov <vel21ripn at gmail dot com> + Vivien Didelot <vivien dot didelot at gmail dot com> + Vladimir Gladkov <vovkos at gmail dot com> + Vladimir Marek <vlmarek at volny dot cz> + Walter Schell <walterschell at users dot noreply dot github dot com> Wesley Shields <wxs at FreeBSD dot org> Xianjie Zhang <xzhang at cup dot hp dot com> Xin Li <delphij at FreeBSD dot org> Xue Jiang Qing <xuejianqing at star-net dot cn> + Yang Luo <hsluoyz at qq dot com> Yen Yen Lim Yoann Vandoorselaere <yoann at prelude-ids dot org> + Yogesh Prasad <yogesh dot prasad at rockwellcollins dot com> Yvan Vanhullebus <vanhu at sourceforge dot net> The original LBL crew: diff --git a/contrib/libpcap/INSTALL.md b/contrib/libpcap/INSTALL.md index 3a303fe0a6ce..d0a19d811a8b 100644 --- a/contrib/libpcap/INSTALL.md +++ b/contrib/libpcap/INSTALL.md @@ -1,105 +1,120 @@ -To build libpcap, run "./configure" (a shell script). The configure -script will determine your system attributes and generate an -appropriate Makefile from Makefile.in. Next run "make". If everything -goes well you can su to root and run "make install". However, you need -not install libpcap if you just want to build tcpdump; just make sure -the tcpdump and libpcap directory trees have the same parent -directory. +# libpcap installation notes +Libpcap can be built either with the configure script and `make`, or +with CMake and any build system supported by CMake. + +To build libpcap with the configure script and `make`: + +* Run `./configure` (a shell script). The configure script will +determine your system attributes and generate an appropriate `Makefile` +from `Makefile.in`. The configure script has a number of options to +control the configuration of libpcap; `./configure --help`` will show +them. + +* Next, run `make`. If everything goes well, you can +`su` to root and run `make install`. However, you need not install +libpcap if you just want to build tcpdump; just make sure the tcpdump +and libpcap directory trees have the same parent directory. + +To build libpcap with CMake and the build system of your choice, from +the command line: + +* Create a build directory into which CMake will put the build files it +generates; CMake does not work as well with builds done in the source +code directory as does the configure script. The build directory may be +created as a subdirectory of the source directory or as a directory +outside the source directory. + +* Change to the build directory and run CMake with the path from the +build directory to the source directory as an argument. The `-G` flag +can be used to select the CMake "generator" appropriate for the build +system you're using; various `-D` flags can be used to control the +configuration of libpcap. + +* Run the build tool. If everything goes well, you can `su` to root and +run the build tool with the `install` target. Building tcpdump from a +libpcap in a build directory is not supported. + +An `uninstall` target is supported with both `./configure` and CMake. + +***DO NOT*** run the build as root; there is no need to do so, running +anything as root that doesn't need to be run as root increases the risk +of damaging your system, and running the build as root will put files in +the build directory that are owned by root and that probably cannot be +overwritten, removed, or replaced except by root, which could cause +permission errors in subsequent builds. If configure says: configure: warning: cannot determine packet capture interface - configure: warning: (see INSTALL for more info) + configure: warning: (see INSTALL.md file for more info) + +or CMake says: + + cannot determine packet capture interface + + (see the INSTALL.md file for more info) then your system either does not support packet capture or your system does support packet capture but libpcap does not support that particular type. (If you have HP-UX, see below.) If your system uses a packet capture not supported by libpcap, please send us patches; don't forget to include an autoconf fragment suitable for use in -configure.ac. - -It is possible to override the default packet capture type, although -the circumstance where this works are limited. For example if you have -installed bpf under SunOS 4 and wish to build a snit libpcap: - - ./configure --with-pcap=snit +`configure.ac`. -Another example is to force a supported packet capture type in the case -where the configure scripts fails to detect it. +It is possible to override the default packet capture type with the +`--with-pcap`` option to `./configure` or the `-DPCAP_TYPE` option to +CMake, although the circumstances where this works are limited. One +possible reason to do that would be to force a supported packet capture +type in the case where the configure or CMake scripts fails to detect +it. -You will need an ANSI C compiler to build libpcap. The configure script -will abort if your compiler is not ANSI compliant. If this happens, use -the generally available GNU C compiler (GCC). +You will need a C99 compiler to build libpcap. The configure script +will abort if your compiler is not C99 compliant. If this happens, use +the generally available GNU C compiler (GCC) or Clang. You will need either Flex 2.5.31 or later, or a version of Lex compatible with it (if any exist), to build libpcap. The configure -script will abort if there isn't any such program. If you have an older -version of Flex, or don't have a compatible version of Lex, the current -version of flex is available at flex.sourceforge.net. +script will abort if there isn't any such program; CMake fails if Flex +or Lex cannot be found, but doesn't ensure that it's compatible with +Flex 2.5.31 or later. If you have an older version of Flex, or don't +have a compatible version of Lex, the current version of Flex is +available [here](https://github.com/westes/flex). You will need either Bison, Berkeley YACC, or a version of YACC compatible with them (if any exist), to build libpcap. The configure -script will abort if there isn't any such program. If you don't have -any such program, the current version of Bison can be found at -http://ftp.gnu.org/gnu/bison/ and the current version of Berkeley YACC -can be found at http://invisible-island.net/byacc/. +script will abort if there isn't any such program; CMake fails if Bison +or some form of YACC cannot be found, but doesn't ensure that it's +compatible with Bison or Berkeley YACC. If you don't have any such +program, the current version of Bison can be found +[here](https://ftp.gnu.org/gnu/bison/) and the current version of +Berkeley YACC can be found [here](https://invisible-island.net/byacc/). Sometimes the stock C compiler does not interact well with Flex and -Bison. The list of problems includes undefined references for alloca. +Bison. The list of problems includes undefined references for alloca(3). You can get around this by installing GCC. -If you use Solaris, there is a bug with bufmod(7) that is fixed in -Solaris 2.3.2 (aka SunOS 5.3.2). Setting a snapshot length with the -broken bufmod(7) results in data be truncated from the FRONT of the -packet instead of the end. The work around is to not set a snapshot -length but this results in performance problems since the entire packet -is copied to user space. If you must run an older version of Solaris, -there is a patch available from Sun; ask for bugid 1149065. After -installing the patch, use "setenv BUFMOD_FIXED" to enable use of -bufmod(7). However, we recommend you run a more current release of -Solaris. +## Linux specifics +On Linux, libpcap will not work if the kernel does not have the packet +socket option enabled; see [this file](doc/README.linux) for more +information. +## Solaris specifics If you use the SPARCompiler, you must be careful to not use the -/usr/ucb/cc interface. If you do, you will get bogus warnings and -perhaps errors. Either make sure your path has /opt/SUNWspro/bin -before /usr/ucb or else: +`/usr/ucb/cc` interface. If you do, you will get bogus warnings and +perhaps errors. Either make sure your path has `/opt/SUNWspro/bin` +before `/usr/ucb` or else: setenv CC /opt/SUNWspro/bin/cc -before running configure. (You might have to do a "make distclean" -if you already ran configure once). - -If you are trying to do packet capture with a FORE ATM card, you may or -may not be able to. They usually only release their driver in object -code so unless their driver supports packet capture, there's not much -libpcap can do. - -If you get an error like: - - tcpdump: recv_ack: bind error 0x??? - -when using DLPI, look for the DL_ERROR_ACK error return values, usually -in /usr/include/sys/dlpi.h, and find the corresponding value. +before running configure. (You might have to do a `make distclean` +if you already ran `configure` once). -Under {DEC OSF/1, Digital UNIX, Tru64 UNIX}, packet capture must be -enabled before it can be used. For instructions on how to enable packet -filter support, see: - - ftp://ftp.digital.com/pub/Digital/dec-faq/Digital-UNIX - -Look for the "How do I configure the Berkeley Packet Filter and capture -tcpdump traces?" item. - -Once you enable packet filter support, your OSF system will support bpf -natively. - -Under Ultrix, packet capture must be enabled before it can be used. For -instructions on how to enable packet filter support, see: - - ftp://ftp.digital.com/pub/Digital/dec-faq/ultrix +See [this file](doc/README.solaris.md) for more up to date +Solaris-related information. +## HP-UX specifics If you use HP-UX, you must have at least version 9 and either the -version of cc that supports ANSI C (cc -Aa) or else use the GNU C +version of `cc` that supports C99 (`cc -AC99`) or else use the GNU C compiler. You must also buy the optional streams package. If you don't have: @@ -113,10 +128,10 @@ need to install the "9.X LAN and DLPI drivers cumulative" patch The DLPI streams package is standard starting with HP-UX 10. The HP implementation of DLPI is a little bit eccentric. Unlike -Solaris, you must attach /dev/dlpi instead of the specific /dev/* +Solaris, you must attach `/dev/dlpi` instead of the specific `/dev/*` network pseudo device entry in order to capture packets. The PPA is based on the ifnet "index" number. Under HP-UX 9, it is necessary to -read /dev/kmem and the kernel symbol file (/hp-ux). Under HP-UX 10, +read `/dev/kmem` and the kernel symbol file (`/hp-ux`). Under HP-UX 10, DLPI can provide information for determining the PPA. It does not seem to be possible to trace the loopback interface. Unlike other DLPI implementations, PHYS implies MULTI and SAP and you get an error if you @@ -137,216 +152,126 @@ doing echo 'lanc_outbound_promisc_flag/W 1' | adb -w /stand/vmunix /dev/mem -You would have to arrange that this happen on reboots; the right way to +You would have to arrange that this happens on reboots; the right way to do that would probably be to put it into an executable script file -"/sbin/init.d/outbound_promisc" and making -"/sbin/rc2.d/S350outbound_promisc" a symbolic link to that script. +`/sbin/init.d/outbound_promisc` and making +`/sbin/rc2.d/S350outbound_promisc` a symbolic link to that script. Finally, testing shows that there can't be more than one simultaneous DLPI user per network interface. -If you use Linux, this version of libpcap is known to compile and run -under Red Hat 4.0 with the 2.0.25 kernel. It may work with earlier 2.X -versions but is guaranteed not to work with 1.X kernels. Running more -than one libpcap program at a time, on a system with a 2.0.X kernel, can -cause problems since promiscuous mode is implemented by twiddling the -interface flags from the libpcap application; the packet capture -mechanism in the 2.2 and later kernels doesn't have this problem. Also, -packet timestamps aren't very good. This appears to be due to haphazard -handling of the timestamp in the kernel. - -Note well: there is rumoured to be a version of tcpdump floating around -called 3.0.3 that includes libpcap and is supposed to support Linux. -You should be advised that neither the Network Research Group at LBNL -nor the Tcpdump Group ever generated a release with this version number. -The LBNL Network Research Group notes with interest that a standard -cracker trick to get people to install trojans is to distribute bogus -packages that have a version number higher than the current release. -They also noted with annoyance that 90% of the Linux related bug reports -they got are due to changes made to unofficial versions of their page. -If you are having trouble but aren't using a version that came from -tcpdump.org, please try that before submitting a bug report! +See [this file](doc/README.hpux) for more information specific to HP-UX. -On Linux, libpcap will not work if the kernel does not have the packet -socket option enabled; see the README.linux file for information about -this. +## AIX specifics +See [this file](doc/README.aix) for information on installing libpcap and +configuring your system to be able to support libpcap. + +## other specifics +If you are trying to do packet capture with a FORE ATM card, you may or +may not be able to. They usually only release their driver in object +code so unless their driver supports packet capture, there's not much +libpcap can do. -If you use AIX, you may not be able to build libpcap from this release. -We do not have an AIX system in house so it's impossible for us to test -AIX patches submitted to us. We are told that you must link against -/lib/pse.exp, that you must use AIX cc or a GNU C compiler newer than -2.7.2, and that you may need to run strload before running a libpcap -application. +If you get an error like: -Read the README.aix file for information on installing libpcap and -configuring your system to be able to support libpcap. + tcpdump: recv_ack: bind error 0x??? -If you use NeXTSTEP, you will not be able to build libpcap from this -release. - -If you use SINIX, you should be able to build libpcap from this -release. It is known to compile and run on SINIX-Y/N 5.42 with the C-DS -V1.0 or V1.1 compiler. But note that in some releases of SINIX, yacc -emits incorrect code; if grammar.y fails to compile, change every -occurence of: - - #ifdef YYDEBUG - -to: - #if YYDEBUG - -Another workaround is to use flex and bison. - -If you use SCO, you might have trouble building libpcap from this -release. We do not have a machine running SCO and have not had reports -of anyone successfully building on it; the current release of libpcap -does not compile on SCO OpenServer 5. Although SCO apparently supports -DLPI to some extent, the DLPI in OpenServer 5 is very non-standard, and -it appears that completely new code would need to be written to capture -network traffic. SCO do not appear to provide tcpdump binaries for -OpenServer 5 or OpenServer 6 as part of SCO Skunkware: - - http://www.sco.com/skunkware/ - -If you use UnixWare, you might be able to build libpcap from this -release, or you might not. We do not have a machine running UnixWare, -so we have not tested it; however, SCO provide packages for libpcap -0.6.2 and tcpdump 3.7.1 in the UnixWare 7/Open UNIX 8 part of SCO -Skunkware, and the source package for libpcap 0.6.2 is not changed from -the libpcap 0.6.2 source release, so this release of libpcap might also -build without changes on UnixWare 7. - -If linking tcpdump fails with "Undefined: _alloca" when using bison on -a Sun4, your version of Bison is broken. In any case version 1.16 or -higher is recommended (1.14 is known to cause problems 1.16 is known to -work). Either pick up a current version from: - - http://ftp.gnu.org/gnu/bison/ - -or hack around it by inserting the lines: - - #ifdef __GNUC__ - #define alloca __builtin_alloca - #else - #ifdef sparc - #include <alloca.h> - #else - char *alloca (); - #endif - #endif - -right after the (100 line!) GNU license comment in bison.simple, remove -grammar.[co] and fire up make again. - -If you use SunOS 4, your kernel must support streams NIT. If you run a -libpcap program and it dies with: - - /dev/nit: No such device - -You must add streams NIT support to your kernel configuration, run -config and boot the new kernel. - -FILES ------ -CHANGES - description of differences between releases -ChmodBPF/* - macOS startup item to set ownership and permissions - on /dev/bpf* -CMakeLists.txt - CMake file -CONTRIBUTING - guidelines for contributing -CREDITS - people that have helped libpcap along -INSTALL.md - this file -LICENSE - the license under which tcpdump is distributed -Makefile.in - compilation rules (input to the configure script) -README.md - description of distribution -doc/README.aix - notes on using libpcap on AIX -doc/README.dag - notes on using libpcap to capture on Endace DAG devices -doc/README.hpux - notes on using libpcap on HP-UX -doc/README.linux.md - notes on using libpcap on Linux -doc/README.macos - notes on using libpcap on macOS -doc/README.septel - notes on using libpcap to capture on Intel/Septel devices -doc/README.sita - notes on using libpcap to capture on SITA devices -doc/README.tru64 - notes on using libpcap on Digital/Tru64 UNIX -doc/README.Win32 - notes on using libpcap on Win32 systems (with Npcap) -VERSION - version of this release -acconfig.h - support for post-2.13 autoconf -aclocal.m4 - autoconf macros -arcnet.h - ARCNET definitions -atmuni31.h - ATM Q.2931 definitions -bpf_dump.c - BPF program printing routines -bpf_filter.c - BPF filtering routines -bpf_image.c - BPF disassembly routine -config.guess - autoconf support -config.h.in - autoconf input -config.sub - autoconf support -configure - configure script (run this first) -configure.ac - configure script source -dlpisubs.c - DLPI-related functions for pcap-dlpi.c and pcap-libdlpi.c -dlpisubs.h - DLPI-related function declarations -etherent.c - /etc/ethers support routines -ethertype.h - Ethernet protocol types and names definitions -fad-getad.c - pcap_findalldevs() for systems with getifaddrs() -fad-gifc.c - pcap_findalldevs() for systems with only SIOCGIFLIST -fad-glifc.c - pcap_findalldevs() for systems with SIOCGLIFCONF -filtertest.c - test program for BPF compiler -findalldevstest.c - test program for pcap_findalldevs() -gencode.c - BPF code generation routines -gencode.h - BPF code generation definitions -grammar.y - filter string grammar -ieee80211.h - 802.11 definitions -install-sh - BSD style install script -lbl/os-*.h - OS-dependent defines and prototypes -llc.h - 802.2 LLC SAP definitions -missing/* - replacements for missing library functions -mkdep - construct Makefile dependency list -msdos/* - drivers for MS-DOS capture support -nametoaddr.c - hostname to address routines -nlpid.h - OSI network layer protocol identifier definitions -net - symlink to bpf/net -optimize.c - BPF optimization routines -pcap/bluetooth.h - public definition of DLT_BLUETOOTH_HCI_H4_WITH_PHDR header -pcap/bpf.h - BPF definitions -pcap/namedb.h - public libpcap name database definitions -pcap/pcap.h - public libpcap definitions -pcap/sll.h - public definition of DLT_LINUX_SLL header -pcap/usb.h - public definition of DLT_USB header -pcap-bpf.c - BSD Packet Filter support -pcap-bpf.h - header for backwards compatibility -pcap-bt-linux.c - Bluetooth capture support for Linux -pcap-bt-linux.h - Bluetooth capture support for Linux -pcap-dag.c - Endace DAG device capture support -pcap-dag.h - Endace DAG device capture support -pcap-dlpi.c - Data Link Provider Interface support -pcap-dos.c - MS-DOS capture support -pcap-dos.h - headers for MS-DOS capture support -pcap-enet.c - enet support -pcap-int.h - internal libpcap definitions -pcap-libdlpi.c - Data Link Provider Interface support for systems with libdlpi -pcap-linux.c - Linux packet socket support -pcap-namedb.h - header for backwards compatibility -pcap-nit.c - SunOS Network Interface Tap support -pcap-nit.h - SunOS Network Interface Tap definitions -pcap-npf.c - WinPcap capture support -pcap-null.c - dummy monitor support (allows offline use of libpcap) -pcap-pf.c - Ultrix and Digital/Tru64 UNIX Packet Filter support -pcap-pf.h - Ultrix and Digital/Tru64 UNIX Packet Filter definitions -pcap-septel.c - Intel/Septel device capture support -pcap-septel.h - Intel/Septel device capture support -pcap-sita.c - SITA device capture support -pcap-sita.h - SITA device capture support -pcap-sita.html - SITA device capture documentation -pcap-stdinc.h - includes and #defines for compiling on Win32 systems -pcap-snit.c - SunOS 4.x STREAMS-based Network Interface Tap support -pcap-snoop.c - IRIX Snoop network monitoring support -pcap-usb-linux.c - USB capture support for Linux -pcap-usb-linux.h - USB capture support for Linux -pcap.3pcap - manual entry for the library -pcap.c - pcap utility routines -pcap.h - header for backwards compatibility -pcap_*.3pcap - manual entries for library functions -pcap-filter.4 - manual entry for filter syntax -pcap-linktype.4 - manual entry for link-layer header types -ppp.h - Point to Point Protocol definitions -savefile.c - offline support -scanner.l - filter string scanner -sunatmpos.h - definitions for SunATM capturing -Win32 - headers and routines for building on Win32 systems +when using DLPI, look for the DL_ERROR_ACK error return values, usually +in `/usr/include/sys/dlpi.h`, and find the corresponding value. + +## Description of files + CHANGES - description of differences between releases + ChmodBPF/* - macOS startup item to set ownership and permissions on /dev/bpf* + CMakeLists.txt - CMake file + CONTRIBUTING.md - guidelines for contributing + CREDITS - people that have helped libpcap along + INSTALL.md - this file + LICENSE - the license under which tcpdump is distributed + Makefile.in - compilation rules (input to the configure script) + README.md - description of distribution + doc/README.aix - notes on using libpcap on AIX + doc/README.dag - notes on using libpcap to capture on Endace DAG devices + doc/README.hpux - notes on using libpcap on HP-UX + doc/README.linux - notes on using libpcap on Linux + doc/README.macos - notes on using libpcap on macOS + doc/README.septel - notes on using libpcap to capture on Intel/Septel devices + doc/README.sita - notes on using libpcap to capture on SITA devices + doc/README.solaris.md - notes on using libpcap on Solaris + doc/README.Win32.md - notes on using libpcap on Win32 systems (with Npcap) + VERSION - version of this release + aclocal.m4 - autoconf macros + arcnet.h - ARCNET definitions + atmuni31.h - ATM Q.2931 definitions + bpf_dump.c - BPF program printing routines + bpf_filter.c - BPF filtering routines + bpf_image.c - BPF disassembly routine + config.guess - autoconf support + config.h.in - autoconf input + config.sub - autoconf support + configure - configure script (run this first) + configure.ac - configure script source + dlpisubs.c - DLPI-related functions for pcap-dlpi.c and pcap-libdlpi.c + dlpisubs.h - DLPI-related function declarations + etherent.c - /etc/ethers support routines + ethertype.h - Ethernet protocol types and names definitions + fad-getad.c - pcap_findalldevs() for systems with getifaddrs() + fad-gifc.c - pcap_findalldevs() for systems with only SIOCGIFLIST + fad-glifc.c - pcap_findalldevs() for systems with SIOCGLIFCONF + testprogs/filtertest.c - test program for BPF compiler + testprogs/findalldevstest.c - test program for pcap_findalldevs() + gencode.c - BPF code generation routines + gencode.h - BPF code generation definitions + grammar.y - filter string grammar + ieee80211.h - 802.11 definitions + install-sh - BSD style install script + lbl/os-*.h - OS-dependent defines and prototypes + llc.h - 802.2 LLC SAP definitions + missing/* - replacements for missing library functions + mkdep - construct Makefile dependency list + msdos/* - drivers for MS-DOS capture support + nametoaddr.c - hostname to address routines + nlpid.h - OSI network layer protocol identifier definitions + optimize.c - BPF optimization routines + pcap/bluetooth.h - public definition of DLT_BLUETOOTH_HCI_H4_WITH_PHDR header + pcap/bpf.h - BPF definitions + pcap/namedb.h - public libpcap name database definitions + pcap/pcap.h - public libpcap definitions + pcap/sll.h - public definitions of DLT_LINUX_SLL and DLT_LINUX_SLL2 headers + pcap/usb.h - public definition of DLT_USB header + pcap-bpf.c - BSD Packet Filter support + pcap-bpf.h - header for backwards compatibility + pcap-bt-linux.c - Bluetooth capture support for Linux + pcap-bt-linux.h - Bluetooth capture support for Linux + pcap-dag.c - Endace DAG device capture support + pcap-dag.h - Endace DAG device capture support + pcap-dlpi.c - Data Link Provider Interface support + pcap-dos.c - MS-DOS capture support + pcap-dos.h - headers for MS-DOS capture support + pcap-enet.c - enet support + pcap-int.h - internal libpcap definitions + pcap-libdlpi.c - Data Link Provider Interface support for systems with libdlpi + pcap-linux.c - Linux packet socket support + pcap-namedb.h - header for backwards compatibility + pcap-nit.c - SunOS Network Interface Tap support + pcap-npf.c - Npcap capture support + pcap-null.c - dummy monitor support (allows offline use of libpcap) + pcap-pf.c - Ultrix and Digital/Tru64 UNIX Packet Filter support + pcap-septel.c - Intel/Septel device capture support + pcap-septel.h - Intel/Septel device capture support + pcap-sita.c - SITA device capture support + pcap-sita.h - SITA device capture support + pcap-sita.html - SITA device capture documentation + pcap-snit.c - SunOS 4.x STREAMS-based Network Interface Tap support + pcap-snoop.c - IRIX Snoop network monitoring support + pcap-usb-linux.c - USB capture support for Linux + pcap-usb-linux.h - USB capture support for Linux + pcap.3pcap - manual entry for the library + pcap.c - pcap utility routines + pcap.h - header for backwards compatibility + pcap_*.3pcap - manual entries for library functions + pcap-filter.manmisc.in - manual entry for filter syntax + pcap-linktype.manmisc.in - manual entry for link-layer header types + ppp.h - Point to Point Protocol definitions + savefile.c - offline support + scanner.l - filter string scanner + sunatmpos.h - definitions for SunATM capturing diff --git a/contrib/libpcap/Makefile-devel-adds b/contrib/libpcap/Makefile-devel-adds index fea63bbce3a7..7cfd6c91d8e0 100644 --- a/contrib/libpcap/Makefile-devel-adds +++ b/contrib/libpcap/Makefile-devel-adds @@ -3,12 +3,12 @@ # From autoconf.info . Works best with GNU Make. # ${srcdir}/configure: configure.ac aclocal.m4 - cd ${srcdir} && autoconf + (cd ${srcdir} && autoconf) # autoheader might not change config.h.in, so touch a stamp file. ${srcdir}/config.h.in: ${srcdir}/stamp-h.in ${srcdir}/stamp-h.in: configure.ac aclocal.m4 - cd ${srcdir} && autoheader + (cd ${srcdir} && autoheader) echo timestamp > ${srcdir}/stamp-h.in config.h: stamp-h diff --git a/contrib/libpcap/Makefile.in b/contrib/libpcap/Makefile.in index 5a6b165da3f0..54246586828d 100644 --- a/contrib/libpcap/Makefile.in +++ b/contrib/libpcap/Makefile.in @@ -38,6 +38,7 @@ mandir = @mandir@ # VPATH srcdir = @srcdir@ +top_srcdir = @top_srcdir@ VPATH = @srcdir@ # @@ -60,16 +61,16 @@ CROSSFLAGS= CFLAGS = @CFLAGS@ ${CROSSFLAGS} LDFLAGS = @LDFLAGS@ ${CROSSFLAGS} DYEXT = @DYEXT@ -V_RPATH_OPT = @V_RPATH_OPT@ +RPATH = @RPATH@ DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@ PROG=libpcap PTHREAD_LIBS=@PTHREAD_LIBS@ BUILD_RPCAPD=@BUILD_RPCAPD@ INSTALL_RPCAPD=@INSTALL_RPCAPD@ -EXTRA_NETWORK_LIBS=@EXTRA_NETWORK_LIBS@ # Standard CFLAGS for building members of a shared library FULL_CFLAGS = $(CCOPT) @V_LIB_CCOPT_FAT@ $(SHLIB_CCOPT) $(INCLS) $(DEFS) $(CFLAGS) +CXXFLAGS = $(CCOPT) @V_LIB_CCOPT_FAT@ $(SHLIB_CCOPT) $(INCLS) $(DEFS) $(CFLAGS) INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ @@ -77,7 +78,7 @@ INSTALL_DATA = @INSTALL_DATA@ RANLIB = @RANLIB@ LEX = @LEX@ -YACC = @YACC@ +BISON_BYACC = @BISON_BYACC@ # Explicitly define compilation rule since SunOS 4's make doesn't like gcc. # Also, gcc does not remove the .o before forking 'as', which can be a @@ -86,40 +87,48 @@ YACC = @YACC@ @rm -f $@ $(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c -PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @BT_MONITOR_SRC@ @NETFILTER_SRC@ @DBUS_SRC@ @NETMAP_SRC@ @RDMA_SRC@ -FSRC = @V_FINDALLDEVS@ -SSRC = @SSRC@ -CSRC = pcap.c gencode.c optimize.c nametoaddr.c etherent.c \ - fmtutils.c \ - savefile.c sf-pcap.c sf-pcapng.c pcap-common.c \ - bpf_image.c bpf_filter.c bpf_dump.c -GENSRC = scanner.c grammar.c +PLATFORM_C_SRC = @PLATFORM_C_SRC@ +PLATFORM_CXX_SRC = @PLATFORM_CXX_SRC@ +MODULE_C_SRC = @MODULE_C_SRC@ +REMOTE_C_SRC = @REMOTE_C_SRC@ +COMMON_C_SRC = pcap.c gencode.c optimize.c nametoaddr.c etherent.c \ + fmtutils.c pcap-util.c \ + savefile.c sf-pcap.c sf-pcapng.c pcap-common.c \ + pcap-usb-linux-common.c bpf_image.c bpf_filter.c bpf_dump.c +GENERATED_C_SRC = scanner.c grammar.c LIBOBJS = @LIBOBJS@ -SRC = $(PSRC) $(FSRC) $(CSRC) $(SSRC) $(GENSRC) +SRC = $(PLATFORM_C_SRC) $(PLATFORM_CXX_SRC) \ + $(MODULE_C_SRC) $(REMOTE_C_SRC) $(COMMON_C_SRC) \ + $(GENERATED_C_SRC) # We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot -# hack the extra indirection -OBJ = $(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS) +# hack the extra indirection, and we have to handle PLATFORM_CXX_SRC +# differently from the defines for C source +OBJ = $(PLATFORM_C_SRC:.c=.o) $(PLATFORM_CXX_SRC:.cpp=.o) \ + $(MODULE_C_SRC:.c=.o) $(REMOTE_C_SRC:.c=.o) $(COMMON_C_SRC:.c=.o) \ + $(GENERATED_C_SRC:.c=.o) \ + $(LIBOBJS) + PUBHDR = \ pcap.h \ pcap-bpf.h \ pcap-namedb.h \ - pcap/bpf.h \ pcap/bluetooth.h \ + pcap/bpf.h \ pcap/can_socketcan.h \ pcap/compiler-tests.h \ pcap/dlt.h \ pcap/funcattrs.h \ - pcap/pcap-inttypes.h \ pcap/ipnet.h \ pcap/namedb.h \ pcap/nflog.h \ + pcap/pcap-inttypes.h \ pcap/pcap.h \ pcap/sll.h \ pcap/socket.h \ - pcap/vlan.h \ - pcap/usb.h + pcap/usb.h \ + pcap/vlan.h HDR = $(PUBHDR) \ arcnet.h \ @@ -139,6 +148,9 @@ HDR = $(PUBHDR) \ pcap-int.h \ pcap-rpcap.h \ pcap-types.h \ + pcap-usb-linux-common.h \ + pcap-util.h \ + pflog.h \ portability.h \ ppp.h \ rpcap-protocol.h \ @@ -154,7 +166,7 @@ TAGFILES = \ $(SRC) $(HDR) CLEANFILES = $(OBJ) libpcap.a libpcap.so.`cat $(srcdir)/VERSION` \ - $(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENSRC) $(GENHDR) \ + $(PROG)-`cat $(srcdir)/VERSION`.tar.gz $(GENERATED_C_SRC) $(GENHDR) \ lex.yy.c pcap-config libpcap.pc MAN1 = pcap-config.1 @@ -193,6 +205,7 @@ MAN3PCAP_NOEXPAND = \ pcap_get_required_select_timeout.3pcap \ pcap_get_selectable_fd.3pcap \ pcap_geterr.3pcap \ + pcap_init.3pcap \ pcap_inject.3pcap \ pcap_is_swapped.3pcap \ pcap_lib_version.3pcap \ @@ -241,15 +254,27 @@ EXTRA_DIST = \ Makefile.in \ Makefile-devel-adds \ README.md \ - doc \ + doc/README.Win32.md \ + doc/README.aix \ + doc/README.dag \ + doc/README.hpux \ + doc/README.linux \ + doc/README.macos \ + doc/README.septel \ + doc/README.sita \ + doc/README.solaris.md \ CONTRIBUTING.md \ TODO \ VERSION \ aclocal.m4 \ + charconv.c \ + charconv.h \ chmod_bpf \ cmake_uninstall.cmake.in \ cmakeconfig.h.in \ + cmake/Modules/FindAirPcap.cmake \ cmake/Modules/FindDAG.cmake \ + cmake/Modules/Finddpdk.cmake \ cmake/Modules/FindFseeko.cmake \ cmake/Modules/FindLFS.cmake \ cmake/Modules/FindPacket.cmake \ @@ -266,7 +291,7 @@ EXTRA_DIST = \ fad-getad.c \ fad-gifc.c \ fad-glifc.c \ - grammar.y \ + grammar.y.in \ install-sh \ lbl/os-aix4.h \ lbl/os-aix7.h \ @@ -280,12 +305,10 @@ EXTRA_DIST = \ missing/asprintf.c \ missing/getopt.c \ missing/getopt.h \ - missing/snprintf.c \ missing/strlcat.c \ missing/strlcpy.c \ missing/strtok_r.c \ missing/win_asprintf.c \ - missing/win_snprintf.c \ mkdep \ msdos/bin2c.c \ msdos/makefile \ @@ -298,6 +321,8 @@ EXTRA_DIST = \ msdos/readme.dos \ nomkdep \ org.tcpdump.chmod_bpf.plist \ + pcap-airpcap.c \ + pcap-airpcap.h \ pcap-bpf.c \ pcap-bt-linux.c \ pcap-bt-linux.h \ @@ -312,7 +337,10 @@ EXTRA_DIST = \ pcap-dlpi.c \ pcap-dos.c \ pcap-dos.h \ + pcap-dpdk.c \ + pcap-dpdk.h \ pcap-enet.c \ + pcap-haiku.cpp \ pcap-int.h \ pcap-libdlpi.c \ pcap-linux.c \ @@ -367,6 +395,8 @@ EXTRA_DIST = \ rpcapd/win32-svc.h \ sockutils.c \ sockutils.h \ + sslutils.c \ + sslutils.h \ scanner.l \ testprogs/CMakeLists.txt \ testprogs/Makefile.in \ @@ -374,16 +404,30 @@ EXTRA_DIST = \ testprogs/capturetest.c \ testprogs/filtertest.c \ testprogs/findalldevstest.c \ + testprogs/findalldevstest-perf.c \ + testprogs/fuzz/CMakeLists.txt \ + testprogs/fuzz/fuzz_both.c \ + testprogs/fuzz/fuzz_both.options \ + testprogs/fuzz/fuzz_filter.c \ + testprogs/fuzz/fuzz_filter.options \ + testprogs/fuzz/fuzz_pcap.c \ + testprogs/fuzz/fuzz_pcap.options \ + testprogs/fuzz/onefile.c \ + testprogs/nonblocktest.c \ testprogs/opentest.c \ testprogs/reactivatetest.c \ testprogs/selpolltest.c \ testprogs/threadsignaltest.c \ testprogs/unix.h \ testprogs/valgrindtest.c \ - tests/shb-option-too-long.pcapng \ - Win32/Prj/wpcap.sln \ - Win32/Prj/wpcap.vcxproj \ - Win32/Prj/wpcap.vcxproj.filters + testprogs/visopts.py \ + testprogs/writecaptest.c + +TEST_DIST = `git ls-files tests | grep -v 'tests/\..*'` + +RELEASE_FILES = $(COMMON_C_SRC) $(HDR) $(MAN1) $(MAN3PCAP_EXPAND) \ + $(MAN3PCAP_NOEXPAND) $(MANFILE) $(MANMISC) $(EXTRA_DIST) \ + $(TEST_DIST) all: libpcap.a shared $(BUILD_RPCAPD) libpcap.pc pcap-config @@ -480,8 +524,27 @@ scanner.h: scanner.c scanner.o: scanner.c grammar.h $(CC) $(FULL_CFLAGS) -c scanner.c -grammar.c: $(srcdir)/grammar.y - $(YACC) -p pcap_ -o grammar.c -d $< +# +# Generate the grammar.y file. +# +# Some Makes, e.g. AIX Make and Solaris Make, can't handle "--file=$@.tmp:$<"; +# for example, the Solaris 9 make man page says +# +# Because make assigns $< and $* as it would for implicit rules +# (according to the suffixes list and the directory contents), +# they may be unreliable when used within explicit target entries. +# +# and this is an explicit target entry. +# +# Therefore, instead of using $<, we explicitly put in $(srcdir)/libpcap.pc.in. +# +grammar.y: $(srcdir)/grammar.y.in ./config.status + @rm -f $@ $@.tmp + ./config.status --file=$@.tmp:$(srcdir)/grammar.y.in + mv $@.tmp $@ + +grammar.c: grammar.y + $(BISON_BYACC) -p pcap_ -o grammar.c -d $< grammar.h: grammar.c ## Recover from the removal of $@ @if test -f $@; then :; else \ @@ -528,7 +591,6 @@ libpcap.pc: $(srcdir)/libpcap.pc.in ./config.status @rm -f $@ $@.tmp ./config.status --file=$@.tmp:$(srcdir)/libpcap.pc.in mv $@.tmp $@ - chmod a+x $@ # # Generate the pcap-config script. See above. @@ -543,13 +605,13 @@ pcap-config: $(srcdir)/pcap-config.in ./config.status # Remote pcap daemon. # build-rpcapd: libpcap.a - cd rpcapd; $(MAKE) + (cd rpcapd; $(MAKE)) # # Test programs - not built by default, and not installed. # testprogs: FORCE - cd testprogs; $(MAKE) + (cd testprogs; $(MAKE)) FORCE: @@ -681,7 +743,7 @@ install-archive-shareda: # install-rpcapd: - cd rpcapd; $(MAKE) DESTDIR=$(DESTDIR) install + (cd rpcapd; $(MAKE) DESTDIR=$(DESTDIR) install) uninstall: uninstall-shared uninstall-rpcapd rm -f $(DESTDIR)$(libdir)/libpcap.a @@ -695,6 +757,7 @@ uninstall: uninstall-shared uninstall-rpcapd for i in $(MAN3PCAP); do \ rm -f $(DESTDIR)$(mandir)/man3/$$i; done rm -f $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description.3pcap + rm -f $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description_or_dlt.3pcap rm -f $(DESTDIR)$(mandir)/man3/pcap_dump_fopen.3pcap rm -f $(DESTDIR)$(mandir)/man3/pcap_freealldevs.3pcap rm -f $(DESTDIR)$(mandir)/man3/pcap_perror.3pcap @@ -737,21 +800,21 @@ uninstall-shared-shareda: uninstall-shared-none: uninstall-rpcapd: - cd rpcapd; $(MAKE) DESTDIR=$(DESTDIR) uninstall + (cd rpcapd; $(MAKE) DESTDIR=$(DESTDIR) uninstall) clean: rm -f $(CLEANFILES) - cd rpcapd; $(MAKE) clean - cd testprogs; $(MAKE) clean + (cd rpcapd; $(MAKE) clean) + (cd testprogs; $(MAKE) clean) distclean: clean - rm -f Makefile config.cache config.log config.status \ - config.h gnuc.h net os-proto.h libpcap.pc \ - pcap-config stamp-h stamp-h.in + rm -f Makefile grammar.y config.cache config.log config.status \ + config.h config.h.in~ configure~ configure.ac~ \ + gnuc.h net os-proto.h libpcap.pc pcap-config stamp-h stamp-h.in rm -f $(MAN3PCAP_EXPAND:.in=) $(MANFILE:.in=) $(MANMISC:.in=) rm -rf autom4te.cache - cd rpcapd; $(MAKE) distclean - cd testprogs; $(MAKE) distclean + (cd rpcapd; $(MAKE) distclean) + (cd testprogs; $(MAKE) distclean) extags: $(TAGFILES) ctags $(TAGFILES) @@ -760,15 +823,21 @@ tags: $(TAGFILES) ctags -wtd $(TAGFILES) releasetar: - @cwd=`pwd` ; dir=`basename $$cwd` ; name=$(PROG)-`cat VERSION` ; \ - mkdir $$name; \ - tar -c --exclude='*~' -f - $(CSRC) $(HDR) $(MAN1) $(MAN3PCAP_EXPAND) \ - $(MAN3PCAP_NOEXPAND) $(MANFILE) $(MANMISC) $(EXTRA_DIST) | \ - (cd $$name; tar xf -); \ - tar -c -z -f $$name.tar.gz $$name; \ - rm -rf $$name - -depend: $(GENSRC) $(GENHDR) - $(MKDEP) -c "$(CC)" -m "$(DEPENDENCY_CFLAG)" $(CFLAGS) $(DEFS) $(INCLS) $(SRC) - cd rpcapd; $(MAKE) depend - cd testprogs; $(MAKE) depend + @TAG=$(PROG)-`cat VERSION` && \ + if git show-ref --tags --quiet --verify -- "refs/tags/$$TAG"; then \ + git archive --prefix="$$TAG"/ -o "$$TAG".tar.gz "$$TAG" \ + $(RELEASE_FILES) && \ + echo "Archive build from tag $$TAG."; \ + else \ + git archive --prefix="$$TAG"/ -o "$$TAG".tar.gz HEAD \ + $(RELEASE_FILES) && \ + echo "No $$TAG tag. Archive build from HEAD."; \ + fi + +depend: $(GENERATED_C_SRC) $(GENHDR) + $(MKDEP) -c "$(CC)" -m "$(DEPENDENCY_CFLAG)" -s "$(srcdir)" $(CFLAGS) $(DEFS) $(INCLS) $(SRC) + (cd rpcapd; $(MAKE) depend) + (cd testprogs; $(MAKE) depend) + +shellcheck: + shellcheck -f gcc -e SC2006 build.sh build_matrix.sh build_common.sh diff --git a/contrib/libpcap/README.md b/contrib/libpcap/README.md index 78cc3c4b41b5..46c33c24125e 100644 --- a/contrib/libpcap/README.md +++ b/contrib/libpcap/README.md @@ -1,22 +1,17 @@ -To report a security issue please send an e-mail to security@tcpdump.org. +# LIBPCAP 1.x.y by [The Tcpdump Group](https://www.tcpdump.org) -To report bugs and other problems, contribute patches, request a -feature, provide generic feedback etc please see the file -[CONTRIBUTING](CONTRIBUTING.md) in the libpcap source tree root. +**To report a security issue please send an e-mail to security@tcpdump.org.** -The directory doc/ has README files about specific operating systems and -options. +To report bugs and other problems, contribute patches, request a +feature, provide generic feedback etc please see the +[guidelines for contributing](CONTRIBUTING.md). -LIBPCAP 1.x.y -Now maintained by "The Tcpdump Group" -https://www.tcpdump.org +The [documentation directory](doc/) has README files about specific +operating systems and options. Anonymous Git is available via: - https://github.com/the-tcpdump-group/libpcap.git -formerly from Lawrence Berkeley National Laboratory - Network Research Group <libpcap@ee.lbl.gov> - ftp://ftp.ee.lbl.gov/old/libpcap-0.4a7.tar.Z + https://github.com/the-tcpdump-group/libpcap.git This directory contains source code for libpcap, a system-independent interface for user-level packet capture. libpcap provides a portable @@ -28,7 +23,14 @@ require this functionality, we've created this system-independent API to ease in porting and to alleviate the need for several system-dependent packet capture modules in each application. -For some platforms there are README.{system} files that discuss issues +```text +formerly from Lawrence Berkeley National Laboratory + Network Research Group <libpcap@ee.lbl.gov> + ftp://ftp.ee.lbl.gov/old/libpcap-0.4a7.tar.Z +``` + +### Support for particular platforms and BPF +For some platforms there are `README.{system}` files that discuss issues with the OS's interface for packet capture on those platforms, such as how to enable support for that interface in the OS, if it's not built in by default. @@ -36,22 +38,10 @@ by default. The libpcap interface supports a filtering mechanism based on the architecture in the BSD packet filter. BPF is described in the 1993 Winter Usenix paper ``The BSD Packet Filter: A New Architecture for -User-level Packet Capture''. A compressed PostScript version can be -found at - - ftp://ftp.ee.lbl.gov/papers/bpf-usenix93.ps.Z - -or - - https://www.tcpdump.org/papers/bpf-usenix93.ps.Z - -and a gzipped version can be found at - - https://www.tcpdump.org/papers/bpf-usenix93.ps.gz - -A PDF version can be found at - - https://www.tcpdump.org/papers/bpf-usenix93.pdf +User-level Packet Capture'' +([compressed PostScript](https://www.tcpdump.org/papers/bpf-usenix93.ps.Z), +[gzipped PostScript](https://www.tcpdump.org/papers/bpf-usenix93.ps.gz), +[PDF](https://www.tcpdump.org/papers/bpf-usenix93.pdf)). Although most packet capture interfaces support in-kernel filtering, libpcap utilizes in-kernel filtering only for the BPF interface. @@ -62,32 +52,25 @@ would translate BPF filters into a filter program that is compatible with the underlying kernel subsystem, but this is not yet implemented. BPF is standard in 4.4BSD, BSD/OS, NetBSD, FreeBSD, OpenBSD, DragonFly -BSD, and macOS; an older, modified and undocumented version is standard -in AIX. {DEC OSF/1, Digital UNIX, Tru64 UNIX} uses the packetfilter -interface but has been extended to accept BPF filters (which libpcap -utilizes). Also, you can add BPF filter support to Ultrix using the -kernel source and/or object patches available in: - - https://www.tcpdump.org/other/bpfext42.tar.Z +BSD, macOS, and Solaris 11; an older, modified and undocumented version +is standard in AIX. {DEC OSF/1, Digital UNIX, Tru64 UNIX} uses the +packetfilter interface but has been extended to accept BPF filters +(which libpcap utilizes). Linux has a number of BPF based systems, and libpcap does not support any of the eBPF mechanisms as yet, although it supports many of the memory mapped receive mechanisms. -See the [README.linux](doc/README.linux.md) file for more information. +See the [Linux-specific README](doc/README.linux) for more information. -Note to Linux distributions and *BSD systems that include libpcap: +### Note to Linux distributions and *BSD systems that include libpcap: There's now a rule to make a shared library, which should work on Linux and *BSD, among other platforms. -It sets the soname of the library to "libpcap.so.1"; this is what it -should be, *NOT* libpcap.so.1.x or libpcap.so.1.x.y or something such as +It sets the soname of the library to `libpcap.so.1`; this is what it +should be, **NOT** `libpcap.so.1.x` or `libpcap.so.1.x.y` or something such as that. We've been maintaining binary compatibility between libpcap releases for quite a while; there's no reason to tie a binary linked with libpcap to a particular release of libpcap. - -Current versions can be found at https://www.tcpdump.org. - - - The TCPdump group diff --git a/contrib/libpcap/TODO b/contrib/libpcap/TODO index aae24c22d251..65e166b60bc1 100644 --- a/contrib/libpcap/TODO +++ b/contrib/libpcap/TODO @@ -31,5 +31,3 @@ Less urgent items + too many functions. There are a lot of functions for everything which violates the KISS principle. Why do we need pcap_strerror, pcap_perror and pcap_geterr? - + the manpage has a brief description of each function but where is the - big picture? Seems like you need to buy UNP for that... diff --git a/contrib/libpcap/VERSION b/contrib/libpcap/VERSION index 9ab8337f3962..587c5f0c7309 100644 --- a/contrib/libpcap/VERSION +++ b/contrib/libpcap/VERSION @@ -1 +1 @@ -1.9.1 +1.10.3 diff --git a/contrib/libpcap/Win32/Prj/wpcap.sln b/contrib/libpcap/Win32/Prj/wpcap.sln deleted file mode 100644 index 5a9fce98ee35..000000000000 --- a/contrib/libpcap/Win32/Prj/wpcap.sln +++ /dev/null @@ -1,28 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wpcap", "wpcap.vcxproj", "{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|Win32.ActiveCfg = Debug|Win32 - {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|Win32.Build.0 = Debug|Win32 - {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|x64.ActiveCfg = Debug|x64 - {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Debug|x64.Build.0 = Debug|x64 - {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|Win32.ActiveCfg = Release|Win32 - {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|Win32.Build.0 = Release|Win32 - {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|x64.ActiveCfg = Release|x64 - {8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/contrib/libpcap/Win32/Prj/wpcap.vcxproj b/contrib/libpcap/Win32/Prj/wpcap.vcxproj deleted file mode 100644 index 43b7099b7707..000000000000 --- a/contrib/libpcap/Win32/Prj/wpcap.vcxproj +++ /dev/null @@ -1,233 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|Win32"> - <Configuration>Debug</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Debug|x64"> - <Configuration>Debug</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|Win32"> - <Configuration>Release</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|x64"> - <Configuration>Release</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - </ItemGroup> - <PropertyGroup Label="Globals"> - <SccProjectName /> - <SccLocalPath /> - <ProjectGuid>{8E92D840-6A36-452A-A13C-6E1BA5A2C5A9}</ProjectGuid> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <PlatformToolset>v120</PlatformToolset> - <UseOfMfc>false</UseOfMfc> - <CharacterSet>MultiByte</CharacterSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <PlatformToolset>v120</PlatformToolset> - <UseOfMfc>false</UseOfMfc> - <CharacterSet>MultiByte</CharacterSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <PlatformToolset>v120</PlatformToolset> - <UseOfMfc>false</UseOfMfc> - <CharacterSet>MultiByte</CharacterSet> - <WholeProgramOptimization>true</WholeProgramOptimization> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <PlatformToolset>v120</PlatformToolset> - <UseOfMfc>false</UseOfMfc> - <CharacterSet>MultiByte</CharacterSet> - <WholeProgramOptimization>true</WholeProgramOptimization> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> - <ImportGroup Label="ExtensionSettings"> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - <Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - <Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - <Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" /> - </ImportGroup> - <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> - <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> - <Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" /> - </ImportGroup> - <PropertyGroup Label="UserMacros" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <OutDir>.\Release\</OutDir> - <IntDir>.\Release\</IntDir> - <LinkIncremental>false</LinkIncremental> - <IncludePath>../../../;$(IncludePath)</IncludePath> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <LinkIncremental>false</LinkIncremental> - <IncludePath>../../../;$(IncludePath)</IncludePath> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <OutDir>.\Debug\</OutDir> - <IntDir>.\Debug\</IntDir> - <LinkIncremental>true</LinkIncremental> - <IncludePath>../../../;$(IncludePath)</IncludePath> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <LinkIncremental>true</LinkIncremental> - <IncludePath>../../../;$(IncludePath)</IncludePath> - </PropertyGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <RuntimeLibrary>MultiThreaded</RuntimeLibrary> - <InlineFunctionExpansion>Default</InlineFunctionExpansion> - <StringPooling>true</StringPooling> - <FunctionLevelLinking>true</FunctionLevelLinking> - <Optimization>MaxSpeed</Optimization> - <SuppressStartupBanner>true</SuppressStartupBanner> - <WarningLevel>Level3</WarningLevel> - <AdditionalIncludeDirectories>../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;NDEBUG;YY_NEVER_INTERACTIVE;_USRDLL;pcap_EXPORTS;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;ENABLE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions)</PreprocessorDefinitions> - </ClCompile> - <ResourceCompile> - <Culture>0x0409</Culture> - <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> - </ResourceCompile> - <Link> - <AdditionalDependencies>ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies)</AdditionalDependencies> - </Link> - <PreBuildEvent> - <Command>call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h -win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l -win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Command> - </PreBuildEvent> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <ClCompile> - <RuntimeLibrary>MultiThreaded</RuntimeLibrary> - <InlineFunctionExpansion>Default</InlineFunctionExpansion> - <StringPooling>true</StringPooling> - <FunctionLevelLinking>true</FunctionLevelLinking> - <Optimization>MaxSpeed</Optimization> - <SuppressStartupBanner>true</SuppressStartupBanner> - <WarningLevel>Level3</WarningLevel> - <AdditionalIncludeDirectories>../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;NDEBUG;YY_NEVER_INTERACTIVE;_USRDLL;pcap_EXPORTS;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;ENABLE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions)</PreprocessorDefinitions> - </ClCompile> - <ResourceCompile> - <Culture>0x0409</Culture> - <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> - </ResourceCompile> - <Link> - <AdditionalDependencies>ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\x64\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies)</AdditionalDependencies> - </Link> - <PreBuildEvent> - <Command>call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h -win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l -win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Command> - </PreBuildEvent> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <ClCompile> - <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> - <InlineFunctionExpansion>Default</InlineFunctionExpansion> - <FunctionLevelLinking>false</FunctionLevelLinking> - <Optimization>Disabled</Optimization> - <SuppressStartupBanner>true</SuppressStartupBanner> - <WarningLevel>Level3</WarningLevel> - <MinimalRebuild>true</MinimalRebuild> - <DebugInformationFormat>EditAndContinue</DebugInformationFormat> - <AdditionalIncludeDirectories>../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;_DEBUG;YY_NEVER_INTERACTIVE;_USRDLL;pcap_EXPORTS;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;ENABLE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> - </ClCompile> - <ResourceCompile> - <Culture>0x0409</Culture> - <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> - </ResourceCompile> - <Link> - <AdditionalDependencies>ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies)</AdditionalDependencies> - </Link> - <PreBuildEvent> - <Command>call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h -win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l -win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Command> - </PreBuildEvent> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <ClCompile> - <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> - <InlineFunctionExpansion>Default</InlineFunctionExpansion> - <FunctionLevelLinking>false</FunctionLevelLinking> - <Optimization>Disabled</Optimization> - <SuppressStartupBanner>true</SuppressStartupBanner> - <WarningLevel>Level3</WarningLevel> - <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> - <AdditionalIncludeDirectories>../../;../../lbl/;../../bpf/;../include/;../../../../common;../../../../dag/include;../../../../dag/drv/windows;../../../Win32-Extensions;./;Win32-Extensions;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <PreprocessorDefinitions>HAVE_VERSION_H;__STDC_VERSION__=199901L;HAVE_PACKET_IS_LOOPBACK_ADAPTER;_DEBUG;YY_NEVER_INTERACTIVE;_USRDLL;pcap_EXPORTS;HAVE_STRERROR;__STDC__;INET6;_WINDOWS;ENABLE_REMOTE;WIN32;_U_=;YY_NO_UNISTD_H;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> - </ClCompile> - <ResourceCompile> - <Culture>0x0409</Culture> - <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> - </ResourceCompile> - <Link> - <AdditionalDependencies>ws2_32.lib;..\..\..\..\packetWin7\Dll\Project\x64\Release No NetMon and AirPcap\Packet.lib;%(AdditionalDependencies)</AdditionalDependencies> - </Link> - <PreBuildEvent> - <Command>call ..\..\GenVersion.bat ..\..\VERSION ..\..\pcap_version.h.in ..\..\pcap_version.h -win_flex -Ppcap_ -7 --outfile=..\..\scanner.c --header-file=..\..\scanner.h ..\..\scanner.l -win_bison -ppcap_ --yacc --output=..\..\grammar.c --defines ..\..\grammar.y</Command> - </PreBuildEvent> - </ItemDefinitionGroup> - <ItemGroup> - <ClCompile Include="..\..\bpf\net\bpf_filter.c" /> - <ClCompile Include="..\..\bpf_dump.c" /> - <ClCompile Include="..\..\bpf_image.c" /> - <ClCompile Include="..\..\etherent.c" /> - <ClCompile Include="..\..\gencode.c" /> - <ClCompile Include="..\..\grammar.c" /> - <ClCompile Include="..\..\inet.c" /> - <ClCompile Include="..\..\missing\win_snprintf.c" /> - <ClCompile Include="..\..\nametoaddr.c" /> - <ClCompile Include="..\..\optimize.c" /> - <ClCompile Include="..\..\pcap-common.c" /> - <ClCompile Include="..\..\pcap-new.c" /> - <ClCompile Include="..\..\pcap-rpcap.c" /> - <ClCompile Include="..\..\pcap-win32.c" /> - <ClCompile Include="..\..\pcap.c" /> - <ClCompile Include="..\..\savefile.c" /> - <ClCompile Include="..\..\scanner.c" /> - <ClCompile Include="..\..\sf-pcapng.c" /> - <ClCompile Include="..\..\sf-pcap.c" /> - <ClCompile Include="..\..\sockutils.c" /> - </ItemGroup> - <ItemGroup> - <ClInclude Include="..\..\pcap-common.h" /> - <ClInclude Include="..\..\pcap-int.h" /> - <ClInclude Include="..\..\pcap-rpcap.h" /> - <ClInclude Include="..\..\pcap-stdinc.h" /> - <ClInclude Include="..\..\pcap.h" /> - <ClInclude Include="..\..\remote-ext.h" /> - <ClInclude Include="..\..\sockutils.h" /> - </ItemGroup> - <ItemGroup> - <ResourceCompile Include="..\..\..\Win32-Extensions\version.rc" /> - </ItemGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> - <ImportGroup Label="ExtensionTargets"> - </ImportGroup> -</Project> diff --git a/contrib/libpcap/Win32/Prj/wpcap.vcxproj.filters b/contrib/libpcap/Win32/Prj/wpcap.vcxproj.filters deleted file mode 100644 index 6e06ccbce11d..000000000000 --- a/contrib/libpcap/Win32/Prj/wpcap.vcxproj.filters +++ /dev/null @@ -1,107 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup> - <ClCompile Include="..\..\bpf_dump.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\..\bpf\net\bpf_filter.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\..\bpf_image.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\..\etherent.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\..\gencode.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\..\grammar.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\..\inet.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\..\nametoaddr.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\..\optimize.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\..\pcap.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\..\pcap-win32.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\..\savefile.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\..\scanner.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\..\sf-pcap.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\..\sf-pcapng.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\..\pcap-common.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\..\fad-helpers.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\..\missing\win_snprintf.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\..\pcap-new.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\..\pcap-rpcap.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="..\..\sockutils.c"> - <Filter>Source Files</Filter> - </ClCompile> - </ItemGroup> - <ItemGroup> - <Filter Include="Header Files"> - <UniqueIdentifier>{c51dce5e-0da9-4e33-a235-d5c76c76485c}</UniqueIdentifier> - </Filter> - <Filter Include="Source Files"> - <UniqueIdentifier>{5ec9fd4b-10b5-4527-b249-56b53d844fb1}</UniqueIdentifier> - </Filter> - <Filter Include="Resource Files"> - <UniqueIdentifier>{c90886f0-8973-436b-a7a1-b9e881544f9a}</UniqueIdentifier> - </Filter> - </ItemGroup> - <ItemGroup> - <ClInclude Include="..\..\pcap-stdinc.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="..\..\pcap-common.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="..\..\pcap.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="..\..\pcap-int.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="..\..\pcap-rpcap.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="..\..\remote-ext.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="..\..\sockutils.h"> - <Filter>Header Files</Filter> - </ClInclude> - </ItemGroup> - <ItemGroup> - <ResourceCompile Include="..\..\..\Win32-Extensions\version.rc"> - <Filter>Resource Files</Filter> - </ResourceCompile> - </ItemGroup> -</Project> diff --git a/contrib/libpcap/aclocal.m4 b/contrib/libpcap/aclocal.m4 index aa91e846ed6b..502a3711f677 100644 --- a/contrib/libpcap/aclocal.m4 +++ b/contrib/libpcap/aclocal.m4 @@ -232,34 +232,27 @@ AC_DEFUN(AC_LBL_C_INIT, ]) dnl -dnl Check whether, if you pass an unknown warning option to the -dnl compiler, it fails or just prints a warning message and succeeds. -dnl Set ac_lbl_unknown_warning_option_error to the appropriate flag -dnl to force an error if it would otherwise just print a warning message -dnl and succeed. +dnl Save the values of various variables that affect compilation and +dnl linking, and that we don't ourselves modify persistently; done +dnl before a test involving compiling or linking is done, so that we +dnl can restore those variables after the test is done. dnl -AC_DEFUN(AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR, - [ - AC_MSG_CHECKING([whether the compiler fails when given an unknown warning option]) +AC_DEFUN(AC_LBL_SAVE_CHECK_STATE, +[ save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy" - AC_TRY_COMPILE( - [], - [return 0], - [ - AC_MSG_RESULT([no]) - # - # We're assuming this is clang, where - # -Werror=unknown-warning-option is the appropriate - # option to force the compiler to fail. - # - ac_lbl_unknown_warning_option_error="-Werror=unknown-warning-option" - ], - [ - AC_MSG_RESULT([yes]) - ]) + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" +]) + +dnl +dnl Restore the values of variables saved by AC_LBL_SAVE_CHECK_STATE. +dnl +AC_DEFUN(AC_LBL_RESTORE_CHECK_STATE, +[ CFLAGS="$save_CFLAGS" - ]) + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" +]) dnl dnl Check whether the compiler option specified as the second argument @@ -271,28 +264,42 @@ dnl with the flag in question, and the "treat warnings as errors" flag dnl set, and don't add the flag to the first argument if the compile dnl fails; this is for warning options cause problems that can't be dnl worked around. If a third argument is supplied, a fourth argument -dnl should also be supplied; it's a message desribing what the test +dnl should also be supplied; it's a message describing what the test dnl program is checking. dnl AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT, [ AC_MSG_CHECKING([whether the compiler supports the $2 option]) save_CFLAGS="$CFLAGS" - if expr "x$2" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error $2" - elif expr "x$2" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror $2" - elif expr "x$2" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror $2" - else - CFLAGS="$CFLAGS $2" - fi - AC_TRY_COMPILE( - [], - [return 0], + CFLAGS="$CFLAGS $2" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([[int main(void) { return 0; }]])], [ AC_MSG_RESULT([yes]) can_add_to_cflags=yes @@ -332,6 +339,7 @@ AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT, AC_MSG_RESULT([no]) CFLAGS="$save_CFLAGS" ]) + ac_c_werror_flag="$save_ac_c_werror_flag" ]) dnl @@ -425,14 +433,14 @@ AC_DEFUN(AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT, if AC_RUN_LOG([eval "$CC $ac_lbl_dependency_flag conftest.c >/dev/null 2>&1"]); then AC_MSG_RESULT([yes, with $ac_lbl_dependency_flag]) DEPENDENCY_CFLAG="$ac_lbl_dependency_flag" - MKDEP='${srcdir}/mkdep' + MKDEP='${top_srcdir}/mkdep' else AC_MSG_RESULT([no]) # # We can't run mkdep, so have "make depend" do # nothing. # - MKDEP='${srcdir}/nomkdep' + MKDEP='${top_srcdir}/nomkdep' fi rm -rf conftest* else @@ -441,7 +449,7 @@ AC_DEFUN(AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT, # We can't run mkdep, so have "make depend" do # nothing. # - MKDEP='${srcdir}/nomkdep' + MKDEP='${top_srcdir}/nomkdep' fi AC_SUBST(DEPENDENCY_CFLAG) AC_SUBST(MKDEP) @@ -460,7 +468,6 @@ dnl V_SHLIB_CCOPT (modified to build position-independent code) dnl V_SHLIB_CMD dnl V_SHLIB_OPT dnl V_SONAME_OPT -dnl V_RPATH_OPT dnl AC_DEFUN(AC_LBL_SHLIBS_INIT, [AC_PREREQ(2.50) @@ -484,11 +491,12 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, aix*) ;; - freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*|midipix*) - # - # Platforms where the linker is the GNU linker - # or accepts command-line arguments like - # those the GNU linker accepts. + freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*|haiku*|midipix*) + # + # Platforms where the C compiler is GCC or accepts + # compatible command-line arguments, and the linker + # is the GNU linker or accepts compatible command-line + # arguments. # # Some instruction sets require -fPIC on some # operating systems. Check for them. If you @@ -509,12 +517,11 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, esac V_SHLIB_CCOPT="$V_SHLIB_CCOPT $PIC_OPT" V_SONAME_OPT="-Wl,-soname," - V_RPATH_OPT="-Wl,-rpath," ;; hpux*) V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic" - # + # # XXX - this assumes GCC is using the HP linker, # rather than the GNU linker, and that the "+h" # option is used on all HP-UX platforms, both .sl @@ -522,7 +529,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, # V_SONAME_OPT="-Wl,+h," # - # By default, directories specifed with -L + # By default, directories specified with -L # are added to the run-time search path, so # we don't add them in pcap-config. # @@ -531,11 +538,12 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, solaris*) V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic" # - # XXX - this assumes GCC is using the Sun linker, - # rather than the GNU linker. + # Sun/Oracle's C compiler, GCC, and GCC-compatible + # compilers support -Wl,{comma-separated list of options}, + # and we use the C compiler, not ld, for all linking, + # including linking to produce a shared library. # V_SONAME_OPT="-Wl,-h," - V_RPATH_OPT="-Wl,-R," ;; esac else @@ -557,7 +565,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, # "-Wl,-soname,{soname}" option, with the soname part # of the option, while on other platforms the C compiler # driver takes it as a regular option with the soname - # following the option. The same applies to V_RPATH_OPT. + # following the option. # case "$host_os" in @@ -568,13 +576,17 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, freebsd*|netbsd*|openbsd*|dragonfly*|linux*) # - # "cc" is GCC. + # Platforms where the C compiler is GCC or accepts + # compatible command-line arguments, and the linker + # is the GNU linker or accepts compatible command-line + # arguments. + # + # XXX - does 64-bit SPARC require -fPIC? # V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic" V_SHLIB_CMD="\$(CC)" V_SHLIB_OPT="-shared" V_SONAME_OPT="-Wl,-soname," - V_RPATH_OPT="-Wl,-rpath," ;; hpux*) @@ -583,29 +595,33 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT, V_SHLIB_OPT="-b" V_SONAME_OPT="+h " # - # By default, directories specifed with -L + # By default, directories specified with -L # are added to the run-time search path, so # we don't add them in pcap-config. # ;; osf*) - # + # # Presumed to be DEC OSF/1, Digital UNIX, or # Tru64 UNIX. # V_SHLIB_CMD="\$(CC)" V_SHLIB_OPT="-shared" V_SONAME_OPT="-soname " - V_RPATH_OPT="-rpath " ;; solaris*) V_SHLIB_CCOPT="$V_SHLIB_CCOPT -Kpic" V_SHLIB_CMD="\$(CC)" V_SHLIB_OPT="-G" - V_SONAME_OPT="-h " - V_RPATH_OPT="-R" + # + # Sun/Oracle's C compiler, GCC, and GCC-compatible + # compilers support -Wl,{comma-separated list of options}, + # and we use the C compiler, not ld, for all linking, + # including linking to produce a shared library. + # + V_SONAME_OPT="-Wl,-h," ;; esac fi @@ -662,6 +678,46 @@ AC_DEFUN(AC_LBL_C_INLINE, fi AC_DEFINE_UNQUOTED(inline, $ac_cv_lbl_inline, [Define as token for inline if inlining supported])]) +# +# Test whether we have __atomic_load_n() and __atomic_store_n(). +# +# We use AC_TRY_LINK because AC_TRY_COMPILE will succeed, as the +# compiler will just think that those functions are undefined, +# and perhaps warn about that, but not fail to compile. +# +AC_DEFUN(AC_PCAP_C___ATOMICS, + [ + AC_MSG_CHECKING(for __atomic_load_n) + AC_CACHE_VAL(ac_cv_have___atomic_load_n, + AC_TRY_LINK([], + [ + int i = 17; + int j; + j = __atomic_load_n(&i, __ATOMIC_RELAXED); + ], + ac_have___atomic_load_n=yes, + ac_have___atomic_load_n=no)) + AC_MSG_RESULT($ac_have___atomic_load_n) + if test $ac_have___atomic_load_n = yes ; then + AC_DEFINE(HAVE___ATOMIC_LOAD_N, 1, + [define if __atomic_load_n is supported by the compiler]) + fi + + AC_MSG_CHECKING(for __atomic_store_n) + AC_CACHE_VAL(ac_cv_have___atomic_store_n, + AC_TRY_LINK([], + [ + int i; + __atomic_store_n(&i, 17, __ATOMIC_RELAXED); + ], + ac_have___atomic_store_n=yes, + ac_have___atomic_store_n=no)) + AC_MSG_RESULT($ac_have___atomic_store_n) + if test $ac_have___atomic_store_n = yes ; then + AC_DEFINE(HAVE___ATOMIC_STORE_N, 1, + [define if __atomic_store_n is supported by the compiler]) + fi]) + dnl dnl If using gcc, make sure we have ANSI ioctl definitions dnl @@ -753,106 +809,6 @@ AC_DEFUN(AC_LBL_HAVE_RUN_PATH, ]) dnl -dnl Checks to see if unaligned memory accesses fail -dnl -dnl usage: -dnl -dnl AC_LBL_UNALIGNED_ACCESS -dnl -dnl results: -dnl -dnl LBL_ALIGN (DEFINED) -dnl -AC_DEFUN(AC_LBL_UNALIGNED_ACCESS, - [AC_MSG_CHECKING(if unaligned accesses fail) - AC_CACHE_VAL(ac_cv_lbl_unaligned_fail, - [case "$host_cpu" in - - # - # These are CPU types where: - # - # the CPU faults on an unaligned access, but at least some - # OSes that support that CPU catch the fault and simulate - # the unaligned access (e.g., Alpha/{Digital,Tru64} UNIX) - - # the simulation is slow, so we don't want to use it; - # - # the CPU, I infer (from the old - # - # XXX: should also check that they don't do weird things (like on arm) - # - # comment) doesn't fault on unaligned accesses, but doesn't - # do a normal unaligned fetch, either (e.g., presumably, ARM); - # - # for whatever reason, the test program doesn't work - # (this has been claimed to be the case for several of those - # CPUs - I don't know what the problem is; the problem - # was reported as "the test program dumps core" for SuperH, - # but that's what the test program is *supposed* to do - - # it dumps core before it writes anything, so the test - # for an empty output file should find an empty output - # file and conclude that unaligned accesses don't work). - # - # This run-time test won't work if you're cross-compiling, so - # in order to support cross-compiling for a particular CPU, - # we have to wire in the list of CPU types anyway, as far as - # I know, so perhaps we should just have a set of CPUs on - # which we know it doesn't work, a set of CPUs on which we - # know it does work, and have the script just fail on other - # cpu types and update it when such a failure occurs. - # - alpha*|arm*|bfin*|hp*|mips*|sh*|sparc*|ia64|nv1) - ac_cv_lbl_unaligned_fail=yes - ;; - - *) - cat >conftest.c <<EOF -# include <sys/types.h> -# include <sys/wait.h> -# include <stdio.h> - unsigned char a[[5]] = { 1, 2, 3, 4, 5 }; - main() { - unsigned int i; - pid_t pid; - int status; - /* avoid "core dumped" message */ - pid = fork(); - if (pid < 0) - exit(2); - if (pid > 0) { - /* parent */ - pid = waitpid(pid, &status, 0); - if (pid < 0) - exit(3); - exit(!WIFEXITED(status)); - } - /* child */ - i = *(unsigned int *)&a[[1]]; - printf("%d\n", i); - exit(0); - } -EOF - ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \ - conftest.c $LIBS >/dev/null 2>&1 - if test ! -x conftest ; then - dnl failed to compile for some reason - ac_cv_lbl_unaligned_fail=yes - else - ./conftest >conftest.out - if test ! -s conftest.out ; then - ac_cv_lbl_unaligned_fail=yes - else - ac_cv_lbl_unaligned_fail=no - fi - fi - rm -f -r conftest* core core.conftest - ;; - esac]) - AC_MSG_RESULT($ac_cv_lbl_unaligned_fail) - if test $ac_cv_lbl_unaligned_fail = yes ; then - AC_DEFINE(LBL_ALIGN,1,[if unaligned access fails]) - fi]) - -dnl dnl If the file .devel exists: dnl Add some warning flags if the compiler supports them dnl If an os prototype include exists, symlink os-proto.h to it @@ -877,16 +833,16 @@ AC_DEFUN(AC_LBL_DEVEL, # Skip all the warning option stuff on some compilers. # if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then - AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR() AC_LBL_CHECK_COMPILER_OPT($1, -W) AC_LBL_CHECK_COMPILER_OPT($1, -Wall) AC_LBL_CHECK_COMPILER_OPT($1, -Wcomma) - AC_LBL_CHECK_COMPILER_OPT($1, -Wdeclaration-after-statement) AC_LBL_CHECK_COMPILER_OPT($1, -Wdocumentation) AC_LBL_CHECK_COMPILER_OPT($1, -Wformat-nonliteral) AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-noreturn) AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-prototypes) AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-variable-declarations) + AC_LBL_CHECK_COMPILER_OPT($1, -Wpointer-arith) + AC_LBL_CHECK_COMPILER_OPT($1, -Wpointer-sign) AC_LBL_CHECK_COMPILER_OPT($1, -Wshadow) AC_LBL_CHECK_COMPILER_OPT($1, -Wsign-compare) AC_LBL_CHECK_COMPILER_OPT($1, -Wstrict-prototypes) @@ -930,6 +886,7 @@ testme(unsigned short a) } ], [generates warnings from ntohs()]) + AC_LBL_CHECK_COMPILER_OPT($1, -Wshorten-64-to-32) fi AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT() # @@ -1057,9 +1014,22 @@ AC_DEFUN(AC_LBL_LIBRARY_NET, [ ], [ # - # We didn't find it. + # Not found in libsocket; test for it in libnetwork, which + # is where it is in Haiku. # - AC_MSG_ERROR([getaddrinfo is required, but wasn't found]) + AC_CHECK_LIB(network, getaddrinfo, + [ + # + # OK, we found it in libnetwork. + # + LIBS="-lnetwork $LIBS" + ], + [ + # + # We didn't find it. + # + AC_MSG_ERROR([getaddrinfo is required, but wasn't found]) + ]) ], -lnsl) # @@ -1077,3 +1047,282 @@ AC_DEFUN(AC_LBL_LIBRARY_NET, [ # DLPI needs putmsg under HPUX so test for -lstr while we're at it AC_SEARCH_LIBS(putmsg, str) ]) + +m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) +dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +dnl serial 11 (pkg-config-0.29) +dnl +dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>. +dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com> +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +dnl 02111-1307, USA. +dnl +dnl As a special exception to the GNU General Public License, if you +dnl distribute this file as part of a program that contains a +dnl configuration script generated by Autoconf, you may include it under +dnl the same distribution terms that you use for the rest of that +dnl program. + +dnl PKG_PREREQ(MIN-VERSION) +dnl ----------------------- +dnl Since: 0.29 +dnl +dnl Verify that the version of the pkg-config macros are at least +dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's +dnl installed version of pkg-config, this checks the developer's version +dnl of pkg.m4 when generating configure. +dnl +dnl To ensure that this macro is defined, also add: +dnl m4_ifndef([PKG_PREREQ], +dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])]) +dnl +dnl See the "Since" comment for each macro you use to see what version +dnl of the macros you require. +m4_defun([PKG_PREREQ], +[m4_define([PKG_MACROS_VERSION], [0.29]) +m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1, + [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])]) +])dnl PKG_PREREQ + +dnl PKG_PROG_PKG_CONFIG([MIN-VERSION]) +dnl ---------------------------------- +dnl Since: 0.16 +dnl +dnl Search for the pkg-config tool and set the PKG_CONFIG variable to +dnl first found in the path. Checks that the version of pkg-config found +dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is +dnl used since that's the first version where most current features of +dnl pkg-config existed. +AC_DEFUN([PKG_PROG_PKG_CONFIG], +[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) +m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) +m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) +AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) +AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) + +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=m4_default([$1], [0.9.0]) + AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + PKG_CONFIG="" + fi +fi[]dnl +])dnl PKG_PROG_PKG_CONFIG + +dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ------------------------------------------------------------------- +dnl Since: 0.18 +dnl +dnl Check to see whether a particular set of modules exists. Similar to +dnl PKG_CHECK_MODULES(), but does not set variables or print errors. +AC_DEFUN([PKG_CHECK_EXISTS], +[ +if test -n "$PKG_CONFIG" && \ + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then + m4_default([$2], [:]) +m4_ifvaln([$3], [else + $3])dnl +fi]) + +dnl _PKG_CONFIG([VARIABLE], [FLAGS], [MODULES]) +dnl --------------------------------------------- +dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting +dnl pkg_failed based on the result. +m4_define([_PKG_CONFIG], +[if test -n "$$1"; then + pkg_cv_[]$1="$$1" + elif test -n "$PKG_CONFIG"; then + PKG_CHECK_EXISTS([$3], + [pkg_cv_[]$1=`$PKG_CONFIG $2 "$3" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes ], + [pkg_failed=yes]) + else + pkg_failed=untried +fi[]dnl +])dnl _PKG_CONFIG + +dnl _PKG_SHORT_ERRORS_SUPPORTED +dnl --------------------------- +dnl Internal check to see if pkg-config supports short errors. +AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], +[ +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi[]dnl +])dnl _PKG_SHORT_ERRORS_SUPPORTED + + +dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +dnl [ACTION-IF-NOT-FOUND]) +dnl -------------------------------------------------------------- +dnl Since: 0.4.0 +AC_DEFUN([PKG_CHECK_MODULES], +[ +AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $2, overriding pkg-config])dnl +AC_ARG_VAR([$1][_LIBS], [linker flags for $2, overriding pkg-config])dnl +AC_ARG_VAR([$1][_LIBS_STATIC], [static-link linker flags for $2, overriding pkg-config])dnl + +pkg_failed=no +AC_MSG_CHECKING([for $2 with pkg-config]) +PKG_CHECK_EXISTS($2, + [ + # + # The package was found, so try to get its C flags and + # libraries. + # + _PKG_CONFIG([$1][_CFLAGS], [--cflags], [$2]) + _PKG_CONFIG([$1][_LIBS], [--libs], [$2]) + _PKG_CONFIG([$1][_LIBS_STATIC], [--libs --static], [$2]) + + m4_define([_PKG_TEXT], [ +Alternatively, you may set the environment variables $1[]_CFLAGS +and $1[]_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details.]) + + if test $pkg_failed = yes; then + # + # That failed - report an error. + # + AC_MSG_RESULT([error]) + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` + else + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD + + m4_default([$4], [AC_MSG_ERROR( +[Package requirements ($2) were not met: + +$$1_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +_PKG_TEXT])[]dnl + ]) + elif test $pkg_failed = untried; then + # + # We don't have pkg-config, so it didn't work. + # + AC_MSG_RESULT([not found (pkg-config not found)]) + else + # + # We found the package. + # + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS + $1[]_LIBS_STATIC=$pkg_cv_[]$1[]_LIBS_STATIC + AC_MSG_RESULT([found]) + $3 + fi[]dnl + ], + [ + # + # The package isn't present. + # + AC_MSG_RESULT([not found]) + ]) +])dnl PKG_CHECK_MODULES + + +dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +dnl [ACTION-IF-NOT-FOUND]) +dnl --------------------------------------------------------------------- +dnl Since: 0.29 +dnl +dnl Checks for existence of MODULES and gathers its build flags with +dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags +dnl and VARIABLE-PREFIX_LIBS from --libs. +AC_DEFUN([PKG_CHECK_MODULES_STATIC], +[ +_save_PKG_CONFIG=$PKG_CONFIG +PKG_CONFIG="$PKG_CONFIG --static" +PKG_CHECK_MODULES($@) +PKG_CONFIG=$_save_PKG_CONFIG[]dnl +])dnl PKG_CHECK_MODULES_STATIC + + +dnl PKG_INSTALLDIR([DIRECTORY]) +dnl ------------------------- +dnl Since: 0.27 +dnl +dnl Substitutes the variable pkgconfigdir as the location where a module +dnl should install pkg-config .pc files. By default the directory is +dnl $libdir/pkgconfig, but the default can be changed by passing +dnl DIRECTORY. The user can override through the --with-pkgconfigdir +dnl parameter. +AC_DEFUN([PKG_INSTALLDIR], +[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) +m4_pushdef([pkg_description], + [pkg-config installation directory @<:@]pkg_default[@:>@]) +AC_ARG_WITH([pkgconfigdir], + [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, + [with_pkgconfigdir=]pkg_default) +AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) +m4_popdef([pkg_default]) +m4_popdef([pkg_description]) +])dnl PKG_INSTALLDIR + + +dnl PKG_NOARCH_INSTALLDIR([DIRECTORY]) +dnl -------------------------------- +dnl Since: 0.27 +dnl +dnl Substitutes the variable noarch_pkgconfigdir as the location where a +dnl module should install arch-independent pkg-config .pc files. By +dnl default the directory is $datadir/pkgconfig, but the default can be +dnl changed by passing DIRECTORY. The user can override through the +dnl --with-noarch-pkgconfigdir parameter. +AC_DEFUN([PKG_NOARCH_INSTALLDIR], +[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) +m4_pushdef([pkg_description], + [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) +AC_ARG_WITH([noarch-pkgconfigdir], + [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, + [with_noarch_pkgconfigdir=]pkg_default) +AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) +m4_popdef([pkg_default]) +m4_popdef([pkg_description]) +])dnl PKG_NOARCH_INSTALLDIR + + +dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, +dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ------------------------------------------- +dnl Since: 0.28 +dnl +dnl Retrieves the value of the pkg-config variable for the given module. +AC_DEFUN([PKG_CHECK_VAR], +[ +AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl + +_PKG_CONFIG([$1], [--variable="][$3]["], [$2]) +AS_VAR_COPY([$1], [pkg_cv_][$1]) + +AS_VAR_IF([$1], [""], [$5], [$4])dnl +])dnl PKG_CHECK_VAR diff --git a/contrib/libpcap/atmuni31.h b/contrib/libpcap/atmuni31.h index 0f85430098ce..7d4f270be9d0 100644 --- a/contrib/libpcap/atmuni31.h +++ b/contrib/libpcap/atmuni31.h @@ -76,7 +76,7 @@ #define PROTO_POS 0 /* offset of protocol discriminator */ #define CALL_REF_POS 2 /* offset of call reference value */ #define MSG_TYPE_POS 5 /* offset of message type */ -#define MSG_LEN_POS 7 /* offset of mesage length */ +#define MSG_LEN_POS 7 /* offset of message length */ #define IE_BEGIN_POS 9 /* offset of first information element */ /* format of signalling messages */ diff --git a/contrib/libpcap/bpf_filter.c b/contrib/libpcap/bpf_filter.c index 33872ff4bbda..8691d0d1a882 100644 --- a/contrib/libpcap/bpf_filter.c +++ b/contrib/libpcap/bpf_filter.c @@ -44,6 +44,11 @@ #include <pcap/pcap-inttypes.h> #include "pcap-types.h" +#include "extract.h" +#include "diag-control.h" + +#define EXTRACT_SHORT EXTRACT_BE_U_2 +#define EXTRACT_LONG EXTRACT_BE_U_4 #ifndef _WIN32 #include <sys/param.h> @@ -55,42 +60,6 @@ #include <stdlib.h> -#define int32 bpf_int32 -#define u_int32 bpf_u_int32 - -#ifndef LBL_ALIGN -/* - * XXX - IA-64? If not, this probably won't work on Win64 IA-64 - * systems, unless LBL_ALIGN is defined elsewhere for them. - * XXX - SuperH? If not, this probably won't work on WinCE SuperH - * systems, unless LBL_ALIGN is defined elsewhere for them. - */ -#if defined(sparc) || defined(__sparc__) || defined(mips) || \ - defined(ibm032) || defined(__alpha) || defined(__hpux) || \ - defined(__arm__) -#define LBL_ALIGN -#endif -#endif - -#ifndef LBL_ALIGN -#ifndef _WIN32 -#include <netinet/in.h> -#endif - -#define EXTRACT_SHORT(p) ((u_short)ntohs(*(u_short *)p)) -#define EXTRACT_LONG(p) (ntohl(*(u_int32 *)p)) -#else -#define EXTRACT_SHORT(p)\ - ((u_short)\ - ((u_short)*((u_char *)p+0)<<8|\ - (u_short)*((u_char *)p+1)<<0)) -#define EXTRACT_LONG(p)\ - ((u_int32)*((u_char *)p+0)<<24|\ - (u_int32)*((u_char *)p+1)<<16|\ - (u_int32)*((u_char *)p+2)<<8|\ - (u_int32)*((u_char *)p+3)<<0) -#endif - #ifdef __linux__ #include <linux/types.h> #include <linux/if_packet.h> @@ -115,13 +84,19 @@ enum { * * Thanks to Ani Sinha <ani@arista.com> for providing initial implementation */ +#if defined(SKF_AD_VLAN_TAG_PRESENT) u_int -bpf_filter_with_aux_data(const struct bpf_insn *pc, const u_char *p, - u_int wirelen, u_int buflen, const struct bpf_aux_data *aux_data) +pcap_filter_with_aux_data(const struct bpf_insn *pc, const u_char *p, + u_int wirelen, u_int buflen, const struct pcap_bpf_aux_data *aux_data) +#else +u_int +pcap_filter_with_aux_data(const struct bpf_insn *pc, const u_char *p, + u_int wirelen, u_int buflen, const struct pcap_bpf_aux_data *aux_data _U_) +#endif { - register u_int32 A, X; + register uint32_t A, X; register bpf_u_int32 k; - u_int32 mem[BPF_MEMWORDS]; + uint32_t mem[BPF_MEMWORDS]; if (pc == 0) /* @@ -160,6 +135,13 @@ bpf_filter_with_aux_data(const struct bpf_insn *pc, const u_char *p, continue; case BPF_LD|BPF_B|BPF_ABS: + /* + * Yes, we know, this switch doesn't do + * anything unless we're building for + * a Linux kernel with removed VLAN + * tags available as meta-data. + */ +DIAG_OFF_DEFAULT_ONLY_SWITCH switch (pc->k) { #if defined(SKF_AD_VLAN_TAG_PRESENT) @@ -183,6 +165,7 @@ bpf_filter_with_aux_data(const struct bpf_insn *pc, const u_char *p, A = p[k]; break; } +DIAG_ON_DEFAULT_ONLY_SWITCH continue; case BPF_LD|BPF_W|BPF_LEN: @@ -405,13 +388,12 @@ bpf_filter_with_aux_data(const struct bpf_insn *pc, const u_char *p, } u_int -bpf_filter(const struct bpf_insn *pc, const u_char *p, u_int wirelen, +pcap_filter(const struct bpf_insn *pc, const u_char *p, u_int wirelen, u_int buflen) { - return bpf_filter_with_aux_data(pc, p, wirelen, buflen, NULL); + return pcap_filter_with_aux_data(pc, p, wirelen, buflen, NULL); } - /* * Return true if the 'fcode' is a valid filter program. * The constraints are that each jump be forward and to a valid @@ -424,7 +406,7 @@ bpf_filter(const struct bpf_insn *pc, const u_char *p, u_int wirelen, * Otherwise, a bogus program could easily crash the system. */ int -bpf_validate(const struct bpf_insn *f, int len) +pcap_validate_filter(const struct bpf_insn *f, int len) { u_int i, from; const struct bpf_insn *p; @@ -546,3 +528,19 @@ bpf_validate(const struct bpf_insn *f, int len) } return BPF_CLASS(f[len - 1].code) == BPF_RET; } + +/* + * Exported because older versions of libpcap exported them. + */ +u_int +bpf_filter(const struct bpf_insn *pc, const u_char *p, u_int wirelen, + u_int buflen) +{ + return pcap_filter(pc, p, wirelen, buflen); +} + +int +bpf_validate(const struct bpf_insn *f, int len) +{ + return pcap_validate_filter(f, len); +} diff --git a/contrib/libpcap/bpf_image.c b/contrib/libpcap/bpf_image.c index ab41d1ef98bd..e48c76d54ed8 100644 --- a/contrib/libpcap/bpf_image.c +++ b/contrib/libpcap/bpf_image.c @@ -28,12 +28,104 @@ #include <stdio.h> #include <string.h> +#ifdef __linux__ +#include <linux/types.h> +#include <linux/if_packet.h> +#include <linux/filter.h> + +/* + * We want our versions of these #defines, not Linux's version. + * (The two should be the same; if not, we have a problem; all BPF + * implementations *should* be source-compatible supersets of ours.) + */ +#undef BPF_STMT +#undef BPF_JUMP +#endif + #include "pcap-int.h" #ifdef HAVE_OS_PROTO_H #include "os-proto.h" #endif +#ifdef SKF_AD_OFF +/* + * Symbolic names for offsets that refer to the special Linux BPF locations. + */ +static const char *offsets[SKF_AD_MAX] = { +#ifdef SKF_AD_PROTOCOL + [SKF_AD_PROTOCOL] = "proto", +#endif +#ifdef SKF_AD_PKTTYPE + [SKF_AD_PKTTYPE] = "type", +#endif +#ifdef SKF_AD_IFINDEX + [SKF_AD_IFINDEX] = "ifidx", +#endif +#ifdef SKF_AD_NLATTR + [SKF_AD_NLATTR] = "nla", +#endif +#ifdef SKF_AD_NLATTR_NEST + [SKF_AD_NLATTR_NEST] = "nlan", +#endif +#ifdef SKF_AD_MARK + [SKF_AD_MARK] = "mark", +#endif +#ifdef SKF_AD_QUEUE + [SKF_AD_QUEUE] = "queue", +#endif +#ifdef SKF_AD_HATYPE + [SKF_AD_HATYPE] = "hatype", +#endif +#ifdef SKF_AD_RXHASH + [SKF_AD_RXHASH] = "rxhash", +#endif +#ifdef SKF_AD_CPU + [SKF_AD_CPU] = "cpu", +#endif +#ifdef SKF_AD_ALU_XOR_X + [SKF_AD_ALU_XOR_X] = "xor_x", +#endif +#ifdef SKF_AD_VLAN_TAG + [SKF_AD_VLAN_TAG] = "vlan_tci", +#endif +#ifdef SKF_AD_VLAN_TAG_PRESENT + [SKF_AD_VLAN_TAG_PRESENT] = "vlanp", +#endif +#ifdef SKF_AD_PAY_OFFSET + [SKF_AD_PAY_OFFSET] = "poff", +#endif +#ifdef SKF_AD_RANDOM + [SKF_AD_RANDOM] = "random", +#endif +#ifdef SKF_AD_VLAN_TPID + [SKF_AD_VLAN_TPID] = "vlan_tpid" +#endif +}; +#endif + +static void +bpf_print_abs_load_operand(char *buf, size_t bufsize, const struct bpf_insn *p) +{ +#ifdef SKF_AD_OFF + const char *sym; + + /* + * It's an absolute load. + * Is the offset a special Linux offset that we know about? + */ + if (p->k >= (bpf_u_int32)SKF_AD_OFF && + p->k < (bpf_u_int32)(SKF_AD_OFF + SKF_AD_MAX) && + (sym = offsets[p->k - (bpf_u_int32)SKF_AD_OFF]) != NULL) { + /* + * Yes. Print the offset symbolically. + */ + (void)snprintf(buf, bufsize, "[%s]", sym); + } else +#endif + (void)snprintf(buf, bufsize, "[%d]", p->k); +} + char * bpf_image(const struct bpf_insn *p, int n) { @@ -46,13 +138,13 @@ bpf_image(const struct bpf_insn *p, int n) default: op = "unimp"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "0x%x", p->code); + (void)snprintf(operand_buf, sizeof operand_buf, "0x%x", p->code); operand = operand_buf; break; case BPF_RET|BPF_K: op = "ret"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); operand = operand_buf; break; @@ -63,19 +155,19 @@ bpf_image(const struct bpf_insn *p, int n) case BPF_LD|BPF_W|BPF_ABS: op = "ld"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "[%d]", p->k); + bpf_print_abs_load_operand(operand_buf, sizeof operand_buf, p); operand = operand_buf; break; case BPF_LD|BPF_H|BPF_ABS: op = "ldh"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "[%d]", p->k); + bpf_print_abs_load_operand(operand_buf, sizeof operand_buf, p); operand = operand_buf; break; case BPF_LD|BPF_B|BPF_ABS: op = "ldb"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "[%d]", p->k); + bpf_print_abs_load_operand(operand_buf, sizeof operand_buf, p); operand = operand_buf; break; @@ -86,91 +178,91 @@ bpf_image(const struct bpf_insn *p, int n) case BPF_LD|BPF_W|BPF_IND: op = "ld"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "[x + %d]", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "[x + %d]", p->k); operand = operand_buf; break; case BPF_LD|BPF_H|BPF_IND: op = "ldh"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "[x + %d]", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "[x + %d]", p->k); operand = operand_buf; break; case BPF_LD|BPF_B|BPF_IND: op = "ldb"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "[x + %d]", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "[x + %d]", p->k); operand = operand_buf; break; case BPF_LD|BPF_IMM: op = "ld"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); operand = operand_buf; break; case BPF_LDX|BPF_IMM: op = "ldx"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); operand = operand_buf; break; case BPF_LDX|BPF_MSH|BPF_B: op = "ldxb"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "4*([%d]&0xf)", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "4*([%d]&0xf)", p->k); operand = operand_buf; break; case BPF_LD|BPF_MEM: op = "ld"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "M[%d]", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "M[%d]", p->k); operand = operand_buf; break; case BPF_LDX|BPF_MEM: op = "ldx"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "M[%d]", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "M[%d]", p->k); operand = operand_buf; break; case BPF_ST: op = "st"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "M[%d]", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "M[%d]", p->k); operand = operand_buf; break; case BPF_STX: op = "stx"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "M[%d]", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "M[%d]", p->k); operand = operand_buf; break; case BPF_JMP|BPF_JA: op = "ja"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "%d", n + 1 + p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "%d", n + 1 + p->k); operand = operand_buf; break; case BPF_JMP|BPF_JGT|BPF_K: op = "jgt"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); operand = operand_buf; break; case BPF_JMP|BPF_JGE|BPF_K: op = "jge"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); operand = operand_buf; break; case BPF_JMP|BPF_JEQ|BPF_K: op = "jeq"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); operand = operand_buf; break; case BPF_JMP|BPF_JSET|BPF_K: op = "jset"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); operand = operand_buf; break; @@ -246,61 +338,61 @@ bpf_image(const struct bpf_insn *p, int n) case BPF_ALU|BPF_ADD|BPF_K: op = "add"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); operand = operand_buf; break; case BPF_ALU|BPF_SUB|BPF_K: op = "sub"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); operand = operand_buf; break; case BPF_ALU|BPF_MUL|BPF_K: op = "mul"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); operand = operand_buf; break; case BPF_ALU|BPF_DIV|BPF_K: op = "div"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); operand = operand_buf; break; case BPF_ALU|BPF_MOD|BPF_K: op = "mod"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); operand = operand_buf; break; case BPF_ALU|BPF_AND|BPF_K: op = "and"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); operand = operand_buf; break; case BPF_ALU|BPF_OR|BPF_K: op = "or"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); operand = operand_buf; break; case BPF_ALU|BPF_XOR|BPF_K: op = "xor"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "#0x%x", p->k); operand = operand_buf; break; case BPF_ALU|BPF_LSH|BPF_K: op = "lsh"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); operand = operand_buf; break; case BPF_ALU|BPF_RSH|BPF_K: op = "rsh"; - (void)pcap_snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); + (void)snprintf(operand_buf, sizeof operand_buf, "#%d", p->k); operand = operand_buf; break; @@ -320,11 +412,11 @@ bpf_image(const struct bpf_insn *p, int n) break; } if (BPF_CLASS(p->code) == BPF_JMP && BPF_OP(p->code) != BPF_JA) { - (void)pcap_snprintf(image, sizeof image, + (void)snprintf(image, sizeof image, "(%03d) %-8s %-16s jt %d\tjf %d", n, op, operand, n + 1 + p->jt, n + 1 + p->jf); } else { - (void)pcap_snprintf(image, sizeof image, + (void)snprintf(image, sizeof image, "(%03d) %-8s %s", n, op, operand); } diff --git a/contrib/libpcap/charconv.c b/contrib/libpcap/charconv.c new file mode 100644 index 000000000000..5f97509ab4e3 --- /dev/null +++ b/contrib/libpcap/charconv.c @@ -0,0 +1,217 @@ +/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef _WIN32 +#include <stdio.h> +#include <errno.h> + +#include <pcap/pcap.h> /* Needed for PCAP_ERRBUF_SIZE */ + +#include "charconv.h" + +wchar_t * +cp_to_utf_16le(UINT codepage, const char *cp_string, DWORD flags) +{ + int utf16le_len; + wchar_t *utf16le_string; + + /* + * Map from the specified code page to UTF-16LE. + * First, find out how big a buffer we'll need. + */ + utf16le_len = MultiByteToWideChar(codepage, flags, cp_string, -1, + NULL, 0); + if (utf16le_len == 0) { + /* + * Error. Fail with EINVAL. + */ + errno = EINVAL; + return (NULL); + } + + /* + * Now attempt to allocate a buffer for that. + */ + utf16le_string = malloc(utf16le_len * sizeof (wchar_t)); + if (utf16le_string == NULL) { + /* + * Not enough memory; assume errno has been + * set, and fail. + */ + return (NULL); + } + + /* + * Now convert. + */ + utf16le_len = MultiByteToWideChar(codepage, flags, cp_string, -1, + utf16le_string, utf16le_len); + if (utf16le_len == 0) { + /* + * Error. Fail with EINVAL. + * XXX - should this ever happen, given that + * we already ran the string through + * MultiByteToWideChar() to find out how big + * a buffer we needed? + */ + free(utf16le_string); + errno = EINVAL; + return (NULL); + } + return (utf16le_string); +} + +char * +utf_16le_to_cp(UINT codepage, const wchar_t *utf16le_string) +{ + int cp_len; + char *cp_string; + + /* + * Map from UTF-16LE to the specified code page. + * First, find out how big a buffer we'll need. + * We convert composite characters to precomposed characters, + * as that's what Windows expects. + */ + cp_len = WideCharToMultiByte(codepage, WC_COMPOSITECHECK, + utf16le_string, -1, NULL, 0, NULL, NULL); + if (cp_len == 0) { + /* + * Error. Fail with EINVAL. + */ + errno = EINVAL; + return (NULL); + } + + /* + * Now attempt to allocate a buffer for that. + */ + cp_string = malloc(cp_len * sizeof (char)); + if (cp_string == NULL) { + /* + * Not enough memory; assume errno has been + * set, and fail. + */ + return (NULL); + } + + /* + * Now convert. + */ + cp_len = WideCharToMultiByte(codepage, WC_COMPOSITECHECK, + utf16le_string, -1, cp_string, cp_len, NULL, NULL); + if (cp_len == 0) { + /* + * Error. Fail with EINVAL. + * XXX - should this ever happen, given that + * we already ran the string through + * WideCharToMultiByte() to find out how big + * a buffer we needed? + */ + free(cp_string); + errno = EINVAL; + return (NULL); + } + return (cp_string); +} + +/* + * Convert an error message string from UTF-8 to the local code page, as + * best we can. + * + * The buffer is assumed to be PCAP_ERRBUF_SIZE bytes long; we truncate + * if it doesn't fit. + */ +void +utf_8_to_acp_truncated(char *errbuf) +{ + wchar_t *utf_16_errbuf; + int retval; + DWORD err; + + /* + * Do this by converting to UTF-16LE and then to the local + * code page. That means we get to use Microsoft's + * conversion routines, rather than having to understand + * all the code pages ourselves, *and* that this routine + * can convert in place. + */ + + /* + * Map from UTF-8 to UTF-16LE. + * First, find out how big a buffer we'll need. + * Convert any invalid characters to REPLACEMENT CHARACTER. + */ + utf_16_errbuf = cp_to_utf_16le(CP_UTF8, errbuf, 0); + if (utf_16_errbuf == NULL) { + /* + * Error. Give up. + */ + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "Can't convert error string to the local code page"); + return; + } + + /* + * Now, convert that to the local code page. + * Use the current thread's code page. For unconvertable + * characters, let it pick the "best fit" character. + * + * XXX - we'd like some way to do what utf_16le_to_utf_8_truncated() + * does if the buffer isn't big enough, but we don't want to have + * to handle all local code pages ourselves; doing so requires + * knowledge of all those code pages, including knowledge of how + * characters are formed in thoe code pages so that we can avoid + * cutting a multi-byte character into pieces. + * + * Converting to an un-truncated string using Windows APIs, and + * then copying to the buffer, still requires knowledge of how + * characters are formed in the target code page. + */ + retval = WideCharToMultiByte(CP_THREAD_ACP, 0, utf_16_errbuf, -1, + errbuf, PCAP_ERRBUF_SIZE, NULL, NULL); + if (retval == 0) { + err = GetLastError(); + free(utf_16_errbuf); + if (err == ERROR_INSUFFICIENT_BUFFER) + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "The error string, in the local code page, didn't fit in the buffer"); + else + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "Can't convert error string to the local code page"); + return; + } + free(utf_16_errbuf); +} +#endif diff --git a/contrib/libpcap/charconv.h b/contrib/libpcap/charconv.h new file mode 100644 index 000000000000..93103d461ef7 --- /dev/null +++ b/contrib/libpcap/charconv.h @@ -0,0 +1,44 @@ +/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */ +/* + * Copyright (c) 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Computer Systems + * Engineering Group at Lawrence Berkeley Laboratory. + * 4. Neither the name of the University nor of the Laboratory may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef charconv_h +#define charconv_h + +#ifdef _WIN32 +extern wchar_t *cp_to_utf_16le(UINT codepage, const char *cp_string, DWORD flags); +extern char *utf_16le_to_cp(UINT codepage, const wchar_t *utf16le_string); +extern void utf_8_to_acp_truncated(char *); +#endif + +#endif /* charconv_h */ diff --git a/contrib/libpcap/cmake/Modules/FindAirPcap.cmake b/contrib/libpcap/cmake/Modules/FindAirPcap.cmake new file mode 100644 index 000000000000..56c71b7bf10d --- /dev/null +++ b/contrib/libpcap/cmake/Modules/FindAirPcap.cmake @@ -0,0 +1,69 @@ +# +# FindAirPcap +# ========== +# +# Find the AirPcap library and include files. +# +# This module defines the following variables: +# +# AirPcap_INCLUDE_DIR - absolute path to the directory containing airpcap.h. +# +# AirPcap_LIBRARY - relative or absolute path to the AirPcap library to +# link with. An absolute path is will be used if the +# AirPcap library is not located in the compiler's +# default search path. + +# AirPcap_FOUND - TRUE if the AirPcap library *and* header are found. +# +# Hints and Backward Compatibility +# ================================ +# +# To tell this module where to look, a user may set the environment variable +# AirPcap_ROOT to point cmake to the *root* of a directory with include and +# lib subdirectories for airpcap.dll (e.g Airpcap_Devpack). +# Alternatively, AirPcap_ROOT may also be set from the CMake command +# line or GUI (e.g cmake -DAirPcap_ROOT=C:\path\to\airpcap_sdk [...]) +# + +# The 64-bit airpcap.lib is located under /x64 +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + # + # For the WinPcap and Npcap SDKs, the Lib subdirectory of the top-level + # directory contains 32-bit libraries; the 64-bit libraries are in the + # Lib/x64 directory. + # + # The only way to *FORCE* CMake to look in the Lib/x64 directory + # without searching in the Lib directory first appears to be to set + # CMAKE_LIBRARY_ARCHITECTURE to "x64". + # + # In newer versions of CMake, CMAKE_LIBRARY_ARCHITECTURE is set according to + # the language, e.g., CMAKE_<LANG>_LIBRARY_ARCHITECTURE. So, set the new + # variable, CMAKE_C_LIBRARY_ARCHITECTURE, so that CMAKE_LIBRARY_ARCHITECTURE + # inherits the correct value. + # + set(CMAKE_C_LIBRARY_ARCHITECTURE "x64") + set(CMAKE_LIBRARY_ARCHITECTURE "x64") +endif() + +# Find the header +find_path(AirPcap_INCLUDE_DIR airpcap.h + PATH_SUFFIXES include +) + +# Find the library +find_library(AirPcap_LIBRARY + NAMES airpcap +) + +# Set AirPcap_FOUND to TRUE if AirPcap_INCLUDE_DIR and AirPcap_LIBRARY are TRUE. +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(AirPcap + DEFAULT_MSG + AirPcap_INCLUDE_DIR + AirPcap_LIBRARY +) + +mark_as_advanced(AirPcap_INCLUDE_DIR AirPcap_LIBRARY) + +set(AirPcap_INCLUDE_DIRS ${AirPcap_INCLUDE_DIR}) +set(AirPcap_LIBRARIES ${AirPcap_LIBRARY}) diff --git a/contrib/libpcap/cmake/Modules/FindDAG.cmake b/contrib/libpcap/cmake/Modules/FindDAG.cmake index ef1352844558..f41b90a24963 100644 --- a/contrib/libpcap/cmake/Modules/FindDAG.cmake +++ b/contrib/libpcap/cmake/Modules/FindDAG.cmake @@ -14,6 +14,12 @@ find_path(DAG_INCLUDE_DIR dagapi.h) find_library(DAG_LIBRARY dag) find_library(DAGCONF_LIBRARY dagconf) +# +# Get link information from the _LIBRARY paths. +# +get_link_info_from_library_path(DAG dag) +get_link_info_from_library_path(DAGCONF dagconf) + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(DAG DEFAULT_MSG @@ -30,3 +36,4 @@ mark_as_advanced( set(DAG_INCLUDE_DIRS ${DAG_INCLUDE_DIR}) set(DAG_LIBRARIES ${DAG_LIBRARY} ${DAGCONF_LIBRARY}) +set(DAG_STATIC_LIBRARIES ${DAG_LIBRARY} ${DAGCONF_LIBRARY}) diff --git a/contrib/libpcap/cmake/Modules/FindPacket.cmake b/contrib/libpcap/cmake/Modules/FindPacket.cmake index f114875bf873..8224cd3f3e5c 100644 --- a/contrib/libpcap/cmake/Modules/FindPacket.cmake +++ b/contrib/libpcap/cmake/Modules/FindPacket.cmake @@ -28,24 +28,23 @@ # # This module defines the following variables: # -# PACKET_INCLUDE_DIR - absolute path to the directory containing Packet32.h. +# Packet_INCLUDE_DIR - absolute path to the directory containing Packet32.h. # -# PACKET_LIBRARY - relative or absolute path to the Packet library to +# Packet_LIBRARY - relative or absolute path to the Packet library to # link with. An absolute path is will be used if the # Packet library is not located in the compiler's -# default search path. See e.g. PACKET_DLL_DIR -# variable below. +# default search path. -# PACKET_FOUND - TRUE if the Packet library *and* header are found. +# Packet_FOUND - TRUE if the Packet library *and* header are found. # # Hints and Backward Compatibility # ================================ # # To tell this module where to look, a user may set the environment variable -# PACKET_DLL_DIR to point cmake to the *root* of a directory with include and -# lib subdirectories for packet.dll (e.g WpdPack/npcap-sdk). -# Alternatively, PACKET_DLL_DIR may also be set from cmake command line or GUI -# (e.g cmake -DPACKET_DLL_DIR=/path/to/packet [...]) +# Packet_ROOT to point cmake to the *root* of a directory with include and +# lib subdirectories for packet.dll (e.g WpdPack or npcap-sdk). +# Alternatively, Packet_ROOT may also be set from cmake command line or GUI +# (e.g cmake -DPacket_ROOT=C:\path\to\packet [...]) # # The 64-bit Packet.lib is located under /x64 @@ -59,30 +58,52 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 8) # without searching in the Lib directory first appears to be to set # CMAKE_LIBRARY_ARCHITECTURE to "x64". # - set(CMAKE_LIBRARY_ARCHITECTURE "x64") + # In newer versions of CMake, CMAKE_LIBRARY_ARCHITECTURE is set according to + # the language, e.g., CMAKE_<LANG>_LIBRARY_ARCHITECTURE. So, set the new + # variable, CMAKE_C_LIBRARY_ARCHITECTURE, so that CMAKE_LIBRARY_ARCHITECTURE + # inherits the correct value. + # + set(archdetect_c_code " + #ifndef _M_ARM64 + #error Not ARM64 + #endif + int main() { return 0; } + ") + + file(WRITE "${CMAKE_BINARY_DIR}/archdetect.c" "${archdetect_c_code}") + try_compile( + IsArm64 + "${CMAKE_BINARY_DIR}/archdetect" + "${CMAKE_BINARY_DIR}/archdetect.c" + ) + if(IsArm64) + set(CMAKE_C_LIBRARY_ARCHITECTURE "ARM64") + set(CMAKE_LIBRARY_ARCHITECTURE "ARM64") + else() + set(CMAKE_C_LIBRARY_ARCHITECTURE "x64") + set(CMAKE_LIBRARY_ARCHITECTURE "x64") + endif() endif() # Find the header -find_path(PACKET_INCLUDE_DIR Packet32.h - HINTS "${PACKET_DLL_DIR}" ENV PACKET_DLL_DIR +find_path(Packet_INCLUDE_DIR Packet32.h PATH_SUFFIXES include Include ) # Find the library -find_library(PACKET_LIBRARY +find_library(Packet_LIBRARY NAMES Packet packet - HINTS "${PACKET_DLL_DIR}" ENV PACKET_DLL_DIR ) -# Set PACKET_FOUND to TRUE if PACKET_INCLUDE_DIR and PACKET_LIBRARY are TRUE. +# Set Packet_FOUND to TRUE if Packet_INCLUDE_DIR and Packet_LIBRARY are TRUE. include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(PACKET +find_package_handle_standard_args(Packet DEFAULT_MSG - PACKET_INCLUDE_DIR - PACKET_LIBRARY + Packet_INCLUDE_DIR + Packet_LIBRARY ) -mark_as_advanced(PACKET_INCLUDE_DIR PACKET_LIBRARY) +mark_as_advanced(Packet_INCLUDE_DIR Packet_LIBRARY) -set(PACKET_INCLUDE_DIRS ${PACKET_INCLUDE_DIR}) -set(PACKET_LIBRARIES ${PACKET_LIBRARY}) +set(Packet_INCLUDE_DIRS ${Packet_INCLUDE_DIR}) +set(Packet_LIBRARIES ${Packet_LIBRARY}) diff --git a/contrib/libpcap/cmake/Modules/FindSNF.cmake b/contrib/libpcap/cmake/Modules/FindSNF.cmake index 76dcced417fe..d873b5aa74f8 100644 --- a/contrib/libpcap/cmake/Modules/FindSNF.cmake +++ b/contrib/libpcap/cmake/Modules/FindSNF.cmake @@ -8,6 +8,11 @@ find_path(SNF_INCLUDE_DIR snf.h /opt/snf) # Try to find the library find_library(SNF_LIBRARY snf /opt/snf) +# +# Get link information from the _LIBRARY paths. +# +get_link_info_from_library_path(SNF snf) + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(SNF DEFAULT_MSG @@ -22,3 +27,4 @@ mark_as_advanced( set(SNF_INCLUDE_DIRS ${SNF_INCLUDE_DIR}) set(SNF_LIBRARIES ${SNF_LIBRARY}) +set(SNF_STATIC_LIBRARIES ${SNF_LIBRARY}) diff --git a/contrib/libpcap/cmake/Modules/Finddpdk.cmake b/contrib/libpcap/cmake/Modules/Finddpdk.cmake new file mode 100644 index 000000000000..323262afa642 --- /dev/null +++ b/contrib/libpcap/cmake/Modules/Finddpdk.cmake @@ -0,0 +1,118 @@ +# Try to find dpdk +# +# Once done, this will define +# +# dpdk_FOUND +# dpdk_INCLUDE_DIRS +# dpdk_LIBRARIES +# dpdk_STATIC_LIBRARIES +# dpdk_LIBS_STATIC +# dpdk_REQUIRES_PRIVATE +# dpdk_PACKAGE_NAME + +# +# We only try to find DPDK using pkg-config; DPDK is *SO* +# complicated - DPDK 19.02, for example, has about 117(!) +# libraries, and the precise set of libraries required has +# changed over time - so attempting to guess which libraries +# you need, and hardcoding that in an attempt to find the +# libraries without DPDK, rather than relying on DPDK to +# tell you, with a .pc file, what libraries are needed, +# is *EXTREMELY* fragile and has caused some bug reports, +# so we're just not going to do it. +# +# If that causes a problem, the only thing we will do is +# accept an alternative way of finding the appropriate +# library set for the installed version of DPDK that is +# as robust as pkg-config (i.e., it had better work as well +# as pkg-config with *ALL* versions of DPDK that provide a +# libdpdk.pc file). +# +# If dpdk_ROOT is set, add ${dpdk_ROOT}/pkgconfig +# to PKG_CONFIG_PATH, so we look for the .pc file there, +# first. +# +if(PKG_CONFIG_FOUND) + set(save_PKG_CONFIG_PATH $ENV{PKG_CONFIG_PATH}) + if(dpdk_ROOT) + set(ENV{PKG_CONFIG_PATH} "${dpdk_ROOT}/pkgconfig:$ENV{PKG_CONFIG_PATH}") + endif() + pkg_check_modules(dpdk QUIET libdpdk) + if(dpdk_FOUND) + # + # Get link information for DPDK. + # + pkg_get_link_info(dpdk libdpdk) + endif() + set(ENV{PKG_CONFIG_PATH} "${save_PKG_CONFIG_PATH}") +endif() + +mark_as_advanced(dpdk_INCLUDE_DIRS dpdk_LIBRARIES dpdk_STATIC_LIBRARIES dpdk_REQUIRES_PRIVATE) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(dpdk DEFAULT_MSG + dpdk_INCLUDE_DIRS + dpdk_LIBRARIES) + +if(dpdk_FOUND) + # + # This depends on CMake support for "imported targets", + # which are not supported until CMake 3.19. + # + # Ubuntu 20.04 provides CMake 3.16.3, so we are *NOT* + # going to require CMake 3.19. If you want to use + # Shiny New Features(TM), wait until all the OSes on + # which a build might conceivably be done, and that + # provide CMake, provide 3.19 or later. + # + # Just don't do this stuff on earlier versions. If that + # breaks something, figure out a way to do it *without* + # "imported targets", and either do this that way, or, + # at least, do it that way on older versions of CMake. + # + # (One good thing about autotools is that only the builders + # of a package, and people doing configure-script development, + # have to care about the autoconf etc. version; you don't + # even need to have autotools installed in order to be able + # to run an autotools-generated configure script, you just + # need an environment UN*Xy enough, and modern enough, to + # run the stuff in the script. + # + # This is *NOT* the case for CMake; not only do you need + # CMake in order to build a package using CMake, you need + # a version recent enough to run the stuff the package's + # CMake files use. + # + # Please keep this in mind when changing any CMake files, + # and keep in mind what versions of CMake come with, for + # example, commonly-used versions of commonly-used + # Linux distributiions.) + # + if(NOT CMAKE_VERSION VERSION_LESS 3.19) + if(NOT TARGET dpdk::cflags) + if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|AMD64") + set(rte_cflags "-march=core2") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm|ARM") + set(rte_cflags "-march=armv7-a") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|AARCH64") + set(rte_cflags "-march=armv8-a+crc") + endif() + add_library(dpdk::cflags INTERFACE IMPORTED) + if (rte_cflags) + set_target_properties(dpdk::cflags PROPERTIES + INTERFACE_COMPILE_OPTIONS "${rte_cflags}") + endif() + endif() + + if(NOT TARGET dpdk::dpdk) + add_library(dpdk::dpdk INTERFACE IMPORTED) + find_package(Threads QUIET) + list(APPEND dpdk_LIBRARIES + Threads::Threads + dpdk::cflags) + set_target_properties(dpdk::dpdk PROPERTIES + INTERFACE_LINK_LIBRARIES "${dpdk_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${dpdk_INCLUDE_DIRS}") + endif() + endif() +endif() diff --git a/contrib/libpcap/cmakeconfig.h.in b/contrib/libpcap/cmakeconfig.h.in index 1639925e35d6..4ac85cc5303a 100644 --- a/contrib/libpcap/cmakeconfig.h.in +++ b/contrib/libpcap/cmakeconfig.h.in @@ -15,9 +15,15 @@ /* define if we have the AIX getprotobyname_r() */ #cmakedefine HAVE_AIX_GETPROTOBYNAME_R 1 +/* define if you have the AirPcap API */ +#cmakedefine HAVE_AIRPCAP_API 1 + /* Define to 1 if you have the `asprintf' function. */ #cmakedefine HAVE_ASPRINTF 1 +/* Define to 1 if you have the <config/HaikuConfig.h> header file. */ +#cmakedefine HAVE_CONFIG_HAIKUCONFIG_H 1 + /* define if you have the DAG API */ #cmakedefine HAVE_DAG_API 1 @@ -69,45 +75,21 @@ /* if libnl exists */ #cmakedefine HAVE_LIBNL 1 -/* if libnl exists and is version 2.x */ -#cmakedefine HAVE_LIBNL_2_x 1 - -/* if libnl exists and is version 3.x */ -#cmakedefine HAVE_LIBNL_3_x 1 - -/* libnl has NLE_FAILURE */ -#cmakedefine HAVE_LIBNL_NLE 1 - -/* libnl has new-style socket api */ -#cmakedefine HAVE_LIBNL_SOCKETS 1 - -/* Define to 1 if you have the <limits.h> header file. */ -#cmakedefine HAVE_LIMITS_H 1 - /* Define to 1 if you have the <linux/compiler.h> header file. */ #cmakedefine HAVE_LINUX_COMPILER_H 1 -/* Define to 1 if you have the <linux/ethtool.h> header file. */ -#cmakedefine HAVE_LINUX_ETHTOOL_H 1 - /* define if we have the Linux getnetbyname_r() */ #cmakedefine HAVE_LINUX_GETNETBYNAME_R 1 /* define if we have the Linux getprotobyname_r() */ #cmakedefine HAVE_LINUX_GETPROTOBYNAME_R 1 -/* Define to 1 if you have the <linux/if_bonding.h> header file. */ -#cmakedefine HAVE_LINUX_IF_BONDING_H 1 - /* Define to 1 if you have the <linux/net_tstamp.h> header file. */ #cmakedefine HAVE_LINUX_NET_TSTAMP_H 1 /* Define to 1 if you have the <linux/socket.h> header file. */ #cmakedefine HAVE_LINUX_SOCKET_H 1 -/* Define to 1 if you have the <linux/sockios.h> header file. */ -#cmakedefine HAVE_LINUX_SOCKIOS_H 1 - /* Define to 1 if you have the <linux/usbdevice_fs.h> header file. */ #cmakedefine HAVE_LINUX_USBDEVICE_FS_H 1 @@ -135,12 +117,12 @@ /* Define to 1 if you have the <net/pfilt.h> header file. */ #cmakedefine HAVE_NET_PFILT_H 1 -/* Define to 1 if you have the <net/pfvar.h> header file. */ -#cmakedefine HAVE_NET_PFVAR_H 1 - /* Define to 1 if you have the <net/raw.h> header file. */ #cmakedefine HAVE_NET_RAW_H 1 +/* Use OpenSSL */ +#cmakedefine HAVE_OPENSSL 1 + /* if there's an os_proto.h for this platform, to use additional prototypes */ #cmakedefine HAVE_OS_PROTO_H 1 @@ -153,9 +135,6 @@ /* Define to 1 if you have a POSIX-style `strerror_r' function. */ #cmakedefine HAVE_POSIX_STRERROR_R 1 -/* define if net/pfvar.h defines PF_NAT through PF_NORDR */ -#cmakedefine HAVE_PF_NAT_THROUGH_PF_NORDR 1 - /* define if you have the Septel API */ #cmakedefine HAVE_SEPTEL_API 1 @@ -186,9 +165,6 @@ /* Define to 1 if you have the `strerror' function. */ #cmakedefine HAVE_STRERROR 1 -/* Define to 1 if you have the `strerror_s' function. */ -#cmakedefine HAVE_STRERROR_S 1 - /* Define to 1 if you have the <strings.h> header file. */ #cmakedefine HAVE_STRINGS_H 1 @@ -216,6 +192,9 @@ /* Define to 1 if `msg_flags' is a member of `struct msghdr'. */ #cmakedefine HAVE_STRUCT_MSGHDR_MSG_FLAGS 1 +/* Define to 1 if the system has the type `struct rte_ether_addr'. */ +#cmakedefine HAVE_STRUCT_RTE_ETHER_ADDR 1 + /* Define to 1 if `hci_channel' is a member of `struct sockaddr_hci'. */ #cmakedefine HAVE_STRUCT_SOCKADDR_HCI_HCI_CHANNEL 1 @@ -228,9 +207,6 @@ /* Define to 1 if `tp_vlan_tci' is a member of `struct tpacket_auxdata'. */ #cmakedefine HAVE_STRUCT_TPACKET_AUXDATA_TP_VLAN_TCI 1 -/* Define to 1 if the system has the type `struct tpacket_stats'. */ -#cmakedefine HAVE_STRUCT_TPACKET_STATS 1 - /* Define to 1 if `bRequestType' is a member of `struct usbdevfs_ctrltransfer'. */ #cmakedefine HAVE_STRUCT_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE 1 @@ -272,7 +248,19 @@ #cmakedefine HAVE_VSNPRINTF 1 /* Define to 1 if you have the `vsyslog' function. */ -#undef HAVE_VSYSLOG +#cmakedefine HAVE_VSYSLOG 1 + +/* Define to 1 if you have the `_wcserror_s' function. */ +#cmakedefine HAVE__WCSERROR_S 1 + +/* define if __atomic_load_n is supported by the compiler */ +#cmakedefine HAVE___ATOMIC_LOAD_N 1 + +/* define if __atomic_store_n is supported by the compiler */ +#cmakedefine HAVE___ATOMIC_STORE_N 1 + +/* Define to 1 if you have the `PacketGetTimestampModes' function. */ +#cmakedefine HAVE_PACKET_GET_TIMESTAMP_MODES 1 /* Define to 1 if you have the `PacketIsLoopbackAdapter' function. */ #cmakedefine HAVE_PACKET_IS_LOOPBACK_ADAPTER 1 @@ -280,12 +268,6 @@ /* IPv6 */ #cmakedefine INET6 1 -/* if unaligned access fails */ -#cmakedefine LBL_ALIGN 1 - -/* path for device for USB sniffing */ -#cmakedefine LINUX_USB_MON_DEV "@LINUX_USB_MON_DEV@" - /* Define to 1 if netinet/ether.h declares `ether_hostton' */ #cmakedefine NETINET_ETHER_H_DECLARES_ETHER_HOSTTON 1 @@ -301,7 +283,7 @@ /* Define to the address where bug reports for this package should be sent. */ #cmakedefine PACKAGE_BUGREPORT 1 -/* Define to the DLL-preferred version string of of this package. */ +/* Define to the DLL-preferred version string of this package. */ #cmakedefine PACKAGE_VERSION_DLL @PACKAGE_VERSION_DLL@ /* Define to the full name of this package. */ @@ -328,24 +310,21 @@ /* support D-Bus sniffing */ #cmakedefine PCAP_SUPPORT_DBUS 1 +/* target host supports DPDK */ +#cmakedefine PCAP_SUPPORT_DPDK 1 + +/* target host supports Linux usbmon for USB sniffing */ +#cmakedefine PCAP_SUPPORT_LINUX_USBMON 1 + /* target host supports netfilter sniffing */ #cmakedefine PCAP_SUPPORT_NETFILTER 1 /* target host supports netmap */ #cmakedefine PCAP_SUPPORT_NETMAP 1 -/* use packet ring capture support on Linux if available */ -#cmakedefine PCAP_SUPPORT_PACKET_RING 1 - /* target host supports RDMA sniffing */ #cmakedefine PCAP_SUPPORT_RDMASNIFF 1 -/* target host supports USB sniffing */ -#cmakedefine PCAP_SUPPORT_USB 1 - -/* include ACN support */ -#cmakedefine SITA 1 - /* Define to 1 if you have the ANSI C header files. */ #cmakedefine STDC_HEADERS 1 diff --git a/contrib/libpcap/config.guess b/contrib/libpcap/config.guess index 2b79f6d837b9..a419d8643b62 100755 --- a/contrib/libpcap/config.guess +++ b/contrib/libpcap/config.guess @@ -1,12 +1,14 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2018 Free Software Foundation, Inc. +# Copyright 1992-2022 Free Software Foundation, Inc. -timestamp='2018-07-06' +# shellcheck disable=SC2006,SC2268 # see below for rationale + +timestamp='2022-08-01' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or +# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but @@ -27,11 +29,19 @@ timestamp='2018-07-06' # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: -# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess +# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess # # Please send patches to <config-patches@gnu.org>. +# The "shellcheck disable" line above the timestamp inhibits complaints +# about features and limitations of the classic Bourne shell that were +# superseded or lifted in POSIX. However, this script identifies a wide +# variety of pre-POSIX systems that do not have POSIX shells at all, and +# even some reasonably current systems (Solaris 10 as case-in-point) still +# have a pre-POSIX /bin/sh. + + me=`echo "$0" | sed -e 's,.*/,,'` usage="\ @@ -50,7 +60,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2018 Free Software Foundation, Inc. +Copyright 1992-2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -84,7 +94,8 @@ if test $# != 0; then exit 1 fi -trap 'exit 1' 1 2 15 +# Just in case it came from the environment. +GUESS= # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires @@ -96,73 +107,90 @@ trap 'exit 1' 1 2 15 # Portable tmp directory creation inspired by the Autoconf team. -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp 2>/dev/null) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in - ,,) echo "int x;" > "$dummy.c" ; - for c in cc gcc c89 c99 ; do - if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' +tmp= +# shellcheck disable=SC2172 +trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 + +set_cc_for_build() { + # prevent multiple calls if $tmp is already set + test "$tmp" && return 0 + : "${TMPDIR=/tmp}" + # shellcheck disable=SC2039,SC3028 + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } + dummy=$tmp/dummy + case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in + ,,) echo "int x;" > "$dummy.c" + for driver in cc gcc c89 c99 ; do + if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then + CC_FOR_BUILD=$driver + break + fi + done + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; + esac +} # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then +if test -f /.attbin/uname ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown -case "$UNAME_SYSTEM" in +case $UNAME_SYSTEM in Linux|GNU|GNU/*) - # If the system lacks a compiler, then just pick glibc. - # We could probably try harder. - LIBC=gnu + LIBC=unknown - eval "$set_cc_for_build" + set_cc_for_build cat <<-EOF > "$dummy.c" #include <features.h> #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc - #else + #elif defined(__GLIBC__) LIBC=gnu + #else + #include <stdarg.h> + /* First heuristic to detect musl libc. */ + #ifdef __DEFINED_va_list + LIBC=musl + #endif #endif EOF - eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" + cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + eval "$cc_set_libc" - # If ldd exists, use it to detect musl libc. - if command -v ldd >/dev/null && \ - ldd --version 2>&1 | grep -q ^musl - then - LIBC=musl + # Second heuristic to detect musl libc. + if [ "$LIBC" = unknown ] && + command -v ldd >/dev/null && + ldd --version 2>&1 | grep -q ^musl; then + LIBC=musl + fi + + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + if [ "$LIBC" = unknown ]; then + LIBC=gnu fi ;; esac # Note: order is significant - the case branches are not exclusive. -case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in +case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, @@ -174,12 +202,12 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ - "/sbin/$sysctl" 2>/dev/null || \ - "/usr/sbin/$sysctl" 2>/dev/null || \ + /sbin/sysctl -n hw.machine_arch 2>/dev/null || \ + /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \ echo unknown)` - case "$UNAME_MACHINE_ARCH" in + case $UNAME_MACHINE_ARCH in + aarch64eb) machine=aarch64_be-unknown ;; armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; @@ -188,18 +216,18 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in earmv*) arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` - machine="${arch}${endian}"-unknown + machine=${arch}${endian}-unknown ;; - *) machine="$UNAME_MACHINE_ARCH"-unknown ;; + *) machine=$UNAME_MACHINE_ARCH-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently (or will in the future) and ABI. - case "$UNAME_MACHINE_ARCH" in + case $UNAME_MACHINE_ARCH in earm*) os=netbsdelf ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval "$set_cc_for_build" + set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then @@ -215,7 +243,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in ;; esac # Determine ABI tags. - case "$UNAME_MACHINE_ARCH" in + case $UNAME_MACHINE_ARCH in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` @@ -226,7 +254,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. - case "$UNAME_VERSION" in + case $UNAME_VERSION in Debian*) release='-gnu' ;; @@ -237,45 +265,57 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "$machine-${os}${release}${abi-}" - exit ;; + GUESS=$machine-${os}${release}${abi-} + ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE + ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE + ;; + *:SecBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'` + GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE + ;; *:LibertyBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` - echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE + ;; *:MidnightBSD:*:*) - echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE + ;; *:ekkoBSD:*:*) - echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE + ;; *:SolidBSD:*:*) - echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE + ;; + *:OS108:*:*) + GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE + ;; macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd"$UNAME_RELEASE" - exit ;; + GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE + ;; *:MirBSD:*:*) - echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE + ;; *:Sortix:*:*) - echo "$UNAME_MACHINE"-unknown-sortix - exit ;; + GUESS=$UNAME_MACHINE-unknown-sortix + ;; + *:Twizzler:*:*) + GUESS=$UNAME_MACHINE-unknown-twizzler + ;; *:Redox:*:*) - echo "$UNAME_MACHINE"-unknown-redox - exit ;; + GUESS=$UNAME_MACHINE-unknown-redox + ;; mips:OSF1:*.*) - echo mips-dec-osf1 - exit ;; + GUESS=mips-dec-osf1 + ;; alpha:OSF1:*:*) + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + trap '' 0 case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` @@ -289,7 +329,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in + case $ALPHA_CPU_TYPE in "EV4 (21064)") UNAME_MACHINE=alpha ;; "EV4.5 (21064)") @@ -326,117 +366,121 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`" - # Reset EXIT trap before exiting to avoid spurious non-zero exit code. - exitcode=$? - trap '' 0 - exit $exitcode ;; + OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + GUESS=$UNAME_MACHINE-dec-osf$OSF_REL + ;; Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit ;; + GUESS=m68k-unknown-sysv4 + ;; *:[Aa]miga[Oo][Ss]:*:*) - echo "$UNAME_MACHINE"-unknown-amigaos - exit ;; + GUESS=$UNAME_MACHINE-unknown-amigaos + ;; *:[Mm]orph[Oo][Ss]:*:*) - echo "$UNAME_MACHINE"-unknown-morphos - exit ;; + GUESS=$UNAME_MACHINE-unknown-morphos + ;; *:OS/390:*:*) - echo i370-ibm-openedition - exit ;; + GUESS=i370-ibm-openedition + ;; *:z/VM:*:*) - echo s390-ibm-zvmoe - exit ;; + GUESS=s390-ibm-zvmoe + ;; *:OS400:*:*) - echo powerpc-ibm-os400 - exit ;; + GUESS=powerpc-ibm-os400 + ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix"$UNAME_RELEASE" - exit ;; + GUESS=arm-acorn-riscix$UNAME_RELEASE + ;; arm*:riscos:*:*|arm*:RISCOS:*:*) - echo arm-unknown-riscos - exit ;; + GUESS=arm-unknown-riscos + ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit ;; + GUESS=hppa1.1-hitachi-hiuxmpp + ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit ;; + case `(/bin/universe) 2>/dev/null` in + att) GUESS=pyramid-pyramid-sysv3 ;; + *) GUESS=pyramid-pyramid-bsd ;; + esac + ;; NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit ;; + GUESS=pyramid-pyramid-svr4 + ;; DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit ;; + GUESS=sparc-icl-nx6 + ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7; exit ;; - esac ;; + sparc) GUESS=sparc-icl-nx7 ;; + esac + ;; s390x:SunOS:*:*) - echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL + ;; sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-hal-solaris2$SUN_REL + ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-sun-solaris2$SUN_REL + ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux"$UNAME_RELEASE" - exit ;; + GUESS=i386-pc-auroraux$UNAME_RELEASE + ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval "$set_cc_for_build" + set_cc_for_build SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. - if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if test "$CC_FOR_BUILD" != no_compiler_found; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + (CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH=x86_64 fi fi - echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=$SUN_ARCH-pc-solaris2$SUN_REL + ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-sun-solaris3$SUN_REL + ;; sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in + case `/usr/bin/arch -k` in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'` + GUESS=sparc-sun-sunos$SUN_REL + ;; sun3*:SunOS:*:*) - echo m68k-sun-sunos"$UNAME_RELEASE" - exit ;; + GUESS=m68k-sun-sunos$UNAME_RELEASE + ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 - case "`/bin/arch`" in + case `/bin/arch` in sun3) - echo m68k-sun-sunos"$UNAME_RELEASE" + GUESS=m68k-sun-sunos$UNAME_RELEASE ;; sun4) - echo sparc-sun-sunos"$UNAME_RELEASE" + GUESS=sparc-sun-sunos$UNAME_RELEASE ;; esac - exit ;; + ;; aushp:SunOS:*:*) - echo sparc-auspex-sunos"$UNAME_RELEASE" - exit ;; + GUESS=sparc-auspex-sunos$UNAME_RELEASE + ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor @@ -446,43 +490,43 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint"$UNAME_RELEASE" - exit ;; + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint"$UNAME_RELEASE" - exit ;; + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint"$UNAME_RELEASE" - exit ;; + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint"$UNAME_RELEASE" - exit ;; + GUESS=m68k-milan-mint$UNAME_RELEASE + ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint"$UNAME_RELEASE" - exit ;; + GUESS=m68k-hades-mint$UNAME_RELEASE + ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint"$UNAME_RELEASE" - exit ;; + GUESS=m68k-unknown-mint$UNAME_RELEASE + ;; m68k:machten:*:*) - echo m68k-apple-machten"$UNAME_RELEASE" - exit ;; + GUESS=m68k-apple-machten$UNAME_RELEASE + ;; powerpc:machten:*:*) - echo powerpc-apple-machten"$UNAME_RELEASE" - exit ;; + GUESS=powerpc-apple-machten$UNAME_RELEASE + ;; RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit ;; + GUESS=mips-dec-mach_bsd4.3 + ;; RISC*:ULTRIX:*:*) - echo mips-dec-ultrix"$UNAME_RELEASE" - exit ;; + GUESS=mips-dec-ultrix$UNAME_RELEASE + ;; VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix"$UNAME_RELEASE" - exit ;; + GUESS=vax-dec-ultrix$UNAME_RELEASE + ;; 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix"$UNAME_RELEASE" - exit ;; + GUESS=clipper-intergraph-clix$UNAME_RELEASE + ;; mips:*:*:UMIPS | mips:*:*:RISCos) - eval "$set_cc_for_build" + set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include <stdio.h> /* for printf() prototype */ @@ -508,78 +552,79 @@ EOF dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`"$dummy" "$dummyarg"` && { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos"$UNAME_RELEASE" - exit ;; + GUESS=mips-mips-riscos$UNAME_RELEASE + ;; Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit ;; + GUESS=powerpc-motorola-powermax + ;; Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit ;; + GUESS=powerpc-harris-powermax + ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit ;; + GUESS=powerpc-harris-powermax + ;; Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit ;; + GUESS=powerpc-harris-powerunix + ;; m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit ;; + GUESS=m88k-harris-cxux7 + ;; m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit ;; + GUESS=m88k-motorola-sysv4 + ;; m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit ;; + GUESS=m88k-motorola-sysv3 + ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ] + if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110 then - if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \ - [ "$TARGET_BINARY_INTERFACE"x = x ] + if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \ + test "$TARGET_BINARY_INTERFACE"x = x then - echo m88k-dg-dgux"$UNAME_RELEASE" + GUESS=m88k-dg-dgux$UNAME_RELEASE else - echo m88k-dg-dguxbcs"$UNAME_RELEASE" + GUESS=m88k-dg-dguxbcs$UNAME_RELEASE fi else - echo i586-dg-dgux"$UNAME_RELEASE" + GUESS=i586-dg-dgux$UNAME_RELEASE fi - exit ;; + ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit ;; + GUESS=m88k-dolphin-sysv3 + ;; M88*:*:R3*:*) # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit ;; + GUESS=m88k-motorola-sysv3 + ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit ;; + GUESS=m88k-tektronix-sysv3 + ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit ;; + GUESS=m68k-tektronix-bsd + ;; *:IRIX*:*:*) - echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" - exit ;; + IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'` + GUESS=mips-sgi-irix$IRIX_REL + ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + GUESS=romp-ibm-aix # uname -m gives an 8 hex-code CPU id + ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) - echo i386-ibm-aix - exit ;; + GUESS=i386-ibm-aix + ;; ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then + if test -x /usr/bin/oslevel ; then IBM_REV=`/usr/bin/oslevel` else - IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" + IBM_REV=$UNAME_VERSION.$UNAME_RELEASE fi - echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" - exit ;; + GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV + ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval "$set_cc_for_build" + set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #include <sys/systemcfg.h> @@ -593,16 +638,16 @@ EOF EOF if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then - echo "$SYSTEM_NAME" + GUESS=$SYSTEM_NAME else - echo rs6000-ibm-aix3.2.5 + GUESS=rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 + GUESS=rs6000-ibm-aix3.2.4 else - echo rs6000-ibm-aix3.2 + GUESS=rs6000-ibm-aix3.2 fi - exit ;; + ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then @@ -610,57 +655,57 @@ EOF else IBM_ARCH=powerpc fi - if [ -x /usr/bin/lslpp ] ; then - IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | + if test -x /usr/bin/lslpp ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \ awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else - IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" + IBM_REV=$UNAME_VERSION.$UNAME_RELEASE fi - echo "$IBM_ARCH"-ibm-aix"$IBM_REV" - exit ;; + GUESS=$IBM_ARCH-ibm-aix$IBM_REV + ;; *:AIX:*:*) - echo rs6000-ibm-aix - exit ;; + GUESS=rs6000-ibm-aix + ;; ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) - echo romp-ibm-bsd4.4 - exit ;; + GUESS=romp-ibm-bsd4.4 + ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to - exit ;; # report: romp-ibm BSD 4.3 + GUESS=romp-ibm-bsd$UNAME_RELEASE # 4.3 with uname added to + ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) - echo rs6000-bull-bosx - exit ;; + GUESS=rs6000-bull-bosx + ;; DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit ;; + GUESS=m68k-bull-sysv3 + ;; 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit ;; + GUESS=m68k-hp-bsd + ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit ;; + GUESS=m68k-hp-bsd4.4 + ;; 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` - case "$UNAME_MACHINE" in + HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` + case $UNAME_MACHINE in 9000/31?) HP_ARCH=m68000 ;; 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then + if test -x /usr/bin/getconf; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "$sc_cpu_version" in + case $sc_cpu_version in 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 - case "$sc_kernel_bits" in + case $sc_kernel_bits in 32) HP_ARCH=hppa2.0n ;; 64) HP_ARCH=hppa2.0w ;; '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi - if [ "$HP_ARCH" = "" ]; then - eval "$set_cc_for_build" + if test "$HP_ARCH" = ""; then + set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE @@ -698,9 +743,9 @@ EOF test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac - if [ "$HP_ARCH" = hppa2.0w ] + if test "$HP_ARCH" = hppa2.0w then - eval "$set_cc_for_build" + set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler @@ -719,14 +764,14 @@ EOF HP_ARCH=hppa64 fi fi - echo "$HP_ARCH"-hp-hpux"$HPUX_REV" - exit ;; + GUESS=$HP_ARCH-hp-hpux$HPUX_REV + ;; ia64:HP-UX:*:*) - HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux"$HPUX_REV" - exit ;; + HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` + GUESS=ia64-hp-hpux$HPUX_REV + ;; 3050*:HI-UX:*:*) - eval "$set_cc_for_build" + set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #include <unistd.h> int @@ -754,36 +799,36 @@ EOF EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 - exit ;; + GUESS=unknown-hitachi-hiuxwe2 + ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) - echo hppa1.1-hp-bsd - exit ;; + GUESS=hppa1.1-hp-bsd + ;; 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit ;; + GUESS=hppa1.0-hp-bsd + ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit ;; + GUESS=hppa1.0-hp-mpeix + ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) - echo hppa1.1-hp-osf - exit ;; + GUESS=hppa1.1-hp-osf + ;; hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit ;; + GUESS=hppa1.0-hp-osf + ;; i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo "$UNAME_MACHINE"-unknown-osf1mk + if test -x /usr/sbin/sysversion ; then + GUESS=$UNAME_MACHINE-unknown-osf1mk else - echo "$UNAME_MACHINE"-unknown-osf1 + GUESS=$UNAME_MACHINE-unknown-osf1 fi - exit ;; + ;; parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit ;; + GUESS=hppa1.1-hp-lites + ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit ;; + GUESS=c1-convex-bsd + ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd @@ -791,17 +836,18 @@ EOF fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit ;; + GUESS=c34-convex-bsd + ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit ;; + GUESS=c38-convex-bsd + ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit ;; + GUESS=c4-convex-bsd + ;; CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=ymp-cray-unicos$CRAY_REL + ;; CRAY*[A-Z]90:*:*:*) echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ @@ -809,103 +855,129 @@ EOF -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) - echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=t90-cray-unicos$CRAY_REL + ;; CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=alphaev5-cray-unicosmk$CRAY_REL + ;; CRAY*SV1:*:*:*) - echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=sv1-cray-unicos$CRAY_REL + ;; *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=craynv-cray-unicosmp$CRAY_REL + ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; + GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} + ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; + GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} + ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE + ;; sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi"$UNAME_RELEASE" - exit ;; + GUESS=sparc-unknown-bsdi$UNAME_RELEASE + ;; *:BSD/OS:*:*) - echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE + ;; + arm:FreeBSD:*:*) + UNAME_PROCESSOR=`uname -p` + set_cc_for_build + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi + else + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf + fi + ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` - case "$UNAME_PROCESSOR" in + case $UNAME_PROCESSOR in amd64) UNAME_PROCESSOR=x86_64 ;; i386) UNAME_PROCESSOR=i586 ;; esac - echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" - exit ;; + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL + ;; i*:CYGWIN*:*) - echo "$UNAME_MACHINE"-pc-cygwin - exit ;; + GUESS=$UNAME_MACHINE-pc-cygwin + ;; *:MINGW64*:*) - echo "$UNAME_MACHINE"-pc-mingw64 - exit ;; + GUESS=$UNAME_MACHINE-pc-mingw64 + ;; *:MINGW*:*) - echo "$UNAME_MACHINE"-pc-mingw32 - exit ;; + GUESS=$UNAME_MACHINE-pc-mingw32 + ;; *:MSYS*:*) - echo "$UNAME_MACHINE"-pc-msys - exit ;; + GUESS=$UNAME_MACHINE-pc-msys + ;; i*:PW*:*) - echo "$UNAME_MACHINE"-pc-pw32 - exit ;; + GUESS=$UNAME_MACHINE-pc-pw32 + ;; + *:SerenityOS:*:*) + GUESS=$UNAME_MACHINE-pc-serenity + ;; *:Interix*:*) - case "$UNAME_MACHINE" in + case $UNAME_MACHINE in x86) - echo i586-pc-interix"$UNAME_RELEASE" - exit ;; + GUESS=i586-pc-interix$UNAME_RELEASE + ;; authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix"$UNAME_RELEASE" - exit ;; + GUESS=x86_64-unknown-interix$UNAME_RELEASE + ;; IA64) - echo ia64-unknown-interix"$UNAME_RELEASE" - exit ;; + GUESS=ia64-unknown-interix$UNAME_RELEASE + ;; esac ;; i*:UWIN*:*) - echo "$UNAME_MACHINE"-pc-uwin - exit ;; + GUESS=$UNAME_MACHINE-pc-uwin + ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; + GUESS=x86_64-pc-cygwin + ;; prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=powerpcle-unknown-solaris2$SUN_REL + ;; *:GNU:*:*) # the GNU system - echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`" - exit ;; + GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'` + GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'` + GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL + ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC" - exit ;; + GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"` + GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC + ;; *:Minix:*:*) - echo "$UNAME_MACHINE"-unknown-minix - exit ;; + GUESS=$UNAME_MACHINE-unknown-minix + ;; aarch64:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; @@ -916,183 +988,236 @@ EOF esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC=gnulibc1 ; fi - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - arc:Linux:*:* | arceb:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; arm*:Linux:*:*) - eval "$set_cc_for_build" + set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi + GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi else - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf + GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf fi fi - exit ;; + ;; avr32*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; cris:Linux:*:*) - echo "$UNAME_MACHINE"-axis-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-axis-linux-$LIBC + ;; crisv32:Linux:*:*) - echo "$UNAME_MACHINE"-axis-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-axis-linux-$LIBC + ;; e2k:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; frv:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; hexagon:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; i*86:Linux:*:*) - echo "$UNAME_MACHINE"-pc-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-pc-linux-$LIBC + ;; ia64:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; k1om:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + loongarch32:Linux:*:* | loongarch64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; m32r*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; m68*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; mips:Linux:*:* | mips64:Linux:*:*) - eval "$set_cc_for_build" + set_cc_for_build + IS_GLIBC=0 + test x"${LIBC}" = xgnu && IS_GLIBC=1 sed 's/^ //' << EOF > "$dummy.c" #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el + #undef mips + #undef mipsel + #undef mips64 + #undef mips64el + #if ${IS_GLIBC} && defined(_ABI64) + LIBCABI=gnuabi64 + #else + #if ${IS_GLIBC} && defined(_ABIN32) + LIBCABI=gnuabin32 + #else + LIBCABI=${LIBC} + #endif + #endif + + #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa64r6 + #else + #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa32r6 + #else + #if defined(__mips64) + CPU=mips64 + #else + CPU=mips + #endif + #endif + #endif + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=${UNAME_MACHINE}el + MIPS_ENDIAN=el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=${UNAME_MACHINE} + MIPS_ENDIAN= #else - CPU= + MIPS_ENDIAN= #endif #endif EOF - eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`" - test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; } + cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'` + eval "$cc_set_vars" + test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } ;; mips64el:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; openrisc*:Linux:*:*) - echo or1k-unknown-linux-"$LIBC" - exit ;; + GUESS=or1k-unknown-linux-$LIBC + ;; or32:Linux:*:* | or1k*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; padre:Linux:*:*) - echo sparc-unknown-linux-"$LIBC" - exit ;; + GUESS=sparc-unknown-linux-$LIBC + ;; parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-"$LIBC" - exit ;; + GUESS=hppa64-unknown-linux-$LIBC + ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; - PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; - *) echo hppa-unknown-linux-"$LIBC" ;; + PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;; + PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;; + *) GUESS=hppa-unknown-linux-$LIBC ;; esac - exit ;; + ;; ppc64:Linux:*:*) - echo powerpc64-unknown-linux-"$LIBC" - exit ;; + GUESS=powerpc64-unknown-linux-$LIBC + ;; ppc:Linux:*:*) - echo powerpc-unknown-linux-"$LIBC" - exit ;; + GUESS=powerpc-unknown-linux-$LIBC + ;; ppc64le:Linux:*:*) - echo powerpc64le-unknown-linux-"$LIBC" - exit ;; + GUESS=powerpc64le-unknown-linux-$LIBC + ;; ppcle:Linux:*:*) - echo powerpcle-unknown-linux-"$LIBC" - exit ;; - riscv32:Linux:*:* | riscv64:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=powerpcle-unknown-linux-$LIBC + ;; + riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; s390:Linux:*:* | s390x:Linux:*:*) - echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-ibm-linux-$LIBC + ;; sh64*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; sh*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; tile*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; vax:Linux:*:*) - echo "$UNAME_MACHINE"-dec-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-dec-linux-$LIBC + ;; x86_64:Linux:*:*) - echo "$UNAME_MACHINE"-pc-linux-"$LIBC" - exit ;; + set_cc_for_build + CPU=$UNAME_MACHINE + LIBCABI=$LIBC + if test "$CC_FOR_BUILD" != no_compiler_found; then + ABI=64 + sed 's/^ //' << EOF > "$dummy.c" + #ifdef __i386__ + ABI=x86 + #else + #ifdef __ILP32__ + ABI=x32 + #endif + #endif +EOF + cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'` + eval "$cc_set_abi" + case $ABI in + x86) CPU=i686 ;; + x32) LIBCABI=${LIBC}x32 ;; + esac + fi + GUESS=$CPU-pc-linux-$LIBCABI + ;; xtensa*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. - echo i386-sequent-sysv4 - exit ;; + GUESS=i386-sequent-sysv4 + ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. - echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" - exit ;; + GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION + ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. - echo "$UNAME_MACHINE"-pc-os2-emx - exit ;; + GUESS=$UNAME_MACHINE-pc-os2-emx + ;; i*86:XTS-300:*:STOP) - echo "$UNAME_MACHINE"-unknown-stop - exit ;; + GUESS=$UNAME_MACHINE-unknown-stop + ;; i*86:atheos:*:*) - echo "$UNAME_MACHINE"-unknown-atheos - exit ;; + GUESS=$UNAME_MACHINE-unknown-atheos + ;; i*86:syllable:*:*) - echo "$UNAME_MACHINE"-pc-syllable - exit ;; + GUESS=$UNAME_MACHINE-pc-syllable + ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos"$UNAME_RELEASE" - exit ;; + GUESS=i386-unknown-lynxos$UNAME_RELEASE + ;; i*86:*DOS:*:*) - echo "$UNAME_MACHINE"-pc-msdosdjgpp - exit ;; + GUESS=$UNAME_MACHINE-pc-msdosdjgpp + ;; i*86:*:4.*:*) UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" + GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL else - echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" + GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL fi - exit ;; + ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in @@ -1100,12 +1225,12 @@ EOF *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac - echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}" - exit ;; + GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` - echo "$UNAME_MACHINE"-pc-isc"$UNAME_REL" + GUESS=$UNAME_MACHINE-pc-isc$UNAME_REL elif /bin/uname -X 2>/dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 @@ -1115,11 +1240,11 @@ EOF && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 - echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" + GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL else - echo "$UNAME_MACHINE"-pc-sysv32 + GUESS=$UNAME_MACHINE-pc-sysv32 fi - exit ;; + ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about @@ -1127,31 +1252,31 @@ EOF # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. - echo i586-pc-msdosdjgpp - exit ;; + GUESS=i586-pc-msdosdjgpp + ;; Intel:Mach:3*:*) - echo i386-pc-mach3 - exit ;; + GUESS=i386-pc-mach3 + ;; paragon:*:*:*) - echo i860-intel-osf1 - exit ;; + GUESS=i860-intel-osf1 + ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 + GUESS=i860-stardent-sysv$UNAME_RELEASE # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 + GUESS=i860-unknown-sysv$UNAME_RELEASE # Unknown i860-SVR4 fi - exit ;; + ;; mini*:CTIX:SYS*5:*) # "miniframe" - echo m68010-convergent-sysv - exit ;; + GUESS=m68010-convergent-sysv + ;; mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit ;; + GUESS=m68k-convergent-sysv + ;; M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit ;; + GUESS=m68k-diab-dnix + ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) @@ -1176,249 +1301,407 @@ EOF /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos"$UNAME_RELEASE" - exit ;; + GUESS=m68k-unknown-lynxos$UNAME_RELEASE + ;; mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit ;; + GUESS=m68k-atari-sysv4 + ;; TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos"$UNAME_RELEASE" - exit ;; + GUESS=sparc-unknown-lynxos$UNAME_RELEASE + ;; rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos"$UNAME_RELEASE" - exit ;; + GUESS=rs6000-unknown-lynxos$UNAME_RELEASE + ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos"$UNAME_RELEASE" - exit ;; + GUESS=powerpc-unknown-lynxos$UNAME_RELEASE + ;; SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv"$UNAME_RELEASE" - exit ;; + GUESS=mips-dde-sysv$UNAME_RELEASE + ;; RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit ;; + GUESS=mips-sni-sysv4 + ;; RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit ;; + GUESS=mips-sni-sysv4 + ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo "$UNAME_MACHINE"-sni-sysv4 + GUESS=$UNAME_MACHINE-sni-sysv4 else - echo ns32k-sni-sysv + GUESS=ns32k-sni-sysv fi - exit ;; + ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says <Richard.M.Bartel@ccMail.Census.GOV> - echo i586-unisys-sysv4 - exit ;; + GUESS=i586-unisys-sysv4 + ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes <hewes@openmarket.com>. # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit ;; + GUESS=hppa1.1-stratus-sysv4 + ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit ;; + GUESS=i860-stratus-sysv4 + ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. - echo "$UNAME_MACHINE"-stratus-vos - exit ;; + GUESS=$UNAME_MACHINE-stratus-vos + ;; *:VOS:*:*) # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit ;; + GUESS=hppa1.1-stratus-vos + ;; mc68*:A/UX:*:*) - echo m68k-apple-aux"$UNAME_RELEASE" - exit ;; + GUESS=m68k-apple-aux$UNAME_RELEASE + ;; news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit ;; + GUESS=mips-sony-newsos6 + ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv"$UNAME_RELEASE" + if test -d /usr/nec; then + GUESS=mips-nec-sysv$UNAME_RELEASE else - echo mips-unknown-sysv"$UNAME_RELEASE" + GUESS=mips-unknown-sysv$UNAME_RELEASE fi - exit ;; + ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit ;; + GUESS=powerpc-be-beos + ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit ;; + GUESS=powerpc-apple-beos + ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit ;; + GUESS=i586-pc-beos + ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. - echo i586-pc-haiku - exit ;; - x86_64:Haiku:*:*) - echo x86_64-unknown-haiku - exit ;; + GUESS=i586-pc-haiku + ;; + ppc:Haiku:*:*) # Haiku running on Apple PowerPC + GUESS=powerpc-apple-haiku + ;; + *:Haiku:*:*) # Haiku modern gcc (not bound by BeOS compat) + GUESS=$UNAME_MACHINE-unknown-haiku + ;; SX-4:SUPER-UX:*:*) - echo sx4-nec-superux"$UNAME_RELEASE" - exit ;; + GUESS=sx4-nec-superux$UNAME_RELEASE + ;; SX-5:SUPER-UX:*:*) - echo sx5-nec-superux"$UNAME_RELEASE" - exit ;; + GUESS=sx5-nec-superux$UNAME_RELEASE + ;; SX-6:SUPER-UX:*:*) - echo sx6-nec-superux"$UNAME_RELEASE" - exit ;; + GUESS=sx6-nec-superux$UNAME_RELEASE + ;; SX-7:SUPER-UX:*:*) - echo sx7-nec-superux"$UNAME_RELEASE" - exit ;; + GUESS=sx7-nec-superux$UNAME_RELEASE + ;; SX-8:SUPER-UX:*:*) - echo sx8-nec-superux"$UNAME_RELEASE" - exit ;; + GUESS=sx8-nec-superux$UNAME_RELEASE + ;; SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux"$UNAME_RELEASE" - exit ;; + GUESS=sx8r-nec-superux$UNAME_RELEASE + ;; SX-ACE:SUPER-UX:*:*) - echo sxace-nec-superux"$UNAME_RELEASE" - exit ;; + GUESS=sxace-nec-superux$UNAME_RELEASE + ;; Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody"$UNAME_RELEASE" - exit ;; + GUESS=powerpc-apple-rhapsody$UNAME_RELEASE + ;; *:Rhapsody:*:*) - echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE + ;; + arm64:Darwin:*:*) + GUESS=aarch64-apple-darwin$UNAME_RELEASE + ;; *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - eval "$set_cc_for_build" - if test "$UNAME_PROCESSOR" = unknown ; then - UNAME_PROCESSOR=powerpc + UNAME_PROCESSOR=`uname -p` + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + if command -v xcode-select > /dev/null 2> /dev/null && \ + ! xcode-select --print-path > /dev/null 2> /dev/null ; then + # Avoid executing cc if there is no toolchain installed as + # cc will be a stub that puts up a graphical alert + # prompting the user to install developer tools. + CC_FOR_BUILD=no_compiler_found + else + set_cc_for_build fi - if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then - if [ "$CC_FOR_BUILD" != no_compiler_found ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - case $UNAME_PROCESSOR in - i386) UNAME_PROCESSOR=x86_64 ;; - powerpc) UNAME_PROCESSOR=powerpc64 ;; - esac - fi - # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc - if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_PPC >/dev/null - then - UNAME_PROCESSOR=powerpc - fi + if test "$CC_FOR_BUILD" != no_compiler_found; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc fi elif test "$UNAME_PROCESSOR" = i386 ; then - # Avoid executing cc on OS X 10.9, as it ships with a stub - # that puts up a graphical alert prompting to install - # developer tools. Any system running Mac OS X 10.7 or - # later (Darwin 11 and later) is required to have a 64-bit - # processor. This is not true of the ARM version of Darwin - # that Apple uses in portable devices. - UNAME_PROCESSOR=x86_64 + # uname -m returns i386 or x86_64 + UNAME_PROCESSOR=$UNAME_MACHINE fi - echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE + ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi - echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE + ;; *:QNX:*:4*) - echo i386-pc-qnx - exit ;; + GUESS=i386-pc-qnx + ;; NEO-*:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk"$UNAME_RELEASE" - exit ;; + GUESS=neo-tandem-nsk$UNAME_RELEASE + ;; NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk"$UNAME_RELEASE" - exit ;; + GUESS=nse-tandem-nsk$UNAME_RELEASE + ;; NSR-*:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk"$UNAME_RELEASE" - exit ;; + GUESS=nsr-tandem-nsk$UNAME_RELEASE + ;; NSV-*:NONSTOP_KERNEL:*:*) - echo nsv-tandem-nsk"$UNAME_RELEASE" - exit ;; + GUESS=nsv-tandem-nsk$UNAME_RELEASE + ;; NSX-*:NONSTOP_KERNEL:*:*) - echo nsx-tandem-nsk"$UNAME_RELEASE" - exit ;; + GUESS=nsx-tandem-nsk$UNAME_RELEASE + ;; *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit ;; + GUESS=mips-compaq-nonstopux + ;; BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit ;; + GUESS=bs2000-siemens-sysv + ;; DS/*:UNIX_System_V:*:*) - echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE + ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. - if test "$cputype" = 386; then + if test "${cputype-}" = 386; then UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" + elif test "x${cputype-}" != x; then + UNAME_MACHINE=$cputype fi - echo "$UNAME_MACHINE"-unknown-plan9 - exit ;; + GUESS=$UNAME_MACHINE-unknown-plan9 + ;; *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit ;; + GUESS=pdp10-unknown-tops10 + ;; *:TENEX:*:*) - echo pdp10-unknown-tenex - exit ;; + GUESS=pdp10-unknown-tenex + ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit ;; + GUESS=pdp10-dec-tops20 + ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit ;; + GUESS=pdp10-xkl-tops20 + ;; *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit ;; + GUESS=pdp10-unknown-tops20 + ;; *:ITS:*:*) - echo pdp10-unknown-its - exit ;; + GUESS=pdp10-unknown-its + ;; SEI:*:*:SEIUX) - echo mips-sei-seiux"$UNAME_RELEASE" - exit ;; + GUESS=mips-sei-seiux$UNAME_RELEASE + ;; *:DragonFly:*:*) - echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" - exit ;; + DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL + ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "$UNAME_MACHINE" in - A*) echo alpha-dec-vms ; exit ;; - I*) echo ia64-dec-vms ; exit ;; - V*) echo vax-dec-vms ; exit ;; + case $UNAME_MACHINE in + A*) GUESS=alpha-dec-vms ;; + I*) GUESS=ia64-dec-vms ;; + V*) GUESS=vax-dec-vms ;; esac ;; *:XENIX:*:SysV) - echo i386-pc-xenix - exit ;; + GUESS=i386-pc-xenix + ;; i*86:skyos:*:*) - echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" - exit ;; + SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'` + GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL + ;; i*86:rdos:*:*) - echo "$UNAME_MACHINE"-pc-rdos - exit ;; - i*86:AROS:*:*) - echo "$UNAME_MACHINE"-pc-aros - exit ;; + GUESS=$UNAME_MACHINE-pc-rdos + ;; + i*86:Fiwix:*:*) + GUESS=$UNAME_MACHINE-pc-fiwix + ;; + *:AROS:*:*) + GUESS=$UNAME_MACHINE-unknown-aros + ;; x86_64:VMkernel:*:*) - echo "$UNAME_MACHINE"-unknown-esx - exit ;; + GUESS=$UNAME_MACHINE-unknown-esx + ;; amd64:Isilon\ OneFS:*:*) - echo x86_64-unknown-onefs - exit ;; + GUESS=x86_64-unknown-onefs + ;; + *:Unleashed:*:*) + GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE + ;; esac +# Do we have a guess based on uname results? +if test "x$GUESS" != x; then + echo "$GUESS" + exit +fi + +# No uname command or uname output not recognized. +set_cc_for_build +cat > "$dummy.c" <<EOF +#ifdef _SEQUENT_ +#include <sys/types.h> +#include <sys/utsname.h> +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#include <signal.h> +#if defined(_SIZE_T_) || defined(SIGLOST) +#include <sys/utsname.h> +#endif +#endif +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include <sys/param.h> + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); +#endif + +#if defined (vax) +#if !defined (ultrix) +#include <sys/param.h> +#if defined (BSD) +#if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +#else +#if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#endif +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#else +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname un; + uname (&un); + printf ("vax-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("vax-dec-ultrix\n"); exit (0); +#endif +#endif +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname *un; + uname (&un); + printf ("mips-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("mips-dec-ultrix\n"); exit (0); +#endif +#endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. +test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } + echo "$0: unable to guess system type" >&2 -case "$UNAME_MACHINE:$UNAME_SYSTEM" in +case $UNAME_MACHINE:$UNAME_SYSTEM in mips:Linux | mips64:Linux) # If we got here on MIPS GNU/Linux, output extra information. cat >&2 <<EOF @@ -1435,9 +1718,17 @@ This script (version $timestamp), has failed to recognize the operating system you are using. If your script is old, overwrite *all* copies of config.guess and config.sub with the latest versions from: - https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess + https://git.savannah.gnu.org/cgit/config.git/plain/config.guess and - https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub + https://git.savannah.gnu.org/cgit/config.git/plain/config.sub +EOF + +our_year=`echo $timestamp | sed 's,-.*,,'` +thisyear=`date +%Y` +# shellcheck disable=SC2003 +script_age=`expr "$thisyear" - "$our_year"` +if test "$script_age" -lt 3 ; then + cat >&2 <<EOF If $0 has already been updated, send the following data and any information you think might be pertinent to config-patches@gnu.org to @@ -1465,6 +1756,7 @@ UNAME_RELEASE = "$UNAME_RELEASE" UNAME_SYSTEM = "$UNAME_SYSTEM" UNAME_VERSION = "$UNAME_VERSION" EOF +fi exit 1 diff --git a/contrib/libpcap/config.h.in b/contrib/libpcap/config.h.in index 94db7bbc4177..282a95591b7d 100644 --- a/contrib/libpcap/config.h.in +++ b/contrib/libpcap/config.h.in @@ -18,6 +18,9 @@ /* Define to 1 if you have the `asprintf' function. */ #undef HAVE_ASPRINTF +/* Define to 1 if you have the <config/HaikuConfig.h> header file. */ +#undef HAVE_CONFIG_HAIKUCONFIG_H + /* Define to 1 if you have the <dagapi.h> header file. */ #undef HAVE_DAGAPI_H @@ -69,8 +72,8 @@ /* Define to 1 if you have the <inttypes.h> header file. */ #undef HAVE_INTTYPES_H -/* Define to 1 if you have the `dag' library (-ldag). */ -#undef HAVE_LIBDAG +/* Define to 1 if you have the `bsd' library (-lbsd). */ +#undef HAVE_LIBBSD /* if libdlpi exists */ #undef HAVE_LIBDLPI @@ -78,45 +81,21 @@ /* if libnl exists */ #undef HAVE_LIBNL -/* if libnl exists and is version 2.x */ -#undef HAVE_LIBNL_2_x - -/* if libnl exists and is version 3.x */ -#undef HAVE_LIBNL_3_x - -/* libnl has NLE_FAILURE */ -#undef HAVE_LIBNL_NLE - -/* libnl has new-style socket api */ -#undef HAVE_LIBNL_SOCKETS - -/* Define to 1 if you have the <limits.h> header file. */ -#undef HAVE_LIMITS_H - /* Define to 1 if you have the <linux/compiler.h> header file. */ #undef HAVE_LINUX_COMPILER_H -/* Define to 1 if you have the <linux/ethtool.h> header file. */ -#undef HAVE_LINUX_ETHTOOL_H - /* define if we have the Linux getnetbyname_r() */ #undef HAVE_LINUX_GETNETBYNAME_R /* define if we have the Linux getprotobyname_r() */ #undef HAVE_LINUX_GETPROTOBYNAME_R -/* Define to 1 if you have the <linux/if_bonding.h> header file. */ -#undef HAVE_LINUX_IF_BONDING_H - /* Define to 1 if you have the <linux/net_tstamp.h> header file. */ #undef HAVE_LINUX_NET_TSTAMP_H /* Define to 1 if you have the <linux/socket.h> header file. */ #undef HAVE_LINUX_SOCKET_H -/* Define to 1 if you have the <linux/sockios.h> header file. */ -#undef HAVE_LINUX_SOCKIOS_H - /* Define to 1 if you have the <linux/usbdevice_fs.h> header file. */ #undef HAVE_LINUX_USBDEVICE_FS_H @@ -135,27 +114,33 @@ /* Define to 1 if you have the <net/enet.h> header file. */ #undef HAVE_NET_ENET_H +/* Define to 1 if you have the <net/if_dl.h> header file. */ +#undef HAVE_NET_IF_DL_H + +/* Define to 1 if you have the <net/if.h> header file. */ +#undef HAVE_NET_IF_H + /* Define to 1 if you have the <net/if_media.h> header file. */ #undef HAVE_NET_IF_MEDIA_H +/* Define to 1 if you have the <net/if_types.h> header file. */ +#undef HAVE_NET_IF_TYPES_H + /* Define to 1 if you have the <net/nit.h> header file. */ #undef HAVE_NET_NIT_H /* Define to 1 if you have the <net/pfilt.h> header file. */ #undef HAVE_NET_PFILT_H -/* Define to 1 if you have the <net/pfvar.h> header file. */ -#undef HAVE_NET_PFVAR_H - /* Define to 1 if you have the <net/raw.h> header file. */ #undef HAVE_NET_RAW_H +/* Use OpenSSL */ +#undef HAVE_OPENSSL + /* if there's an os_proto.h for this platform, to use additional prototypes */ #undef HAVE_OS_PROTO_H -/* define if net/pfvar.h defines PF_NAT through PF_NORDR */ -#undef HAVE_PF_NAT_THROUGH_PF_NORDR - /* Define to 1 if you have a POSIX-style `strerror_r' function. */ #undef HAVE_POSIX_STRERROR_R @@ -165,9 +150,6 @@ /* define if you have the Myricom SNF API */ #undef HAVE_SNF_API -/* Define to 1 if you have the `snprintf' function. */ -#undef HAVE_SNPRINTF - /* Define to 1 if the system has the type `socklen_t'. */ #undef HAVE_SOCKLEN_T @@ -189,9 +171,6 @@ /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR -/* Define to 1 if you have the `strerror_s' function. */ -#undef HAVE_STRERROR_S - /* Define to 1 if you have the <strings.h> header file. */ #undef HAVE_STRINGS_H @@ -219,6 +198,9 @@ /* Define to 1 if `msg_flags' is a member of `struct msghdr'. */ #undef HAVE_STRUCT_MSGHDR_MSG_FLAGS +/* Define to 1 if the system has the type `struct rte_ether_addr'. */ +#undef HAVE_STRUCT_RTE_ETHER_ADDR + /* Define to 1 if `hci_channel' is a member of `struct sockaddr_hci'. */ #undef HAVE_STRUCT_SOCKADDR_HCI_HCI_CHANNEL @@ -231,9 +213,6 @@ /* Define to 1 if `tp_vlan_tci' is a member of `struct tpacket_auxdata'. */ #undef HAVE_STRUCT_TPACKET_AUXDATA_TP_VLAN_TCI -/* Define to 1 if the system has the type `struct tpacket_stats'. */ -#undef HAVE_STRUCT_TPACKET_STATS - /* Define to 1 if `bRequestType' is a member of `struct usbdevfs_ctrltransfer'. */ #undef HAVE_STRUCT_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE @@ -271,20 +250,20 @@ /* Define to 1 if you have the `vasprintf' function. */ #undef HAVE_VASPRINTF -/* Define to 1 if you have the `vsnprintf' function. */ -#undef HAVE_VSNPRINTF - /* Define to 1 if you have the `vsyslog' function. */ #undef HAVE_VSYSLOG -/* IPv6 */ -#undef INET6 +/* Define to 1 if you have the `_wcserror_s' function. */ +#undef HAVE__WCSERROR_S + +/* define if __atomic_load_n is supported by the compiler */ +#undef HAVE___ATOMIC_LOAD_N -/* if unaligned access fails */ -#undef LBL_ALIGN +/* define if __atomic_store_n is supported by the compiler */ +#undef HAVE___ATOMIC_STORE_N -/* path for device for USB sniffing */ -#undef LINUX_USB_MON_DEV +/* IPv6 */ +#undef INET6 /* Define to 1 if netinet/ether.h declares `ether_hostton' */ #undef NETINET_ETHER_H_DECLARES_ETHER_HOSTTON @@ -325,23 +304,26 @@ /* support D-Bus sniffing */ #undef PCAP_SUPPORT_DBUS +/* target host supports DPDK */ +#undef PCAP_SUPPORT_DPDK + +/* target host supports Linux usbmon for USB sniffing */ +#undef PCAP_SUPPORT_LINUX_USBMON + /* target host supports netfilter sniffing */ #undef PCAP_SUPPORT_NETFILTER /* target host supports netmap */ #undef PCAP_SUPPORT_NETMAP -/* use packet ring capture support on Linux if available */ -#undef PCAP_SUPPORT_PACKET_RING - /* target host supports RDMA sniffing */ #undef PCAP_SUPPORT_RDMASNIFF -/* target host supports USB sniffing */ -#undef PCAP_SUPPORT_USB +/* The size of `const void *', as computed by sizeof. */ +#undef SIZEOF_CONST_VOID_P -/* include ACN support */ -#undef SITA +/* The size of `void *', as computed by sizeof. */ +#undef SIZEOF_VOID_P /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS diff --git a/contrib/libpcap/config.sub b/contrib/libpcap/config.sub index c95acc681d1b..fbaa37f2352d 100755 --- a/contrib/libpcap/config.sub +++ b/contrib/libpcap/config.sub @@ -1,12 +1,14 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2018 Free Software Foundation, Inc. +# Copyright 1992-2022 Free Software Foundation, Inc. -timestamp='2018-07-03' +# shellcheck disable=SC2006,SC2268 # see below for rationale + +timestamp='2022-08-01' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or +# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but @@ -33,7 +35,7 @@ timestamp='2018-07-03' # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: -# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub +# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases @@ -50,6 +52,13 @@ timestamp='2018-07-03' # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. +# The "shellcheck disable" line above the timestamp inhibits complaints +# about features and limitations of the classic Bourne shell that were +# superseded or lifted in POSIX. However, this script identifies a wide +# variety of pre-POSIX systems that do not have POSIX shells at all, and +# even some reasonably current systems (Solaris 10 as case-in-point) still +# have a pre-POSIX /bin/sh. + me=`echo "$0" | sed -e 's,.*/,,'` usage="\ @@ -67,7 +76,7 @@ Report bugs and patches to <config-patches@gnu.org>." version="\ GNU config.sub ($timestamp) -Copyright 1992-2018 Free Software Foundation, Inc. +Copyright 1992-2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -89,7 +98,7 @@ while test $# -gt 0 ; do - ) # Use stdin as input. break ;; -* ) - echo "$me: invalid option $1$help" + echo "$me: invalid option $1$help" >&2 exit 1 ;; *local*) @@ -111,9 +120,12 @@ case $# in esac # Split fields of configuration type -IFS="-" read -r field1 field2 field3 field4 <<EOF +# shellcheck disable=SC2162 +saved_IFS=$IFS +IFS="-" read field1 field2 field3 field4 <<EOF $1 EOF +IFS=$saved_IFS # Separate into logical components for further validation case $1 in @@ -123,55 +135,68 @@ case $1 in ;; *-*-*-*) basic_machine=$field1-$field2 - os=$field3-$field4 + basic_os=$field3-$field4 ;; *-*-*) # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two # parts maybe_os=$field2-$field3 case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc \ - | linux-newlib* | linux-musl* | linux-uclibc* | uclinux-uclibc* \ + nto-qnx* | linux-* | uclinux-uclibc* \ | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ | storm-chaos* | os2-emx* | rtmk-nova*) basic_machine=$field1 - os=$maybe_os + basic_os=$maybe_os ;; android-linux) basic_machine=$field1-unknown - os=linux-android + basic_os=linux-android ;; *) basic_machine=$field1-$field2 - os=$field3 + basic_os=$field3 ;; esac ;; *-*) - # Second component is usually, but not always the OS - case $field2 in - # Prevent following clause from handling this valid os - sun*os*) - basic_machine=$field1 - os=$field2 - ;; - # Manufacturers - dec* | mips* | sequent* | encore* | pc532* | sgi* | sony* \ - | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ - | unicom* | ibm* | next | hp | isi* | apollo | altos* \ - | convergent* | ncr* | news | 32* | 3600* | 3100* | hitachi* \ - | c[123]* | convex* | sun | crds | omron* | dg | ultra | tti* \ - | harris | dolphin | highlevel | gould | cbm | ns | masscomp \ - | apple | axis | knuth | cray | microblaze* \ - | sim | cisco | oki | wec | wrs | winbond) - basic_machine=$field1-$field2 - os= - ;; - *) - basic_machine=$field1 - os=$field2 - ;; + # A lone config we happen to match not fitting any pattern + case $field1-$field2 in + decstation-3100) + basic_machine=mips-dec + basic_os= + ;; + *-*) + # Second component is usually, but not always the OS + case $field2 in + # Prevent following clause from handling this valid os + sun*os*) + basic_machine=$field1 + basic_os=$field2 + ;; + zephyr*) + basic_machine=$field1-unknown + basic_os=$field2 + ;; + # Manufacturers + dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ + | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ + | unicom* | ibm* | next | hp | isi* | apollo | altos* \ + | convergent* | ncr* | news | 32* | 3600* | 3100* \ + | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \ + | ultra | tti* | harris | dolphin | highlevel | gould \ + | cbm | ns | masscomp | apple | axis | knuth | cray \ + | microblaze* | sim | cisco \ + | oki | wec | wrs | winbond) + basic_machine=$field1-$field2 + basic_os= + ;; + *) + basic_machine=$field1 + basic_os=$field2 + ;; + esac + ;; esac ;; *) @@ -180,1105 +205,1100 @@ case $1 in case $field1 in 386bsd) basic_machine=i386-pc - os=bsd + basic_os=bsd ;; a29khif) basic_machine=a29k-amd - os=udi + basic_os=udi ;; adobe68k) basic_machine=m68010-adobe - os=scout + basic_os=scout + ;; + alliant) + basic_machine=fx80-alliant + basic_os= + ;; + altos | altos3068) + basic_machine=m68k-altos + basic_os= ;; am29k) basic_machine=a29k-none - os=bsd + basic_os=bsd ;; amdahl) basic_machine=580-amdahl - os=sysv + basic_os=sysv + ;; + amiga) + basic_machine=m68k-unknown + basic_os= ;; amigaos | amigados) basic_machine=m68k-unknown - os=amigaos + basic_os=amigaos ;; amigaunix | amix) basic_machine=m68k-unknown - os=sysv4 + basic_os=sysv4 ;; apollo68) basic_machine=m68k-apollo - os=sysv + basic_os=sysv ;; apollo68bsd) basic_machine=m68k-apollo - os=bsd + basic_os=bsd ;; aros) basic_machine=i386-pc - os=aros + basic_os=aros ;; aux) basic_machine=m68k-apple - os=aux + basic_os=aux ;; balance) basic_machine=ns32k-sequent - os=dynix + basic_os=dynix ;; blackfin) basic_machine=bfin-unknown - os=linux + basic_os=linux ;; cegcc) basic_machine=arm-unknown - os=cegcc + basic_os=cegcc + ;; + convex-c1) + basic_machine=c1-convex + basic_os=bsd + ;; + convex-c2) + basic_machine=c2-convex + basic_os=bsd + ;; + convex-c32) + basic_machine=c32-convex + basic_os=bsd + ;; + convex-c34) + basic_machine=c34-convex + basic_os=bsd + ;; + convex-c38) + basic_machine=c38-convex + basic_os=bsd ;; cray) basic_machine=j90-cray - os=unicos + basic_os=unicos + ;; + crds | unos) + basic_machine=m68k-crds + basic_os= ;; - craynv) - basic_machine=craynv-cray - os=unicosmp + da30) + basic_machine=m68k-da30 + basic_os= + ;; + decstation | pmax | pmin | dec3100 | decstatn) + basic_machine=mips-dec + basic_os= ;; delta88) basic_machine=m88k-motorola - os=sysv3 + basic_os=sysv3 ;; dicos) basic_machine=i686-pc - os=dicos + basic_os=dicos ;; djgpp) basic_machine=i586-pc - os=msdosdjgpp + basic_os=msdosdjgpp ;; ebmon29k) basic_machine=a29k-amd - os=ebmon + basic_os=ebmon ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson - os=ose + basic_os=ose ;; gmicro) basic_machine=tron-gmicro - os=sysv + basic_os=sysv ;; go32) basic_machine=i386-pc - os=go32 + basic_os=go32 ;; h8300hms) basic_machine=h8300-hitachi - os=hms + basic_os=hms ;; h8300xray) basic_machine=h8300-hitachi - os=xray + basic_os=xray ;; h8500hms) basic_machine=h8500-hitachi - os=hms + basic_os=hms ;; harris) basic_machine=m88k-harris - os=sysv3 + basic_os=sysv3 ;; - hp300bsd) + hp300 | hp300hpux) basic_machine=m68k-hp - os=bsd + basic_os=hpux ;; - hp300hpux) + hp300bsd) basic_machine=m68k-hp - os=hpux + basic_os=bsd ;; hppaosf) basic_machine=hppa1.1-hp - os=osf + basic_os=osf ;; hppro) basic_machine=hppa1.1-hp - os=proelf + basic_os=proelf ;; i386mach) basic_machine=i386-mach - os=mach - ;; - vsta) - basic_machine=i386-unknown - os=vsta + basic_os=mach ;; isi68 | isi) basic_machine=m68k-isi - os=sysv + basic_os=sysv ;; m68knommu) basic_machine=m68k-unknown - os=linux + basic_os=linux ;; magnum | m3230) basic_machine=mips-mips - os=sysv + basic_os=sysv ;; merlin) basic_machine=ns32k-utek - os=sysv + basic_os=sysv ;; mingw64) basic_machine=x86_64-pc - os=mingw64 + basic_os=mingw64 ;; mingw32) basic_machine=i686-pc - os=mingw32 + basic_os=mingw32 ;; mingw32ce) basic_machine=arm-unknown - os=mingw32ce + basic_os=mingw32ce ;; monitor) basic_machine=m68k-rom68k - os=coff + basic_os=coff ;; morphos) basic_machine=powerpc-unknown - os=morphos + basic_os=morphos ;; moxiebox) basic_machine=moxie-unknown - os=moxiebox + basic_os=moxiebox ;; msdos) basic_machine=i386-pc - os=msdos + basic_os=msdos ;; msys) basic_machine=i686-pc - os=msys + basic_os=msys ;; mvs) basic_machine=i370-ibm - os=mvs + basic_os=mvs ;; nacl) basic_machine=le32-unknown - os=nacl + basic_os=nacl ;; ncr3000) basic_machine=i486-ncr - os=sysv4 + basic_os=sysv4 ;; netbsd386) - basic_machine=i386-unknown - os=netbsd + basic_machine=i386-pc + basic_os=netbsd ;; netwinder) basic_machine=armv4l-rebel - os=linux + basic_os=linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony - os=newsos + basic_os=newsos ;; news1000) basic_machine=m68030-sony - os=newsos + basic_os=newsos ;; necv70) basic_machine=v70-nec - os=sysv + basic_os=sysv ;; nh3000) basic_machine=m68k-harris - os=cxux + basic_os=cxux ;; nh[45]000) basic_machine=m88k-harris - os=cxux + basic_os=cxux ;; nindy960) basic_machine=i960-intel - os=nindy + basic_os=nindy ;; mon960) basic_machine=i960-intel - os=mon960 + basic_os=mon960 ;; nonstopux) basic_machine=mips-compaq - os=nonstopux + basic_os=nonstopux ;; os400) basic_machine=powerpc-ibm - os=os400 + basic_os=os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson - os=ose + basic_os=ose ;; os68k) basic_machine=m68k-none - os=os68k + basic_os=os68k ;; paragon) basic_machine=i860-intel - os=osf + basic_os=osf ;; parisc) basic_machine=hppa-unknown - os=linux + basic_os=linux + ;; + psp) + basic_machine=mipsallegrexel-sony + basic_os=psp ;; pw32) basic_machine=i586-unknown - os=pw32 + basic_os=pw32 ;; rdos | rdos64) basic_machine=x86_64-pc - os=rdos + basic_os=rdos ;; rdos32) basic_machine=i386-pc - os=rdos + basic_os=rdos ;; rom68k) basic_machine=m68k-rom68k - os=coff + basic_os=coff ;; sa29200) basic_machine=a29k-amd - os=udi + basic_os=udi ;; sei) basic_machine=mips-sei - os=seiux + basic_os=seiux + ;; + sequent) + basic_machine=i386-sequent + basic_os= ;; sps7) basic_machine=m68k-bull - os=sysv2 + basic_os=sysv2 + ;; + st2000) + basic_machine=m68k-tandem + basic_os= ;; stratus) basic_machine=i860-stratus - os=sysv4 + basic_os=sysv4 + ;; + sun2) + basic_machine=m68000-sun + basic_os= ;; sun2os3) basic_machine=m68000-sun - os=sunos3 + basic_os=sunos3 ;; sun2os4) basic_machine=m68000-sun - os=sunos4 + basic_os=sunos4 + ;; + sun3) + basic_machine=m68k-sun + basic_os= ;; sun3os3) basic_machine=m68k-sun - os=sunos3 + basic_os=sunos3 ;; sun3os4) basic_machine=m68k-sun - os=sunos4 + basic_os=sunos4 + ;; + sun4) + basic_machine=sparc-sun + basic_os= ;; sun4os3) basic_machine=sparc-sun - os=sunos3 + basic_os=sunos3 ;; sun4os4) basic_machine=sparc-sun - os=sunos4 + basic_os=sunos4 ;; sun4sol2) basic_machine=sparc-sun - os=solaris2 + basic_os=solaris2 + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + basic_os= ;; sv1) basic_machine=sv1-cray - os=unicos + basic_os=unicos ;; symmetry) basic_machine=i386-sequent - os=dynix + basic_os=dynix ;; t3e) basic_machine=alphaev5-cray - os=unicos + basic_os=unicos ;; t90) basic_machine=t90-cray - os=unicos + basic_os=unicos ;; toad1) basic_machine=pdp10-xkl - os=tops20 + basic_os=tops20 ;; tpf) basic_machine=s390x-ibm - os=tpf + basic_os=tpf ;; udi29k) basic_machine=a29k-amd - os=udi + basic_os=udi ;; ultra3) basic_machine=a29k-nyu - os=sym1 + basic_os=sym1 ;; v810 | necv810) basic_machine=v810-nec - os=none + basic_os=none ;; vaxv) basic_machine=vax-dec - os=sysv + basic_os=sysv ;; vms) basic_machine=vax-dec - os=vms + basic_os=vms + ;; + vsta) + basic_machine=i386-pc + basic_os=vsta ;; vxworks960) basic_machine=i960-wrs - os=vxworks + basic_os=vxworks ;; vxworks68) basic_machine=m68k-wrs - os=vxworks + basic_os=vxworks ;; vxworks29k) basic_machine=a29k-wrs - os=vxworks + basic_os=vxworks ;; xbox) basic_machine=i686-pc - os=mingw32 + basic_os=mingw32 ;; ymp) basic_machine=ymp-cray - os=unicos + basic_os=unicos ;; *) basic_machine=$1 - os= + basic_os= ;; esac ;; esac -# Decode aliases for certain CPU-COMPANY combinations. +# Decode 1-component or ad-hoc basic machines case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | aarch64 | aarch64_be \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arceb \ - | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv6m | armv[78][arm] \ - | avr | avr32 \ - | ba \ - | be32 | be64 \ - | bfin \ - | c4x | c8051 | clipper | csky \ - | d10v | d30v | dlx | dsp16xx \ - | e2k | epiphany \ - | fido | fr30 | frv | ft32 \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ - | i370 | i860 | i960 | ia16 | ia64 \ - | ip2k | iq2000 \ - | k1om \ - | le32 | le64 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa32r6 | mipsisa32r6el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64r6 | mipsisa64r6el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipsr5900 | mipsr5900el \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | moxie \ - | mt \ - | msp430 \ - | nds32 | nds32le | nds32be \ - | nfp \ - | nios | nios2 | nios2eb | nios2el \ - | ns16k | ns32k \ - | open8 | or1k | or1knd | or32 \ - | pdp10 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pru \ - | pyramid \ - | riscv | riscv32 | riscv64 \ - | rl78 | rx \ - | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | visium \ - | wasm32 \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) - basic_machine=$basic_machine-unknown - ;; - c54x) - basic_machine=tic54x-unknown - ;; - c55x) - basic_machine=tic55x-unknown - ;; - c6x) - basic_machine=tic6x-unknown - ;; - leon|leon[3-9]) - basic_machine=sparc-$basic_machine - ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) - basic_machine=$basic_machine-unknown - os=${os:-none} - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65) + # Here we handle the default manufacturer of certain CPU types. It is in + # some cases the only manufacturer, in others, it is the most popular. + w89k) + cpu=hppa1.1 + vendor=winbond ;; - m9s12z | m68hcs12z | hcs12z | s12z) - basic_machine=s12z-unknown - os=${os:-none} + op50n) + cpu=hppa1.1 + vendor=oki ;; - ms1) - basic_machine=mt-unknown + op60c) + cpu=hppa1.1 + vendor=oki ;; - strongarm | thumb | xscale) - basic_machine=arm-unknown + ibm*) + cpu=i370 + vendor=ibm ;; - xgate) - basic_machine=$basic_machine-unknown - os=${os:-none} + orion105) + cpu=clipper + vendor=highlevel ;; - xscaleeb) - basic_machine=armeb-unknown + mac | mpw | mac-mpw) + cpu=m68k + vendor=apple ;; - - xscaleel) - basic_machine=armel-unknown + pmac | pmac-mpw) + cpu=powerpc + vendor=apple ;; - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | aarch64-* | aarch64_be-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | ba-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | c8051-* | clipper-* | craynv-* | csky-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | e2k-* | elxsi-* \ - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ - | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ - | ip2k-* | iq2000-* \ - | k1om-* \ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ - | microblaze-* | microblazeel-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64octeon-* | mips64octeonel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64r5900-* | mips64r5900el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa32r6-* | mipsisa32r6el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64r6-* | mipsisa64r6el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipsr5900-* | mipsr5900el-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nfp-* \ - | nios-* | nios2-* | nios2eb-* | nios2el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ - | or1k*-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pru-* \ - | pyramid-* \ - | riscv-* | riscv32-* | riscv64-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ - | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ - | visium-* \ - | wasm32-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | xstormy16-* | xtensa*-* \ - | ymp-* \ - | z8k-* | z80-*) - ;; - # Recognize the basic CPU types without company name, with glob match. - xtensa*) - basic_machine=$basic_machine-unknown - ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att + cpu=m68000 + vendor=att ;; 3b*) - basic_machine=we32k-att - ;; - abacus) - basic_machine=abacus-unknown - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'` - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - asmjs) - basic_machine=asmjs-unknown - ;; - blackfin-*) - basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'` - os=linux + cpu=we32k + vendor=att ;; bluegene*) - basic_machine=powerpc-ibm - os=cnk - ;; - c54x-*) - basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'` - ;; - c90) - basic_machine=c90-cray - os=${os:-unicos} - ;; - convex-c1) - basic_machine=c1-convex - os=bsd - ;; - convex-c2) - basic_machine=c2-convex - os=bsd - ;; - convex-c32) - basic_machine=c32-convex - os=bsd - ;; - convex-c34) - basic_machine=c34-convex - os=bsd - ;; - convex-c38) - basic_machine=c38-convex - os=bsd - ;; - cr16 | cr16-*) - basic_machine=cr16-unknown - os=${os:-elf} - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=${os:-elf} - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec + cpu=powerpc + vendor=ibm + basic_os=cnk ;; decsystem10* | dec10*) - basic_machine=pdp10-dec - os=tops10 + cpu=pdp10 + vendor=dec + basic_os=tops10 ;; decsystem20* | dec20*) - basic_machine=pdp10-dec - os=tops20 + cpu=pdp10 + vendor=dec + basic_os=tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=${os:-bosx} + cpu=m68k + vendor=motorola ;; dpx2*) - basic_machine=m68k-bull - os=sysv3 - ;; - e500v[12]) - basic_machine=powerpc-unknown - os=$os"spe" - ;; - e500v[12]-*) - basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` - os=$os"spe" + cpu=m68k + vendor=bull + basic_os=sysv3 ;; encore | umax | mmax) - basic_machine=ns32k-encore + cpu=ns32k + vendor=encore ;; elxsi) - basic_machine=elxsi-elxsi - os=${os:-bsd} + cpu=elxsi + vendor=elxsi + basic_os=${basic_os:-bsd} ;; fx2800) - basic_machine=i860-alliant + cpu=i860 + vendor=alliant ;; genix) - basic_machine=ns32k-ns + cpu=ns32k + vendor=ns ;; h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=hiuxwe2 - ;; - hp300-*) - basic_machine=m68k-hp + cpu=hppa1.1 + vendor=hitachi + basic_os=hiuxwe2 ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp + cpu=hppa1.0 + vendor=hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp + cpu=m68000 + vendor=hp ;; hp9k3[2-9][0-9]) - basic_machine=m68k-hp + cpu=m68k + vendor=hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp + cpu=hppa1.0 + vendor=hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm + cpu=hppa1.0 + vendor=hp ;; i*86v32) - basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` - os=sysv32 + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv32 ;; i*86v4*) - basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` - os=sysv4 + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv4 ;; i*86v) - basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` - os=sysv + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv ;; i*86sol2) - basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` - os=solaris2 + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=solaris2 ;; j90 | j90-cray) - basic_machine=j90-cray - os=${os:-unicos} + cpu=j90 + vendor=cray + basic_os=${basic_os:-unicos} ;; iris | iris4d) - basic_machine=mips-sgi - case $os in + cpu=mips + vendor=sgi + case $basic_os in irix*) ;; *) - os=irix4 + basic_os=irix4 ;; esac ;; - leon-*|leon[3-9]-*) - basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'` - ;; - m68knommu-*) - basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'` - os=linux - ;; - microblaze*) - basic_machine=microblaze-xilinx - ;; miniframe) - basic_machine=m68000-convergent + cpu=m68000 + vendor=convergent ;; *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=mint - ;; - mips3*-*) - basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown - ;; - ms1-*) - basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'` + cpu=m68k + vendor=atari + basic_os=mint ;; news-3600 | risc-news) - basic_machine=mips-sony - os=newsos + cpu=mips + vendor=sony + basic_os=newsos ;; next | m*-next) - basic_machine=m68k-next - case $os in - nextstep* ) + cpu=m68k + vendor=next + case $basic_os in + openstep*) + ;; + nextstep*) ;; ns2*) - os=nextstep2 + basic_os=nextstep2 ;; *) - os=nextstep3 + basic_os=nextstep3 ;; esac ;; np1) - basic_machine=np1-gould + cpu=np1 + vendor=gould ;; - neo-tandem) - basic_machine=neo-tandem + op50n-* | op60c-*) + cpu=hppa1.1 + vendor=oki + basic_os=proelf ;; - nse-tandem) - basic_machine=nse-tandem + pa-hitachi) + cpu=hppa1.1 + vendor=hitachi + basic_os=hiuxwe2 ;; - nsr-tandem) - basic_machine=nsr-tandem + pbd) + cpu=sparc + vendor=tti ;; - nsv-tandem) - basic_machine=nsv-tandem + pbb) + cpu=m68k + vendor=tti ;; - nsx-tandem) - basic_machine=nsx-tandem + pc532) + cpu=ns32k + vendor=pc532 ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=proelf + pn) + cpu=pn + vendor=gould ;; - openrisc | openrisc-*) - basic_machine=or32-unknown + power) + cpu=power + vendor=ibm ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=hiuxwe2 + ps2) + cpu=i386 + vendor=ibm ;; - parisc-*) - basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'` - os=linux + rm[46]00) + cpu=mips + vendor=siemens ;; - pbd) - basic_machine=sparc-tti + rtpc | rtpc-*) + cpu=romp + vendor=ibm ;; - pbb) - basic_machine=m68k-tti + sde) + cpu=mipsisa32 + vendor=sde + basic_os=${basic_os:-elf} ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 + simso-wrs) + cpu=sparclite + vendor=wrs + basic_os=vxworks ;; - pc98) - basic_machine=i386-pc + tower | tower-32) + cpu=m68k + vendor=ncr ;; - pc98-*) - basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'` + vpp*|vx|vx-*) + cpu=f301 + vendor=fujitsu ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc + w65) + cpu=w65 + vendor=wdc ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc + w89k-*) + cpu=hppa1.1 + vendor=winbond + basic_os=proelf ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc + none) + cpu=none + vendor=none ;; - pentium4) - basic_machine=i786-pc + leon|leon[3-9]) + cpu=sparc + vendor=$basic_machine ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'` + leon-*|leon[3-9]-*) + cpu=sparc + vendor=`echo "$basic_machine" | sed 's/-.*//'` ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` + + *-*) + # shellcheck disable=SC2162 + saved_IFS=$IFS + IFS="-" read cpu vendor <<EOF +$basic_machine +EOF + IFS=$saved_IFS ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + cpu=$basic_machine + vendor=pc ;; - pentium4-*) - basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'` + # These rules are duplicated from below for sake of the special case above; + # i.e. things that normalized to x86 arches should also default to "pc" + pc98) + cpu=i386 + vendor=pc ;; - pn) - basic_machine=pn-gould + x64 | amd64) + cpu=x86_64 + vendor=pc ;; - power) basic_machine=power-ibm + # Recognize the basic CPU types without company name. + *) + cpu=$basic_machine + vendor=unknown ;; - ppc | ppcbe) basic_machine=powerpc-unknown +esac + +unset -v basic_machine + +# Decode basic machines in the full and proper CPU-Company form. +case $cpu-$vendor in + # Here we handle the default manufacturer of certain CPU types in canonical form. It is in + # some cases the only manufacturer, in others, it is the most popular. + craynv-unknown) + vendor=cray + basic_os=${basic_os:-unicosmp} ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` + c90-unknown | c90-cray) + vendor=cray + basic_os=${Basic_os:-unicos} ;; - ppcle | powerpclittle) - basic_machine=powerpcle-unknown + fx80-unknown) + vendor=alliant ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'` + romp-unknown) + vendor=ibm ;; - ppc64) basic_machine=powerpc64-unknown + mmix-unknown) + vendor=knuth ;; - ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'` + microblaze-unknown | microblazeel-unknown) + vendor=xilinx ;; - ppc64le | powerpc64little) - basic_machine=powerpc64le-unknown + rs6000-unknown) + vendor=ibm ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'` + vax-unknown) + vendor=dec ;; - ps2) - basic_machine=i386-ibm + pdp11-unknown) + vendor=dec ;; - rm[46]00) - basic_machine=mips-siemens + we32k-unknown) + vendor=att ;; - rtpc | rtpc-*) - basic_machine=romp-ibm + cydra-unknown) + vendor=cydrome ;; - s390 | s390-*) - basic_machine=s390-ibm + i370-ibm*) + vendor=ibm ;; - s390x | s390x-*) - basic_machine=s390x-ibm + orion-unknown) + vendor=highlevel ;; - sb1) - basic_machine=mipsisa64sb1-unknown + xps-unknown | xps100-unknown) + cpu=xps100 + vendor=honeywell ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown + + # Here we normalize CPU types with a missing or matching vendor + armh-unknown | armh-alt) + cpu=armv7l + vendor=alt + basic_os=${basic_os:-linux-gnueabihf} ;; - sde) - basic_machine=mipsisa32-sde - os=${os:-elf} + dpx20-unknown | dpx20-bull) + cpu=rs6000 + vendor=bull + basic_os=${basic_os:-bosx} ;; - sequent) - basic_machine=i386-sequent + + # Here we normalize CPU types irrespective of the vendor + amd64-*) + cpu=x86_64 ;; - sh5el) - basic_machine=sh5le-unknown + blackfin-*) + cpu=bfin + basic_os=linux ;; - simso-wrs) - basic_machine=sparclite-wrs - os=vxworks + c54x-*) + cpu=tic54x ;; - spur) - basic_machine=spur-unknown + c55x-*) + cpu=tic55x ;; - st2000) - basic_machine=m68k-tandem + c6x-*) + cpu=tic6x ;; - strongarm-* | thumb-*) - basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'` + e500v[12]-*) + cpu=powerpc + basic_os=${basic_os}"spe" ;; - sun2) - basic_machine=m68000-sun + mips3*-*) + cpu=mips64 ;; - sun3 | sun3-*) - basic_machine=m68k-sun + ms1-*) + cpu=mt ;; - sun4) - basic_machine=sparc-sun + m68knommu-*) + cpu=m68k + basic_os=linux ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun + m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*) + cpu=s12z ;; - tile*) - basic_machine=$basic_machine-unknown - os=linux-gnu + openrisc-*) + cpu=or32 ;; - tx39) - basic_machine=mipstx39-unknown + parisc-*) + cpu=hppa + basic_os=linux ;; - tx39el) - basic_machine=mipstx39el-unknown + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + cpu=i586 ;; - tower | tower-32) - basic_machine=m68k-ncr + pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*) + cpu=i686 ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + cpu=i686 ;; - w65*) - basic_machine=w65-wdc - os=none + pentium4-*) + cpu=i786 ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=proelf + pc98-*) + cpu=i386 ;; - x64) - basic_machine=x86_64-pc + ppc-* | ppcbe-*) + cpu=powerpc ;; - xps | xps100) - basic_machine=xps100-honeywell + ppcle-* | powerpclittle-*) + cpu=powerpcle ;; - xscale-* | xscalee[bl]-*) - basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'` + ppc64-*) + cpu=powerpc64 ;; - none) - basic_machine=none-none - os=${os:-none} + ppc64le-* | powerpc64little-*) + cpu=powerpc64le ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond + sb1-*) + cpu=mipsisa64sb1 ;; - op50n) - basic_machine=hppa1.1-oki + sb1el-*) + cpu=mipsisa64sb1el ;; - op60c) - basic_machine=hppa1.1-oki + sh5e[lb]-*) + cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'` ;; - romp) - basic_machine=romp-ibm + spur-*) + cpu=spur ;; - mmix) - basic_machine=mmix-knuth + strongarm-* | thumb-*) + cpu=arm ;; - rs6000) - basic_machine=rs6000-ibm + tx39-*) + cpu=mipstx39 ;; - vax) - basic_machine=vax-dec + tx39el-*) + cpu=mipstx39el ;; - pdp11) - basic_machine=pdp11-dec + x64-*) + cpu=x86_64 ;; - we32k) - basic_machine=we32k-att + xscale-* | xscalee[bl]-*) + cpu=`echo "$cpu" | sed 's/^xscale/arm/'` ;; - sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown + arm64-* | aarch64le-*) + cpu=aarch64 ;; - cydra) - basic_machine=cydra-cydrome + + # Recognize the canonical CPU Types that limit and/or modify the + # company names they are paired with. + cr16-*) + basic_os=${basic_os:-elf} ;; - orion) - basic_machine=orion-highlevel + crisv32-* | etraxfs*-*) + cpu=crisv32 + vendor=axis ;; - orion105) - basic_machine=clipper-highlevel + cris-* | etrax*-*) + cpu=cris + vendor=axis ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple + crx-*) + basic_os=${basic_os:-elf} ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple + neo-tandem) + cpu=neo + vendor=tandem + ;; + nse-tandem) + cpu=nse + vendor=tandem ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. + nsr-tandem) + cpu=nsr + vendor=tandem + ;; + nsv-tandem) + cpu=nsv + vendor=tandem + ;; + nsx-tandem) + cpu=nsx + vendor=tandem + ;; + mipsallegrexel-sony) + cpu=mipsallegrexel + vendor=sony ;; + tile*-*) + basic_os=${basic_os:-linux-gnu} + ;; + *) - echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 - exit 1 + # Recognize the canonical CPU types that are allowed with any + # company name. + case $cpu in + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | abacus \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \ + | alphapca5[67] | alpha64pca5[67] \ + | am33_2.0 \ + | amdgcn \ + | arc | arceb | arc32 | arc64 \ + | arm | arm[lb]e | arme[lb] | armv* \ + | avr | avr32 \ + | asmjs \ + | ba \ + | be32 | be64 \ + | bfin | bpf | bs2000 \ + | c[123]* | c30 | [cjt]90 | c4x \ + | c8051 | clipper | craynv | csky | cydra \ + | d10v | d30v | dlx | dsp16xx \ + | e2k | elxsi | epiphany \ + | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \ + | h8300 | h8500 \ + | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i*86 | i860 | i960 | ia16 | ia64 \ + | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ + | lm32 \ + | loongarch32 | loongarch64 \ + | m32c | m32r | m32rle \ + | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \ + | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \ + | m88110 | m88k | maxq | mb | mcore | mep | metag \ + | microblaze | microblazeel \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64eb | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r3 | mipsisa32r3el \ + | mipsisa32r5 | mipsisa32r5el \ + | mipsisa32r6 | mipsisa32r6el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r3 | mipsisa64r3el \ + | mipsisa64r5 | mipsisa64r5el \ + | mipsisa64r6 | mipsisa64r6el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mmix \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nfp \ + | nios | nios2 | nios2eb | nios2el \ + | none | np1 | ns16k | ns32k | nvptx \ + | open8 \ + | or1k* \ + | or32 \ + | orion \ + | picochip \ + | pdp10 | pdp11 | pj | pjl | pn | power \ + | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \ + | pru \ + | pyramid \ + | riscv | riscv32 | riscv32be | riscv64 | riscv64be \ + | rl78 | romp | rs6000 | rx \ + | s390 | s390x \ + | score \ + | sh | shl \ + | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \ + | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \ + | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \ + | spu \ + | tahoe \ + | thumbv7* \ + | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \ + | tron \ + | ubicom32 \ + | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \ + | vax \ + | visium \ + | w65 \ + | wasm32 | wasm64 \ + | we32k \ + | x86 | x86_64 | xc16x | xgate | xps100 \ + | xstormy16 | xtensa* \ + | ymp \ + | z8k | z80) + ;; + + *) + echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2 + exit 1 + ;; + esac ;; esac # Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'` +case $vendor in + digital*) + vendor=dec ;; - *-commodore*) - basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'` + commodore*) + vendor=cbm ;; *) ;; @@ -1286,8 +1306,49 @@ esac # Decode manufacturer-specific aliases for certain operating systems. -if [ x$os != x ] +if test x$basic_os != x then + +# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just +# set os. +case $basic_os in + gnu/linux*) + kernel=linux + os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'` + ;; + os2-emx) + kernel=os2 + os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'` + ;; + nto-qnx*) + kernel=nto + os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'` + ;; + *-*) + # shellcheck disable=SC2162 + saved_IFS=$IFS + IFS="-" read kernel os <<EOF +$basic_os +EOF + IFS=$saved_IFS + ;; + # Default OS when just kernel was specified + nto*) + kernel=nto + os=`echo "$basic_os" | sed -e 's|nto|qnx|'` + ;; + linux*) + kernel=linux + os=`echo "$basic_os" | sed -e 's|linux|gnu|'` + ;; + *) + kernel= + os=$basic_os + ;; +esac + +# Now, normalize the OS (knowing we just have one component, it's not a kernel, +# etc.) case $os in # First match some system type aliases that might get confused # with valid system types. @@ -1299,7 +1360,7 @@ case $os in os=cnk ;; solaris1 | solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` + os=`echo "$os" | sed -e 's|solaris1|sunos4|'` ;; solaris) os=solaris2 @@ -1307,9 +1368,6 @@ case $os in unixware*) os=sysv4.2uw ;; - gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` - ;; # es1800 is here to avoid being matched by es* (a different OS) es1800*) os=ose @@ -1331,12 +1389,9 @@ case $os in os=sco3.2v4 ;; sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'` ;; - sco3.2v[4-9]* | sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - ;; - scout) + sco*v* | scout) # Don't match below ;; sco*) @@ -1345,77 +1400,25 @@ case $os in psos*) os=psos ;; - # Now accept the basic system types. - # The portable systems comes first. - # Each alternative MUST end in a * to match a version number. - # sysv* is not here because it comes later, after sysvr4. - gnu* | bsd* | mach* | minix* | genix* | ultrix* | irix* \ - | *vms* | esix* | aix* | cnk* | sunos | sunos[34]*\ - | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ - | sym* | kopensolaris* | plan9* \ - | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ - | aos* | aros* | cloudabi* | sortix* \ - | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ - | clix* | riscos* | uniplus* | iris* | rtu* | xenix* \ - | knetbsd* | mirbsd* | netbsd* \ - | bitrig* | openbsd* | solidbsd* | libertybsd* \ - | ekkobsd* | kfreebsd* | freebsd* | riscix* | lynxos* \ - | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ - | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ - | udi* | eabi* | lites* | ieee* | go32* | aux* | hcos* \ - | chorusrdb* | cegcc* | glidix* \ - | cygwin* | msys* | pe* | moss* | proelf* | rtems* \ - | midipix* | mingw32* | mingw64* | linux-gnu* | linux-android* \ - | linux-newlib* | linux-musl* | linux-uclibc* \ - | uxpv* | beos* | mpeix* | udk* | moxiebox* \ - | interix* | uwin* | mks* | rhapsody* | darwin* \ - | openstep* | oskit* | conix* | pw32* | nonstopux* \ - | storm-chaos* | tops10* | tenex* | tops20* | its* \ - | os2* | vos* | palmos* | uclinux* | nucleus* \ - | morphos* | superux* | rtmk* | windiss* \ - | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ - | skyos* | haiku* | rdos* | toppers* | drops* | es* \ - | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ - | midnightbsd*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; qnx*) - case $basic_machine in - x86-* | i*86-*) - ;; - *) - os=nto-$os - ;; - esac + os=qnx ;; hiux*) os=hiuxwe2 ;; - nto-qnx*) - ;; - nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` - ;; - sim | xray | os68k* | v88r* \ - | windows* | osx | abug | netware* | os9* \ - | macos* | mpw* | magic* | mmixware* | mon960* | lnews*) - ;; - linux-dietlibc) - os=linux-dietlibc - ;; - linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; lynx*178) os=lynxos178 ;; lynx*5) os=lynxos5 ;; + lynxos*) + # don't get caught up in next wildcard + ;; lynx*) os=lynxos ;; - mac*) + mac[0-9]*) os=`echo "$os" | sed -e 's|mac|macos|'` ;; opened*) @@ -1460,12 +1463,9 @@ case $os in ns2) os=nextstep2 ;; - nsk*) - os=nsk - ;; # Preserve the version number of sinix5. sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` + os=`echo "$os" | sed -e 's|sinix|sysv|'` ;; sinix*) os=sysv4 @@ -1488,18 +1488,12 @@ case $os in sysvr4) os=sysv4 ;; - # This must come after sysvr4. - sysv*) - ;; ose*) os=ose ;; *mint | mint[0-9]* | *MiNT | MiNT[0-9]*) os=mint ;; - zvmoe) - os=zvmoe - ;; dicos*) os=dicos ;; @@ -1507,7 +1501,7 @@ case $os in # Until real need of OS specific support for # particular features comes up, bare metal # configurations are quite functional. - case $basic_machine in + case $cpu in arm*) os=eabi ;; @@ -1516,19 +1510,11 @@ case $os in ;; esac ;; - nacl*) - ;; - ios) - ;; - none) - ;; - *-eabi) - ;; *) - echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2 - exit 1 + # No normalization, but not necessarily accepted, that comes below. ;; esac + else # Here we handle the default operating systems that come with various machines. @@ -1541,7 +1527,8 @@ else # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. -case $basic_machine in +kernel= +case $cpu-$vendor in score-*) os=elf ;; @@ -1552,7 +1539,8 @@ case $basic_machine in os=riscix1.2 ;; arm*-rebel) - os=linux + kernel=linux + os=gnu ;; arm*-semi) os=aout @@ -1718,86 +1706,180 @@ case $basic_machine in os=none ;; esac + fi +# Now, validate our (potentially fixed-up) OS. +case $os in + # Sometimes we do "kernel-libc", so those need to count as OSes. + musl* | newlib* | relibc* | uclibc*) + ;; + # Likewise for "kernel-abi" + eabi* | gnueabi*) + ;; + # VxWorks passes extra cpu info in the 4th filed. + simlinux | simwindows | spe) + ;; + # Now accept the basic system types. + # The portable systems comes first. + # Each alternative MUST end in a * to match a version number. + gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \ + | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \ + | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ + | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \ + | hiux* | abug | nacl* | netware* | windows* \ + | os9* | macos* | osx* | ios* \ + | mpw* | magic* | mmixware* | mon960* | lnews* \ + | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ + | aos* | aros* | cloudabi* | sortix* | twizzler* \ + | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ + | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \ + | mirbsd* | netbsd* | dicos* | openedition* | ose* \ + | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \ + | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \ + | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ + | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ + | udi* | lites* | ieee* | go32* | aux* | hcos* \ + | chorusrdb* | cegcc* | glidix* | serenity* \ + | cygwin* | msys* | pe* | moss* | proelf* | rtems* \ + | midipix* | mingw32* | mingw64* | mint* \ + | uxpv* | beos* | mpeix* | udk* | moxiebox* \ + | interix* | uwin* | mks* | rhapsody* | darwin* \ + | openstep* | oskit* | conix* | pw32* | nonstopux* \ + | storm-chaos* | tops10* | tenex* | tops20* | its* \ + | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \ + | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \ + | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ + | skyos* | haiku* | rdos* | toppers* | drops* | es* \ + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ + | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ + | fiwix* ) + ;; + # This one is extra strict with allowed versions + sco3.2v2 | sco3.2v[4-9]* | sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + ;; + none) + ;; + *) + echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2 + exit 1 + ;; +esac + +# As a final step for OS-related things, validate the OS-kernel combination +# (given a valid OS), if there is a kernel. +case $kernel-$os in + linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \ + | linux-musl* | linux-relibc* | linux-uclibc* ) + ;; + uclinux-uclibc* ) + ;; + -dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* ) + # These are just libc implementations, not actual OSes, and thus + # require a kernel. + echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2 + exit 1 + ;; + kfreebsd*-gnu* | kopensolaris*-gnu*) + ;; + vxworks-simlinux | vxworks-simwindows | vxworks-spe) + ;; + nto-qnx*) + ;; + os2-emx) + ;; + *-eabi* | *-gnueabi*) + ;; + -*) + # Blank kernel with real OS is always fine. + ;; + *-*) + echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2 + exit 1 + ;; +esac + # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - riscix*) +case $vendor in + unknown) + case $cpu-$os in + *-riscix*) vendor=acorn ;; - sunos*) + *-sunos*) vendor=sun ;; - cnk*|-aix*) + *-cnk* | *-aix*) vendor=ibm ;; - beos*) + *-beos*) vendor=be ;; - hpux*) + *-hpux*) vendor=hp ;; - mpeix*) + *-mpeix*) vendor=hp ;; - hiux*) + *-hiux*) vendor=hitachi ;; - unos*) + *-unos*) vendor=crds ;; - dgux*) + *-dgux*) vendor=dg ;; - luna*) + *-luna*) vendor=omron ;; - genix*) + *-genix*) vendor=ns ;; - clix*) + *-clix*) vendor=intergraph ;; - mvs* | opened*) + *-mvs* | *-opened*) + vendor=ibm + ;; + *-os400*) vendor=ibm ;; - os400*) + s390-* | s390x-*) vendor=ibm ;; - ptx*) + *-ptx*) vendor=sequent ;; - tpf*) + *-tpf*) vendor=ibm ;; - vxsim* | vxworks* | windiss*) + *-vxsim* | *-vxworks* | *-windiss*) vendor=wrs ;; - aux*) + *-aux*) vendor=apple ;; - hms*) + *-hms*) vendor=hitachi ;; - mpw* | macos*) + *-mpw* | *-macos*) vendor=apple ;; - *mint | mint[0-9]* | *MiNT | MiNT[0-9]*) + *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*) vendor=atari ;; - vos*) + *-vos*) vendor=stratus ;; esac - basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"` ;; esac -echo "$basic_machine-$os" +echo "$cpu-$vendor-${kernel:+$kernel-}$os" exit # Local variables: diff --git a/contrib/libpcap/configure b/contrib/libpcap/configure index fa15fc7314eb..91fd1806e8a4 100755 --- a/contrib/libpcap/configure +++ b/contrib/libpcap/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for pcap 1.9.1. +# Generated by GNU Autoconf 2.69 for pcap 1.10.3. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -577,8 +577,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='pcap' PACKAGE_TARNAME='pcap' -PACKAGE_VERSION='1.9.1' -PACKAGE_STRING='pcap 1.9.1' +PACKAGE_VERSION='1.10.3' +PACKAGE_STRING='pcap 1.10.3' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -620,65 +620,74 @@ ac_includes_default="\ #endif" ac_subst_vars='LTLIBOBJS +RPCAPD_LIBS +INSTALL_RPCAPD +BUILD_RPCAPD +PTHREAD_LIBS +REMOTE_C_SRC +MODULE_C_SRC +PLATFORM_CXX_SRC +PLATFORM_C_SRC +ADDLARCHIVEOBJS +ADDLOBJS +RPATH +V_SONAME_OPT +V_SHLIB_OPT +V_SHLIB_CMD +V_SHLIB_CCOPT INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM -RDMA_SRC PCAP_SUPPORT_RDMASNIFF -DBUS_SRC +LIBIBVERBS_LIBS_STATIC +LIBIBVERBS_LIBS +LIBIBVERBS_CFLAGS PCAP_SUPPORT_DBUS -PKGCONFIG -BT_MONITOR_SRC -BT_SRC +DBUS_LIBS_STATIC +DBUS_LIBS +DBUS_CFLAGS PCAP_SUPPORT_BT -NETMAP_SRC +PCAP_SUPPORT_DPDK +DPDK_LIBS_STATIC +DPDK_LIBS +DPDK_CFLAGS PCAP_SUPPORT_NETMAP -NETFILTER_SRC PCAP_SUPPORT_NETFILTER -USB_SRC -PCAP_SUPPORT_USB -EXTRA_NETWORK_LIBS -RPCAPD_LIBS -INSTALL_RPCAPD -BUILD_RPCAPD -PTHREAD_LIBS +PCAP_SUPPORT_LINUX_USBMON +MKDEP +DEPENDENCY_CFLAG +LN_S +AR +RANLIB MAN_ADMIN_COMMANDS MAN_MISC_INFO MAN_FILE_FORMATS MAN_DEVICES DYEXT -SSRC -ADDLARCHIVEOBJS -ADDLOBJS -V_YACC -V_RPATH_OPT -V_SONAME_OPT -V_SHLIB_OPT -V_SHLIB_CMD -V_SHLIB_CCOPT -V_PCAP -V_LEX -V_INCLS -V_FINDALLDEVS -V_DEFS V_PROG_LDFLAGS_FAT V_PROG_CCOPT_FAT V_LIB_LDFLAGS_FAT V_LIB_CCOPT_FAT -V_CCOPT -MKDEP -DEPENDENCY_CFLAG -LN_S -AR -RANLIB -YFLAGS -YACC +REENTRANT_PARSER +BISON_BYACC LEXLIB LEX_OUTPUT_ROOT LEX -PCAP_SUPPORT_PACKET_RING +OPENSSL_LIBS_STATIC +OPENSSL_LIBS +OPENSSL_CFLAGS +LIBNL_LIBS_STATIC +LIBNL_LIBS +LIBNL_CFLAGS +BREW +PKG_CONFIG_LIBDIR +PKG_CONFIG_PATH +PKG_CONFIG VALGRINDTEST_SRC LIBOBJS +ac_ct_CXX +CXXFLAGS +CXX EGREP GREP CPP @@ -702,6 +711,12 @@ build_os build_vendor build_cpu build +LIBS_PRIVATE +REQUIRES_PRIVATE +LIBS_STATIC +V_INCLS +V_DEFS +V_CCOPT target_alias host_alias build_alias @@ -721,7 +736,6 @@ infodir docdir oldincludedir includedir -runstatedir localstatedir sharedstatedir sysconfdir @@ -747,10 +761,8 @@ enable_option_checking with_gcc enable_largefile enable_protochain -with_sita with_pcap with_libnl -enable_packet_ring enable_ipv6 with_dag with_dag_includes @@ -767,6 +779,7 @@ enable_universal enable_shared enable_usb enable_netmap +with_dpdk enable_bluetooth enable_dbus enable_rdma @@ -780,8 +793,27 @@ LDFLAGS LIBS CPPFLAGS CPP -YACC -YFLAGS' +CXX +CXXFLAGS +CCC +PKG_CONFIG +PKG_CONFIG_PATH +PKG_CONFIG_LIBDIR +LIBNL_CFLAGS +LIBNL_LIBS +LIBNL_LIBS_STATIC +OPENSSL_CFLAGS +OPENSSL_LIBS +OPENSSL_LIBS_STATIC +DPDK_CFLAGS +DPDK_LIBS +DPDK_LIBS_STATIC +DBUS_CFLAGS +DBUS_LIBS +DBUS_LIBS_STATIC +LIBIBVERBS_CFLAGS +LIBIBVERBS_LIBS +LIBIBVERBS_LIBS_STATIC' # Initialize some variables set by options. @@ -820,7 +852,6 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' -runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1073,15 +1104,6 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; - -runstatedir | --runstatedir | --runstatedi | --runstated \ - | --runstate | --runstat | --runsta | --runst | --runs \ - | --run | --ru | --r) - ac_prev=runstatedir ;; - -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ - | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ - | --run=* | --ru=* | --r=*) - runstatedir=$ac_optarg ;; - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1219,7 +1241,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir runstatedir + libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1332,7 +1354,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures pcap 1.9.1 to adapt to many kinds of systems. +\`configure' configures pcap 1.10.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1372,7 +1394,6 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -1399,7 +1420,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of pcap 1.9.1:";; + short | recursive ) echo "Configuration of pcap 1.10.3:";; esac cat <<\_ACEOF @@ -1409,17 +1430,15 @@ Optional Features: --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --disable-largefile omit support for large files --disable-protochain disable \"protochain\" insn - --enable-packet-ring enable packet ring support on Linux [default=yes] --enable-ipv6 build IPv6-capable version [default=yes] --enable-remote enable remote packet capture [default=no] - --disable-remote disable remote packet capture --enable-optimizer-dbg build optimizer debugging code --enable-yydebug build parser debugging code --disable-universal don't build universal on macOS --enable-shared build shared libraries [default=yes, if support available] - --enable-usb enable USB capture support [default=yes, if support - available] + --enable-usb enable Linux usbmon USB capture support + [default=yes, if support available] --enable-netmap enable netmap support [default=yes, if support available] --enable-bluetooth enable Bluetooth support [default=yes, if support @@ -1433,7 +1452,6 @@ Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --without-gcc don't use gcc - --with-sita include SITA support --with-pcap=TYPE use packet capture TYPE --without-libnl disable libnl support [default=yes, on Linux, if present] @@ -1454,6 +1472,8 @@ Optional Packages: --with-turbocap[=DIR] include Riverbed TurboCap support (located in directory DIR, if supplied). [default=yes, if present] + --with-dpdk[=DIR] include DPDK support (located in directory DIR, if + supplied). [default=yes, if present] Some influential environment variables: CC C compiler command @@ -1464,12 +1484,39 @@ Some influential environment variables: CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir> CPP C preprocessor - YACC The `Yet Another Compiler Compiler' implementation to use. - Defaults to the first program found out of: `bison -y', `byacc', - `yacc'. - YFLAGS The list of arguments that will be passed by default to $YACC. - This script will default YFLAGS to the empty string to avoid a - default value of `-d' given by some make applications. + CXX C++ compiler command + CXXFLAGS C++ compiler flags + PKG_CONFIG path to pkg-config utility + PKG_CONFIG_PATH + directories to add to pkg-config's search path + PKG_CONFIG_LIBDIR + path overriding pkg-config's built-in search path + LIBNL_CFLAGS + C compiler flags for libnl-genl-3.0, overriding pkg-config + LIBNL_LIBS linker flags for libnl-genl-3.0, overriding pkg-config + LIBNL_LIBS_STATIC + static-link linker flags for libnl-genl-3.0, overriding + pkg-config + OPENSSL_CFLAGS + C compiler flags for openssl, overriding pkg-config + OPENSSL_LIBS + linker flags for openssl, overriding pkg-config + OPENSSL_LIBS_STATIC + static-link linker flags for openssl, overriding pkg-config + DPDK_CFLAGS C compiler flags for libdpdk, overriding pkg-config + DPDK_LIBS linker flags for libdpdk, overriding pkg-config + DPDK_LIBS_STATIC + static-link linker flags for libdpdk, overriding pkg-config + DBUS_CFLAGS C compiler flags for dbus-1, overriding pkg-config + DBUS_LIBS linker flags for dbus-1, overriding pkg-config + DBUS_LIBS_STATIC + static-link linker flags for dbus-1, overriding pkg-config + LIBIBVERBS_CFLAGS + C compiler flags for libibverbs, overriding pkg-config + LIBIBVERBS_LIBS + linker flags for libibverbs, overriding pkg-config + LIBIBVERBS_LIBS_STATIC + static-link linker flags for libibverbs, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -1537,7 +1584,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -pcap configure 1.9.1 +pcap configure 1.10.3 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1589,13 +1636,13 @@ fi } # ac_fn_c_try_compile -# ac_fn_c_try_link LINENO -# ----------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_link () +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; @@ -1603,37 +1650,216 @@ case "(($ac_try" in esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>conftest.err + (eval "$ac_link") 2>&5 ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - test -x conftest$ac_exeext - }; then : + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : ac_retval=0 else - $as_echo "$as_me: failed program was:" >&5 + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_retval=1 + ac_retval=$ac_status fi - # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information - # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would - # interfere with the next link command; also delete a directory that is - # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval -} # ac_fn_c_try_link +} # ac_fn_c_try_run + +# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES +# -------------------------------------------- +# Tries to find the compile-time value of EXPR in a program that includes +# INCLUDES, setting VAR accordingly. Returns whether the value could be +# computed +ac_fn_c_compute_int () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_lo=0 ac_mid=0 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=$ac_mid; break +else + as_fn_arith $ac_mid + 1 && ac_lo=$as_val + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) < 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=-1 ac_mid=-1 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_lo=$ac_mid; break +else + as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + ac_lo= ac_hi= +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=$ac_mid +else + as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in #(( +?*) eval "$3=\$ac_lo"; ac_retval=0 ;; +'') ac_retval=1 ;; +esac + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +static long int longval () { return $2; } +static unsigned long int ulongval () { return $2; } +#include <stdio.h> +#include <stdlib.h> +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (($2) < 0) + { + long int i = longval (); + if (i != ($2)) + return 1; + fprintf (f, "%ld", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ($2)) + return 1; + fprintf (f, "%lu", i); + } + /* Do not output a trailing newline, as this causes \r\n confusion + on some platforms. */ + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + echo >>conftest.val; read $3 <conftest.val; ac_retval=0 +else + ac_retval=1 +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f conftest.val + + fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_compute_int # ac_fn_c_try_cpp LINENO # ---------------------- @@ -1672,6 +1898,300 @@ fi } # ac_fn_c_try_cpp +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_compile + +# ac_fn_cxx_try_compile LINENO +# ---------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_cxx_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_compile + +# ac_fn_cxx_try_run LINENO +# ------------------------ +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_cxx_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_run + +# ac_fn_cxx_compute_int LINENO EXPR VAR INCLUDES +# ---------------------------------------------- +# Tries to find the compile-time value of EXPR in a program that includes +# INCLUDES, setting VAR accordingly. Returns whether the value could be +# computed +ac_fn_cxx_compute_int () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_lo=0 ac_mid=0 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_hi=$ac_mid; break +else + as_fn_arith $ac_mid + 1 && ac_lo=$as_val + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) < 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_hi=-1 ac_mid=-1 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_lo=$ac_mid; break +else + as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + ac_lo= ac_hi= +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_hi=$ac_mid +else + as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in #(( +?*) eval "$3=\$ac_lo"; ac_retval=0 ;; +'') ac_retval=1 ;; +esac + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +static long int longval () { return $2; } +static unsigned long int ulongval () { return $2; } +#include <stdio.h> +#include <stdlib.h> +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (($2) < 0) + { + long int i = longval (); + if (i != ($2)) + return 1; + fprintf (f, "%ld", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ($2)) + return 1; + fprintf (f, "%lu", i); + } + /* Do not output a trailing newline, as this causes \r\n confusion + on some platforms. */ + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_run "$LINENO"; then : + echo >>conftest.val; read $3 <conftest.val; ac_retval=0 +else + ac_retval=1 +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +rm -f conftest.val + + fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_cxx_compute_int + # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using @@ -1759,79 +2279,6 @@ fi } # ac_fn_c_check_header_mongrel -# ac_fn_c_try_run LINENO -# ---------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes -# that executables *can* be run. -ac_fn_c_try_run () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then : - ac_retval=0 -else - $as_echo "$as_me: program exited with status $ac_status" >&5 - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=$ac_status -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_run - -# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES -# ------------------------------------------------------- -# Tests whether HEADER exists and can be compiled using the include files in -# INCLUDES, setting the cache variable VAR accordingly. -ac_fn_c_check_header_compile () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 -$as_echo_n "checking for $2... " >&6; } -if eval \${$3+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -#include <$2> -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - -} # ac_fn_c_check_header_compile - # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly @@ -2059,7 +2506,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by pcap $as_me 1.9.1, which was +It was created by pcap $as_me 1.10.3, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2410,6 +2857,86 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu +# +# These are the variables that are used in Makefile, pcap-config, and +# libpcap.pc. +# +# CFLAGS: inherited from the environment, not modified by us (except +# temporarily during tests that involve compilation). Used only when +# compiling C source. +# +# CXXFLAGS: inherited from the environment, not modified by us. Used only +# when compiling C++ source. +# +# LDFLAGS: inherited from the environment, not modified by us. +# +# LIBS: inherited from the environment; we add libraries required by +# libpcap. Librares that the core libpcap code requires are added +# first; libraries required by additional pcap modules are first +# added to ADDITIONAL_LIBS, and only added to LIBS at the end, after +# we're finished doing configuration tests for the modules. +# +# LIBS_STATIC: libraries with which a program using the libpcap *static* +# library needs to be linked. This is a superset of LIBS, used in +# pcap-config, so that "pcap-config --libs --static" will report them. +# Initialized to LIBS. +# +# REQUIRES_PRIVATE: pkg-config package names for additional libraries +# with which a program using the libpcap *static* library needs to be +# linked and for which a .pc file exists. This is used in libpcap.pc, +# so that "pkg-config --libs --static" will report them, and so that +# those libraries will be determined using the library's .pc file, not +# from our .pc file. Initialized to an empty string. +# +# V_CCOPT: additional compiler flags other than -I and -D flags +# needed when compiling libpcap. Used in Makefile for both C and +# C++ source. +# +# V_DEFS: additional -D compiler flags needed when compiling +# libpcap. Used in Makefile for both C and C++ source. +# +# V_INCLS: additional -I compiler flags needed when compiling +# libpcap. Used in Makefile for both C and C++ source. +# +# ADDITIONAL_LIBS: additional libraries with which the libpcap dynamic +# library needs to be linked. Used in Makwfile; not used in pcap-config +# or libpcap.pc, as, in all platforms on which we run, if a dynamic +# library is linked with other dynamic libraries, a program using +# that dynamic library doesn't have to link with those libraries - +# they will be automatically loaded at run time. Initialized to an +# empty string. +# +# ADDITIONAL_LIBS_STATIC: additional libraries with which a program +# using the libpcap *static* library needs to be linked. This is used +# in pcap-config, so that "pcap-config --libs --static" will report +# them. Initialized to an empty string. +# +# REQUIRES_PRIVATE: pkg-config package names for additional libraries +# with which a program using the libpcap *static* library needs to be +# linked and for which a .pc file exists. This is used in libpcap.pc, +# so that "pkg-config --libs --static" will report them, and so that +# those libraries will be determined using the library's .pc file, not +# from our .pc file. Initialized to an empty string. +# +# LIBS_PRIVATE: pkg-config package names for additional libraries with +# which a program using the libpcap *static* library needs to be linked +# and for which a .pc file does not exist. This is used in libpcap.pc, +# so that "pkg-config --libs --static" will report them (those libraries +# cannot be determined using the library's .pc file, as there is no such +# file, so it has to come from our .pc file. Initialized to an empty +# string. +# +LIBS_STATIC="" +REQUIRES_PRIVATE="" +LIBS_PRIVATE="" + + + + + + + + ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then @@ -2624,8 +3151,9 @@ fi fi # -# Try to enable as many C99 features as we can. -# At minimum, we want C++/C99-style // comments. +# We require C99 or later. +# Try to get it, which may involve adding compiler flags; +# if that fails, give up. # ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -3594,9 +4122,779 @@ fi if test "$ac_cv_prog_cc_c99" = "no"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: The C compiler does not support C99; there may be compiler errors" >&5 -$as_echo "$as_me: WARNING: The C compiler does not support C99; there may be compiler errors" >&2;} + as_fn_error $? "The C compiler does not support C99" "$LINENO" 5 +fi + +# +# Get the size of a void *, to determine whether this is a 32-bit +# or 64-bit build. +# + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + # <limits.h> exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <ac_nonexistent.h> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_GREP" || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_EGREP" || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <float.h> + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <string.h> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdlib.h> + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <ctype.h> +#include <stdlib.h> +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of void *" >&5 +$as_echo_n "checking size of void *... " >&6; } +if ${ac_cv_sizeof_void_p+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (void *))" "ac_cv_sizeof_void_p" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_void_p" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (void *) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_void_p=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_void_p" >&5 +$as_echo "$ac_cv_sizeof_void_p" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_VOID_P $ac_cv_sizeof_void_p +_ACEOF + + +ac_lbl_c_sizeof_void_p="$ac_cv_sizeof_void_p" + +# +# We only need a C++ compiler for Haiku; all code except for its +# pcap module is in C. +# +case "$host_os" in +haiku*) + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +if test -z "$CXX"; then + if test -n "$CCC"; then + CXX=$CCC + else + if test -n "$ac_tool_prefix"; then + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 +$as_echo "$CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CXX" && break + done +fi +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 +$as_echo "$ac_ct_CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CXX" && break +done + + if test "x$ac_ct_CXX" = x; then + CXX="g++" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_ct_CXX + fi +fi + + fi +fi +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 +$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } +if ${ac_cv_cxx_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 +$as_echo "$ac_cv_cxx_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GXX=yes +else + GXX= +fi +ac_test_CXXFLAGS=${CXXFLAGS+set} +ac_save_CXXFLAGS=$CXXFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 +$as_echo_n "checking whether $CXX accepts -g... " >&6; } +if ${ac_cv_prog_cxx_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_cxx_werror_flag=$ac_cxx_werror_flag + ac_cxx_werror_flag=yes + ac_cv_prog_cxx_g=no + CXXFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cxx_g=yes +else + CXXFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + +else + ac_cxx_werror_flag=$ac_save_cxx_werror_flag + CXXFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cxx_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cxx_werror_flag=$ac_save_cxx_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 +$as_echo "$ac_cv_prog_cxx_g" >&6; } +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS=$ac_save_CXXFLAGS +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + # + # Make sure C and C++ have the same pointer sizes with the flags + # they're given; if they don't, it means that the compilers for the + # languages will, with those flags, not produce code that can be + # linked together. + # + # We have to use different data types, because the results of + # a test are cached, so if we test for the size of a given type + # in C, the subsequent test in C++ will use the cached variable. + # We trick autoconf by testing the size of a "void *" in C and a + # "const void *" in C++. + # + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of const void *" >&5 +$as_echo_n "checking size of const void *... " >&6; } +if ${ac_cv_sizeof_const_void_p+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_cxx_compute_int "$LINENO" "(long int) (sizeof (const void *))" "ac_cv_sizeof_const_void_p" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_const_void_p" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (const void *) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_const_void_p=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_const_void_p" >&5 +$as_echo "$ac_cv_sizeof_const_void_p" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_CONST_VOID_P $ac_cv_sizeof_const_void_p +_ACEOF + + + ac_lbl_cxx_sizeof_void_p="$ac_cv_sizeof_const_void_p" + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + if test "$ac_lbl_cxx_sizeof_void_p" -eq 0; then + as_fn_error $? "No C++ compiler was found" "$LINENO" 5 + fi + if test "$ac_lbl_c_sizeof_void_p" -ne "$ac_lbl_cxx_sizeof_void_p"; then + as_fn_error $? "C compiler $CC produces code with $ac_lbl_c_sizeof_void_p-byte pointers +while C++ compiler $CXX produces code with $ac_lbl_cxx_sizeof_void_p-byte pointers. This prevents +code in those languages from being combined." "$LINENO" 5 + fi + ;; +esac @@ -3617,28 +4915,36 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -fvisibility=hidden option" >&5 $as_echo_n "checking whether the compiler supports the -fvisibility=hidden option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-fvisibility=hidden" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -fvisibility=hidden" - elif expr "x-fvisibility=hidden" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -fvisibility=hidden" - elif expr "x-fvisibility=hidden" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -fvisibility=hidden" - else - CFLAGS="$CFLAGS -fvisibility=hidden" - fi + CFLAGS="$CFLAGS -fvisibility=hidden" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main () -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : @@ -3694,6 +5000,7 @@ $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" else V_INCLS="$V_INCLS -I/usr/local/include" @@ -3717,28 +5024,36 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -fvisibility=hidden option" >&5 $as_echo_n "checking whether the compiler supports the -fvisibility=hidden option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-fvisibility=hidden" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -fvisibility=hidden" - elif expr "x-fvisibility=hidden" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -fvisibility=hidden" - elif expr "x-fvisibility=hidden" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -fvisibility=hidden" - else - CFLAGS="$CFLAGS -fvisibility=hidden" - fi + CFLAGS="$CFLAGS -fvisibility=hidden" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main () -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : @@ -3794,6 +5109,7 @@ $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" ;; @@ -3879,28 +5195,36 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -xldscope=hidden option" >&5 $as_echo_n "checking whether the compiler supports the -xldscope=hidden option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-xldscope=hidden" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -xldscope=hidden" - elif expr "x-xldscope=hidden" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -xldscope=hidden" - elif expr "x-xldscope=hidden" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -xldscope=hidden" - else - CFLAGS="$CFLAGS -xldscope=hidden" - fi + CFLAGS="$CFLAGS -xldscope=hidden" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main () -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : @@ -3956,6 +5280,7 @@ $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" ;; @@ -4018,11 +5343,12 @@ $as_echo "#define const /**/" >>confdefs.h aix*) ;; - freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*|midipix*) - # - # Platforms where the linker is the GNU linker - # or accepts command-line arguments like - # those the GNU linker accepts. + freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*|haiku*|midipix*) + # + # Platforms where the C compiler is GCC or accepts + # compatible command-line arguments, and the linker + # is the GNU linker or accepts compatible command-line + # arguments. # # Some instruction sets require -fPIC on some # operating systems. Check for them. If you @@ -4043,12 +5369,11 @@ $as_echo "#define const /**/" >>confdefs.h esac V_SHLIB_CCOPT="$V_SHLIB_CCOPT $PIC_OPT" V_SONAME_OPT="-Wl,-soname," - V_RPATH_OPT="-Wl,-rpath," ;; hpux*) V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic" - # + # # XXX - this assumes GCC is using the HP linker, # rather than the GNU linker, and that the "+h" # option is used on all HP-UX platforms, both .sl @@ -4056,7 +5381,7 @@ $as_echo "#define const /**/" >>confdefs.h # V_SONAME_OPT="-Wl,+h," # - # By default, directories specifed with -L + # By default, directories specified with -L # are added to the run-time search path, so # we don't add them in pcap-config. # @@ -4065,11 +5390,12 @@ $as_echo "#define const /**/" >>confdefs.h solaris*) V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic" # - # XXX - this assumes GCC is using the Sun linker, - # rather than the GNU linker. + # Sun/Oracle's C compiler, GCC, and GCC-compatible + # compilers support -Wl,{comma-separated list of options}, + # and we use the C compiler, not ld, for all linking, + # including linking to produce a shared library. # V_SONAME_OPT="-Wl,-h," - V_RPATH_OPT="-Wl,-R," ;; esac else @@ -4091,7 +5417,7 @@ $as_echo "#define const /**/" >>confdefs.h # "-Wl,-soname,{soname}" option, with the soname part # of the option, while on other platforms the C compiler # driver takes it as a regular option with the soname - # following the option. The same applies to V_RPATH_OPT. + # following the option. # case "$host_os" in @@ -4102,13 +5428,17 @@ $as_echo "#define const /**/" >>confdefs.h freebsd*|netbsd*|openbsd*|dragonfly*|linux*) # - # "cc" is GCC. + # Platforms where the C compiler is GCC or accepts + # compatible command-line arguments, and the linker + # is the GNU linker or accepts compatible command-line + # arguments. + # + # XXX - does 64-bit SPARC require -fPIC? # V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic" V_SHLIB_CMD="\$(CC)" V_SHLIB_OPT="-shared" V_SONAME_OPT="-Wl,-soname," - V_RPATH_OPT="-Wl,-rpath," ;; hpux*) @@ -4117,29 +5447,33 @@ $as_echo "#define const /**/" >>confdefs.h V_SHLIB_OPT="-b" V_SONAME_OPT="+h " # - # By default, directories specifed with -L + # By default, directories specified with -L # are added to the run-time search path, so # we don't add them in pcap-config. # ;; osf*) - # + # # Presumed to be DEC OSF/1, Digital UNIX, or # Tru64 UNIX. # V_SHLIB_CMD="\$(CC)" V_SHLIB_OPT="-shared" V_SONAME_OPT="-soname " - V_RPATH_OPT="-rpath " ;; solaris*) V_SHLIB_CCOPT="$V_SHLIB_CCOPT -Kpic" V_SHLIB_CMD="\$(CC)" V_SHLIB_OPT="-G" - V_SONAME_OPT="-h " - V_RPATH_OPT="-R" + # + # Sun/Oracle's C compiler, GCC, and GCC-compatible + # compilers support -Wl,{comma-separated list of options}, + # and we use the C compiler, not ld, for all linking, + # including linking to produce a shared library. + # + V_SONAME_OPT="-Wl,-h," ;; esac fi @@ -4207,6 +5541,125 @@ cat >>confdefs.h <<_ACEOF _ACEOF + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __atomic_load_n" >&5 +$as_echo_n "checking for __atomic_load_n... " >&6; } + if ${ac_cv_have___atomic_load_n+:} false; then : + $as_echo_n "(cached) " >&6 +else + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + int i = 17; + int j; + j = __atomic_load_n(&i, __ATOMIC_RELAXED); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_have___atomic_load_n=yes +else + ac_have___atomic_load_n=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_have___atomic_load_n" >&5 +$as_echo "$ac_have___atomic_load_n" >&6; } + if test $ac_have___atomic_load_n = yes ; then + +$as_echo "#define HAVE___ATOMIC_LOAD_N 1" >>confdefs.h + + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __atomic_store_n" >&5 +$as_echo_n "checking for __atomic_store_n... " >&6; } + if ${ac_cv_have___atomic_store_n+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + int i; + __atomic_store_n(&i, 17, __ATOMIC_RELAXED); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_have___atomic_store_n=yes +else + ac_have___atomic_store_n=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_have___atomic_store_n" >&5 +$as_echo "$ac_have___atomic_store_n" >&6; } + if test $ac_have___atomic_store_n = yes ; then + +$as_echo "#define HAVE___ATOMIC_STORE_N 1" >>confdefs.h + + fi + # # Try to arrange for large file support. # @@ -4235,7 +5688,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -4281,7 +5734,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -4305,7 +5758,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -4350,7 +5803,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -4374,7 +5827,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -4479,404 +5932,7 @@ $as_echo "#define HAVE_FSEEKO 1" >>confdefs.h fi -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 -$as_echo_n "checking how to run the C preprocessor... " >&6; } -# On Suns, sometimes $CPP names a directory. -if test -n "$CPP" && test -d "$CPP"; then - CPP= -fi -if test -z "$CPP"; then - if ${ac_cv_prog_CPP+:} false; then : - $as_echo_n "(cached) " >&6 -else - # Double quotes because CPP needs to be expanded - for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" - do - ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since - # <limits.h> exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include <limits.h> -#else -# include <assert.h> -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <ac_nonexistent.h> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - break -fi - - done - ac_cv_prog_CPP=$CPP - -fi - CPP=$ac_cv_prog_CPP -else - ac_cv_prog_CPP=$CPP -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 -$as_echo "$CPP" >&6; } -ac_preproc_ok=false -for ac_c_preproc_warn_flag in '' yes -do - # Use a header file that comes with gcc, so configuring glibc - # with a fresh cross-compiler works. - # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since - # <limits.h> exists even on freestanding compilers. - # On the NeXT, cc -E runs the code through the compiler's parser, - # not just through cpp. "Syntax error" is here to catch this case. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __STDC__ -# include <limits.h> -#else -# include <assert.h> -#endif - Syntax error -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - -else - # Broken: fails on valid input. -continue -fi -rm -f conftest.err conftest.i conftest.$ac_ext - - # OK, works on sane cases. Now check whether nonexistent headers - # can be detected and how. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <ac_nonexistent.h> -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - # Broken: success on invalid input. -continue -else - # Passes both tests. -ac_preproc_ok=: -break -fi -rm -f conftest.err conftest.i conftest.$ac_ext - -done -# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.i conftest.err conftest.$ac_ext -if $ac_preproc_ok; then : - -else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details" "$LINENO" 5; } -fi - -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 -$as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if ${ac_cv_path_GREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -z "$GREP"; then - ac_path_GREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_GREP" || continue -# Check for GNU ac_path_GREP and select it if it is found. - # Check for GNU $ac_path_GREP -case `"$ac_path_GREP" --version 2>&1` in -*GNU*) - ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'GREP' >> "conftest.nl" - "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_GREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_GREP="$ac_path_GREP" - ac_path_GREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_GREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_GREP"; then - as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_GREP=$GREP -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 -$as_echo "$ac_cv_path_GREP" >&6; } - GREP="$ac_cv_path_GREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 -$as_echo_n "checking for egrep... " >&6; } -if ${ac_cv_path_EGREP+:} false; then : - $as_echo_n "(cached) " >&6 -else - if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 - then ac_cv_path_EGREP="$GREP -E" - else - if test -z "$EGREP"; then - ac_path_EGREP_found=false - # Loop through the user's path and test for each of PROGNAME-LIST - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do - for ac_exec_ext in '' $ac_executable_extensions; do - ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - as_fn_executable_p "$ac_path_EGREP" || continue -# Check for GNU ac_path_EGREP and select it if it is found. - # Check for GNU $ac_path_EGREP -case `"$ac_path_EGREP" --version 2>&1` in -*GNU*) - ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; -*) - ac_count=0 - $as_echo_n 0123456789 >"conftest.in" - while : - do - cat "conftest.in" "conftest.in" >"conftest.tmp" - mv "conftest.tmp" "conftest.in" - cp "conftest.in" "conftest.nl" - $as_echo 'EGREP' >> "conftest.nl" - "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break - diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - as_fn_arith $ac_count + 1 && ac_count=$as_val - if test $ac_count -gt ${ac_path_EGREP_max-0}; then - # Best one so far, save it but keep looking for a better one - ac_cv_path_EGREP="$ac_path_EGREP" - ac_path_EGREP_max=$ac_count - fi - # 10*(2^10) chars as input seems more than enough - test $ac_count -gt 10 && break - done - rm -f conftest.in conftest.tmp conftest.nl conftest.out;; -esac - - $ac_path_EGREP_found && break 3 - done - done - done -IFS=$as_save_IFS - if test -z "$ac_cv_path_EGREP"; then - as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 - fi -else - ac_cv_path_EGREP=$EGREP -fi - - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 -$as_echo "$ac_cv_path_EGREP" >&6; } - EGREP="$ac_cv_path_EGREP" - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 -$as_echo_n "checking for ANSI C header files... " >&6; } -if ${ac_cv_header_stdc+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <stdlib.h> -#include <stdarg.h> -#include <string.h> -#include <float.h> - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - ac_cv_header_stdc=yes -else - ac_cv_header_stdc=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - -if test $ac_cv_header_stdc = yes; then - # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <string.h> - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <stdlib.h> - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then : - -else - ac_cv_header_stdc=no -fi -rm -f conftest* - -fi - -if test $ac_cv_header_stdc = yes; then - # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then : - : -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <ctype.h> -#include <stdlib.h> -#if ((' ' & 0x0FF) == 0x020) -# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') -# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) -#else -# define ISLOWER(c) \ - (('a' <= (c) && (c) <= 'i') \ - || ('j' <= (c) && (c) <= 'r') \ - || ('s' <= (c) && (c) <= 'z')) -# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) -#endif - -#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) -int -main () -{ - int i; - for (i = 0; i < 256; i++) - if (XOR (islower (i), ISLOWER (i)) - || toupper (i) != TOUPPER (i)) - return 2; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - -else - ac_cv_header_stdc=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 -$as_echo "$ac_cv_header_stdc" >&6; } -if test $ac_cv_header_stdc = yes; then - -$as_echo "#define STDC_HEADERS 1" >>confdefs.h - -fi - -# On IRIX 5.3, sys/types and inttypes.h are conflicting. -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default -" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -for ac_header in sys/ioccom.h sys/sockio.h limits.h +for ac_header in sys/ioccom.h sys/sockio.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -4901,74 +5957,65 @@ fi done -for ac_header in net/pfvar.h -do : - ac_fn_c_check_header_compile "$LINENO" "net/pfvar.h" "ac_cv_header_net_pfvar_h" "#include <sys/types.h> -#include <sys/socket.h> -#include <net/if.h> -" -if test "x$ac_cv_header_net_pfvar_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_NET_PFVAR_H 1 -_ACEOF -fi -done + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" -if test "$ac_cv_header_net_pfvar_h" = yes; then +case "$host_os" in +haiku*) # - # Check for various PF actions. + # Haiku needs _BSD_SOURCE for the _IO* macros because it doesn't use them. # - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether net/pfvar.h defines PF_NAT through PF_NORDR" >&5 -$as_echo_n "checking whether net/pfvar.h defines PF_NAT through PF_NORDR... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext + CFLAGS="$CFLAGS -D_BSD_SOURCE" + # + # Haiku has getpass in libbsd. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getpass in -lbsd" >&5 +$as_echo_n "checking for getpass in -lbsd... " >&6; } +if ${ac_cv_lib_bsd_getpass+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lbsd $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include <sys/types.h> - #include <sys/socket.h> - #include <net/if.h> - #include <net/pfvar.h> + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char getpass (); int main () { -return PF_NAT+PF_NONAT+PF_BINAT+PF_NOBINAT+PF_RDR+PF_NORDR; +return getpass (); ; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -$as_echo "#define HAVE_PF_NAT_THROUGH_PF_NORDR 1" >>confdefs.h - - +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_bsd_getpass=yes else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + ac_cv_lib_bsd_getpass=no fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS fi - -case "$host_os" in -linux*|uclinux*) - for ac_header in linux/sockios.h linux/if_bonding.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" " -#include <sys/socket.h> -#include <linux/if.h> - -" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bsd_getpass" >&5 +$as_echo "$ac_cv_lib_bsd_getpass" >&6; } +if test "x$ac_cv_lib_bsd_getpass" = xyes; then : cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define HAVE_LIBBSD 1 _ACEOF -fi + LIBS="-lbsd $LIBS" -done +fi ;; esac @@ -5019,6 +6066,11 @@ $as_echo "$ac_cv_lbl_gcc_fixincludes" >&6; } fi fi + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + + for ac_func in strerror do : ac_fn_c_check_func "$LINENO" "strerror" "ac_cv_func_strerror" @@ -5079,14 +6131,14 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else # - # We don't have strerror_r; do we have strerror_s? + # We don't have strerror_r; do we have _wcserror_s? # - for ac_func in strerror_s + for ac_func in _wcserror_s do : - ac_fn_c_check_func "$LINENO" "strerror_s" "ac_cv_func_strerror_s" -if test "x$ac_cv_func_strerror_s" = xyes; then : + ac_fn_c_check_func "$LINENO" "_wcserror_s" "ac_cv_func__wcserror_s" +if test "x$ac_cv_func__wcserror_s" = xyes; then : cat >>confdefs.h <<_ACEOF -#define HAVE_STRERROR_S 1 +#define HAVE__WCSERROR_S 1 _ACEOF fi @@ -5112,41 +6164,22 @@ done # -# Either: -# -# we have snprintf() and vsnprintf(), and have asprintf() and -# vasprintf(); -# -# we have snprintf() and vsnprintf(), but don't have asprintf() -# or vasprintf(); -# -# we have neither snprintf() nor vsnprintf(), and don't have -# asprintf() or vasprintf(), either. +# Make sure we have vsnprintf() and snprintf(); we require them. # -# We assume that if we have asprintf() we have vasprintf(), as well -# as snprintf() and vsnprintf(), and that if we have snprintf() we -# have vsnprintf(). -# -# For the first case, we don't need any replacement routines. -# For the second case, we need replacement asprintf()/vasprintf() -# routines. -# For the third case, we need replacement snprintf()/vsnprintf() and -# asprintf()/vasprintf() routines. -# -needsnprintf=no -for ac_func in vsnprintf snprintf -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -if eval test \"x\$"$as_ac_var"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF +ac_fn_c_check_func "$LINENO" "vsnprintf" "ac_cv_func_vsnprintf" +if test "x$ac_cv_func_vsnprintf" = xyes; then : else - needsnprintf=yes + as_fn_error $? "vsnprintf() is required but wasn't found" "$LINENO" 5 fi -done + +ac_fn_c_check_func "$LINENO" "snprintf" "ac_cv_func_snprintf" +if test "x$ac_cv_func_snprintf" = xyes; then : + +else + as_fn_error $? "snprintf() is required but wasn't found" "$LINENO" 5 +fi + needasprintf=no for ac_func in vasprintf asprintf @@ -5163,23 +6196,7 @@ else fi done -if test $needsnprintf = yes; then - # - # We assume we have none of them; missing/snprintf.c supplies - # all of them. - # - case " $LIBOBJS " in - *" snprintf.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS snprintf.$ac_objext" - ;; -esac - -elif test $needasprintf = yes; then - # - # We assume we have snprintf()/vsnprintf() but lack - # asprintf()/vasprintf(); missing/asprintf.c supplies - # the latter (using vsnprintf()). - # +if test $needasprintf = yes; then case " $LIBOBJS " in *" asprintf.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS asprintf.$ac_objext" @@ -5356,9 +6373,61 @@ if test "x$ac_cv_lib_socket_getaddrinfo" = xyes; then : else # - # We didn't find it. + # Not found in libsocket; test for it in libnetwork, which + # is where it is in Haiku. # - as_fn_error $? "getaddrinfo is required, but wasn't found" "$LINENO" 5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getaddrinfo in -lnetwork" >&5 +$as_echo_n "checking for getaddrinfo in -lnetwork... " >&6; } +if ${ac_cv_lib_network_getaddrinfo+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lnetwork $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char getaddrinfo (); +int +main () +{ +return getaddrinfo (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_network_getaddrinfo=yes +else + ac_cv_lib_network_getaddrinfo=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_network_getaddrinfo" >&5 +$as_echo "$ac_cv_lib_network_getaddrinfo" >&6; } +if test "x$ac_cv_lib_network_getaddrinfo" = xyes; then : + + # + # OK, we found it in libnetwork. + # + LIBS="-lnetwork $LIBS" + +else + + # + # We didn't find it. + # + as_fn_error $? "getaddrinfo is required, but wasn't found" "$LINENO" 5 + +fi + fi @@ -5836,7 +6905,7 @@ fi # This test fails if we don't have <arpa/inet.h> # (if we have ether_hostton(), we should have # networking, and if we have networking, we should - # have <arapa/inet.h>) or if we do but it doesn't + # have <arpa/inet.h>) or if we do but it doesn't # declare ether_hostton(). # # Unset ac_cv_have_decl_ether_hostton so we don't @@ -6101,25 +7170,6 @@ $as_echo "${enable_protochain}" >&6; } # VALGRINDTEST_SRC= -# -# SITA support is mutually exclusive with native capture support; -# "--with-sita" selects SITA support. -# - -# Check whether --with-sita was given. -if test "${with_sita+set}" = set; then : - withval=$with_sita; - if test ! "x$withval" = "xno" ; then - -$as_echo "#define SITA 1" >>confdefs.h - - { $as_echo "$as_me:${as_lineno-$LINENO}: Enabling SITA ACN support" >&5 -$as_echo "$as_me: Enabling SITA ACN support" >&6;} - V_PCAP=sita - fi - -else - # Check whether --with-pcap was given. if test "${with_pcap+set}" = set; then : @@ -6254,6 +7304,18 @@ fi done + for ac_header in config/HaikuConfig.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "config/HaikuConfig.h" "ac_cv_header_config_HaikuConfig_h" "$ac_includes_default" +if test "x$ac_cv_header_config_HaikuConfig_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_CONFIG_HAIKUCONFIG_H 1 +_ACEOF + +fi + +done + if test "$ac_cv_lbl_bpf_h_defines_biocsetif" = yes; then # @@ -6279,11 +7341,6 @@ done # No prizes for guessing this one. # V_PCAP=linux - - # - # XXX - this won't work with older kernels that have - # SOCK_PACKET sockets but not PF_PACKET sockets. - # VALGRINDTEST_SRC=valgrindtest.c elif test "$ac_cv_header_net_pfilt_h" = yes; then # @@ -6315,6 +7372,11 @@ done # DLPI on pre-Solaris 11 SunOS 5, HP-UX, possibly others. # V_PCAP=dlpi + elif test "$ac_cv_header_config_HaikuConfig_h" = yes; then + # + # Haiku. + # + V_PCAP=haiku else # # Nothing we support. @@ -6322,8 +7384,8 @@ done V_PCAP=null { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot determine packet capture interface" >&5 $as_echo "$as_me: WARNING: cannot determine packet capture interface" >&2;} - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: (see the INSTALL doc for more info)" >&5 -$as_echo "$as_me: WARNING: (see the INSTALL doc for more info)" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: (see the INSTALL.md file for more info)" >&5 +$as_echo "$as_me: WARNING: (see the INSTALL.md file for more info)" >&2;} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking packet capture type" >&5 @@ -6333,16 +7395,236 @@ $as_echo "$V_PCAP" >&6; } # -# Do capture-mechanism-dependent tests. +# Do we have pkg-config? +# + + + + + + + +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. +set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +PKG_CONFIG=$ac_cv_path_PKG_CONFIG +if test -n "$PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 +$as_echo "$PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_path_PKG_CONFIG"; then + ac_pt_PKG_CONFIG=$PKG_CONFIG + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $ac_pt_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG +if test -n "$ac_pt_PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 +$as_echo "$ac_pt_PKG_CONFIG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_pt_PKG_CONFIG" = x; then + PKG_CONFIG="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + PKG_CONFIG=$ac_pt_PKG_CONFIG + fi +else + PKG_CONFIG="$ac_cv_path_PKG_CONFIG" +fi + +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=0.9.0 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 +$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + PKG_CONFIG="" + fi +fi + +# +# Do we have the brew command from Homebrew? +# +# Extract the first word of "brew", so it can be a program name with args. +set dummy brew; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_BREW+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $BREW in + [\\/]* | ?:[\\/]*) + ac_cv_path_BREW="$BREW" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_BREW="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +BREW=$ac_cv_path_BREW +if test -n "$BREW"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BREW" >&5 +$as_echo "$BREW" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + +# +# Solaris pkg-config is annoying. For at least one package (D-Bus, I'm +# looking at *you*!), there are separate include files for 32-bit and +# 64-bit builds (I guess using "unsigned long long" as a 64-bit integer +# type on a 64-bit build is like crossing the beams or soething), and +# there are two separate .pc files, so if we're doing a 32-bit build we +# should make sure we look in /usr/lib/pkgconfig for .pc files and if +# we're doing a 64-bit build we should make sure we look in +# /usr/lib/amd64/pkgconfig for .pc files. +# +case "$host_os" in + +solaris*) + if test "$ac_cv_sizeof_void_p" -eq 8; then + # + # 64-bit build. If the path is empty, set it to + # /usr/lib/amd64/pkgconfig; otherwise, if + # /usr/lib/pkgconfig appears in the path, prepend + # /usr/lib/amd64/pkgconfig to it; otherwise, put + # /usr/lib/amd64/pkgconfig at the end. + # + if test -z "$PKG_CONFIG_PATH"; then + # + # Not set, or empty. Set it to + # /usr/lib/amd64/pkgconfig. + # + PKG_CONFIG_PATH=/usr/lib/amd64/pkgconfig + elif test ! -z `echo "$PKG_CONFIG_PATH" | grep "/usr/lib/pkgconfig"`; then + # + # It contains /usr/lib/pkgconfig. Prepend + # /usr/lib/amd64/pkgconfig to /usr/lib/pkgconfig. + # + PKG_CONFIG_PATH=`echo "$PKG_CONFIG_PATH" | sed "s;/usr/lib/pkgconfig;/usr/lib/amd64/pkgconfig:/usr/lib/pkgconfig;"` + else + # + # Not empty, but doesn't contain /usr/lib/pkgconfig. + # Append /usr/lib/amd64/pkgconfig to it. + # + PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/lib/amd64/pkgconfig" + fi + export PKG_CONFIG_PATH + elif test "$ac_cv_sizeof_void_p" -eq 4; then + # + # 32-bit build. If /usr/amd64/lib/pkgconfig appears + # in the path, prepend /usr/lib/pkgconfig to it. + # + if test ! -z `echo "$PKG_CONFIG_PATH" | grep "/usr/lib/amd64/pkgconfig"`; then + # + # It contains /usr/lib/amd64/pkgconfig. Prepend + # /usr/lib/pkgconfig to /usr/lib/amd64/pkgconfig. + # + PKG_CONFIG_PATH=`echo "$PKG_CONFIG_PATH" | sed "s;/usr/lib/amd64/pkgconfig;/usr/lib/pkgconfig:/usr/lib/amd64/pkgconfig;"` + export PKG_CONFIG_PATH + fi + fi +esac + +# +# Handle each capture type. # case "$V_PCAP" in dlpi) # - # Needed for common functions used by pcap-[dlpi,libdlpi].c - # - SSRC="dlpisubs.c" - - # # Checks for some header files. # for ac_header in sys/bufmod.h sys/dlpi_ext.h @@ -6370,7 +7652,7 @@ done # Also, due to the bug above applications that link to libpcap with # libdlpi will have to add "-L/lib" option to "configure". # - saved_ldflags=$LDFLAGS + save_LDFLAGS="$LDFLAGS" LDFLAGS="$LIBS -L/lib" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlpi_walk in -ldlpi" >&5 $as_echo_n "checking for dlpi_walk in -ldlpi... " >&6; } @@ -6411,16 +7693,32 @@ $as_echo "$ac_cv_lib_dlpi_dlpi_walk" >&6; } if test "x$ac_cv_lib_dlpi_dlpi_walk" = xyes; then : LIBS="-ldlpi $LIBS" + LIBS_STATIC="-ldlpi $LIBS_STATIC" + LIBS_PRIVATE="-ldlpi $LIBS_PRIVATE" V_PCAP=libdlpi + # + # Capture module plus common code needed for + # common functions used by pcap-[dlpi,libdlpi].c + # + PLATFORM_C_SRC="pcap-libdlpi.c dlpisubs.c" + $as_echo "#define HAVE_LIBDLPI 1" >>confdefs.h else - V_PCAP=dlpi + + V_PCAP=dlpi + + # + # Capture module plus common code needed for + # common functions used by pcap-[dlpi,libdlpi].c + # + PLATFORM_C_SRC="pcap-dlpi.c dlpisubs.c" + fi - LDFLAGS=$saved_ldflags + LDFLAGS="$save_LDFLAGS" # # Checks whether <sys/dlpi.h> is usable, to catch weird SCO @@ -6482,8 +7780,44 @@ fi ;; +enet) + # + # Capture module + # + PLATFORM_C_SRC="pcap-enet.c" + ;; + +haiku) + # + # Capture module + # + PLATFORM_CXX_SRC="pcap-haiku.cpp" + + # + # Just for the sake of it. + # + for ac_header in net/if.h net/if_dl.h net/if_types.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + ;; + linux) # + # Capture module + # + PLATFORM_C_SRC="pcap-linux.c" + + # # Do we have the wireless extensions? # for ac_header in linux/wireless.h @@ -6506,6 +7840,12 @@ done # # Do we have libnl? + # We only want version 3. Version 2 was, apparently, + # short-lived, and version 1 is source and binary + # incompatible with version 3, and it appears that, + # these days, everybody's using version 3. We're + # not supporting older versions of the Linux kernel; + # let's drop support for older versions of libnl, too. # # Check whether --with-libnl was given. @@ -6517,161 +7857,178 @@ fi if test x$with_libnl != xno ; then - have_any_nl="no" + # + # Check for libnl-genl-3.0 with pkg-config. + # - incdir=-I/usr/include/libnl3 - libnldir= - case "$with_libnl" in - yes|if_available) - ;; +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libnl-genl-3.0 with pkg-config" >&5 +$as_echo_n "checking for libnl-genl-3.0 with pkg-config... " >&6; } - *) - if test -d $withval; then - libnldir=-L${withval}/lib/.libs - incdir=-I${withval}/include - fi - ;; - esac +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnl-genl-3.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libnl-genl-3.0") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then - # - # Try libnl 3.x first. - # - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_socket_alloc in -lnl-3" >&5 -$as_echo_n "checking for nl_socket_alloc in -lnl-3... " >&6; } -if ${ac_cv_lib_nl_3_nl_socket_alloc+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lnl-3 ${incdir} ${libnldir} -lnl-genl-3 -lnl-3 $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ + # + # The package was found, so try to get its C flags and + # libraries. + # + if test -n "$LIBNL_CFLAGS"; then + pkg_cv_LIBNL_CFLAGS="$LIBNL_CFLAGS" + elif test -n "$PKG_CONFIG"; then -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char nl_socket_alloc (); -int -main () -{ -return nl_socket_alloc (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_nl_3_nl_socket_alloc=yes +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnl-genl-3.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libnl-genl-3.0") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNL_CFLAGS=`$PKG_CONFIG --cflags "libnl-genl-3.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else - ac_cv_lib_nl_3_nl_socket_alloc=no + pkg_failed=yes fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS + else + pkg_failed=untried fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nl_3_nl_socket_alloc" >&5 -$as_echo "$ac_cv_lib_nl_3_nl_socket_alloc" >&6; } -if test "x$ac_cv_lib_nl_3_nl_socket_alloc" = xyes; then : - - # - # Yes, we have libnl 3.x. - # - LIBS="${libnldir} -lnl-genl-3 -lnl-3 $LIBS" - -$as_echo "#define HAVE_LIBNL 1" >>confdefs.h - + if test -n "$LIBNL_LIBS"; then + pkg_cv_LIBNL_LIBS="$LIBNL_LIBS" + elif test -n "$PKG_CONFIG"; then -$as_echo "#define HAVE_LIBNL_3_x 1" >>confdefs.h - - -$as_echo "#define HAVE_LIBNL_NLE 1" >>confdefs.h - - -$as_echo "#define HAVE_LIBNL_SOCKETS 1" >>confdefs.h - - V_INCLS="$V_INCLS ${incdir}" - have_any_nl="yes" +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnl-genl-3.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libnl-genl-3.0") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNL_LIBS=`$PKG_CONFIG --libs "libnl-genl-3.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + if test -n "$LIBNL_LIBS_STATIC"; then + pkg_cv_LIBNL_LIBS_STATIC="$LIBNL_LIBS_STATIC" + elif test -n "$PKG_CONFIG"; then +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnl-genl-3.0\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libnl-genl-3.0") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNL_LIBS_STATIC=`$PKG_CONFIG --libs --static "libnl-genl-3.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried fi - if test x$have_any_nl = xno ; then - # - # Try libnl 2.x - # - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_socket_alloc in -lnl" >&5 -$as_echo_n "checking for nl_socket_alloc in -lnl... " >&6; } -if ${ac_cv_lib_nl_nl_socket_alloc+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lnl $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char nl_socket_alloc (); -int -main () -{ -return nl_socket_alloc (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_nl_nl_socket_alloc=yes + if test $pkg_failed = yes; then + # + # That failed - report an error. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: error" >&5 +$as_echo "error" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes else - ac_cv_lib_nl_nl_socket_alloc=no + _pkg_short_errors_supported=no fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nl_nl_socket_alloc" >&5 -$as_echo "$ac_cv_lib_nl_nl_socket_alloc" >&6; } -if test "x$ac_cv_lib_nl_nl_socket_alloc" = xyes; then : + if test $_pkg_short_errors_supported = yes; then + LIBNL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libnl-genl-3.0" 2>&1` + else + LIBNL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libnl-genl-3.0" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$LIBNL_PKG_ERRORS" >&5 - # - # Yes, we have libnl 2.x. - # - LIBS="${libnldir} -lnl-genl -lnl $LIBS" + as_fn_error $? "Package requirements (libnl-genl-3.0) were not met: -$as_echo "#define HAVE_LIBNL 1" >>confdefs.h +$LIBNL_PKG_ERRORS +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. -$as_echo "#define HAVE_LIBNL_2_x 1" >>confdefs.h +Alternatively, you may set the environment variables LIBNL_CFLAGS +and LIBNL_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 + elif test $pkg_failed = untried; then + # + # We don't have pkg-config, so it didn't work. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found (pkg-config not found)" >&5 +$as_echo "not found (pkg-config not found)" >&6; } + else + # + # We found the package. + # + LIBNL_CFLAGS=$pkg_cv_LIBNL_CFLAGS + LIBNL_LIBS=$pkg_cv_LIBNL_LIBS + LIBNL_LIBS_STATIC=$pkg_cv_LIBNL_LIBS_STATIC + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 +$as_echo "found" >&6; } + + pkg_config_found_libnl=yes + V_INCLS="$V_INCLS $LIBNL_CFLAGS" + ADDITIONAL_LIBS="$LIBNL_LIBS $ADDITIONAL_LIBS" + ADDITIONAL_LIBS_STATIC="$LIBNL_LIBS_STATIC $ADDITIONAL_LIBS_STATIC" + REQUIRES_PRIVATE="libnl-genl-3.0 $REQUIRES_PRIVATE" -$as_echo "#define HAVE_LIBNL_NLE 1" >>confdefs.h +$as_echo "#define HAVE_LIBNL 1" >>confdefs.h -$as_echo "#define HAVE_LIBNL_SOCKETS 1" >>confdefs.h + fi +else - have_any_nl="yes" + # + # The package isn't present. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } fi - fi - if test x$have_any_nl = xno ; then + if test x$pkg_config_found_libnl != xyes; then # - # No, we don't; do we have libnl 1.x? + # OK, either we don't have pkg-config or there + # wasn't a .pc file for it; Check for it directly. # - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_handle_alloc in -lnl" >&5 -$as_echo_n "checking for nl_handle_alloc in -lnl... " >&6; } -if ${ac_cv_lib_nl_nl_handle_alloc+:} false; then : + case "$with_libnl" in + + yes|if_available) + incdir=-I/usr/include/libnl3 + libnldir= + ;; + + *) + if test -d $withval; then + libnldir=-L${withval}/lib + incdir=-I${withval}/include + fi + ;; + esac + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_socket_alloc in -lnl-3" >&5 +$as_echo_n "checking for nl_socket_alloc in -lnl-3... " >&6; } +if ${ac_cv_lib_nl_3_nl_socket_alloc+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS -LIBS="-lnl $LIBS" +LIBS="-lnl-3 ${incdir} ${libnldir} -lnl-genl-3 -lnl-3 $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -6681,88 +8038,54 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char nl_handle_alloc (); +char nl_socket_alloc (); int main () { -return nl_handle_alloc (); +return nl_socket_alloc (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_nl_nl_handle_alloc=yes + ac_cv_lib_nl_3_nl_socket_alloc=yes else - ac_cv_lib_nl_nl_handle_alloc=no + ac_cv_lib_nl_3_nl_socket_alloc=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nl_nl_handle_alloc" >&5 -$as_echo "$ac_cv_lib_nl_nl_handle_alloc" >&6; } -if test "x$ac_cv_lib_nl_nl_handle_alloc" = xyes; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nl_3_nl_socket_alloc" >&5 +$as_echo "$ac_cv_lib_nl_3_nl_socket_alloc" >&6; } +if test "x$ac_cv_lib_nl_3_nl_socket_alloc" = xyes; then : # - # Yes. + # Yes, we have libnl 3.x. # - LIBS="${libnldir} -lnl $LIBS" + ADDITIONAL_LIBS="${libnldir} -lnl-genl-3 -lnl-3 $ADDITIONAL_LIBS" + ADDITIONAL_LIBS_STATIC="${libnldir} -lnl-genl-3 -lnl-3 $ADDITIONAL_LIBS_STATIC" + LIBS_PRIVATE="${libnldir} -lnl-genl-3 -lnl-3 $LIBS_PRIVATE" $as_echo "#define HAVE_LIBNL 1" >>confdefs.h - have_any_nl="yes" - -fi - - fi - - if test x$have_any_nl = xno ; then - # - # No, we don't have libnl at all. - # - if test x$with_libnl = xyes ; then - as_fn_error $? "libnl support requested but libnl not found" "$LINENO" 5 - fi - fi - fi - - for ac_header in linux/ethtool.h -do : - ac_fn_c_check_header_compile "$LINENO" "linux/ethtool.h" "ac_cv_header_linux_ethtool_h" " -$ac_includes_default -#include <linux/types.h> - -" -if test "x$ac_cv_header_linux_ethtool_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LINUX_ETHTOOL_H 1 -_ACEOF - -fi - -done + V_INCLS="$V_INCLS ${incdir}" +else - # - # Check to see if struct tpacket_stats is defined in - # <linux/if_packet.h>. If so, then pcap-linux.c can use this - # to report proper statistics. - # - # -Scott Barron - # - ac_fn_c_check_type "$LINENO" "struct tpacket_stats" "ac_cv_type_struct_tpacket_stats" " - #include <linux/if_packet.h> - -" -if test "x$ac_cv_type_struct_tpacket_stats" = xyes; then : - -cat >>confdefs.h <<_ACEOF -#define HAVE_STRUCT_TPACKET_STATS 1 -_ACEOF - + # + # No, we don't have libnl at all. + # Fail if the user explicitly requested + # it. + # + if test x$with_libnl = xyes ; then + as_fn_error $? "libnl support requested but libnl not found" "$LINENO" 5 + fi fi + fi + fi # # Check to see if the tpacket_auxdata struct has a tp_vlan_tci member. @@ -6790,6 +8113,11 @@ fi bpf) # + # Capture module + # + PLATFORM_C_SRC="pcap-bpf.c" + + # # Check whether we have the *BSD-style ioctls. # for ac_header in net/if_media.h @@ -6828,12 +8156,44 @@ fi ;; +pf) + # + # Capture module + # + PLATFORM_C_SRC="pcap-pf.c" + ;; + +snit) + # + # Capture module + # + PLATFORM_C_SRC="pcap-snit.c" + ;; + +snoop) + # + # Capture module + # + PLATFORM_C_SRC="pcap-snoop.c" + ;; + dag) # # --with-pcap=dag is the only way to get here, and it means # "DAG support but nothing else" # V_DEFS="$V_DEFS -DDAG_ONLY" + PLATFORM_C_SRC="pcap-dag.c" + xxx_only=yes + ;; + +dpdk) + # + # --with-pcap=dpdk is the only way to get here, and it means + # "DPDK support but nothing else" + # + V_DEFS="$V_DEFS -DDPDK_ONLY" + PLATFORM_C_SRC="pcap-dpdk.c" xxx_only=yes ;; @@ -6843,6 +8203,7 @@ septel) # "Septel support but nothing else" # V_DEFS="$V_DEFS -DSEPTEL_ONLY" + PLATFORM_C_SRC="pcap-septel.c" xxx_only=yes ;; @@ -6852,10 +8213,15 @@ snf) # "SNF support but nothing else" # V_DEFS="$V_DEFS -DSNF_ONLY" + PLATFORM_C_SRC="pcap-snf.c" xxx_only=yes ;; null) + # + # Capture module + # + PLATFORM_C_SRC="pcap-null.c" ;; *) @@ -6879,7 +8245,7 @@ if test "x$ac_cv_header_ifaddrs_h" = xyes; then : # We have the header, so we use "getifaddrs()" to # get the list of interfaces. # - V_FINDALLDEVS=fad-getad.c + PLATFORM_C_SRC="$PLATFORM_C_SRC fad-getad.c" else @@ -6948,18 +8314,15 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_have_siocglifconf" >&5 $as_echo "$ac_cv_lbl_have_siocglifconf" >&6; } if test $ac_cv_lbl_have_siocglifconf = yes ; then - V_FINDALLDEVS=fad-glifc.c + PLATFORM_C_SRC="$PLATFORM_C_SRC fad-glifc.c" else - V_FINDALLDEVS=fad-gifc.c + PLATFORM_C_SRC="$PLATFORM_C_SRC fad-gifc.c" fi fi fi -fi - - case "$host_os" in linux*) for ac_header in linux/net_tstamp.h @@ -6981,21 +8344,6 @@ $as_echo "$as_me: no hardware timestamp support implemented for $host_os" >&6;} ;; esac -# Check whether --enable-packet-ring was given. -if test "${enable_packet_ring+set}" = set; then : - enableval=$enable_packet_ring; -else - enable_packet_ring=yes -fi - - -if test "x$enable_packet_ring" != "xno" ; then - -$as_echo "#define PCAP_SUPPORT_PACKET_RING 1" >>confdefs.h - - -fi - # # Check for socklen_t. # @@ -7105,10 +8453,21 @@ if test "$want_dag" != no; then if test -z "$dag_lib_dir"; then dag_lib_dir="$dag_root/lib" + # + # Handle multiarch systems. + # + if test -d "$dag_lib_dir/$host" + then + dag_lib_dir="$dag_lib_dir/$host" + fi fi - V_INCLS="$V_INCLS -I$dag_include_dir" + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + + CFLAGS="$CFLAGS -I$dag_include_dir" for ac_header in dagapi.h do : ac_fn_c_check_header_mongrel "$LINENO" "dagapi.h" "ac_cv_header_dagapi_h" "$ac_includes_default" @@ -7122,16 +8481,27 @@ fi done + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + + if test "$ac_cv_header_dagapi_h" = yes; then + V_INCLS="$V_INCLS -I$dag_include_dir" + if test $V_PCAP != dag ; then - SSRC="$SSRC pcap-dag.c" + MODULE_C_SRC="$MODULE_C_SRC pcap-dag.c" fi # Check for various DAG API functions. # Don't need to save and restore LIBS to prevent -ldag being # included if there's a found-action (arg 3). - saved_ldflags=$LDFLAGS + + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + LDFLAGS="-L$dag_lib_dir" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dag_attach_stream in -ldag" >&5 $as_echo_n "checking for dag_attach_stream in -ldag... " >&6; } @@ -7170,11 +8540,15 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dag_dag_attach_stream" >&5 $as_echo "$ac_cv_lib_dag_dag_attach_stream" >&6; } if test "x$ac_cv_lib_dag_dag_attach_stream" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBDAG 1 -_ACEOF - LIBS="-ldag $LIBS" + # + # We assume that if we have libdag we have + # libdagconf, as they're installed at the + # same time from the same package. + # + ADDITIONAL_LIBS="-L$dag_lib_dir $ADDITIONAL_LIBS -ldag -ldagconf" + ADDITIONAL_LIBS_STATIC="-L$dag_lib_dir $ADDITIONAL_LIBS_STATIC -ldag -ldagconf" + LIBS_PRIVATE="-L$dag_lib_dir $LIBS_PRIVATE -ldag -ldagconf" else as_fn_error $? "DAG library lacks streams support" "$LINENO" 5 @@ -7309,20 +8683,27 @@ $as_echo "#define HAVE_DAG_GET_STREAM_ERF_TYPES 1" >>confdefs.h fi - LDFLAGS=$saved_ldflags + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + # # We assume that if we have libdag we have libdagconf, # as they're installed at the same time from the same # package. # - LIBS="$LIBS -ldag -ldagconf" - LDFLAGS="$LDFLAGS -L$dag_lib_dir" - if test "$dag_large_streams" = 1; then $as_echo "#define HAVE_DAG_LARGE_STREAMS_API 1" >>confdefs.h + + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + + LIBS="$LIBS -ldag -ldagconf" + LDFLAGS="$LDFLAGS -L$dag_lib_dir" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for vdag_set_device_info in -lvdag" >&5 $as_echo_n "checking for vdag_set_device_info in -lvdag... " >&6; } if ${ac_cv_lib_vdag_vdag_set_device_info+:} false; then : @@ -7365,6 +8746,11 @@ else ac_dag_have_vdag="0" fi + + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + if test "$ac_dag_have_vdag" = 1; then $as_echo "#define HAVE_DAG_VDAG 1" >>confdefs.h @@ -7372,7 +8758,9 @@ $as_echo "#define HAVE_DAG_VDAG 1" >>confdefs.h if test "$ac_lbl_have_pthreads" != "found"; then as_fn_error $? "DAG requires pthreads, but we didn't find them" "$LINENO" 5 fi - LIBS="$LIBS $PTHREAD_LIBS" + ADDITIONAL_LIBS="$ADDITIONAL_LIBS $PTHREAD_LIBS" + ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $PTHREAD_LIBS" + LIBS_PRIVATE="$LIBS_PRIVATE $PTHREAD_LIBS" fi fi @@ -7380,7 +8768,6 @@ $as_echo "#define HAVE_DAG_VDAG 1" >>confdefs.h $as_echo "#define HAVE_DAG_API 1" >>confdefs.h else - if test "$V_PCAP" = dag; then # User requested "dag" capture type but we couldn't # find the DAG API support. @@ -7388,10 +8775,11 @@ $as_echo "#define HAVE_DAG_API 1" >>confdefs.h fi if test "$want_dag" = yes; then - # User wanted DAG support but we couldn't find it. + # User wanted DAG support but we couldn't find it. as_fn_error $? "DAG support requested with --with-dag, but the DAG headers weren't found at $dag_include_dir: make sure the DAG support is installed, specify a different path or paths if necessary, or don't request DAG support" "$LINENO" 5 fi fi + CFLAGS="$save_CFLAGS" fi @@ -7457,7 +8845,7 @@ $as_echo "yes ($septel_include_dir)" >&6; } ADDLARCHIVEOBJS="$ADDLARCHIVEOBJS $septel_tools_dir/asciibin.o $septel_tools_dir/bit2byte.o $septel_tools_dir/confirm.o $septel_tools_dir/fmtmsg.o $septel_tools_dir/gct_unix.o $septel_tools_dir/hqueue.o $septel_tools_dir/ident.o $septel_tools_dir/mem.o $septel_tools_dir/pack.o $septel_tools_dir/parse.o $septel_tools_dir/pool.o $septel_tools_dir/sdlsig.o $septel_tools_dir/strtonum.o $septel_tools_dir/timer.o $septel_tools_dir/trace.o" if test "$V_PCAP" != septel ; then - SSRC="$SSRC pcap-septel.c" + MODULE_C_SRC="$MODULE_C_SRC pcap-septel.c" fi @@ -7474,7 +8862,7 @@ $as_echo "no" >&6; } fi if test "$want_septel" = yes; then - # User wanted Septel support but we couldn't find it. + # User wanted Septel support but we couldn't find it. as_fn_error $? "Septel support requested with --with-septel, but the Septel headers weren't found at $septel_include_dir: make sure the Septel support is installed, specify a different path or paths if necessary, or don't request Septel support" "$LINENO" 5 fi fi @@ -7558,11 +8946,22 @@ $as_echo_n "checking whether we have Myricom Sniffer API... " >&6; } if test -z "$snf_lib_dir"; then snf_lib_dir="$snf_root/lib" + # + # Handle multiarch systems. + # + if test -d "$snf_lib_dir/$host" + then + snf_lib_dir="$snf_lib_dir/$host" + fi fi if test -f "$snf_include_dir/snf.h"; then # We found a header; make sure we can link with the library - saved_ldflags=$LDFLAGS + + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -L$snf_lib_dir" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for snf_init in -lsnf" >&5 $as_echo_n "checking for snf_init in -lsnf... " >&6; } @@ -7604,7 +9003,11 @@ if test "x$ac_cv_lib_snf_snf_init" = xyes; then : ac_cv_lbl_snf_api="yes" fi - LDFLAGS="$saved_ldflags" + + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + if test "$ac_cv_lbl_snf_api" = no; then as_fn_error $? "SNF API cannot correctly be linked; check config.log" "$LINENO" 5 fi @@ -7615,11 +9018,12 @@ fi $as_echo "yes ($snf_root)" >&6; } V_INCLS="$V_INCLS -I$snf_include_dir" - LIBS="$LIBS -lsnf" - LDFLAGS="$LDFLAGS -L$snf_lib_dir" + ADDITIONAL_LIBS="$ADDITIONAL_LIBS -L$snf_lib_dir -lsnf" + ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC -L$snf_lib_dir -lsnf" + LIBS_PRIVATE="$LIBS_PRIVATE -L$snf_lib_dir -lsnf" if test "$V_PCAP" != snf ; then - SSRC="$SSRC pcap-snf.c" + MODULE_C_SRC="$MODULE_C_SRC pcap-snf.c" fi @@ -7682,12 +9086,16 @@ if test "$want_turbocap" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether TurboCap is supported" >&5 $as_echo_n "checking whether TurboCap is supported... " >&6; } + save_CFLAGS="$CFLAGS" save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + if test ! -z "$turbocap_root"; then TURBOCAP_CFLAGS="-I$turbocap_root/include" - TURBOCAP_LIBS="-L$turbocap_root/lib" + TURBOCAP_LDFLAGS="-L$turbocap_root/lib" CFLAGS="$CFLAGS $TURBOCAP_CFLAGS" + LDFLAGS="$LDFLAGS $TURBOCAP_LDFLAGS" fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -7712,14 +9120,20 @@ if ac_fn_c_try_compile "$LINENO"; then : fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + if test $ac_cv_lbl_turbocap_api = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - SSRC="$SSRC pcap-tc.c" + MODULE_C_SRC="$MODULE_C_SRC pcap-tc.c" V_INCLS="$V_INCLS $TURBOCAP_CFLAGS" - LIBS="$LIBS $TURBOCAP_LIBS -lTcApi -lpthread -lstdc++" + ADDITIONAL_LIBS="$ADDITIONAL_LIBS $TURBOCAP_LDFLAGS -lTcApi -lpthread -lstdc++" + ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $TURBOCAP_LDFLAGS -lTcApi -lpthread -lstdc++" + LIBS_PRIVATE="$LIBS_PRIVATE $TURBOCAP_LDFLAGS -lTcApi -lpthread -lstdc++" $as_echo "#define HAVE_TC_API 1" >>confdefs.h @@ -7729,7 +9143,7 @@ $as_echo "#define HAVE_TC_API 1" >>confdefs.h $as_echo "no" >&6; } if test "$want_turbocap" = yes; then - # User wanted Turbo support but we couldn't find it. + # User wanted Turbo support but we couldn't find it. as_fn_error $? "TurboCap support requested with --with-turbocap, but the TurboCap headers weren't found: make sure the TurboCap support is installed or don't request TurboCap support" "$LINENO" 5 fi fi @@ -7869,10 +9283,350 @@ _ACEOF fi + # + # Optionally, we may want to support SSL. + # Check for OpenSSL/libressl. + # + # First, try looking for it with pkg-config, if we have it. + # + # Homebrew's pkg-config does not, by default, look for + # pkg-config files for packages it has installed. + # Furthermore, at least for OpenSSL, they appear to be + # dumped in package-specific directories whose paths are + # not only package-specific but package-version-specific. + # + # So the only way to find openssl is to get the value of + # PKG_CONFIG_PATH from "brew --env openssl" and add that + # to PKG_CONFIG_PATH. (No, we can't just assume it's under + # /usr/local; Homebrew have conveniently chosen to put it + # under /opt/homebrew on ARM.) + # + # That's the nice thing about Homebrew - it makes things easier! + # Thanks! + # + save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH" + if test -n "$BREW"; then + openssl_pkgconfig_dir=`$BREW --env --plain openssl | sed -n 's/PKG_CONFIG_PATH: //p'` + PKG_CONFIG_PATH="$openssl_pkgconfig_dir:$PKG_CONFIG_PATH" + fi + + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for openssl with pkg-config" >&5 +$as_echo_n "checking for openssl with pkg-config... " >&6; } + +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl\""; } >&5 + ($PKG_CONFIG --exists --print-errors "openssl") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + + # + # The package was found, so try to get its C flags and + # libraries. + # + if test -n "$OPENSSL_CFLAGS"; then + pkg_cv_OPENSSL_CFLAGS="$OPENSSL_CFLAGS" + elif test -n "$PKG_CONFIG"; then + +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl\""; } >&5 + ($PKG_CONFIG --exists --print-errors "openssl") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_OPENSSL_CFLAGS=`$PKG_CONFIG --cflags "openssl" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + if test -n "$OPENSSL_LIBS"; then + pkg_cv_OPENSSL_LIBS="$OPENSSL_LIBS" + elif test -n "$PKG_CONFIG"; then + +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl\""; } >&5 + ($PKG_CONFIG --exists --print-errors "openssl") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_OPENSSL_LIBS=`$PKG_CONFIG --libs "openssl" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + if test -n "$OPENSSL_LIBS_STATIC"; then + pkg_cv_OPENSSL_LIBS_STATIC="$OPENSSL_LIBS_STATIC" + elif test -n "$PKG_CONFIG"; then + +if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl\""; } >&5 + ($PKG_CONFIG --exists --print-errors "openssl") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_OPENSSL_LIBS_STATIC=`$PKG_CONFIG --libs --static "openssl" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + + if test $pkg_failed = yes; then + # + # That failed - report an error. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: error" >&5 +$as_echo "error" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + OPENSSL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "openssl" 2>&1` + else + OPENSSL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "openssl" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$OPENSSL_PKG_ERRORS" >&5 + + as_fn_error $? "Package requirements (openssl) were not met: + +$OPENSSL_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + + +Alternatively, you may set the environment variables OPENSSL_CFLAGS +and OPENSSL_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details." "$LINENO" 5 + elif test $pkg_failed = untried; then + # + # We don't have pkg-config, so it didn't work. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found (pkg-config not found)" >&5 +$as_echo "not found (pkg-config not found)" >&6; } + else + # + # We found the package. + # + OPENSSL_CFLAGS=$pkg_cv_OPENSSL_CFLAGS + OPENSSL_LIBS=$pkg_cv_OPENSSL_LIBS + OPENSSL_LIBS_STATIC=$pkg_cv_OPENSSL_LIBS_STATIC + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 +$as_echo "found" >&6; } + + # + # We found OpenSSL/libressl. + # + HAVE_OPENSSL=yes + REQUIRES_PRIVATE="$REQUIRES_PRIVATE openssl" + + fi +else + + # + # The package isn't present. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + +fi + + PKG_CONFIG_PATH="$save_PKG_CONFIG_PATH" + + # + # If it wasn't found, and we have Homebrew installed, see + # if it's in Homebrew. + # + if test "x$HAVE_OPENSSL" != "xyes" -a -n "$BREW"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for openssl in Homebrew" >&5 +$as_echo_n "checking for openssl in Homebrew... " >&6; } + # + # The brew man page lies when it speaks of + # $BREW --prefix --installed <formula> + # outputting nothing. In Homebrew 3.3.16, + # it produces output regardless of whether + # the formula is installed or not, so we + # send the standard output and error to + # the bit bucket. + # + if $BREW --prefix --installed openssl >/dev/null 2>&1; then + # + # Yes. Get the include directory and library + # directory. (No, we can't just assume it's + # under /usr/local; Homebrew have conveniently + # chosen to put it under /opt/homebrew on ARM.) + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + HAVE_OPENSSL=yes + openssl_path=`$BREW --prefix openssl` + OPENSSL_CFLAGS="-I$openssl_path/include" + OPENSSL_LIBS="-L$openssl_path/lib -lssl -lcrypto" + OPENSSL_LIBS_STATIC="-L$openssl_path/lib -lssl -lcrypto" + OPENSSL_LIBS_PRIVATE="-L$openssl_path/lib -lssl -lcrypto" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + fi + fi + + # + # If it wasn't found, and /usr/local/include and /usr/local/lib + # exist, check if it's in /usr/local. (We check whether they + # exist because, if they don't exist, the compiler will warn + # about that and then ignore the argument, so they test + # using just the system header files and libraries.) + # + # We include the standard include file to 1) make sure that + # it's installed (if it's just a shared library for the + # benefit of existing programs, that's not useful) and 2) + # because SSL_library_init() is a library routine in some + # versions and a #defined wrapper around OPENSSL_init_ssl() + # in others. + # + if test "x$HAVE_OPENSSL" != "xyes" -a -d "/usr/local/include" -a -d "/usr/local/lib"; then + + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + + CFLAGS="$CFLAGS -I/usr/local/include" + LIBS="$LIBS -L/usr/local/lib -lssl -lcrypto" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have OpenSSL/libressl in /usr/local that we can use" >&5 +$as_echo_n "checking whether we have OpenSSL/libressl in /usr/local that we can use... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include <openssl/ssl.h> + +int +main () +{ + +SSL_library_init(); +return 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + HAVE_OPENSSL=yes + OPENSSL_CFLAGS="-I/usr/local/include" + OPENSSL_LIBS="-L/usr/local/lib -lssl -lcrypto" + OPENSSL_LIBS_STATIC="-L/usr/local/lib -lssl -lcrypto" + OPENSSL_LIBS_PRIVATE="-L/usr/local/lib -lssl -lcrypto" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + + fi + + # + # If it wasn't found, check if it's a system library. + # + # We include the standard include file to 1) make sure that + # it's installed (if it's just a shared library for the + # benefit of existing programs, that's not useful) and 2) + # because SSL_library_init() is a library routine in some + # versions and a #defined wrapper around OPENSSL_init_ssl() + # in others. + # + if test "x$HAVE_OPENSSL" != "xyes"; then + + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + + LIBS="$LIBS -lssl -lcrypto" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have a system OpenSSL/libressl that we can use" >&5 +$as_echo_n "checking whether we have a system OpenSSL/libressl that we can use... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include <openssl/ssl.h> + +int +main () +{ + +SSL_library_init(); +return 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + HAVE_OPENSSL=yes + OPENSSL_LIBS="-lssl -lcrypto" + OPENSSL_LIBS_STATIC="-lssl -lcrypto" + OPENSSL_LIBS_PRIVATE="-lssl -lcrypto" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + + fi + + # + # OK, did we find it? + # + if test "x$HAVE_OPENSSL" = "xyes"; then + +$as_echo "#define HAVE_OPENSSL 1" >>confdefs.h + + V_INCLS="$V_INCLS $OPENSSL_CFLAGS" + ADDITIONAL_LIBS="$ADDITIONAL_LIBS $OPENSSL_LIBS" + ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $OPENSSL_LIBS_STATIC" + LIBS_PRIVATE="$LIBS_PRIVATE $OPENSSL_LIBS_PRIVATE" + REQUIRES_PRIVATE="$REQUIRES_PRIVATE $OPENSSL_REQUIRES_PRIVATE" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: OpenSSL not found" >&5 +$as_echo "$as_me: OpenSSL not found" >&6;} + fi + $as_echo "#define ENABLE_REMOTE /**/" >>confdefs.h - SSRC="$SSRC pcap-new.c pcap-rpcap.c rpcap-protocol.c sockutils.c" + REMOTE_C_SRC="$REMOTE_C_SRC pcap-new.c pcap-rpcap.c rpcap-protocol.c sockutils.c sslutils.c" BUILD_RPCAPD=build-rpcapd INSTALL_RPCAPD=install-rpcapd ;; @@ -8096,23 +9850,38 @@ fi $as_echo "$tcpdump_cv_capable_lex" >&6; } if test $tcpdump_cv_capable_lex = insufficient ; then as_fn_error $? "$LEX is insufficient to compile libpcap. - libpcap requires Flex 2.5.31 or later, or a compatible version of lex." "$LINENO" 5 + libpcap requires Flex 2.5.31 or later, or a compatible version of lex. + If a suitable version of Lex/Flex is available as a non-standard command + and/or not in the PATH, you can specify it using the LEX environment + variable. That said, on some systems the error can mean that Flex/Lex is + actually acceptable, but m4 is not. Likewise, if a suitable version of + m4 (such as GNU M4) is available but has not been detected, you can + specify it using the M4 environment variable." "$LINENO" 5 fi # # Look for yacc/bison/byacc. +# If it's Bison, we do not want -y, as 1) we will be using -o to cause +# the output for XXX.y to be written to XXX.c and 2) we don't want +# it to issue warnings about stuff not supported by POSIX YACC - we +# want to use that stuff, and don't care whether plain YACC supports +# it or not, we require either Bison or Berkeley YACC. +# +BISON_BYACC="" # -for ac_prog in 'bison -y' byacc +# Look for Bison. +# +for ac_prog in bison do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_YACC+:} false; then : +if ${ac_cv_prog_BISON_BYACC+:} false; then : $as_echo_n "(cached) " >&6 else - if test -n "$YACC"; then - ac_cv_prog_YACC="$YACC" # Let the user override the test. + if test -n "$BISON_BYACC"; then + ac_cv_prog_BISON_BYACC="$BISON_BYACC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH @@ -8121,7 +9890,7 @@ do test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_YACC="$ac_prog" + ac_cv_prog_BISON_BYACC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -8131,44 +9900,131 @@ IFS=$as_save_IFS fi fi -YACC=$ac_cv_prog_YACC -if test -n "$YACC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $YACC" >&5 -$as_echo "$YACC" >&6; } +BISON_BYACC=$ac_cv_prog_BISON_BYACC +if test -n "$BISON_BYACC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BISON_BYACC" >&5 +$as_echo "$BISON_BYACC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi - test -n "$YACC" && break + test -n "$BISON_BYACC" && break done -test -n "$YACC" || YACC="yacc" +if test x"$BISON_BYACC" != x; then + # + # We found Bison. + # + # Bison prior to 2.4(.1) doesn't support "%define api.pure", so use + # "%pure-parser". + # + bison_major_version=`$BISON_BYACC -V | sed -n 's/.* \([1-9][0-9]*\)\.[0-9][0-9.]*/\1/p'` + bison_minor_version=`$BISON_BYACC -V | sed -n 's/.* [1-9][0-9]*\.\([0-9]+\).*/\1/p'` + if test "$bison_major_version" -lt 2 -o \ + \( "$bison_major_version" -eq 2 -a "$bison_major_version" -lt 4 \) + then + REENTRANT_PARSER="%pure-parser" + else + REENTRANT_PARSER="%define api.pure" + fi +else + # + # We didn't find Bison; check for Berkeley YACC, under the + # names byacc and yacc. + # + for ac_prog in byacc yacc +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_BISON_BYACC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$BISON_BYACC"; then + ac_cv_prog_BISON_BYACC="$BISON_BYACC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_BISON_BYACC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS -# -# Make sure it supports the -p flag and supports processing our -# grammar.y. -# -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for capable yacc/bison" >&5 -$as_echo_n "checking for capable yacc/bison... " >&6; } +fi +fi +BISON_BYACC=$ac_cv_prog_BISON_BYACC +if test -n "$BISON_BYACC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BISON_BYACC" >&5 +$as_echo "$BISON_BYACC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$BISON_BYACC" && break +done + + if test x"$BISON_BYACC" != x; then + # + # Make sure this is Berkeley YACC, not AT&T YACC; + # the latter doesn't support reentrant parsers. + # Run it with "-V"; that succeeds and reports the + # version number with Berkeley YACC, but will + # (probably) fail with various vendor flavors + # of AT&T YACC. + # + # Hopefully this also eliminates any versions + # of Berkeley YACC that don't support reentrant + # parsers, if there are any. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for capable yacc" >&5 +$as_echo_n "checking for capable yacc... " >&6; } if ${tcpdump_cv_capable_yacc+:} false; then : $as_echo_n "(cached) " >&6 else - if $YACC -p pcap_ -o /dev/null $srcdir/grammar.y >/dev/null 2>&1; then - tcpdump_cv_capable_yacc=yes - else - tcpdump_cv_capable_yacc=insufficient - fi + if $BISON_BYACC -V >/dev/null 2>&1; then + tcpdump_cv_capable_yacc=yes + else + tcpdump_cv_capable_yacc=insufficient + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcpdump_cv_capable_yacc" >&5 $as_echo "$tcpdump_cv_capable_yacc" >&6; } -if test $tcpdump_cv_capable_yacc = insufficient ; then - as_fn_error $? "$YACC is insufficient to compile libpcap. + if test $tcpdump_cv_capable_yacc = insufficient ; then + as_fn_error $? "$BISON_BYACC is insufficient to compile libpcap. + libpcap requires Bison, a newer version of Berkeley YACC with support + for reentrant parsers, or another YACC compatible with them." "$LINENO" 5 + fi + else + # + # OK, we found neither byacc nor yacc. + # + as_fn_error $? "Neither bison, byacc, nor yacc was found. libpcap requires Bison, a newer version of Berkeley YACC with support for reentrant parsers, or another YACC compatible with them." "$LINENO" 5 + fi + + # + # Berkeley YACC doesn't support "%define api.pure", so use + # "%pure-parser". + # + REENTRANT_PARSER="%pure-parser" fi + + # # Do various checks for various OSes and versions of those OSes. # @@ -8266,7 +10122,7 @@ fi V_PROG_LDFLAGS_FAT="-arch ppc -arch ppc64" ;; - darwin8.[456]|darwin.[456].*) + darwin8.[456]|darwin8.[456].*) # # Tiger, subsequent to Intel support but prior # to x86-64 support. Build libraries and @@ -8331,26 +10187,26 @@ fi V_PROG_LDFLAGS_FAT="-arch x86_64 -arch i386" ;; - darwin*) + darwin1[1-8]*) # - # Post-Snow Leopard. Build libraries for x86-64 - # and 32-bit x86, with x86-64 first, and build - # executables only for x86-64. (That's what - # Apple does.) This requires no special flags - # for programs. - # XXX - update if and when Apple drops support - # for 32-bit x86 code and if and when Apple adds - # ARM-based Macs. (You're on your own for iOS - # etc.) - # - # XXX - check whether we *can* build for - # i386 and, if not, suggest that the user - # install the /usr/include headers if they - # want to build fat. + # Post-Snow Leopard, pre-Catalina. Build + # libraries for x86-64 and 32-bit x86, with + # x86-64 first, and build executables only for + # x86-64. (That's what Apple does.) This + # requires no special flags for programs. + # + # We check whether we *can* build for i386 and, + # if not, suggest that the user install the + # /usr/include headers if they want to build + # fat. # { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether building for 32-bit x86 is supported" >&5 $as_echo_n "checking whether building for 32-bit x86 is supported... " >&6; } - save_CFLAGS="$CFLAGS" + + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + CFLAGS="$CFLAGS -arch i386" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -8363,12 +10219,24 @@ return 0; return 0; } _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - V_LIB_CCOPT_FAT="-arch x86_64 -arch i386" - V_LIB_LDFLAGS_FAT="-arch x86_64 -arch i386" + V_LIB_CCOPT_FAT="-arch x86_64" + V_LIB_LDFLAGS_FAT="-arch x86_64" + + # + # OpenSSL installation on macOS seems + # to install only the libs for 64-bit + # x86 - at least that's what Brew does: + # only configure 32-bit builds if we + # don't have OpenSSL. + # + if test "$HAVE_OPENSSL" != yes; then + V_LIB_CCOPT_FAT="$V_LIB_CCOPT_FAT -arch i386" + V_LIB_LDFLAGS_FAT="$V_LIB_LDFLAGS_FAT -arch i386" + fi else @@ -8400,8 +10268,97 @@ $as_echo "$as_me: WARNING: Compiling for 32-bit x86 gives an error; try installi esac fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS="$save_CFLAGS" +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + + ;; + + darwin19*) + # + # Catalina. Build libraries and executables + # only for x86-64. (That's what Apple does; + # 32-bit x86 binaries are not supported on + # Catalina.) + # + V_LIB_CCOPT_FAT="-arch x86_64" + V_LIB_LDFLAGS_FAT="-arch x86_64" + V_PROG_CCOPT_FAT="-arch x86_64" + V_PROG_LDFLAGS_FAT="-arch x86_64" + ;; + + darwin*) + # + # Post-Catalina. Build libraries and + # executables for x86-64 and ARM64. + # (That's what Apple does, except they + # build for arm64e, which may include + # some of the pointer-checking extensions.) + # + # If we're building with libssl, make sure + # we can build fat with it (i.e., that it + # was built fat); if we can't, don't set + # the target architectures, and just + # build for the host we're on. + # + # Otherwise, just add both of them. + # + if test "$HAVE_OPENSSL" = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether building fat with libssl is supported" >&5 +$as_echo_n "checking whether building fat with libssl is supported... " >&6; } + + save_CFLAGS="$CFLAGS" + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + + CFLAGS="$CFLAGS -arch x86_64 -arch arm64" + LDFLAGS="$LDFLAGS $OPENSSL_LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include <openssl/ssl.h> + +int +main () +{ + + SSL_library_init(); + return 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + V_LIB_CCOPT_FAT="-arch x86_64 -arch arm64" + V_LIB_LDFLAGS_FAT="-arch x86_64 -arch arm64" + V_PROG_CCOPT_FAT="-arch x86_64 -arch arm64" + V_PROG_LDFLAGS_FAT="-arch x86_64 -arch arm64" + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + LDFLAGS="$save_LDFLAGS" + + else + V_LIB_CCOPT_FAT="-arch x86_64 -arch arm64" + V_LIB_LDFLAGS_FAT="-arch x86_64 -arch arm64" + V_PROG_CCOPT_FAT="-arch x86_64 -arch arm64" + V_PROG_LDFLAGS_FAT="-arch x86_64 -arch arm64" + fi ;; esac fi @@ -8473,23 +10430,15 @@ irix*) MAN_MISC_INFO=5 ;; -linux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*|midipix*) +linux*|freebsd*|netbsd*|openbsd*|dragonfly*|kfreebsd*|gnu*|haiku*|midipix*) DYEXT="so" - - # - # Compiler assumed to be GCC; run-time linker may require a -R - # flag. - # - if test "$libdir" != "/usr/lib"; then - V_RFLAGS=-Wl,-R$libdir - fi ;; osf*) DYEXT="so" # - # DEC OSF/1, a/k/a Digial UNIX, a/k/a Tru64 UNIX. + # 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. @@ -8567,6 +10516,15 @@ $as_echo "#define HAVE_SOLARIS 1" >>confdefs.h ;; esac + + + + + + + + + # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then : enableval=$enable_shared; @@ -8782,67 +10740,130 @@ rm -f os-proto.h # if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler fails when given an unknown warning option" >&5 -$as_echo_n "checking whether the compiler fails when given an unknown warning option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -W option" >&5 +$as_echo_n "checking whether the compiler supports the -W option... " >&6; } save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy" + CFLAGS="$CFLAGS -W" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main () -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + can_add_to_cflags=yes # - # We're assuming this is clang, where - # -Werror=unknown-warning-option is the appropriate - # option to force the compiler to fail. + # The compile supports this; do we have some C code for + # which the warning should *not* appear? + # We test the fourth argument because the third argument + # could contain quotes, breaking the test. # - ac_lbl_unknown_warning_option_error="-Werror=unknown-warning-option" + if test "x" != "x" + then + CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -W " >&5 +$as_echo_n "checking whether -W ... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + # + # Not a problem. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 + # + # A problem. + # + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + can_add_to_cflags=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS="$save_CFLAGS" + fi + CFLAGS="$save_CFLAGS" + if test x"$can_add_to_cflags" = "xyes" + then + V_CCOPT="$V_CCOPT -W" + fi +else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -W option" >&5 -$as_echo_n "checking whether the compiler supports the -W option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + CFLAGS="$save_CFLAGS" + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wall option" >&5 +$as_echo_n "checking whether the compiler supports the -Wall option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-W" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -W" - elif expr "x-W" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -W" - elif expr "x-W" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -W" - else - CFLAGS="$CFLAGS -W" - fi + CFLAGS="$CFLAGS -Wall" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main () -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : @@ -8858,8 +10879,8 @@ $as_echo "yes" >&6; } if test "x" != "x" then CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -W " >&5 -$as_echo_n "checking whether -W ... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wall " >&5 +$as_echo_n "checking whether -Wall ... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -8887,7 +10908,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$save_CFLAGS" if test x"$can_add_to_cflags" = "xyes" then - V_CCOPT="$V_CCOPT -W" + V_CCOPT="$V_CCOPT -Wall" fi else @@ -8898,33 +10919,42 @@ $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wall option" >&5 -$as_echo_n "checking whether the compiler supports the -Wall option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wcomma option" >&5 +$as_echo_n "checking whether the compiler supports the -Wcomma option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wall" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wall" - elif expr "x-Wall" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wall" - elif expr "x-Wall" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wall" - else - CFLAGS="$CFLAGS -Wall" - fi + CFLAGS="$CFLAGS -Wcomma" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoconf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main () -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : @@ -8940,8 +10970,8 @@ $as_echo "yes" >&6; } if test "x" != "x" then CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wall " >&5 -$as_echo_n "checking whether -Wall ... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wcomma " >&5 +$as_echo_n "checking whether -Wcomma ... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -8969,7 +10999,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$save_CFLAGS" if test x"$can_add_to_cflags" = "xyes" then - V_CCOPT="$V_CCOPT -Wall" + V_CCOPT="$V_CCOPT -Wcomma" fi else @@ -8980,33 +11010,42 @@ $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wcomma option" >&5 -$as_echo_n "checking whether the compiler supports the -Wcomma option... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wdocumentation option" >&5 +$as_echo_n "checking whether the compiler supports the -Wdocumentation option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wcomma" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wcomma" - elif expr "x-Wcomma" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wcomma" - elif expr "x-Wcomma" : "x-m.*" >/dev/null - then - |