Skip to content

Commit 4dba29f

Browse files
committed
Issue #6 (library-check) improved AX_CHECK_LIB
Previous implementation of AX_CHECK_LIB macro fails whether any function in argument list has not been found and informs only about this function. This causes several configure runs to detect all names which has not been found. Current implementation validates the entire list of required functions for one library required by one component and informs about all functions that have not been found.
1 parent 2d62b99 commit 4dba29f

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

ac-macros/ax-macros.m4

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,20 @@ AC_DEFUN([AX_RAW_CHECK_PROG], [
4141
# $1 - library name (without 'lib' prefix and extension suffix)
4242
# $2 - list of required functions
4343
AC_DEFUN([AX_CHECK_LIB], [
44+
NOT_FOUND=''
45+
CACHED_LIBS=$LIBS
4446
for sub in $2
4547
do
46-
AC_CHECK_LIB([$1], [$sub], [
47-
# The check below is necessary for deduplication of $1 library
48-
# within LIBS variable
49-
AS_IF([echo $LIBS | grep -q "$1"], [], [
50-
AS_VAR_APPEND([LIBS], [-l$1])
51-
])
52-
], [
53-
AC_MSG_ERROR([Function $sub does not exist in $1])
54-
])
48+
AC_CHECK_LIB([$1], [$sub], [ ], [ NOT_FOUND="$NOT_FOUND $sub" ])
5549
done
50+
AS_IF([test "x$NOT_FOUND" == "x"], [
51+
# Deduplication of $1 library in LIBS: if library $1 already exists in
52+
# LIBS it won't be added, otherwise new LIBS will contain CACHED_LIBS
53+
# and -l$1.
54+
# Rationale for this hack # is written in autoconf documentation
55+
# (https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Libraries.html)
56+
AS_CASE(["$LIBS"], [*"-l$1"*], [], [LIBS="$CACHED_LIBS -l$1"])
57+
], [
58+
AC_MSG_ERROR([Functions:$NOT_FOUND do not exist in $1])
59+
])
5660
])

0 commit comments

Comments
 (0)