> Am 04.04.2025 um 17:19 schrieb Iain Sandoe <iains....@gmail.com>:
> 
> Nightstrike kindly made an initial review of this patch (offlist) and
> pointed out a few things. This, thus, is version 2 - it does not change
> in basic mechanism but is even shorter.
> 
> This is blocking some already-approved patches and the one that allows
> the use of libquadmath..
> 
> Tested on x86_64, aarch64-linux (and x86_64 darwin with the libquadmath
> stuff).
> 
> Note that this does not include the regenerated files, since that makes
> the patch huge.
> 
> OK for trunk?

Ok

Thanks,
Richard 

> --- 8< --
> 
> Currently, the library is configured as if it was written in C, however
> all the sources are C++, so update to use C++ as the configure language
> (and check the CXX instead of CC).
> 
> Reorder the configuration steps so that we setup the tools and environment
> before carrying out tests.
> 
> Remove unused configuration machinery.
> 
> Also we configured extra ld flags but never used them. There is no need
> to make these extra_ldflags darwin-specific, additions could be required
> by other hosts.
> 
> libgcobol/ChangeLog:
> 
>    * Makefile.am: Use the configured LIBS and extra_ldflags.
>    * Makefile.in: Regenerate.
>    * configure: Regenerate.
>    * configure.ac: Shift configure to use c++. Order tests for tools
>    and environment before other tests.
> 
> Signed-off-by: Iain Sandoe <i...@sandoe.co.uk>
> ---
> libgcobol/Makefile.am  |    36 +-
> libgcobol/Makefile.in  |   293 +-
> libgcobol/aclocal.m4   |    20 -
> libgcobol/config.h.in  |     6 -
> libgcobol/configure    | 17731 ++++++++++++++++++---------------------
> libgcobol/configure.ac |   269 +-
> 6 files changed, 8390 insertions(+), 9965 deletions(-)
> 
> diff --git a/libgcobol/Makefile.am b/libgcobol/Makefile.am
> index 45217421b1c..e47fa3dbbd4 100644
> --- a/libgcobol/Makefile.am
> +++ b/libgcobol/Makefile.am
> @@ -25,9 +25,9 @@ ACLOCAL_AMFLAGS = -I .. -I ../config
> # May be used by various substitution variables.
> gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
> 
> +# Skip the whole process if we are not building libgcobol.
> if BUILD_LIBGCOBOL
> toolexeclib_LTLIBRARIES  = libgcobol.la
> -endif
> 
> ##
> ## 2.2.12 Automatic Dependency Tracking
> @@ -43,22 +43,26 @@ libgcobol_la_SOURCES =                \
>    libgcobol.cc                \
>    valconv.cc
> 
> -libgcobol_la_LINK = $(LIBTOOL) --mode=link --tag=CXX $(CXX)    \
> -        -o libgcobol$(libsuffix).la            \
> -        -Wc,-shared-libgcc                \
> -        -version-info $(LIBGCOBOL_VERSION)        \
> -        -lstdc++                    \
> -        $(LTLDFLAGS) $(LTLIBICONV) $(LIBM)
> -
> WARN_CFLAGS = -W -Wall -Wwrite-strings
> 
> -AM_CXXFLAGS = $(CXXFLAGS_FOR_TARGET)
> +AM_CPPFLAGS = -I. -I$(srcdir)
> +AM_CFLAGS = $(XCFLAGS)
> +AM_CXXFLAGS = $(XCFLAGS)
> +AM_CXXFLAGS += $(WARN_CFLAGS)
> +AM_CXXFLAGS += -DIN_TARGET_LIBS
> +AM_CXXFLAGS += -fno-strict-aliasing
> +
> +if ENABLE_DARWIN_AT_RPATH
> +# Handle embedded rpaths for Darwin.
> +extra_ldflags_libgcobol += -Wc,-nodefaultrpaths
> +extra_ldflags_libgcobol += -Wl,-rpath,@loader_path
> +endif
> 
> -# not defined: DEFS, MAX_ERRORS, LTLDFLAGS
> -ALL_CXXFLAGS = -I. -I$(srcdir) $(AM_CPPFLAGS) $(DEFS)        \
> -    $(XCFLAGS) $(AM_CXXFLAGS) $(WARN_CFLAGS) $(MAX_ERRORS)    \
> -    -DIN_GCC -DIN_TARGET_LIBS -fno-strict-aliasing
> +# We want to link with the c++ runtime.
> +libgcobol_la_LINK = $(CXXLINK) $(libgcobol_la_LDFLAGS)
> +version_arg = -version-info $(LIBGCOBOL_VERSION)
> +libgcobol_la_LDFLAGS = $(LTLDFLAGS) $(LTLIBICONV) \
> +    $(extra_ldflags_libgcobol) $(LIBS) \
> +    $(version_arg)
> 
> -%.lo: %.cc
> -    $(LIBTOOL) --mode=compile --tag=CXX $(CXX) -c    \
> -        -o $@ $(INCLUDES) $(ALL_CXXFLAGS) $<
> +endif BUILD_LIBGCOBOL
> diff --git a/libgcobol/configure.ac b/libgcobol/configure.ac
> index 6b287a1ac70..123d87649d0 100644
> --- a/libgcobol/configure.ac
> +++ b/libgcobol/configure.ac
> @@ -26,8 +26,32 @@ AC_INIT(package-unused, version-unused,,libgcobol)
> AC_CONFIG_SRCDIR(Makefile.am)
> AC_CONFIG_HEADER(config.h)
> 
> +# Do not delete or change the following two lines.  For why, see
> +# http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
> +AC_CANONICAL_SYSTEM
> +ACX_NONCANONICAL_TARGET
> +
> AM_ENABLE_MULTILIB(, ..)
> 
> +target_alias=${target_alias-$host_alias}
> +AC_SUBST(target_alias)
> +
> +AM_MAINTAINER_MODE
> +
> +AM_INIT_AUTOMAKE([1.15.1 no-define foreign no-dist -Wall -Wno-portability])
> +
> +AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
> +AC_ARG_ENABLE(version-specific-runtime-libs,
> +AS_HELP_STRING([--enable-version-specific-runtime-libs],
> +[Specify that runtime libraries should be installed in a compiler-specific 
> directory]),
> +[case "$enableval" in
> + yes) version_specific_libs=yes ;;
> + no)  version_specific_libs=no ;;
> + *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific 
> libs]);;
> + esac],
> +[version_specific_libs=no])
> +AC_MSG_RESULT($version_specific_libs)
> +
> # This works around the fact that libtool configuration may change LD
> # for this particular configuration, but some shells, instead of
> # keeping the changes in LD private, export them just because LD is
> @@ -38,107 +62,40 @@ GCC_NO_EXECUTABLES
> 
> AC_USE_SYSTEM_EXTENSIONS
> 
> -# Do not delete or change the following two lines.  For why, see
> -# http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
> -AC_CANONICAL_SYSTEM
> -target_alias=${target_alias-$host_alias}
> -AC_SUBST(target_alias)
> -
> -AM_INIT_AUTOMAKE # ([1.15.1 no-define foreign no-dist -Wall 
> -Wno-portability])
> +# Find other programs we need.
> +AC_CHECK_TOOL(AR, ar)
> +AC_CHECK_TOOL(NM, nm)
> +AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
> +AC_PROG_MAKE_SET
> +AC_PROG_INSTALL
> 
> -AH_TEMPLATE(PACKAGE, [Name of package])
> -AH_TEMPLATE(VERSION, [Version number of package])
> +AM_PROG_LIBTOOL
> +LT_INIT
> 
> -AC_ARG_WITH(cross-host,
> -[  --with-cross-host=HOST           Configuring with a cross compiler])
> +AC_LIBTOOL_DLOPEN
> +LT_LIB_M
> 
> -# Checks for header files.
> -AC_CHECK_HEADERS(malloc.h)
> +AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = 
> xyes])
> 
> -AC_CANONICAL_HOST
> -ACX_NONCANONICAL_HOST
> -ACX_NONCANONICAL_TARGET
> -GCC_TOPLEV_SUBDIRS
> +AC_SUBST(enable_shared)
> +AC_SUBST(enable_static)
> 
> -AC_CHECK_SIZEOF([void *])
> +# This library is written in C++ and needs to link with the C++ runtime.
> +AC_LANG([C++])
> 
> -# Get target configury.
> -unset LIBGCOBOL_SUPPORTED
> -. ${srcdir}/configure.tgt
> +# We must force CC/CXX to /not/ be precious variables; otherwise
> +# the wrong, non-multilib-adjusted value will be used in multilibs.
> +# As a side effect, we have to subst CFLAGS ourselves.
> 
> -# -----------------
> -# __int128 support
> -# -----------------
> +m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
> +m4_define([_AC_ARG_VAR_PRECIOUS],[])
> +AC_PROG_CXX
> +m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
> 
> -AC_CACHE_CHECK([whether __int128 is supported], [libgcobol_cv_have_int128],
> -  [GCC_TRY_COMPILE_OR_LINK([
> -    __int128 foo (__int128 )
> -    {
> -    __int128 aaa;
> -     return (__int128) aaa;
> -    }
> -
> -    __int128 bar (__int128 )
> -    {
> -    __int128 aaa;
> -     return (__int128) aaa;
> -    }
> -  ],[
> -    foo (1);
> -    bar (1);
> -  ],[
> -    libgcobol_cv_have_int128=yes
> -  ],[
> -    libgcobol_cv_have_int128=no
> -])])
> -# The following conditional is useful when this creates a Makefile.am file 
> that
> -# is subsequently processed into a Makefile.in file.  At the present time,
> -# however the libgcobol build uses a hardcoded Makefile.in file.
> -AM_CONDITIONAL(BUILD_LIBGCOBOL, [test "x$LIBGCOBOL_SUPPORTED" = xyes && test 
> "x$libgcobol_cv_have_int128" = xyes])
> +AC_SUBST(CXXFLAGS)
> 
> GCC_WITH_TOOLEXECLIBDIR
> 
> -AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
> -AC_ARG_ENABLE(version-specific-runtime-libs,
> -[  --enable-version-specific-runtime-libs    Specify that runtime libraries 
> should be installed in a compiler-specific directory ],
> -[case "$enableval" in
> - yes) version_specific_libs=yes ;;
> - no)  version_specific_libs=no ;;
> - *)   AC_MSG_ERROR([Unknown argument to enable/disable version-specific 
> libs]);;
> - esac],
> -[version_specific_libs=no])
> -AC_MSG_RESULT($version_specific_libs)
> -
> -AC_ARG_WITH(slibdir,
> -[  --with-slibdir=DIR      shared libraries in DIR [LIBDIR]],
> -slibdir="$with_slibdir",
> -if test "${version_specific_libs}" = yes; then
> -  slibdir='$(libsubdir)'
> -elif test -n "$with_cross_host" && test x"$with_cross_host" != x"no"; then
> -  slibdir='$(exec_prefix)/$(host_noncanonical)/lib'
> -else
> -  slibdir='$(libdir)'
> -fi)
> -AC_SUBST(slibdir)
> -
> -# Command-line options.
> -# Very limited version of AC_MAINTAINER_MODE.
> -AC_ARG_ENABLE([maintainer-mode],
> -  [AC_HELP_STRING([--enable-maintainer-mode],
> -                 [enable make rules and dependencies not useful (and
> -                  sometimes confusing) to the casual installer])],
> -  [case ${enable_maintainer_mode} in
> -     yes) MAINT='' ;;
> -     no) MAINT='#' ;;
> -     *) AC_MSG_ERROR([--enable-maintainer-mode must be yes or no]) ;;
> -   esac
> -   maintainer_mode=${enableval}],
> -  [MAINT='#'])
> -AC_SUBST([MAINT])dnl
> -
> -toolexecdir=no
> -toolexeclibdir=no
> -
> # Calculate toolexeclibdir
> # Also toolexecdir, though it's only used in toolexeclibdir
> case ${version_specific_libs} in
> @@ -166,55 +123,70 @@ case ${version_specific_libs} in
>     esac
>     ;;
> esac
> -
> AC_SUBST(toolexecdir)
> AC_SUBST(toolexeclibdir)
> 
> -# Determine what GCC version number to use in filesystem paths.
> -GCC_BASE_VER
> +# For iconv support.
> +AM_ICONV
> 
> -AH_TEMPLATE(PACKAGE, [Name of package])
> -AH_TEMPLATE(VERSION, [Version number of package])
> +# Checks for header files.
> +AC_CHECK_HEADERS(malloc.h)
> 
> -AM_MAINTAINER_MODE
> +AC_CHECK_SIZEOF([void *])
> 
> -# Check the compiler.
> -# The same as in boehm-gc and libstdc++. Have to borrow it from there.
> -# We must force CC to /not/ be precious variables; otherwise
> -# the wrong, non-multilib-adjusted value will be used in multilibs.
> -# As a side effect, we have to subst CFLAGS ourselves.
> +# Get target configury.
> +unset LIBGCOBOL_SUPPORTED
> +. ${srcdir}/configure.tgt
> 
> -m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
> -m4_define([_AC_ARG_VAR_PRECIOUS],[])
> -AC_PROG_CC
> -AC_PROG_CXX
> -AM_PROG_AS
> -m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
> +# -----------------
> +# __int128 support
> +# -----------------
> 
> -AC_SUBST(CFLAGS)
> +AC_CACHE_CHECK([whether __int128 is supported], [libgcobol_cv_have_int128],
> +  [GCC_TRY_COMPILE_OR_LINK([
> +    __int128 foo (__int128 )
> +    {
> +    __int128 aaa;
> +     return (__int128) aaa;
> +    }
> 
> -# In order to override CFLAGS_FOR_TARGET, all of our special flags go
> -# in XCFLAGS.  But we need them in CFLAGS during configury.  So put them
> -# in both places for now and restore CFLAGS at the end of config.
> -save_CFLAGS="$CFLAGS"
> +    __int128 bar (__int128 )
> +    {
> +    __int128 aaa;
> +     return (__int128) aaa;
> +    }
> +  ],[
> +    foo (1);
> +    bar (1);
> +  ],[
> +    libgcobol_cv_have_int128=yes
> +  ],[
> +    libgcobol_cv_have_int128=no
> +])])
> 
> -# Find other programs we need.
> -AC_CHECK_TOOL(AR, ar)
> -AC_CHECK_TOOL(NM, nm)
> -AC_CHECK_TOOL(RANLIB, ranlib, ranlib-not-found-in-path-error)
> -AC_PROG_MAKE_SET
> -AC_PROG_INSTALL
> +AM_CONDITIONAL(BUILD_LIBGCOBOL, [test "x$LIBGCOBOL_SUPPORTED" = xyes && test 
> "x$libgcobol_cv_have_int128" = xyes])
> 
> -AM_PROG_LIBTOOL
> -LT_INIT
> +# Check if functions are available in libc before adding extra libs.
> +AC_SEARCH_LIBS([malloc], [c])
> +AC_SEARCH_LIBS([clock_gettime], [c rt])
> +AC_SEARCH_LIBS([cosf128], [c m])
> 
> -AC_LIBTOOL_DLOPEN
> -LT_LIB_M
> +# libgcobol soname version
> +LIBGCOBOL_VERSION=1:0:0
> +AC_SUBST(LIBGCOBOL_VERSION)
> 
> -AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = 
> xyes])
> +## added, currently unused.
> +# VERSION_SUFFIX=$(echo $LIBGCOBOL_VERSION | tr  ':' '.' )
> +# AC_SUBST(VERSION_SUFFIX)
> +## end added
> 
> -AC_SUBST(enable_shared)
> -AC_SUBST(enable_static)
> +extra_ldflags_libgcobol=
> +case $host in
> +  *-*-darwin*)
> +    extra_ldflags_libgcobol=-Wl,-U,___cobol_main ;;
> +  *) ;;
> +esac
> +AC_SUBST(extra_ldflags_libgcobol)
> 
> # These are GLIBC
> AC_CHECK_FUNCS_ONCE(random_r srandom_r initstate_r setstate_r)
> @@ -228,53 +200,12 @@ else
>   multilib_arg=
> fi
> 
> -AC_LANG_C
> -# Check the compiler.
> -# The same as in boehm-gc and libstdc++. Have to borrow it from there.
> -# We must force CC to /not/ be precious variables; otherwise
> -# the wrong, non-multilib-adjusted value will be used in multilibs.
> -# As a side effect, we have to subst CFLAGS ourselves.
> -
> -m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
> -m4_define([_AC_ARG_VAR_PRECIOUS],[])
> -AC_PROG_CC
> -m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
> -
> -AC_SUBST(CFLAGS)
> -
> -CC_FOR_BUILD=${CC_FOR_BUILD:-gcc}
> -AC_SUBST(CC_FOR_BUILD)
> -
> -AC_SEARCH_LIBS([malloc], [c])
> -AC_SEARCH_LIBS([cosf], [m])
> -AC_SEARCH_LIBS([clock_gettime], [rt])
> -
> -# Add dependencies for libgcobol.spec file
> -SPEC_LIBGCOBOL_DEPS="$LIBS"
> -AC_SUBST(SPEC_LIBGCOBOL_DEPS)
> -
> -# libgcobol soname version
> -LIBGCOBOL_VERSION=1:0:0
> -AC_SUBST(LIBGCOBOL_VERSION)
> -
> -## added
> -VERSION_SUFFIX=$(echo $LIBGCOBOL_VERSION | tr  ':' '.' )
> -AC_SUBST(VERSION_SUFFIX)
> -## end added
> -
> # Determine what GCC version number to use in filesystem paths.
> GCC_BASE_VER
> 
> -extra_darwin_ldflags_libgcobol=
> -case $host in
> -  *-*-darwin*)
> -    extra_darwin_ldflags_libgcobol=-Wl,-U,___cobol_main ;;
> -  *) ;;
> -esac
> -AC_SUBST(extra_darwin_ldflags_libgcobol)
> -
> -# For iconv support.
> -AM_ICONV
> +# Add dependencies for libgcobol.spec file
> +#SPEC_LIBGCOBOL_DEPS="$LIBS"
> +#AC_SUBST(SPEC_LIBGCOBOL_DEPS)
> 
> AC_CONFIG_SRCDIR([Makefile.am])
> AC_CONFIG_FILES([Makefile])
> --
> 2.39.2 (Apple Git-143)
> 

Reply via email to