From: Jakub Jelinek Date: Sat, 14 Feb 2026 17:05:38 +0000 (+0100) Subject: libgcobol: Add --with-target-libxml2{,-lib,-include}= configure options [PR122839] X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a1bb1b70d017e4816650ed42d316accf2d93944;p=thirdparty%2Fgcc.git libgcobol: Add --with-target-libxml2{,-lib,-include}= configure options [PR122839] The following patch adds new configure options similar to ObjC/Algol68 --with-bdw-gc{,-lib,-include}= configure options where one can override the default of -I /usr/include/libxml2 and -lxml2 for finding libxml2 headers and library. Similarly to the bdw-gc options, the override can be for all multilibs or just specific to each multilib. Tested also with ../configure --enable-languages=c,c++,cobol --with-target-libxml2=/tmp/libxml2 \ --disable-bootstrap --disable-libsanitizer --disable-libgomp 2026-02-14 Jakub Jelinek PR cobol/122839 * configure.ac (--with-target-libxml2, --with-target-libxml2-include, --with-target-libxml2-lib): New configure options, use those to find libxml2. (LIBXML2_CPPFLAGS, LIBXML2_LIBS): New AC_SUBSTs. * Makefile.am (AM_CPPFLAGS): Add $(LIBXML2_CPPFLAGS) rather than -I /usr/include/libxml2. (libgcobol_la_LDFLAGS): Add $(LIBXML2_LIBS). * configure: Regenerate. * config.h.in: Regenerate. * Makefile.in: Regenerate. * doc/install.texi (COBOL-Specific Options): New. --- diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi index 03039141d24..d40f0c3a11d 100644 --- a/gcc/doc/install.texi +++ b/gcc/doc/install.texi @@ -3063,6 +3063,31 @@ to be available for each multilib variant, unless configured with @samp{zlib} is only used when the system installed library is not available. @end table +@subheading COBOL-Specific Options + +The following options apply to the build of the COBOL runtime library. + +@table @code +@item --with-target-libxml2=@var{list} +@itemx --with-target-libxml2-include=@var{list} +@itemx --with-target-libxml2-lib=@var{list} +Specify search directories for the libxml2 header files and +libraries. @var{list} is a comma separated list of key value pairs of the +form @samp{@var{multilibdir}=@var{path}}, where the default multilib key +is named as @samp{.} (dot), or is omitted (e.g.@: +@samp{--with-target-libxml2=/opt/libxml2,32=/opt-libxml2-32}). + +The options @option{--with-target-libxml2-include} and +@option{--with-target-libxml2-lib} must always be specified together +for each multilib variant and they take precedence over +@option{--with-target-libxml2}. If @option{--with-target-libxml2-include} +is missing values for a multilib, then the value for the default +multilib is used (e.g.@: @samp{--with-target-libxml2-include=/opt/libxml2/include} +@samp{--with-target-libxml2-lib=/opt/libxml2/lib64,32=/opt-libxml2/lib32}). +If none of these options are specified, the library is assumed in +default locations. +@end table + @html

