summaryrefslogtreecommitdiffstats
path: root/m4macros/ax_find_library.m4
diff options
context:
space:
mode:
authorAndrei Pavel <andrei@isc.org>2022-10-14 18:37:25 +0200
committerAndrei Pavel <andrei@isc.org>2022-10-21 16:45:25 +0200
commit168df1d9b6348d495bef11d0bbc4c341dff92cc4 (patch)
tree0ac5428de2cd36e43bd8c04241316d64ee19cbb3 /m4macros/ax_find_library.m4
parent[#2311] fix ERROR: unbound variable in xml_reporting_test_lib.sh (diff)
downloadkea-168df1d9b6348d495bef11d0bbc4c341dff92cc4.tar.xz
kea-168df1d9b6348d495bef11d0bbc4c341dff92cc4.zip
[#2311] ax_find_library: add -L if pkg-config doesn't
Solves a problem in RHEL where -L${libdir} is missing from "pkg-config --libs".
Diffstat (limited to 'm4macros/ax_find_library.m4')
-rw-r--r--m4macros/ax_find_library.m419
1 files changed, 14 insertions, 5 deletions
diff --git a/m4macros/ax_find_library.m4 b/m4macros/ax_find_library.m4
index a2263bf5cc..702c4e3432 100644
--- a/m4macros/ax_find_library.m4
+++ b/m4macros/ax_find_library.m4
@@ -102,10 +102,13 @@ AC_DEFUN([AX_FIND_LIBRARY], [
fi
libraries_found=true
- LIBRARY_LIBS="-L${p}/lib"
- if test -n "${ISC_RPATH_FLAG}"; then
- LIBRARY_LIBS="${LIBRARY_LIBS} ${ISC_RPATH_FLAG}${p}/lib"
- fi
+
+ # Add -L.
+ for l in lib lib64; do
+ if test -d "${p}/${l}"; then
+ LIBRARY_LIBS="-L${p}/{l}"
+ fi
+ done
for i in ${list_of_libraries}; do
i_found=false
for l in lib lib64; do
@@ -140,7 +143,7 @@ AC_DEFUN([AX_FIND_LIBRARY], [
LIBRARY_LIBS="$(printf '%s' "${LIBRARY_LIBS}" | sed 's/^ *//g;s/ *$//g')"
# Add to the runtime search path if the flag is not already added.
- if test -n "${ISC_RPATH_FLAG}" && test "$(printf '%s\n' "${LIBRARY_LIBS}" | grep -Fc -e "${ISC_RPATH_FLAG}")" = 0; then
+ if test -n "${ISC_RPATH_FLAG}" && test "$(printf '%s\n' "${LIBRARY_LIBS}" | grep -Fc -- "${ISC_RPATH_FLAG}")" = 0; then
library_location=$(printf '%s\n' "${LIBRARY_LIBS}" | grep -Eo '\-L.*\b' | sed 's/-L//g')
if test -n "${library_location}"; then
LIBRARY_LIBS="${LIBRARY_LIBS} ${ISC_RPATH_FLAG}${library_location}"
@@ -201,10 +204,16 @@ AC_DEFUN([AX_FIND_LIBRARY_WITH_PKG_CONFIG], [
# Get the flags.
LIBRARY_CPPFLAGS=$("${PKG_CONFIG}" --cflags-only-other "${library_pc_or_name}")
LIBRARY_INCLUDEDIR=$("${PKG_CONFIG}" --cflags-only-I "${library_pc_or_name}")
+ LIBRARY_LIBDIR=$("${PKG_CONFIG}" --variable libdir "${library_pc_or_name}")
LIBRARY_LIBS=$("${PKG_CONFIG}" --libs "${library_pc_or_name}")
LIBRARY_VERSION=$("${PKG_CONFIG}" --modversion "${library_pc_or_name}")
LIBRARY_PREFIX=$("${PKG_CONFIG}" --variable=prefix "${library_pc_or_name}")
+ # Sometimes pkg-config is stubborn in including -L, so let's include it ourselves.
+ if test -n "${LIBRARY_LIBDIR}" && test "$(printf '%s\n' "${LIBRARY_LIBS}" | grep -Fc -- -L)" = 0; then
+ LIBRARY_LIBS="-L${LIBRARY_LIBDIR} ${LIBRARY_LIBS}"
+ fi
+
# Get the variables.
for i in $(printf '%s' "${list_of_variables}" | sed 's/,/ /g'); do
# The export is not strictly required here, but we need a way to