]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
autotools: split MATH_LIBS and ISNAN_LIBS
authorKarel Zak <kzak@redhat.com>
Thu, 16 Apr 2026 14:13:29 +0000 (16:13 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 28 Apr 2026 09:16:23 +0000 (11:16 +0200)
Separate libm detection into two variables, consistent with how
meson.build handles lib_m vs math_libs:

 - MATH_LIBS: unconditional -lm for general math functions (floor,
   round, etc.), used by hwclock and test_pty
 - ISNAN_LIBS: conditional -lm only when isnan is not available
   in libc, used by script, scriptreplay, scriptlive

Previously MATH_LIBS was only set when isnan needed -lm, making it
unreliable for utilities that need other math functions.

Signed-off-by: Karel Zak <kzak@redhat.com>
configure.ac
term-utils/Makemodule.am

index ad832f747afbe8578797177623f183fc2ed26c26..c9b9b38a694316c8521944a8ea4f9e3703f520ed 100644 (file)
@@ -747,11 +747,14 @@ AS_IF([test "x$ul_cv_syscall_statmount" = xno ||
    ])
 
 
+AC_CHECK_LIB([m], [floor], [MATH_LIBS="-lm"])
+AC_SUBST([MATH_LIBS])
+
 AC_CHECK_FUNCS([isnan], [],
-       [AC_CHECK_LIB([m], [isnan], [MATH_LIBS="-lm"])]
-       [AC_CHECK_LIB([m], [__isnan], [MATH_LIBS="-lm"])]
+       [AC_CHECK_LIB([m], [isnan], [ISNAN_LIBS="-lm"])]
+       [AC_CHECK_LIB([m], [__isnan], [ISNAN_LIBS="-lm"])]
 )
-AC_SUBST([MATH_LIBS])
+AC_SUBST([ISNAN_LIBS])
 
 
 dnl lib/mononotic.c may require -lrt
index 14f87b558ae77cf84584037c8ecaf602c5460513..7ce3d8b92ce77b570759753f8e9394c9ba11deda 100644 (file)
@@ -7,7 +7,7 @@ script_SOURCES = term-utils/script.c \
                 include/pty-session.h \
                 lib/monotonic.c
 script_CFLAGS = $(AM_CFLAGS) -Wno-format-y2k
-script_LDADD = $(LDADD) libcommon.la $(MATH_LIBS) $(REALTIME_LIBS) -lutil
+script_LDADD = $(LDADD) libcommon.la $(ISNAN_LIBS) $(REALTIME_LIBS) -lutil
 if HAVE_UTEMPTER
 script_LDADD += -lutempter
 endif
@@ -25,7 +25,7 @@ dist_noinst_DATA += term-utils/scriptreplay.1.adoc
 scriptreplay_SOURCES = term-utils/scriptreplay.c \
                       term-utils/script-playutils.c \
                       term-utils/script-playutils.h
-scriptreplay_LDADD = $(LDADD) libcommon.la $(MATH_LIBS)
+scriptreplay_LDADD = $(LDADD) libcommon.la $(ISNAN_LIBS)
 endif # BUILD_SCRIPTREPLAY
 
 if BUILD_SCRIPTLIVE
@@ -38,7 +38,7 @@ scriptlive_SOURCES = term-utils/scriptlive.c \
                       lib/pty-session.c \
                       include/pty-session.h \
                       lib/monotonic.c
-scriptlive_LDADD = $(LDADD) libcommon.la $(MATH_LIBS) $(REALTIME_LIBS) -lutil
+scriptlive_LDADD = $(LDADD) libcommon.la $(ISNAN_LIBS) $(REALTIME_LIBS) -lutil
 endif # BUILD_SCRIPTLIVE