https://gcc.gnu.org/g:24fec6e35ee0edd44c31cfcf3f13948368d429e3
commit r17-5573-g24fec6e35ee0edd44c31cfcf3f13948368d429e3 Author: Jose E. Marchesi <[email protected]> Date: Mon Oct 26 11:22:25 2026 +0100 a68: make libga68 to depend on -lm Some of the Algol 68 standard operators rely on non-trivial math functions for their implementation. This includes floor, ceil, arctan, etc. This patch does what libgfortran and other GCC run-time libs do, which is to depend on libm in targets providing one. The decision of which targets provide libm is left to the LT_LIB_M libtool macro. Signed-off-by: Jose E. Marchesi <[email protected]> libga68/ChangeLog * configure.ac: Invoke LT_LIB_M and add $LIBM to SPEC_LIBGA68_DEPS. * configure: Regenerate. * Makefile.am (libga68_la_LDFLAGS): Link with $(LIBM). Diff: --- libga68/Makefile.am | 3 +- libga68/configure | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++- libga68/configure.ac | 5 ++ 3 files changed, 155 insertions(+), 3 deletions(-) diff --git a/libga68/Makefile.am b/libga68/Makefile.am index c26e5b12a3b3..0f7c028e4095 100644 --- a/libga68/Makefile.am +++ b/libga68/Makefile.am @@ -134,7 +134,8 @@ libga68_la_SOURCES = libga68.c \ libga68_la_LIBTOOLFLAGS = libga68_la_CFLAGS = $(LIBGA68_GCFLAGS) $(LIBGA68_BOEHM_GC_INCLUDES) libga68_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \ - $(version_arg) $(lt_host_flags) $(extra_darwin_ldflags_libga68) + $(version_arg) $(lt_host_flags) \ + $(LIBM) $(extra_darwin_ldflags_libga68) libga68_la_DEPENDENCIES = libga68.spec $(version_dep) standard.lo posix.lo libga68_la_LIBADD = $(LIBGA68_BOEHM_GC_LIBS) standard.lo posix.lo diff --git a/libga68/configure b/libga68/configure index b5f6c6a9ad87..386da87d67c4 100755 --- a/libga68/configure +++ b/libga68/configure @@ -638,6 +638,7 @@ LIBGA68_BOEHM_GC_LIBS LIBGA68_BOEHM_GC_INCLUDES LIBGA68_GCFLAGS extra_darwin_ldflags_libga68 +LIBM LIBGA68_USE_SYMVER_SUN_FALSE LIBGA68_USE_SYMVER_SUN_TRUE LIBGA68_USE_SYMVER_GNU_FALSE @@ -12835,7 +12836,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12838 "configure" +#line 12839 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12941,7 +12942,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12944 "configure" +#line 12945 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -13451,6 +13452,151 @@ else fi +# Some standard operators require non-trivial math. + +LIBM= +case $host in +*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) + # These system don't have libm, or don't need it + ;; +*-ncr-sysv4.3*) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _mwvalidcheckl in -lmw" >&5 +$as_echo_n "checking for _mwvalidcheckl in -lmw... " >&6; } +if ${ac_cv_lib_mw__mwvalidcheckl+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lmw $LIBS" +if test x$gcc_no_link = xyes; then + as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 +fi +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char _mwvalidcheckl (); +int +main () +{ +return _mwvalidcheckl (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_mw__mwvalidcheckl=yes +else + ac_cv_lib_mw__mwvalidcheckl=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mw__mwvalidcheckl" >&5 +$as_echo "$ac_cv_lib_mw__mwvalidcheckl" >&6; } +if test "x$ac_cv_lib_mw__mwvalidcheckl" = xyes; then : + LIBM="-lmw" +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cos in -lm" >&5 +$as_echo_n "checking for cos in -lm... " >&6; } +if ${ac_cv_lib_m_cos+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lm $LIBS" +if test x$gcc_no_link = xyes; then + as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 +fi +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char cos (); +int +main () +{ +return cos (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_m_cos=yes +else + ac_cv_lib_m_cos=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_cos" >&5 +$as_echo "$ac_cv_lib_m_cos" >&6; } +if test "x$ac_cv_lib_m_cos" = xyes; then : + LIBM="$LIBM -lm" +fi + + ;; +*) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cos in -lm" >&5 +$as_echo_n "checking for cos in -lm... " >&6; } +if ${ac_cv_lib_m_cos+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lm $LIBS" +if test x$gcc_no_link = xyes; then + as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 +fi +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char cos (); +int +main () +{ +return cos (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_m_cos=yes +else + ac_cv_lib_m_cos=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_cos" >&5 +$as_echo "$ac_cv_lib_m_cos" >&6; } +if test "x$ac_cv_lib_m_cos" = xyes; then : + LIBM="-lm" +fi + + ;; +esac + + +SPEC_LIBGA68_DEPS="$SPEC_LIBGA68_DEPS $LIBM" + # The Boehm GC # Check whether --enable-algol68-gc was given. diff --git a/libga68/configure.ac b/libga68/configure.ac index d84088febe8a..17b4e0002e4e 100644 --- a/libga68/configure.ac +++ b/libga68/configure.ac @@ -229,6 +229,11 @@ AM_CONDITIONAL(LIBGA68_USE_SYMVER, [test "x$ga68_use_symver" != xno]) AM_CONDITIONAL(LIBGA68_USE_SYMVER_GNU, [test "x$ga68_use_symver" = xgnu]) AM_CONDITIONAL(LIBGA68_USE_SYMVER_SUN, [test "x$ga68_use_symver" = xsun]) +# Some standard operators require non-trivial math. + +LT_LIB_M +SPEC_LIBGA68_DEPS="$SPEC_LIBGA68_DEPS $LIBM" + # The Boehm GC AC_ARG_ENABLE(algol68-gc,
