aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2022-09-27 21:17:12 -0700
committerGuy Harris <gharris@sonic.net>2022-09-27 21:17:27 -0700
commit6493919a4c7cf15d3d4f9878b2f290dd36efafc0 (patch)
treec797eba2390098aee1f7209a3f9687666998cc7e
parent7375f7ca574ff862f4886bcbf093ada57c485db9 (diff)
autoconf, cmake: fix generated pcap-config and libpcap.pc.
In libpcap.pc, don't put libraries into Libs.private if we can just put the package to which the libraries belong in Requires.private and let pkg-config do the work. When configuring with CMake, make sure that we do *NOT* put library full paths into the lists of libraries required when linking statically against libpcap. In the configure script, do a push settings/pop settings operation before checking various libraries similar to what's done in CMake files, to make sure that the results of the tests aren't affected by tests done previously. Have the macros for autoconf that run pcap-config take arbitrary arguments rather than a single flag value, to allow testing with --libs and --static. This should fix issue #1062.
-rw-r--r--CMakeLists.txt160
-rw-r--r--aclocal.m436
-rw-r--r--cmake/Modules/FindDAG.cmake1
-rw-r--r--cmake/Modules/FindSNF.cmake1
-rw-r--r--cmake/Modules/Finddpdk.cmake12
-rw-r--r--config.h.in3
-rwxr-xr-xconfigure496
-rw-r--r--configure.ac261
-rw-r--r--libpcap.pc.in3
-rw-r--r--pcap-config.in10
10 files changed, 823 insertions, 160 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4170759d..67f97652 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -628,6 +628,9 @@ endif()
# that's been set, it skips the test, so we need different variables.
#
set(PCAP_LINK_LIBRARIES "")
+set(LIBS_STATIC "")
+set(REQUIRES_PRIVATE "")
+set(LIBS_PRIVATE "")
include(CheckLibraryExists)
if(WIN32)
#
@@ -663,6 +666,8 @@ else(WIN32)
# OK, we found it in libsocket.
#
set(PCAP_LINK_LIBRARIES socket nsl ${PCAP_LINK_LIBRARIES})
+ set(LIBS_STATIC "-lsocket -lnsl ${LIBS_STATIC}")
+ set(LIBS_PRIVATE "-lsocket -lnsl ${LIBS_PRIVATE}")
else(LIBSOCKET_HAS_GETADDRINFO)
check_library_exists(network getaddrinfo "" LIBNETWORK_HAS_GETADDRINFO)
if(LIBNETWORK_HAS_GETADDRINFO)
@@ -670,6 +675,8 @@ else(WIN32)
# OK, we found it in libnetwork (Haiku).
#
set(PCAP_LINK_LIBRARIES network ${PCAP_LINK_LIBRARIES})
+ set(LIBS_STATIC "-lnetwork ${LIBS_STATIC}")
+ set(LIBS_PRIVATE "-lnetwork ${LIBS_PRIVATE}")
else(LIBNETWORK_HAS_GETADDRINFO)
#
# We didn't find it.
@@ -691,6 +698,8 @@ else(WIN32)
# Yes - link with it as well.
#
set(PCAP_LINK_LIBRARIES xnet ${PCAP_LINK_LIBRARIES})
+ set(LIBS_STATIC "-lxnet ${LIBS_STATIC}")
+ set(LIBS_PRIVATE "-lxnet ${LIBS_PRIVATE}")
endif(LIBXNET_HAS_RECVMSG)
endif(NOT STDLIBS_HAVE_GETADDRINFO)
@@ -700,6 +709,8 @@ else(WIN32)
check_library_exists(str putmsg "" LIBSTR_HAS_PUTMSG)
if(LIBSTR_HAS_PUTMSG)
set(PCAP_LINK_LIBRARIES str ${PCAP_LINK_LIBRARIES})
+ set(LIBS_STATIC "-lstr ${LIBS_STATIC}")
+ set(LIBS_PRIVATE "-lstr ${LIBS_PRIVATE}")
endif(LIBSTR_HAS_PUTMSG)
endif(NOT STDLIBS_HAVE_PUTMSG)
@@ -1155,6 +1166,42 @@ if(NOT "${SANITIZER_FLAGS}" STREQUAL "")
endif()
#
+# For getting a raw list of --libs --static information from a
+# pkg-config module.
+#
+macro(pkg_get_static_link_info _prefix _package)
+ 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()
+endmacro()
+
+#
# OpenSSL/libressl.
#
find_package(OpenSSL)
@@ -1164,6 +1211,50 @@ if(OPENSSL_FOUND)
#
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.
+ #
+ # Furthermore, it also does not appear to set OPENSSL_STATIC_LIBRARIES
+ # for us, even though it uses pkg_check_modules(), which does appear
+ # to set the _STATIC_LIBRARIES variable.
+ #
+ # And, even if it *did* set it, it'd set it to a list of library names
+ # or something such as that, rather than to the sequence of -L and -l
+ # flags that we need for the pcap-config script.
+ #
+ # If it were to set OPENSSL_STATIC_LDFLAGS, that would be a
+ # (semicolon-separated) list of -L and -l flags (and other flags, as
+ # needed), which is at least something we could turn into such a list,
+ # but, again, it doesn't.
+ #
+ # Therefore, if we have pkg-config, we try to run pkg-config ourselves
+ # on openssl, with --libs --static.
+ #
+ if (PKG_CONFIG_EXECUTABLE)
+ pkg_get_static_link_info(OPENSSL openssl)
+ if (NOT 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....
+ #
+ endif()
+ set(LIBS_STATIC "${LIBS_STATIC} ${OPENSSL_LIBS_STATIC}")
+ set(REQUIRES_PRIVATE "${REQUIRES_PRIVATE} ${OPENSSL_PACKAGE_NAME}")
+ else()
+ #
+ # No pkg-config binary, so FindOpenSSL.cmake obviously didn't
+ # use pkg-config to find OpenSSL. Just ...
+ #
+message(STATUS "XXX FIX ME")
+ endif()
set(HAVE_OPENSSL YES)
endif(OPENSSL_FOUND)
@@ -1430,6 +1521,8 @@ else(WIN32)
# XXX - add -L/lib
#
set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} dlpi)
+ set(LIBS_STATIC "${LIBS_STATIC} -ldlpi")
+ set(LIBS_PRIVATE "${LIBS_PRIVATE} dlpi")
set(PCAP_TYPE libdlpi)
endif()
@@ -1462,9 +1555,16 @@ else(WIN32)
# let's drop support for older versions of libnl, too.
#
if(BUILD_WITH_LIBNL)
- pkg_check_modules(LIBNL libnl-3.0)
+ pkg_check_modules(LIBNL libnl-genl-3.0)
if(LIBNL_FOUND)
set(PCAP_LINK_LIBRARIES ${LIBNL_LIBRARIES} ${PCAP_LINK_LIBRARIES})
+
+ #
+ # Get raw link flags from pkg-config.
+ #
+ pkg_get_static_link_info(LIBNL libnl-genl-3.0)
+ set(LIBS_STATIC "${LIBNL_LIBS_STATIC} ${LIBS_STATIC}")
+ set(REQUIRES_PRIVATE "${LIBNL_PACKAGE_NAME} ${REQUIRES_PRIVATE}")
else()
cmake_push_check_state()
set(CMAKE_REQUIRED_LIBRARIES nl-3)
@@ -1476,6 +1576,8 @@ else(WIN32)
#
set(PCAP_LINK_LIBRARIES nl-genl-3 nl-3 ${PCAP_LINK_LIBRARIES})
include_directories("/usr/include/libnl3")
+ set(LIBS_STATIC "-lnl-genl-3 -lnl-3 ${LIBS_STATIC}")
+ set(LIBS_PRIVATE "-lnl-genl-3 -lnl-3 ${LIBS_PRIVATE}")
endif()
endif()
else()
@@ -1558,6 +1660,8 @@ 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_STATIC "-lsocket ${LIBS_STATIC}")
+ set(LIBS_PRIVATE "-lsocket ${LIBS_PRIVATE}")
set(HAVE_GETIFADDRS TRUE)
endif()
endif()
@@ -1739,6 +1843,8 @@ if(NOT DISABLE_DPDK)
include_directories(AFTER ${dpdk_INCLUDE_DIRS})
link_directories(AFTER ${dpdk_LIBRARIES})
set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${dpdk_LIBRARIES})
+ 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)
@@ -1841,13 +1947,30 @@ if(NOT DISABLE_DBUS)
list(APPEND DBUS_LIBRARY_FULLPATHS ${_libfullpath})
endforeach()
set(PCAP_LINK_LIBRARIES ${PCAP_LINK_LIBRARIES} ${DBUS_LIBRARY_FULLPATHS})
+
+ #
+ # Get static library information for DPDK.
+ #
+ pkg_get_static_link_info(DBUS dbus-1)
+ 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)
pkg_check_modules(LIBIBVERBS libibverbs)
- if(NOT LIBIBVERBS_FOUND)
+ 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_static_link_info(LIBIBVERBS libibverbs)
+ else()
#
# pkg-config didn't find it; try to look for it ourselves
#
@@ -1855,6 +1978,14 @@ if(NOT DISABLE_RDMA)
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_STATIC -libverbs)
+ set(LIBIBVERBS_LIBS_PRIVATE -libverbs)
endif()
endif()
if(LIBIBVERBS_FOUND)
@@ -1864,6 +1995,9 @@ if(NOT DISABLE_RDMA)
if(PCAP_SUPPORT_RDMASNIFF)
set(PROJECT_SOURCE_LIST_C ${PROJECT_SOURCE_LIST_C} pcap-rdmasniff.c)
set(PCAP_LINK_LIBRARIES ${LIBIBVERBS_LIBRARIES} ${PCAP_LINK_LIBRARIES})
+ 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_FOUND)
@@ -1904,12 +2038,21 @@ 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})
+ #
+ # XXX - this needs more static library work to handle
+ # compiler-command-style rather than CMake-style
+ # flags.
+ #
+ set(LIBS_STATIC "${LIBS_STATIC} ${DAG_STATIC_LIBRARIES}")
+ set(LIBS_PRIVATE "${LIBS_PRIVATE} ${DAG_STATIC_LIBRARIES}")
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_STATIC "${LIBS_STATIC} ${CMAKE_THREAD_LIBS_INIT}")
+ set(LIBS_PRIVATE "${LIBS_PRIVATE} ${CMAKE_THREAD_LIBS_INIT}")
endif()
endif()
endif()
@@ -1955,6 +2098,13 @@ 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})
+ #
+ # XXX - this needs more static library work to handle
+ # compiler-command-style rather than CMake-style
+ # flags.
+ #
+ set(LIBS_STATIC "${LIBS_STATIC} ${SNF_STATIC_LIBRARIES}")
+ set(LIBS_PRIVATE "${LIBS_PRIVATE} ${SNF_STATIC_LIBRARIES}")
endif()
endif()
@@ -2346,6 +2496,8 @@ 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_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]*")
@@ -2992,10 +3144,6 @@ if(NOT MSVC)
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)
diff --git a/aclocal.m4 b/aclocal.m4
index 56290498..ae7fe0ff 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -232,6 +232,29 @@ AC_DEFUN(AC_LBL_C_INIT,
])
dnl
+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_SAVE_CHECK_STATE,
+[
+ save_CFLAGS="$CFLAGS"
+ 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
dnl is supported by the compiler and, if so, add it to the macro
dnl specified as the first argument
@@ -1121,7 +1144,7 @@ m4_ifvaln([$3], [else
$3])dnl
fi])
-dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+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.
@@ -1130,7 +1153,7 @@ m4_define([_PKG_CONFIG],
pkg_cv_[]$1="$$1"
elif test -n "$PKG_CONFIG"; then
PKG_CHECK_EXISTS([$3],
- [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
+ [pkg_cv_[]$1=`$PKG_CONFIG $2 "$3" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes ],
[pkg_failed=yes])
else
@@ -1159,6 +1182,7 @@ 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])
@@ -1168,8 +1192,9 @@ 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][_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
@@ -1211,6 +1236,7 @@ _PKG_TEXT])[]dnl
#
$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
@@ -1295,7 +1321,7 @@ AC_DEFUN([PKG_CHECK_VAR],
[
AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
-_PKG_CONFIG([$1], [variable="][$3]["], [$2])
+_PKG_CONFIG([$1], [--variable="][$3]["], [$2])
AS_VAR_COPY([$1], [pkg_cv_][$1])
AS_VAR_IF([$1], [""], [$5], [$4])dnl
diff --git a/cmake/Modules/FindDAG.cmake b/cmake/Modules/FindDAG.cmake
index ef135284..067b36e0 100644
--- a/cmake/Modules/FindDAG.cmake
+++ b/cmake/Modules/FindDAG.cmake
@@ -30,3 +30,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/cmake/Modules/FindSNF.cmake b/cmake/Modules/FindSNF.cmake
index 76dcced4..47118761 100644
--- a/cmake/Modules/FindSNF.cmake
+++ b/cmake/Modules/FindSNF.cmake
@@ -22,3 +22,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/cmake/Modules/Finddpdk.cmake b/cmake/Modules/Finddpdk.cmake
index a328482f..793f4876 100644
--- a/cmake/Modules/Finddpdk.cmake
+++ b/cmake/Modules/Finddpdk.cmake
@@ -5,6 +5,10 @@
# 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*
@@ -34,10 +38,16 @@ if(PKG_CONFIG_FOUND)
set(ENV{PKG_CONFIG_PATH} "${dpdk_ROOT}/pkgconfig:$ENV{PKG_CONFIG_PATH}")
endif()
pkg_check_modules(dpdk QUIET libdpdk)
+ if(dpdk_FOUND)
+ #
+ # Get static library information for DPDK.
+ #
+ pkg_get_static_link_info(dpdk libdpdk)
+ endif()
set(ENV{PKG_CONFIG_PATH} "${save_PKG_CONFIG_PATH}")
endif()
-mark_as_advanced(dpdk_INCLUDE_DIRS ${dpdk_LIBRARIES})
+mark_as_advanced(dpdk_INCLUDE_DIRS dpdk_LIBRARIES dpdk_STATIC_LIBRARIES dpdk_REQUIRES_PRIVATE)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(dpdk DEFAULT_MSG
diff --git a/config.h.in b/config.h.in
index 653a0566..82732a10 100644
--- a/config.h.in
+++ b/config.h.in
@@ -78,9 +78,6 @@
/* Define to 1 if you have the `bsd' library (-lbsd). */
#undef HAVE_LIBBSD
-/* Define to 1 if you have the `dag' library (-ldag). */
-#undef HAVE_LIBDAG
-
/* if libdlpi exists */
#undef HAVE_LIBDLPI
diff --git a/configure b/configure
index c6dbfa86..6e8dfa3d 100755
--- a/configure
+++ b/configure
@@ -635,20 +635,20 @@ V_SONAME_OPT
V_SHLIB_OPT
V_SHLIB_CMD
V_SHLIB_CCOPT
-V_INCLS
-V_DEFS
-V_CCOPT
INSTALL_DATA
INSTALL_SCRIPT
INSTALL_PROGRAM
PCAP_SUPPORT_RDMASNIFF
+LIBIBVERBS_LIBS_STATIC
LIBIBVERBS_LIBS
LIBIBVERBS_CFLAGS
PCAP_SUPPORT_DBUS
+DBUS_LIBS_STATIC
DBUS_LIBS
DBUS_CFLAGS
PCAP_SUPPORT_BT
PCAP_SUPPORT_DPDK
+DPDK_LIBS_STATIC
DPDK_LIBS
DPDK_CFLAGS
PCAP_SUPPORT_NETMAP
@@ -673,8 +673,10 @@ BISON_BYACC
LEXLIB
LEX_OUTPUT_ROOT
LEX
+OPENSSL_LIBS_STATIC
OPENSSL_LIBS
OPENSSL_CFLAGS
+LIBNL_LIBS_STATIC
LIBNL_LIBS
LIBNL_CFLAGS
BREW
@@ -709,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
@@ -793,14 +801,19 @@ 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
+LIBIBVERBS_LIBS_STATIC'
# Initialize some variables set by options.
@@ -1481,18 +1494,29 @@ Some influential environment variables:
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.
@@ -2833,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
@@ -5854,6 +5958,11 @@ fi
done
+
+ save_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+ save_LDFLAGS="$LDFLAGS"
+
case "$host_os" in
haiku*)
#
@@ -5957,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"
@@ -7596,6 +7710,8 @@ $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
#
@@ -7814,6 +7930,24 @@ 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
@@ -7860,12 +7994,15 @@ $as_echo "not found (pkg-config not found)" >&6; }
#
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"
- LIBS="$LIBNL_LIBS $LIBS"
+ 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 1" >>confdefs.h
@@ -7943,7 +8080,9 @@ 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"
+ 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
@@ -8345,7 +8484,11 @@ if test "$want_dag" != no; then
fi
fi
+
save_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+ save_LDFLAGS="$LDFLAGS"
+
CFLAGS="$CFLAGS -I$dag_include_dir"
for ac_header in dagapi.h
do :
@@ -8360,6 +8503,11 @@ 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"
@@ -8371,7 +8519,11 @@ done
# 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).
- save_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; }
@@ -8410,11 +8562,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
@@ -8549,20 +8705,27 @@ $as_echo "#define HAVE_DAG_GET_STREAM_ERF_TYPES 1" >>confdefs.h
fi
- LDFLAGS="$save_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 :
@@ -8605,6 +8768,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
@@ -8612,7 +8780,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
@@ -8620,7 +8790,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.
@@ -8810,7 +8979,11 @@ $as_echo_n "checking whether we have Myricom Sniffer API... " >&6; }
if test -f "$snf_include_dir/snf.h"; then
# We found a header; make sure we can link with the library
- save_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; }
@@ -8852,7 +9025,11 @@ if test "x$ac_cv_lib_snf_snf_init" = xyes; then :
ac_cv_lbl_snf_api="yes"
fi
- LDFLAGS="$save_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
@@ -8863,8 +9040,9 @@ 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
MODULE_C_SRC="$MODULE_C_SRC pcap-snf.c"
@@ -8930,12 +9108,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
@@ -8960,14 +9142,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; }
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
@@ -9196,6 +9384,24 @@ 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
@@ -9242,6 +9448,7 @@ $as_echo "not found (pkg-config not found)" >&6; }
#
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; }
@@ -9249,6 +9456,7 @@ $as_echo "found" >&6; }
# We found OpenSSL/libressl.
#
HAVE_OPENSSL=yes
+ REQUIRES_PRIVATE="openssl $REQUIRES_PRIVATE"
fi
else
@@ -9292,6 +9500,8 @@ $as_echo "yes" >&6; }
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; }
@@ -9313,8 +9523,11 @@ $as_echo "no" >&6; }
# 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_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
@@ -9342,15 +9555,21 @@ $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
+ nnn
+ { $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"
+
+ CFLAGS="$save_CFLAGS"
+ LIBS="$save_LIBS"
+ LDFLAGS="$save_LDFLAGS"
+
fi
#
@@ -9364,7 +9583,11 @@ rm -f core conftest.err conftest.$ac_objext \
# in others.
#
if test "x$HAVE_OPENSSL" != "xyes"; then
- save_LIBS="$LIBS"
+
+ 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; }
@@ -9390,6 +9613,8 @@ if ac_fn_c_try_link "$LINENO"; then :
$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
@@ -9397,7 +9622,11 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
- LIBS="$save_LIBS"
+
+ CFLAGS="$save_CFLAGS"
+ LIBS="$save_LIBS"
+ LDFLAGS="$save_LDFLAGS"
+
fi
#
@@ -9407,8 +9636,11 @@ rm -f core conftest.err conftest.$ac_objext \
$as_echo "#define HAVE_OPENSSL 1" >>confdefs.h
- CFLAGS="$CFLAGS $OPENSSL_CFLAGS"
- LIBS="$LIBS $OPENSSL_LIBS"
+ 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;}
@@ -9993,7 +10225,11 @@ fi
#
{ $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. */
@@ -10057,7 +10293,11 @@ $as_echo "$as_me: WARNING: Compiling for 32-bit x86 gives an error; try installi
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
- CFLAGS="$save_CFLAGS"
+
+ CFLAGS="$save_CFLAGS"
+ LIBS="$save_LIBS"
+ LDFLAGS="$save_LDFLAGS"
+
;;
darwin19*)
@@ -10092,8 +10332,11 @@ rm -f core conftest.err conftest.$ac_objext \
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_LDFLAGS="$LDFLAGS"
+
+ 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
@@ -10128,8 +10371,11 @@ $as_echo "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
- CFLAGS="$save_CFLAGS"
- LDFLAGS="$save_LDFLAGS"
+
+ 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"
@@ -12631,6 +12877,24 @@ fi
else
pkg_failed=untried
fi
+ if test -n "$DPDK_LIBS_STATIC"; then
+ pkg_cv_DPDK_LIBS_STATIC="$DPDK_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 \"libdpdk\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "libdpdk") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_DPDK_LIBS_STATIC=`$PKG_CONFIG --libs --static "libdpdk" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
@@ -12677,6 +12941,7 @@ $as_echo "not found (pkg-config not found)" >&6; }
#
DPDK_CFLAGS=$pkg_cv_DPDK_CFLAGS
DPDK_LIBS=$pkg_cv_DPDK_LIBS
+ DPDK_LIBS_STATIC=$pkg_cv_DPDK_LIBS_STATIC
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
$as_echo "found" >&6; }
@@ -12705,43 +12970,41 @@ fi
# We call rte_eth_dev_count_avail(), and older versions
# of DPDK didn't have it, so check for it.
#
- save_CFLAGS="$CFLAGS"
- save_LIBS="$LIBS"
- save_LDFLAGS="$LDFLAGS"
+
+ save_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+ save_LDFLAGS="$LDFLAGS"
+
CFLAGS="$CFLAGS $DPDK_CFLAGS"
LIBS="$LIBS $DPDK_LIBS"
- LDFLAGS="$LDFLAGS $DPDK_LDFLAGS"
ac_fn_c_check_func "$LINENO" "rte_eth_dev_count_avail" "ac_cv_func_rte_eth_dev_count_avail"
if test "x$ac_cv_func_rte_eth_dev_count_avail" = xyes; then :
fi
- CFLAGS="$save_CFLAGS"
- LIBS="$save_LIBS"
- LDFLAGS="$save_LDFLAGS"
+
+ CFLAGS="$save_CFLAGS"
+ LIBS="$save_LIBS"
+ LDFLAGS="$save_LDFLAGS"
+
fi
if test "$ac_cv_func_rte_eth_dev_count_avail" = yes; then
#
- # We found a usable DPDK. Build with it.
- #
- CFLAGS="$CFLAGS $DPDK_CFLAGS"
- LIBS="$LIBS $DPDK_LIBS"
- LDFLAGS="$LDFLAGS $DPDK_LDFLAGS"
- V_INCLS="$V_INCLS $DPDK_CFLAGS"
-
-$as_echo "#define PCAP_SUPPORT_DPDK 1" >>confdefs.h
-
- if test $V_PCAP != dpdk ; then
- MODULE_C_SRC="$MODULE_C_SRC pcap-dpdk.c"
- fi
-
+ # We found a usable DPDK.
#
# Check whether the rte_ether.h file defines
# struct ether_addr or struct rte_ether_addr.
#
# ("API compatibility? That's for losers!")
#
+
+ save_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+ save_LDFLAGS="$LDFLAGS"
+
+ CFLAGS="$CFLAGS $DPDK_CFLAGS"
+ LIBS="$LIBS $DPDK_LIBS"
ac_fn_c_check_type "$LINENO" "struct rte_ether_addr" "ac_cv_type_struct_rte_ether_addr" "
#include <rte_ether.h>
@@ -12755,6 +13018,27 @@ _ACEOF
fi
+
+ CFLAGS="$save_CFLAGS"
+ LIBS="$save_LIBS"
+ LDFLAGS="$save_LDFLAGS"
+
+
+ #
+ # We can build with DPDK.
+ #
+ V_INCLS="$V_INCLS $DPDK_CFLAGS"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: DPDK_LIBS_STATIC is $DPDK_LIBS_STATIC" >&5
+$as_echo "$as_me: WARNING: DPDK_LIBS_STATIC is $DPDK_LIBS_STATIC" >&2;}
+ ADDITIONAL_LIBS="$ADDITIONAL_LIBS $DPDK_LIBS"
+ ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $DPDK_LIBS_STATIC"
+ REQUIRES_PRIVATE="libdpdk $REQUIRES_PRIVATE"
+
+$as_echo "#define PCAP_SUPPORT_DPDK 1" >>confdefs.h
+
+ if test $V_PCAP != dpdk ; then
+ MODULE_C_SRC="$MODULE_C_SRC pcap-dpdk.c"
+ fi
else
#
# We didn't find a usable DPDK.
@@ -13066,6 +13350,24 @@ fi
else
pkg_failed=untried
fi
+ if test -n "$DBUS_LIBS_STATIC"; then
+ pkg_cv_DBUS_LIBS_STATIC="$DBUS_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 \"dbus-1\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "dbus-1") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_DBUS_LIBS_STATIC=`$PKG_CONFIG --libs --static "dbus-1" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
@@ -13106,11 +13408,15 @@ $as_echo "not found (pkg-config not found)" >&6; }
#
DBUS_CFLAGS=$pkg_cv_DBUS_CFLAGS
DBUS_LIBS=$pkg_cv_DBUS_LIBS
+ DBUS_LIBS_STATIC=$pkg_cv_DBUS_LIBS_STATIC
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
$as_echo "found" >&6; }
- save_CFLAGS="$CFLAGS"
- save_LIBS="$LIBS"
+
+ save_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+ save_LDFLAGS="$LDFLAGS"
+
CFLAGS="$CFLAGS $DBUS_CFLAGS"
LIBS="$LIBS $DBUS_LIBS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the D-Bus library defines dbus_connection_read_write" >&5
@@ -13140,6 +13446,9 @@ $as_echo "#define PCAP_SUPPORT_DBUS 1" >>confdefs.h
MODULE_C_SRC="$MODULE_C_SRC pcap-dbus.c"
V_INCLS="$V_INCLS $DBUS_CFLAGS"
+ ADDITIONAL_LIBS="$ADDITIONAL_LIBS $DBUS_LIBS"
+ ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $DBUS_LIBS_STATIC"
+ REQUIRES_PRIVATE="dbus-1 $REQUIRES_PRIVATE"
else
@@ -13148,12 +13457,15 @@ $as_echo "no" >&6; }
if test "x$enable_dbus" = "xyes"; then
as_fn_error $? "--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()" "$LINENO" 5
fi
- LIBS="$save_LIBS"
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
- CFLAGS="$save_CFLAGS"
+
+ CFLAGS="$save_CFLAGS"
+ LIBS="$save_LIBS"
+ LDFLAGS="$save_LDFLAGS"
+
fi
else
@@ -13237,6 +13549,24 @@ fi
else
pkg_failed=untried
fi
+ if test -n "$LIBIBVERBS_LIBS_STATIC"; then
+ pkg_cv_LIBIBVERBS_LIBS_STATIC="$LIBIBVERBS_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 \"libibverbs\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "libibverbs") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_LIBIBVERBS_LIBS_STATIC=`$PKG_CONFIG --libs --static "libibverbs" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
@@ -13283,10 +13613,12 @@ $as_echo "not found (pkg-config not found)" >&6; }
#
LIBIBVERBS_CFLAGS=$pkg_cv_LIBIBVERBS_CFLAGS
LIBIBVERBS_LIBS=$pkg_cv_LIBIBVERBS_LIBS
+ LIBIBVERBS_LIBS_STATIC=$pkg_cv_LIBIBVERBS_LIBS_STATIC
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
$as_echo "found" >&6; }
found_libibverbs=yes
+ LIBIBVERBS_REQUIRES_PRIVATE="libibverbs"
fi
else
@@ -13342,6 +13674,13 @@ if test "x$ac_cv_lib_ibverbs_ibv_get_device_list" = xyes; then :
found_libibverbs=yes
LIBIBVERBS_CFLAGS=""
LIBIBVERBS_LIBS="-libverbs"
+ # 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.
+ LIBIBVERBS_LIBS_STATIC="-libverbs"
+ LIBIBVERBS_LIBS_PRIVATE="-libverbs"
fi
@@ -13349,10 +13688,13 @@ fi
fi
if test "x$found_libibverbs" = "xyes"; then
- save_CFLAGS="$CFLAGS"
- save_LIBS="$LIBS"
- CFLAGS="$LIBIBVERBS_CFLAGS"
- LIBS="$LIBIBVERBS_LIBS"
+
+ save_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+ save_LDFLAGS="$LDFLAGS"
+
+ CFLAGS="$CFLAGS $LIBIBVERBS_CFLAGS"
+ LIBS="$LIBS $LIBIBVERBS_LIBS"
ac_fn_c_check_header_mongrel "$LINENO" "infiniband/verbs.h" "ac_cv_header_infiniband_verbs_h" "$ac_includes_default"
if test "x$ac_cv_header_infiniband_verbs_h" = xyes; then :
@@ -13404,8 +13746,11 @@ rm -f core conftest.err conftest.$ac_objext \
fi
- CFLAGS="$save_CFLAGS"
- LIBS="$save_LIBS"
+
+ CFLAGS="$save_CFLAGS"
+ LIBS="$save_LIBS"
+ LDFLAGS="$save_LDFLAGS"
+
fi
if test "x$found_usable_libibverbs" = "xyes"
@@ -13415,7 +13760,12 @@ $as_echo "#define PCAP_SUPPORT_RDMASNIFF /**/" >>confdefs.h
MODULE_C_SRC="$MODULE_C_SRC pcap-rdmasniff.c"
CFLAGS="$LIBIBVERBS_CFLAGS $CFLAGS"
- LIBS="$LIBIBVERBS_LIBS $LIBS"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: LIBIBVERBS_LIBS_STATIC is $LIBIBVERBS_LIBS_STATIC" >&5
+$as_echo "$as_me: WARNING: LIBIBVERBS_LIBS_STATIC is $LIBIBVERBS_LIBS_STATIC" >&2;}
+ ADDITIONAL_LIBS="$LIBIBVERBS_LIBS $ADDITIONAL_LIBS"
+ ADDITIONAL_LIBS_STATIC="$LIBIBVERBS_LIBS_STATIC $ADDITIONAL_LIBS_STATIC"
+ LIBS_PRIVATE="$LIBIBVERBS_LIBS_PRIVATE $LIBS_PRIVATE"
+ REQUIRES_PRIVATE="$LIBIBVERBS_REQUIRES_PRIVATE $REQUIRES_PRIVATE"
fi
fi
@@ -13588,8 +13938,12 @@ ac_config_headers="$ac_config_headers config.h"
-
-
+#
+# We're done with configuration operations; add ADDITIONAL_LIBS and
+# ADDITIONAL_LIBS_STATIC to LIBS and LIBS_STATIC, respectively.
+#
+LIBS="$ADDITIONAL_LIBS $LIBS"
+LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $LIBS_STATIC"
ac_config_commands="$ac_config_commands default-1"
diff --git a/configure.ac b/configure.ac
index ebd8b997..ce48942b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,6 +20,86 @@ AC_INIT(pcap, m4_esyscmd_s([cat VERSION]))
AC_CONFIG_SRCDIR(pcap.c)
AC_SUBST(PACKAGE_NAME)
+#
+# 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_SUBST(V_CCOPT)
+AC_SUBST(V_DEFS)
+AC_SUBST(V_INCLS)
+AC_SUBST(LIBS_STATIC)
+AC_SUBST(REQUIRES_PRIVATE)
+AC_SUBST(LIBS_PRIVATE)
+
AC_CANONICAL_SYSTEM
AC_LBL_C_INIT_BEFORE_CC(V_CCOPT, V_INCLS)
@@ -98,6 +178,7 @@ dnl
AC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h)
AC_CHECK_HEADERS(netpacket/packet.h)
+AC_LBL_SAVE_CHECK_STATE
case "$host_os" in
haiku*)
#
@@ -112,6 +193,7 @@ haiku*)
esac
AC_LBL_FIXINCLUDES
+AC_LBL_RESTORE_CHECK_STATE
AC_CHECK_FUNCS(strerror)
AC_CHECK_FUNC(strerror_r,
@@ -847,6 +929,8 @@ dlpi)
AC_CHECK_LIB(dlpi, dlpi_walk,
[
LIBS="-ldlpi $LIBS"
+ LIBS_STATIC="-ldlpi $LIBS_STATIC"
+ LIBS_PRIVATE="-ldlpi $LIBS_PRIVATE"
V_PCAP=libdlpi
#
@@ -956,7 +1040,9 @@ linux)
[
pkg_config_found_libnl=yes
V_INCLS="$V_INCLS $LIBNL_CFLAGS"
- LIBS="$LIBNL_LIBS $LIBS"
+ ADDITIONAL_LIBS="$LIBNL_LIBS $ADDITIONAL_LIBS"
+ ADDITIONAL_LIBS_STATIC="$LIBNL_LIBS_STATIC $ADDITIONAL_LIBS_STATIC"
+ REQUIRES_PRIVATE="libnl-genl-3.0 $REQUIRES_PRIVATE"
AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
])
@@ -985,7 +1071,9 @@ linux)
#
# Yes, we have libnl 3.x.
#
- LIBS="${libnldir} -lnl-genl-3 -lnl-3 $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"
AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
V_INCLS="$V_INCLS ${incdir}"
],[
@@ -1290,9 +1378,10 @@ if test "$want_dag" != no; then
fi
fi
- save_CFLAGS="$CFLAGS"
+ AC_LBL_SAVE_CHECK_STATE
CFLAGS="$CFLAGS -I$dag_include_dir"
AC_CHECK_HEADERS([dagapi.h])
+ AC_LBL_RESTORE_CHECK_STATE
if test "$ac_cv_header_dagapi_h" = yes; then
@@ -1305,42 +1394,52 @@ if test "$want_dag" != no; then
# 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).
- save_LDFLAGS="$LDFLAGS"
+ AC_LBL_SAVE_CHECK_STATE
LDFLAGS="-L$dag_lib_dir"
AC_CHECK_LIB([dag], [dag_attach_stream],
- [],
+ [
+ #
+ # 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"
+ ],
[AC_MSG_ERROR(DAG library lacks streams support)])
AC_CHECK_LIB([dag], [dag_attach_stream64], [dag_large_streams="1"], [dag_large_streams="0"])
AC_CHECK_LIB([dag],[dag_get_erf_types], [
AC_DEFINE(HAVE_DAG_GET_ERF_TYPES, 1, [define if you have dag_get_erf_types()])])
AC_CHECK_LIB([dag],[dag_get_stream_erf_types], [
AC_DEFINE(HAVE_DAG_GET_STREAM_ERF_TYPES, 1, [define if you have dag_get_stream_erf_types()])])
-
- LDFLAGS="$save_LDFLAGS"
+ AC_LBL_RESTORE_CHECK_STATE
#
# 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
AC_DEFINE(HAVE_DAG_LARGE_STREAMS_API, 1, [define if you have large streams capable DAG API])
+ AC_LBL_SAVE_CHECK_STATE
+ LIBS="$LIBS -ldag -ldagconf"
+ LDFLAGS="$LDFLAGS -L$dag_lib_dir"
AC_CHECK_LIB([vdag],[vdag_set_device_info], [ac_dag_have_vdag="1"], [ac_dag_have_vdag="0"])
+ AC_LBL_RESTORE_CHECK_STATE
if test "$ac_dag_have_vdag" = 1; then
AC_DEFINE(HAVE_DAG_VDAG, 1, [define if you have vdag_set_device_info()])
if test "$ac_lbl_have_pthreads" != "found"; then
AC_MSG_ERROR([DAG requires pthreads, but we didn't find them])
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
AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
else
-
if test "$V_PCAP" = dag; then
# User requested "dag" capture type but we couldn't
# find the DAG API support.
@@ -1508,10 +1607,10 @@ if test "$with_snf" != no; then
if test -f "$snf_include_dir/snf.h"; then
# We found a header; make sure we can link with the library
- save_LDFLAGS="$LDFLAGS"
+ AC_LBL_SAVE_CHECK_STATE
LDFLAGS="$LDFLAGS -L$snf_lib_dir"
AC_CHECK_LIB([snf], [snf_init], [ac_cv_lbl_snf_api="yes"])
- LDFLAGS="$save_LDFLAGS"
+ AC_LBL_RESTORE_CHECK_STATE
if test "$ac_cv_lbl_snf_api" = no; then
AC_MSG_ERROR(SNF API cannot correctly be linked; check config.log)
fi
@@ -1521,8 +1620,9 @@ if test "$with_snf" != no; then
AC_MSG_RESULT([yes ($snf_root)])
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
MODULE_C_SRC="$MODULE_C_SRC pcap-snf.c"
@@ -1579,12 +1679,12 @@ if test "$want_turbocap" != no; then
AC_MSG_CHECKING(whether TurboCap is supported)
- save_CFLAGS="$CFLAGS"
- save_LIBS="$LIBS"
+ AC_LBL_SAVE_CHECK_STATE
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
AC_TRY_COMPILE(
@@ -1598,13 +1698,15 @@ if test "$want_turbocap" != no; then
],
ac_cv_lbl_turbocap_api=yes)
- CFLAGS="$save_CFLAGS"
+ AC_LBL_RESTORE_CHECK_STATE
if test $ac_cv_lbl_turbocap_api = yes; then
AC_MSG_RESULT(yes)
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++"
AC_DEFINE(HAVE_TC_API, 1, [define if you have the TurboCap API])
else
@@ -1710,6 +1812,7 @@ yes) AC_MSG_RESULT(yes)
# We found OpenSSL/libressl.
#
HAVE_OPENSSL=yes
+ REQUIRES_PRIVATE="openssl $REQUIRES_PRIVATE"
])
PKG_CONFIG_PATH="$save_PKG_CONFIG_PATH"
@@ -1740,6 +1843,8 @@ yes) AC_MSG_RESULT(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
AC_MSG_RESULT(no)
fi
@@ -1760,8 +1865,7 @@ yes) AC_MSG_RESULT(yes)
# 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"
+ AC_LBL_SAVE_CHECK_STATE
CFLAGS="$CFLAGS -I/usr/local/include"
LIBS="$LIBS -L/usr/local/lib -lssl -lcrypto"
AC_MSG_CHECKING(whether we have OpenSSL/libressl in /usr/local that we can use)
@@ -1778,10 +1882,11 @@ return 0;
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"
+ ],nnn
AC_MSG_RESULT(no))
- CFLAGS="$save_CFLAGS"
- LIBS="$save_LIBS"
+ AC_LBL_RESTORE_CHECK_STATE
fi
#
@@ -1795,7 +1900,7 @@ return 0;
# in others.
#
if test "x$HAVE_OPENSSL" != "xyes"; then
- save_LIBS="$LIBS"
+ AC_LBL_SAVE_CHECK_STATE
LIBS="$LIBS -lssl -lcrypto"
AC_MSG_CHECKING(whether we have a system OpenSSL/libressl that we can use)
AC_TRY_LINK(
@@ -1810,9 +1915,11 @@ return 0;
AC_MSG_RESULT(yes)
HAVE_OPENSSL=yes
OPENSSL_LIBS="-lssl -lcrypto"
+ OPENSSL_LIBS_STATIC="-lssl -lcrypto"
+ OPENSSL_LIBS_PRIVATE="-lssl -lcrypto"
],
AC_MSG_RESULT(no))
- LIBS="$save_LIBS"
+ AC_LBL_RESTORE_CHECK_STATE
fi
#
@@ -1820,8 +1927,11 @@ return 0;
#
if test "x$HAVE_OPENSSL" = "xyes"; then
AC_DEFINE([HAVE_OPENSSL], [1], [Use OpenSSL])
- CFLAGS="$CFLAGS $OPENSSL_CFLAGS"
- LIBS="$LIBS $OPENSSL_LIBS"
+ 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
AC_MSG_NOTICE(OpenSSL not found)
fi
@@ -2128,7 +2238,7 @@ darwin*)
# fat.
#
AC_MSG_CHECKING(whether building for 32-bit x86 is supported)
- save_CFLAGS="$CFLAGS"
+ AC_LBL_SAVE_CHECK_STATE
CFLAGS="$CFLAGS -arch i386"
AC_TRY_LINK(
[],
@@ -2175,7 +2285,7 @@ darwin*)
;;
esac
])
- CFLAGS="$save_CFLAGS"
+ AC_LBL_RESTORE_CHECK_STATE
;;
darwin19*)
@@ -2209,8 +2319,7 @@ darwin*)
#
if test "$HAVE_OPENSSL" = yes; then
AC_MSG_CHECKING(whether building fat with libssl is supported)
- save_CFLAGS="$CFLAGS"
- save_LDFLAGS="$LDFLAGS"
+ AC_LBL_SAVE_CHECK_STATE
CFLAGS="$CFLAGS -arch x86_64 -arch arm64"
LDFLAGS="$LDFLAGS $OPENSSL_LIBS"
AC_TRY_LINK(
@@ -2230,8 +2339,7 @@ darwin*)
],
[AC_MSG_RESULT(no)]
)
- CFLAGS="$save_CFLAGS"
- LDFLAGS="$save_LDFLAGS"
+ AC_LBL_RESTORE_CHECK_STATE
else
V_LIB_CCOPT_FAT="-arch x86_64 -arch arm64"
V_LIB_LDFLAGS_FAT="-arch x86_64 -arch arm64"
@@ -2644,41 +2752,43 @@ if test "$want_dpdk" != no; then
# We call rte_eth_dev_count_avail(), and older versions
# of DPDK didn't have it, so check for it.
#
- save_CFLAGS="$CFLAGS"
- save_LIBS="$LIBS"
- save_LDFLAGS="$LDFLAGS"
+ AC_LBL_SAVE_CHECK_STATE
CFLAGS="$CFLAGS $DPDK_CFLAGS"
LIBS="$LIBS $DPDK_LIBS"
- LDFLAGS="$LDFLAGS $DPDK_LDFLAGS"
AC_CHECK_FUNC(rte_eth_dev_count_avail)
- CFLAGS="$save_CFLAGS"
- LIBS="$save_LIBS"
- LDFLAGS="$save_LDFLAGS"
+ AC_LBL_RESTORE_CHECK_STATE
fi
if test "$ac_cv_func_rte_eth_dev_count_avail" = yes; then
#
- # We found a usable DPDK. Build with it.
- #
- CFLAGS="$CFLAGS $DPDK_CFLAGS"
- LIBS="$LIBS $DPDK_LIBS"
- LDFLAGS="$LDFLAGS $DPDK_LDFLAGS"
- V_INCLS="$V_INCLS $DPDK_CFLAGS"
- AC_DEFINE(PCAP_SUPPORT_DPDK, 1, [target host supports DPDK])
- if test $V_PCAP != dpdk ; then
- MODULE_C_SRC="$MODULE_C_SRC pcap-dpdk.c"
- fi
-
+ # We found a usable DPDK.
#
# Check whether the rte_ether.h file defines
# struct ether_addr or struct rte_ether_addr.
#
# ("API compatibility? That's for losers!")
#
+ AC_LBL_SAVE_CHECK_STATE
+ CFLAGS="$CFLAGS $DPDK_CFLAGS"
+ LIBS="$LIBS $DPDK_LIBS"
AC_CHECK_TYPES(struct rte_ether_addr,,,
[
#include <rte_ether.h>
])
+ AC_LBL_RESTORE_CHECK_STATE
+
+ #
+ # We can build with DPDK.
+ #
+ V_INCLS="$V_INCLS $DPDK_CFLAGS"
+AC_MSG_WARN([DPDK_LIBS_STATIC is $DPDK_LIBS_STATIC])
+ ADDITIONAL_LIBS="$ADDITIONAL_LIBS $DPDK_LIBS"
+ ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $DPDK_LIBS_STATIC"
+ REQUIRES_PRIVATE="libdpdk $REQUIRES_PRIVATE"
+ AC_DEFINE(PCAP_SUPPORT_DPDK, 1, [target host supports DPDK])
+ if test $V_PCAP != dpdk ; then
+ MODULE_C_SRC="$MODULE_C_SRC pcap-dpdk.c"
+ fi
else
#
# We didn't find a usable DPDK.
@@ -2896,8 +3006,7 @@ fi
if test "x$enable_dbus" != "xno"; then
PKG_CHECK_MODULES(DBUS, dbus-1,
[
- save_CFLAGS="$CFLAGS"
- save_LIBS="$LIBS"
+ AC_LBL_SAVE_CHECK_STATE
CFLAGS="$CFLAGS $DBUS_CFLAGS"
LIBS="$LIBS $DBUS_LIBS"
AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write)
@@ -2914,15 +3023,17 @@ if test "x$enable_dbus" != "xno"; then
AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing])
MODULE_C_SRC="$MODULE_C_SRC pcap-dbus.c"
V_INCLS="$V_INCLS $DBUS_CFLAGS"
+ ADDITIONAL_LIBS="$ADDITIONAL_LIBS $DBUS_LIBS"
+ ADDITIONAL_LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $DBUS_LIBS_STATIC"
+ REQUIRES_PRIVATE="dbus-1 $REQUIRES_PRIVATE"
],
[
AC_MSG_RESULT([no])
if test "x$enable_dbus" = "xyes"; then
AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()])
fi
- LIBS="$save_LIBS"
])
- CFLAGS="$save_CFLAGS"
+ AC_LBL_RESTORE_CHECK_STATE
],
[
if test "x$enable_dbus" = "xyes"; then
@@ -2947,6 +3058,7 @@ if test "x$enable_rdma" != "xno"; then
PKG_CHECK_MODULES(LIBIBVERBS, libibverbs,
[
found_libibverbs=yes
+ LIBIBVERBS_REQUIRES_PRIVATE="libibverbs"
])
if test "x$found_libibverbs" != "xyes"; then
@@ -2955,15 +3067,21 @@ if test "x$enable_rdma" != "xno"; then
found_libibverbs=yes
LIBIBVERBS_CFLAGS=""
LIBIBVERBS_LIBS="-libverbs"
+ # 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.
+ LIBIBVERBS_LIBS_STATIC="-libverbs"
+ LIBIBVERBS_LIBS_PRIVATE="-libverbs"
]
)
fi
if test "x$found_libibverbs" = "xyes"; then
- save_CFLAGS="$CFLAGS"
- save_LIBS="$LIBS"
- CFLAGS="$LIBIBVERBS_CFLAGS"
- LIBS="$LIBIBVERBS_LIBS"
+ AC_LBL_SAVE_CHECK_STATE
+ CFLAGS="$CFLAGS $LIBIBVERBS_CFLAGS"
+ LIBS="$LIBS $LIBIBVERBS_LIBS"
AC_CHECK_HEADER(infiniband/verbs.h, [
#
# ibv_create_flow may be defined as a static inline
@@ -2994,8 +3112,7 @@ if test "x$enable_rdma" != "xno"; then
]
)
])
- CFLAGS="$save_CFLAGS"
- LIBS="$save_LIBS"
+ AC_LBL_RESTORE_CHECK_STATE
fi
if test "x$found_usable_libibverbs" = "xyes"
@@ -3003,7 +3120,11 @@ if test "x$enable_rdma" != "xno"; then
AC_DEFINE(PCAP_SUPPORT_RDMASNIFF, , [target host supports RDMA sniffing])
MODULE_C_SRC="$MODULE_C_SRC pcap-rdmasniff.c"
CFLAGS="$LIBIBVERBS_CFLAGS $CFLAGS"
- LIBS="$LIBIBVERBS_LIBS $LIBS"
+AC_MSG_WARN([LIBIBVERBS_LIBS_STATIC is $LIBIBVERBS_LIBS_STATIC])
+ ADDITIONAL_LIBS="$LIBIBVERBS_LIBS $ADDITIONAL_LIBS"
+ ADDITIONAL_LIBS_STATIC="$LIBIBVERBS_LIBS_STATIC $ADDITIONAL_LIBS_STATIC"
+ LIBS_PRIVATE="$LIBIBVERBS_LIBS_PRIVATE $LIBS_PRIVATE"
+ REQUIRES_PRIVATE="$LIBIBVERBS_REQUIRES_PRIVATE $REQUIRES_PRIVATE"
fi
AC_SUBST(PCAP_SUPPORT_RDMASNIFF)
fi
@@ -3067,9 +3188,6 @@ AC_PROG_INSTALL
AC_CONFIG_HEADER(config.h)
-AC_SUBST(V_CCOPT)
-AC_SUBST(V_DEFS)
-AC_SUBST(V_INCLS)
AC_SUBST(V_SHLIB_CCOPT)
AC_SUBST(V_SHLIB_CMD)
AC_SUBST(V_SHLIB_OPT)
@@ -3086,6 +3204,13 @@ AC_SUBST(BUILD_RPCAPD)
AC_SUBST(INSTALL_RPCAPD)
AC_SUBST(RPCAPD_LIBS)
+#
+# We're done with configuration operations; add ADDITIONAL_LIBS and
+# ADDITIONAL_LIBS_STATIC to LIBS and LIBS_STATIC, respectively.
+#
+LIBS="$ADDITIONAL_LIBS $LIBS"
+LIBS_STATIC="$ADDITIONAL_LIBS_STATIC $LIBS_STATIC"
+
AC_OUTPUT_COMMANDS([if test -f .devel; then
echo timestamp > stamp-h
cat $srcdir/Makefile-devel-adds >> Makefile
diff --git a/libpcap.pc.in b/libpcap.pc.in
index 628c13b0..629e662a 100644
--- a/libpcap.pc.in
+++ b/libpcap.pc.in
@@ -13,6 +13,7 @@ libdir="@libdir@"
Name: libpcap
Description: Platform-independent network traffic capture library
Version: @PACKAGE_VERSION@
+Requires.private: @REQUIRES_PRIVATE@
Libs: -L${libdir} @RPATH@ -l@PACKAGE_NAME@
-Libs.private: @LIBS@
+Libs.private: @LIBS_PRIVATE@
Cflags: -I${includedir}
diff --git a/pcap-config.in b/pcap-config.in
index 35aedfce..5df96d20 100644
--- a/pcap-config.in
+++ b/pcap-config.in
@@ -12,7 +12,7 @@ prefix="@prefix@"
exec_prefix="@exec_prefix@"
includedir="@includedir@"
libdir="@libdir@"
-LIBS="@LIBS@"
+LIBS_STATIC="@LIBS_STATIC@"
static=0
show_cflags=0
@@ -61,19 +61,19 @@ then
#
if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
then
- echo "-I$includedir $LPATH -l@PACKAGE_NAME@ $LIBS"
+ echo "-I$includedir $LPATH -l@PACKAGE_NAME@ $LIBS_STATIC"
elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
then
- echo "-I$includedir $LPATH $LIBS"
+ echo "-I$includedir $LPATH $LIBS_STATIC"
elif [ "$show_cflags" = 1 ]
then
echo "-I$includedir"
elif [ "$show_libs" = 1 ]
then
- echo "$LPATH -l@PACKAGE_NAME@ $LIBS"
+ echo "$LPATH -l@PACKAGE_NAME@ $LIBS_STATIC"
elif [ "$show_additional_libs" = 1 ]
then
- echo "$LIBS"
+ echo "$LIBS_STATIC"
fi
else
#