From 5c309768cb4e55172f0609e931f0f481d7518c60 Mon Sep 17 00:00:00 2001 From: Oneric Date: Fri, 13 Nov 2020 23:49:11 +0100 Subject: configure: use AC_SEARCH_LIBS instead of AC_CHECK_LIB This avoids unneccessary -lm flags on some platforms integrating libm into libc and allows us to detect systems that do not provide implementations of math functions in either libc or libm. The caveat is, that some systems, like FreeBSD split their math functions between libc and libm. By checking for C99 lrint instead of C89 fabs, this check correctly includes libm in FreeBSD; let's hope this also holds for other systems splitting up their math.h implementations. --- configure.ac | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index b5c880a..66a8fe3 100644 --- a/configure.ac +++ b/configure.ac @@ -55,7 +55,12 @@ AC_SEARCH_LIBS([iconv_open], [iconv], use_libiconv=true) AS_IF([test "x$use_libiconv" = xtrue], [ AC_DEFINE(CONFIG_ICONV, 1, [use iconv]) ]) -AC_CHECK_LIB([m], [fabs]) +# Locate math functions. Most systems have it either in libc or libm, but a few +# have some, eg C89, functions in libc and others in libm. Use C99 lrint to probe. +AC_SEARCH_LIBS([lrint], [m], + [], + [AC_MSG_ERROR([Unable to locate math functions!])] +) pkg_libs="$LIBS" LIBS="$OLDLIBS $LIBS" -- cgit v1.2.3