diff --git a/libgcobol/Makefile.am b/libgcobol/Makefile.am index 79310647b3e..de9ee0e3539 100644 --- a/libgcobol/Makefile.am +++ b/libgcobol/Makefile.am @@ -85,7 +85,7 @@ nobase_libsubinclude_HEADERS = \ WARN_CFLAGS = -W -Wall -Wwrite-strings AM_CPPFLAGS = -I. -I posix/shim $(LIBQUADINCLUDE) -AM_CPPFLAGS += -I /usr/include/libxml2 +AM_CPPFLAGS += $(LIBXML2_CPPFLAGS) AM_CFLAGS = $(XCFLAGS) AM_CXXFLAGS = $(XCFLAGS) @@ -103,7 +103,7 @@ endif libgcobol_la_LINK = $(CXXLINK) $(libgcobol_la_LDFLAGS) version_arg = -version-info $(LIBGCOBOL_VERSION) libgcobol_la_LDFLAGS = $(LTLDFLAGS) $(LIBQUADLIB) $(LTLIBICONV) \ - $(extra_ldflags_libgcobol) $(LIBS) $(version_arg) + $(extra_ldflags_libgcobol) $(LIBS) $(LIBXML2_LIBS) $(version_arg) libgcobol_la_DEPENDENCIES = libgcobol.spec $(LIBQUADLIB_DEP) endif BUILD_LIBGCOBOL diff --git a/libgcobol/Makefile.in b/libgcobol/Makefile.in index fa8b7bdf4eb..687fda2a508 100644 --- a/libgcobol/Makefile.in +++ b/libgcobol/Makefile.in @@ -312,6 +312,8 @@ LIBQUADLIB_DEP = @LIBQUADLIB_DEP@ LIBQUADSPEC = @LIBQUADSPEC@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ +LIBXML2_CPPFLAGS = @LIBXML2_CPPFLAGS@ +LIBXML2_LIBS = @LIBXML2_LIBS@ LIPO = @LIPO@ LLVM_CONFIG = @LLVM_CONFIG@ LN_S = @LN_S@ @@ -454,8 +456,7 @@ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER) @BUILD_LIBGCOBOL_TRUE@WARN_CFLAGS = -W -Wall -Wwrite-strings @BUILD_LIBGCOBOL_TRUE@AM_CPPFLAGS = -I. -I posix/shim \ -@BUILD_LIBGCOBOL_TRUE@ $(LIBQUADINCLUDE) -I \ -@BUILD_LIBGCOBOL_TRUE@ /usr/include/libxml2 +@BUILD_LIBGCOBOL_TRUE@ $(LIBQUADINCLUDE) $(LIBXML2_CPPFLAGS) @BUILD_LIBGCOBOL_TRUE@AM_CFLAGS = $(XCFLAGS) @BUILD_LIBGCOBOL_TRUE@AM_CXXFLAGS = $(XCFLAGS) $(WARN_CFLAGS) \ @BUILD_LIBGCOBOL_TRUE@ -DIN_TARGET_LIBS -fstrict-aliasing \ @@ -465,7 +466,7 @@ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER) @BUILD_LIBGCOBOL_TRUE@libgcobol_la_LINK = $(CXXLINK) $(libgcobol_la_LDFLAGS) @BUILD_LIBGCOBOL_TRUE@version_arg = -version-info $(LIBGCOBOL_VERSION) @BUILD_LIBGCOBOL_TRUE@libgcobol_la_LDFLAGS = $(LTLDFLAGS) $(LIBQUADLIB) $(LTLIBICONV) \ -@BUILD_LIBGCOBOL_TRUE@ $(extra_ldflags_libgcobol) $(LIBS) $(version_arg) +@BUILD_LIBGCOBOL_TRUE@ $(extra_ldflags_libgcobol) $(LIBS) $(LIBXML2_LIBS) $(version_arg) @BUILD_LIBGCOBOL_TRUE@libgcobol_la_DEPENDENCIES = libgcobol.spec $(LIBQUADLIB_DEP) all: config.h diff --git a/libgcobol/config.h.in b/libgcobol/config.h.in index 9f988369feb..1b511d0330d 100644 --- a/libgcobol/config.h.in +++ b/libgcobol/config.h.in @@ -55,9 +55,6 @@ /* Define to 1 if you have the `random_r' function. */ #undef HAVE_RANDOM_R -/* Define to 1 if you have the `xmlParseChunk' function. */ -#undef HAVE_SAX_XML_PARSER - /* Define to 1 if you have the `setstate_r' function. */ #undef HAVE_SETSTATE_R diff --git a/libgcobol/configure b/libgcobol/configure index 18676aafa94..950b1e26262 100755 --- a/libgcobol/configure +++ b/libgcobol/configure @@ -644,6 +644,8 @@ LIBQUADINCLUDE LIBQUADLIB_DEP LIBQUADLIB LIBQUADSPEC +LIBXML2_LIBS +LIBXML2_CPPFLAGS extra_ldflags_libgcobol LIBGCOBOL_VERSION BUILD_LIBGCOBOL_FALSE @@ -803,6 +805,9 @@ with_toolexeclibdir enable_rpath with_libiconv_prefix with_libiconv_type +with_target_libxml2 +with_target_libxml2_include +with_target_libxml2_lib enable_libquadmath with_gcc_major_version_only ' @@ -1472,6 +1477,16 @@ Optional Packages: --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib --without-libiconv-prefix don't search for libiconv in includedir and libdir --with-libiconv-type=TYPE type of library to search for (auto/static/shared) + --with-target-libxml2=PATHLIST + specify prefix directory for installed libxml2 + package. Equivalent to + --with-target-libxml2-include=PATH/include plus + --with-target-libxml2-lib=PATH/lib + --with-target-libxml2-include=PATHLIST + specify directories for installed libxml2 include + files + --with-target-libxml2-lib=PATHLIST + specify directories for installed libxml2 library --with-gcc-major-version-only use only GCC major number in filesystem paths @@ -12199,7 +12214,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12202 "configure" +#line 12217 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12305,7 +12320,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12308 "configure" +#line 12323 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -17666,99 +17681,111 @@ fi # These are libxml2. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for xmlSAXUserParseMemory in -lxml2" >&5 -$as_echo_n "checking for xmlSAXUserParseMemory in -lxml2... " >&6; } -if ${ac_cv_lib_xml2_xmlSAXUserParseMemory+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lxml2 $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 xmlSAXUserParseMemory (); -int -main () -{ -return xmlSAXUserParseMemory (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_xml2_xmlSAXUserParseMemory=yes -else - ac_cv_lib_xml2_xmlSAXUserParseMemory=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS +# Check whether --with-target-libxml2 was given. +if test "${with_target_libxml2+set}" = set; then : + withval=$with_target_libxml2; fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_xml2_xmlSAXUserParseMemory" >&5 -$as_echo "$ac_cv_lib_xml2_xmlSAXUserParseMemory" >&6; } -if test "x$ac_cv_lib_xml2_xmlSAXUserParseMemory" = xyes; then : - LIBS="-lxml2 $LIBS" -$as_echo "#define HAVE_SAX_XML_PARSER 1" >>confdefs.h +# Check whether --with-target-libxml2-include was given. +if test "${with_target_libxml2_include+set}" = set; then : + withval=$with_target_libxml2_include; fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for xmlParseChunk in -lxml2" >&5 -$as_echo_n "checking for xmlParseChunk in -lxml2... " >&6; } -if ${ac_cv_lib_xml2_xmlParseChunk+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lxml2 $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 xmlParseChunk (); -int -main () -{ -return xmlParseChunk (); - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_link "$LINENO"; then : - ac_cv_lib_xml2_xmlParseChunk=yes -else - ac_cv_lib_xml2_xmlParseChunk=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS +# Check whether --with-target-libxml2-lib was given. +if test "${with_target_libxml2_lib+set}" = set; then : + withval=$with_target_libxml2_lib; fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_xml2_xmlParseChunk" >&5 -$as_echo "$ac_cv_lib_xml2_xmlParseChunk" >&6; } -if test "x$ac_cv_lib_xml2_xmlParseChunk" = xyes; then : - LIBS="-lxml2 $LIBS" -$as_echo "#define HAVE_SAX_XML_PARSER 1" >>confdefs.h +if test "x$use_libgcobol" = xyes && test "x$libgcobol_cv_have_int128" = xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libxml2" >&5 +$as_echo_n "checking for libxml2... " >&6; } + if test "x$with_target_libxml2$with_target_libxml2_include$with_target_libxml2_lib" = x; then + LIBXML2_CPPFLAGS="-I /usr/include/libxml2" + LIBXML2_LIBS="-lxml2" + else + if test "x$with_target_libxml2_include" = x && test "x$with_target_libxml2_lib" != x; then + as_fn_error $? "found --with-target-libxml2-lib but --with-target-libxml2-include missing" "$LINENO" 5 + elif test "x$with_target_libxml2_include" != x && test "x$with_target_libxml2_lib" = x; then + as_fn_error $? "found --with-target-libxml2-include but --with-target-libxml2-lib missing" "$LINENO" 5 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: using paths configured with --with-target-libxml2 options" >&5 +$as_echo "using paths configured with --with-target-libxml2 options" >&6; } + fi + mldir=`${CC-gcc} --print-multi-directory 2>/dev/null` + libxml2_val= + if test "x$with_target_libxml2" != x; then + for i in `echo $with_target_libxml2 | tr ',' ' '`; do + case "$i" in + *=*) sd=${i%%=*}; d=${i#*=} ;; + *) sd=.; d=$i ;; + esac + if test "$mldir" = "$sd"; then + libxml2_val=$d + fi + done + if test "x$libxml2_val" = x; then + as_fn_error $? "no multilib path ($mldir) found in --with-target-libxml2" "$LINENO" 5 + fi + libxml2_inc_dir="$libxml2_val/include" + libxml2_lib_dir="$libxml2_val/lib" + fi + libxml2_val= + if test "x$with_target_libxml2_include" != x; then + for i in `echo $with_target_libxml2_include | tr ',' ' '`; do + case "$i" in + *=*) sd=${i%%=*}; d=${i#*=} ;; + *) sd=.; d=$i; fallback=$i ;; + esac + if test "$mldir" = "$sd"; then + libxml2_val=$d + fi + done + if test "x$libxml2_val" = x && test "x$libxml2_inc_dir" = x && test "x$fallback" != x; then + libxml2_inc_dir="$fallback" + elif test "x$libxml2_val" = x; then + as_fn_error $? "no multilib path ($mldir) found in --with-target-libxml2-include" "$LINENO" 5 + else + libxml2_inc_dir="$libxml2_val" + fi + fi + libxml2_val= + if test "x$with_target_libxml2_lib" != x; then + for i in `echo $with_target_libxml2_lib | tr ',' ' '`; do + case "$i" in + *=*) sd=${i%%=*}; d=${i#*=} ;; + *) sd=.; d=$i ;; + esac + if test "$mldir" = "$sd"; then + libxml2_val=$d + fi + done + if test "x$libxml2_val" = x; then + as_fn_error $? "no multilib path ($mldir) found in --with-target-libxml2-lib" "$LINENO" 5 + fi + libxml2_lib_dir="$libxml2_val" + fi + if test "x$libxml2_inc_dir" = x; then + as_fn_error $? "no multilib path ($mldir) found in --with-target-libxml2-include" "$LINENO" 5 + fi + if test "x$libxml2_lib_dir" = x; then + as_fn_error $? "no multilib path ($mldir) found in --with-target-libxml2-lib" "$LINENO" 5 + fi + LIBXML2_CPPFLAGS="-I$libxml2_inc_dir" + LIBXML2_LIBS="-L$libxml2_lib_dir -lxml2" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5 +$as_echo "found" >&6; } + fi +else + LIBXML2_CPPFLAGS= + LIBXML2_LIBS= fi + # Copied from gcc/configure.ac. 2025-06-05 R.J.Dubner # At least for glibc, clock_gettime is in librt. But don't pull that # in if it still doesn't give us the function we want. diff --git a/libgcobol/configure.ac b/libgcobol/configure.ac index 9b6ea7ebbf3..2675ed8e961 100644 --- a/libgcobol/configure.ac +++ b/libgcobol/configure.ac @@ -233,14 +233,102 @@ libgcobol_have_cacosf128=no AC_SEARCH_LIBS([cacosf128], [c m], libgcobol_have_cacosf128=yes) # These are libxml2. -AC_CHECK_LIB(xml2, xmlSAXUserParseMemory, - [LIBS="-lxml2 $LIBS" - AC_DEFINE(HAVE_SAX_XML_PARSER, 1, - [Define to 1 if you have the `xmlSAXUserParseMemory' function.])]) -AC_CHECK_LIB(xml2, xmlParseChunk, - [LIBS="-lxml2 $LIBS" - AC_DEFINE(HAVE_SAX_XML_PARSER, 1, - [Define to 1 if you have the `xmlParseChunk' function.])]) +AC_ARG_WITH([target-libxml2], +[AS_HELP_STRING([--with-target-libxml2=PATHLIST], + [specify prefix directory for installed libxml2 package. + Equivalent to --with-target-libxml2-include=PATH/include + plus --with-target-libxml2-lib=PATH/lib])]) +AC_ARG_WITH([target-libxml2-include], +[AS_HELP_STRING([--with-target-libxml2-include=PATHLIST], + [specify directories for installed libxml2 include files])]) +AC_ARG_WITH([target-libxml2-lib], +[AS_HELP_STRING([--with-target-libxml2-lib=PATHLIST], + [specify directories for installed libxml2 library])]) + +if test "x$use_libgcobol" = xyes && test "x$libgcobol_cv_have_int128" = xyes; then + AC_MSG_CHECKING([for libxml2]) + if test "x$with_target_libxml2$with_target_libxml2_include$with_target_libxml2_lib" = x; then + dnl no libxml2 options, assuming libxml2 in default locations + LIBXML2_CPPFLAGS="-I /usr/include/libxml2" + LIBXML2_LIBS="-lxml2" + else + dnl libxml2 options passed by configure flags + if test "x$with_target_libxml2_include" = x && test "x$with_target_libxml2_lib" != x; then + AC_MSG_ERROR([found --with-target-libxml2-lib but --with-target-libxml2-include missing]) + elif test "x$with_target_libxml2_include" != x && test "x$with_target_libxml2_lib" = x; then + AC_MSG_ERROR([found --with-target-libxml2-include but --with-target-libxml2-lib missing]) + else + AC_MSG_RESULT([using paths configured with --with-target-libxml2 options]) + fi + mldir=`${CC-gcc} --print-multi-directory 2>/dev/null` + libxml2_val= + if test "x$with_target_libxml2" != x; then + for i in `echo $with_target_libxml2 | tr ',' ' '`; do + case "$i" in + *=*) sd=${i%%=*}; d=${i#*=} ;; + *) sd=.; d=$i ;; + esac + if test "$mldir" = "$sd"; then + libxml2_val=$d + fi + done + if test "x$libxml2_val" = x; then + AC_MSG_ERROR([no multilib path ($mldir) found in --with-target-libxml2]) + fi + libxml2_inc_dir="$libxml2_val/include" + libxml2_lib_dir="$libxml2_val/lib" + fi + libxml2_val= + if test "x$with_target_libxml2_include" != x; then + for i in `echo $with_target_libxml2_include | tr ',' ' '`; do + case "$i" in + *=*) sd=${i%%=*}; d=${i#*=} ;; + *) sd=.; d=$i; fallback=$i ;; + esac + if test "$mldir" = "$sd"; then + libxml2_val=$d + fi + done + if test "x$libxml2_val" = x && test "x$libxml2_inc_dir" = x && test "x$fallback" != x; then + libxml2_inc_dir="$fallback" + elif test "x$libxml2_val" = x; then + AC_MSG_ERROR([no multilib path ($mldir) found in --with-target-libxml2-include]) + else + libxml2_inc_dir="$libxml2_val" + fi + fi + libxml2_val= + if test "x$with_target_libxml2_lib" != x; then + for i in `echo $with_target_libxml2_lib | tr ',' ' '`; do + case "$i" in + *=*) sd=${i%%=*}; d=${i#*=} ;; + *) sd=.; d=$i ;; + esac + if test "$mldir" = "$sd"; then + libxml2_val=$d + fi + done + if test "x$libxml2_val" = x; then + AC_MSG_ERROR([no multilib path ($mldir) found in --with-target-libxml2-lib]) + fi + libxml2_lib_dir="$libxml2_val" + fi + if test "x$libxml2_inc_dir" = x; then + AC_MSG_ERROR([no multilib path ($mldir) found in --with-target-libxml2-include]) + fi + if test "x$libxml2_lib_dir" = x; then + AC_MSG_ERROR([no multilib path ($mldir) found in --with-target-libxml2-lib]) + fi + LIBXML2_CPPFLAGS="-I$libxml2_inc_dir" + LIBXML2_LIBS="-L$libxml2_lib_dir -lxml2" + AC_MSG_RESULT([found]) + fi +else + LIBXML2_CPPFLAGS= + LIBXML2_LIBS= +fi +AC_SUBST(LIBXML2_CPPFLAGS) +AC_SUBST(LIBXML2_LIBS) # Copied from gcc/configure.ac. 2025-06-05 R.J.Dubner # At least for glibc, clock_gettime is in librt. But don't pull that