libgcobol: Check if the target needs libm.

Use the libtool config check and $(LIBM).

libgcobol/ChangeLog:

	* Makefile.am: Use $(LIBM) to add the math lib when
	it is needed.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Check if the target wants libm.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
This commit is contained in:
Iain Sandoe 2025-03-21 10:22:58 +00:00
parent e70fe5ed46
commit 8f1f35f1cb
4 changed files with 148 additions and 4 deletions

View file

@ -48,7 +48,7 @@ libgcobol_la_LINK = $(LIBTOOL) --mode=link --tag=CXX $(CXX) \
-Wc,-shared-libgcc \
-version-info $(LIBGCOBOL_VERSION) \
-lstdc++ \
$(LTLDFLAGS) $(LTLIBICONV)
$(LTLDFLAGS) $(LTLIBICONV) $(LIBM)
WARN_CFLAGS = -W -Wall -Wwrite-strings

View file

@ -305,6 +305,7 @@ LD = @LD@
LDFLAGS = @LDFLAGS@
LIBGCOBOL_VERSION = @LIBGCOBOL_VERSION@
LIBICONV = @LIBICONV@
LIBM = @LIBM@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
@ -428,7 +429,7 @@ libgcobol_la_LINK = $(LIBTOOL) --mode=link --tag=CXX $(CXX) \
-Wc,-shared-libgcc \
-version-info $(LIBGCOBOL_VERSION) \
-lstdc++ \
$(LTLDFLAGS) $(LTLIBICONV)
$(LTLDFLAGS) $(LTLIBICONV) $(LIBM)
WARN_CFLAGS = -W -Wall -Wwrite-strings
AM_CXXFLAGS = $(CXXFLAGS_FOR_TARGET)

146
libgcobol/configure vendored
View file

@ -646,6 +646,7 @@ enable_static
enable_shared
ENABLE_DARWIN_AT_RPATH_FALSE
ENABLE_DARWIN_AT_RPATH_TRUE
LIBM
CXXCPP
OTOOL64
OTOOL
@ -12908,7 +12909,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 12911 "configure"
#line 12912 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -13014,7 +13015,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 13017 "configure"
#line 13018 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -16348,6 +16349,147 @@ enable_dlopen=yes
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
if test x$enable_darwin_at_rpath = xyes; then
ENABLE_DARWIN_AT_RPATH_TRUE=

View file

@ -209,6 +209,7 @@ AM_PROG_LIBTOOL
LT_INIT
AC_LIBTOOL_DLOPEN
LT_LIB_M
AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])