configure: use pkg-config for libxml2 detection (fixes #2173)

Origin: bfdf002a53
Bug: https://github.com/OSGeo/gdal/issues/2173
Bug-Debian: https://bugs.debian.org/949167

Gbp-Pq: Name 0001-configure-use-pkg-config-for-libxml2-detection-fixes.patch
This commit is contained in:
Even Rouault 2022-05-14 03:28:47 +08:00 committed by openKylinBot
parent 61311a1636
commit ac98137bd8
2 changed files with 217 additions and 63 deletions

241
configure vendored
View File

@ -718,7 +718,8 @@ SQLITE3_VERSION
LIBXML2_LIB
LIBXML2_INC
HAVE_LIBXML2
LIBXML2_CONFIG
LIBXML2_LIBS
LIBXML2_CFLAGS
CURL_LIB
CURL_INC
CURL_SETTING
@ -1250,6 +1251,8 @@ OPENJPEG_CFLAGS
OPENJPEG_LIBS
LIBKML_CFLAGS
LIBKML_LIBS
LIBXML2_CFLAGS
LIBXML2_LIBS
POPPLER_CFLAGS
POPPLER_LIBS'
@ -2181,7 +2184,7 @@ Optional Packages:
--with-odbc=ARG Include ODBC support (ARG=no or path)
--with-dods-root=ARG Include DODS support (ARG=no or absolute path)
--with-curl=ARG Include curl (ARG=path to curl-config.)
--with-xml2=ARG Include libxml2 (ARG=path to xml2-config.)
--with-xml2=ARG Include libxml2 (ARG=yes/no)
--with-spatialite=ARG Include SpatiaLite support (ARG=no(default), yes, dlopen (only supported for Spatialite >= 4.1.2) or path)
--with-spatialite-soname=ARG Spatialite shared object name (e.g. libspatialite.so), only used if --with-spatiliate=dlopen
--with-sqlite3=[ARG] use SQLite 3 library [default=yes], optionally
@ -2263,6 +2266,10 @@ Some influential environment variables:
LIBKML_CFLAGS
C compiler flags for LIBKML, overriding pkg-config
LIBKML_LIBS linker flags for LIBKML, overriding pkg-config
LIBXML2_CFLAGS
C compiler flags for LIBXML2, overriding pkg-config
LIBXML2_LIBS
linker flags for LIBXML2, overriding pkg-config
POPPLER_CFLAGS
C compiler flags for POPPLER, overriding pkg-config
POPPLER_LIBS
@ -10906,11 +10913,8 @@ _LT_EOF
test $ac_status = 0; }; then
# Now try to grab the symbols.
nlist=conftest.nm
if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5
(eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } && test -s "$nlist"; then
$ECHO "$as_me:$LINENO: $NM conftest.$ac_objext | $lt_cv_sys_global_symbol_pipe > $nlist" >&5
if eval "$NM" conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist 2>&5 && test -s "$nlist"; then
# Try sorting and uniquifying the output.
if sort "$nlist" | uniq > "$nlist"T; then
mv -f "$nlist"T "$nlist"
@ -17209,7 +17213,7 @@ with_gnu_ld=$lt_cv_prog_gnu_ld
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"'
else
GXX=no
@ -17701,7 +17705,7 @@ fi
# explicitly linking system object files so we need to strip them
# from the output so that they don't get included in the library
# dependencies.
output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
;;
*)
if test yes = "$GXX"; then
@ -17766,7 +17770,7 @@ fi
# explicitly linking system object files so we need to strip them
# from the output so that they don't get included in the library
# dependencies.
output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
;;
*)
if test yes = "$GXX"; then
@ -18105,7 +18109,7 @@ fi
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"'
else
# FIXME: insert proper C++ library support
@ -18189,7 +18193,7 @@ fi
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"'
else
# g++ 2.7 appears to require '-G' NOT '-shared' on this
# platform.
@ -18200,7 +18204,7 @@ fi
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"'
fi
hardcode_libdir_flag_spec_CXX='$wl-R $wl$libdir'
@ -31246,7 +31250,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mfhdf_SDreaddata" >&5
$as_echo "$ac_cv_lib_mfhdf_SDreaddata" >&6; }
if test "x$ac_cv_lib_mfhdf_SDreaddata" = xyes; then :
HDF_LIB_NAME="-lmfhdfalt -ldfalt"
HDF_LIB_NAME="-lmfhdf -ldf"
else
HDF_LIB_NAME=missing
fi
@ -31306,7 +31310,7 @@ if ${ac_cv_lib_mfhdf_SDreaddata+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lmfhdfalt -ldfalt -ljpeg -lz $LIBS"
LIBS="-lmfhdf -ldf -ljpeg -lz $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@ -31337,7 +31341,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mfhdf_SDreaddata" >&5
$as_echo "$ac_cv_lib_mfhdf_SDreaddata" >&6; }
if test "x$ac_cv_lib_mfhdf_SDreaddata" = xyes; then :
HDF_LIB_NAME="-lmfhdfalt -ldfalt"
HDF_LIB_NAME="-lmfhdf -ldf"
else
HDF_LIB_NAME=missing
fi
@ -31352,7 +31356,7 @@ if ${ac_cv_lib_mfhdf_SDreaddata+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lmfhdfalt -ldfalt -lsz -ljpeg -lz $LIBS"
LIBS="-lmfhdf -ldf -lsz -ljpeg -lz $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@ -31383,7 +31387,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mfhdf_SDreaddata" >&5
$as_echo "$ac_cv_lib_mfhdf_SDreaddata" >&6; }
if test "x$ac_cv_lib_mfhdf_SDreaddata" = xyes; then :
HDF_LIB_NAME="-lmfhdfalt -ldfalt -lsz"
HDF_LIB_NAME="-lmfhdf -ldf -lsz"
else
HDF_LIB_NAME=missing
fi
@ -36447,21 +36451,22 @@ if test "${with_xml2+set}" = set; then :
fi
if test "`basename xx/$with_xml2`" = "xml2-config" ; then
LIBXML2_CONFIG="$with_xml2"
elif test "$with_xml2" = "no" ; then
LIBXML2_CONFIG=no
else
# Extract the first word of "xml2-config", so it can be a program name with args.
set dummy xml2-config; ac_word=$2
if test "x$with_xml2" = "xyes" -o "x$with_xml2" = "x" ; then
if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_LIBXML2_CONFIG+:} false; then :
if ${ac_cv_path_PKG_CONFIG+:} false; then :
$as_echo_n "(cached) " >&6
else
case $LIBXML2_CONFIG in
case $PKG_CONFIG in
[\\/]* | ?:[\\/]*)
ac_cv_path_LIBXML2_CONFIG="$LIBXML2_CONFIG" # Let the user override the test with a path.
ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@ -36471,7 +36476,7 @@ do
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_LIBXML2_CONFIG="$as_dir/$ac_word$ac_exec_ext"
ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
@ -36479,14 +36484,13 @@ done
done
IFS=$as_save_IFS
test -z "$ac_cv_path_LIBXML2_CONFIG" && ac_cv_path_LIBXML2_CONFIG="no"
;;
esac
fi
LIBXML2_CONFIG=$ac_cv_path_LIBXML2_CONFIG
if test -n "$LIBXML2_CONFIG"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBXML2_CONFIG" >&5
$as_echo "$LIBXML2_CONFIG" >&6; }
PKG_CONFIG=$ac_cv_path_PKG_CONFIG
if test -n "$PKG_CONFIG"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
$as_echo "$PKG_CONFIG" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
@ -36494,16 +36498,159 @@ fi
fi
if test -z "$ac_cv_path_PKG_CONFIG"; then
ac_pt_PKG_CONFIG=$PKG_CONFIG
# Extract the first word of "pkg-config", so it can be a program name with args.
set dummy pkg-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then :
$as_echo_n "(cached) " >&6
else
case $ac_pt_PKG_CONFIG in
[\\/]* | ?:[\\/]*)
ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
if test "$LIBXML2_CONFIG" != "no" ; then
;;
esac
fi
ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
if test -n "$ac_pt_PKG_CONFIG"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
$as_echo "$ac_pt_PKG_CONFIG" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test "x$ac_pt_PKG_CONFIG" = x; then
PKG_CONFIG=""
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
PKG_CONFIG=$ac_pt_PKG_CONFIG
fi
else
PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
fi
fi
if test -n "$PKG_CONFIG"; then
_pkg_min_version=0.21
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
PKG_CONFIG=""
fi
fi
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBXML2" >&5
$as_echo_n "checking for LIBXML2... " >&6; }
if test -n "$PKG_CONFIG"; then
if test -n "$LIBXML2_CFLAGS"; then
pkg_cv_LIBXML2_CFLAGS="$LIBXML2_CFLAGS"
else
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libxml-2.0\""; } >&5
($PKG_CONFIG --exists --print-errors "libxml-2.0") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_LIBXML2_CFLAGS=`$PKG_CONFIG --cflags "libxml-2.0" 2>/dev/null`
else
pkg_failed=yes
fi
fi
else
pkg_failed=untried
fi
if test -n "$PKG_CONFIG"; then
if test -n "$LIBXML2_LIBS"; then
pkg_cv_LIBXML2_LIBS="$LIBXML2_LIBS"
else
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libxml-2.0\""; } >&5
($PKG_CONFIG --exists --print-errors "libxml-2.0") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_LIBXML2_LIBS=`$PKG_CONFIG --libs "libxml-2.0" 2>/dev/null`
else
pkg_failed=yes
fi
fi
else
pkg_failed=untried
fi
if test $pkg_failed = yes; then
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
LIBXML2_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "libxml-2.0"`
else
LIBXML2_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "libxml-2.0"`
fi
# Put the nasty error message in config.log where it belongs
echo "$LIBXML2_PKG_ERRORS" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
HAVE_LIBXML2=no
elif test $pkg_failed = untried; then
HAVE_LIBXML2=no
else
LIBXML2_CFLAGS=$pkg_cv_LIBXML2_CFLAGS
LIBXML2_LIBS=$pkg_cv_LIBXML2_LIBS
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
HAVE_LIBXML2=yes
fi
if test "${HAVE_LIBXML2}" = "yes"; then
SAVED_LIBS="${LIBS}"
LIBS="${LIBXML2_LIBS}"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for xmlParseDoc in -lxml2" >&5
$as_echo_n "checking for xmlParseDoc in -lxml2... " >&6; }
if ${ac_cv_lib_xml2_xmlParseDoc+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lxml2 `$LIBXML2_CONFIG --libs` $LIBS"
LIBS="-lxml2 $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@ -36539,14 +36686,19 @@ else
HAVE_LIBXML2=no
fi
LIBS="${SAVED_LIBS}"
fi
fi
if test "$HAVE_LIBXML2" = "yes" ; then
LIBXML2_INC=`$LIBXML2_CONFIG --cflags`
LIBXML2_LIB=`$LIBXML2_CONFIG --libs`
if test "${HAVE_LIBXML2}" = "yes"; then
LIBXML2_INC="${LIBXML2_CFLAGS}"
LIBXML2_LIB="${LIBXML2_LIBS}"
else
if test "x$with_xml2" = "xyes"; then
as_fn_error $? "--with-xml2 was requested, but libxml2 is not available" "$LINENO" 5
fi
fi
elif test "x$with_xml2" != "xno"; then
as_fn_error $? "Only --with-xml2=yes/no supported" "$LINENO" 5
fi
HAVE_LIBXML2=$HAVE_LIBXML2
@ -37059,7 +37211,7 @@ if ${ac_cv_lib_spatialite_spatialite_target_cpu+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lspatialite -lsqlite3 $LIBS"
LIBS="-lspatialite $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@ -43465,7 +43617,6 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
cat <<_LT_EOF >> "$cfgfile"
#! $SHELL
# Generated automatically by $as_me ($PACKAGE) $VERSION
# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
# Provide generalized library-building support services.

View File

@ -4048,27 +4048,30 @@ LIBXML2_INC=
LIBXML2_LIB=
AC_ARG_WITH(xml2,
[ --with-xml2[=ARG] Include libxml2 (ARG=path to xml2-config.)],,,)
[ --with-xml2[=ARG] Include libxml2 (ARG=yes/no)],,,)
if test "`basename xx/$with_xml2`" = "xml2-config" ; then
LIBXML2_CONFIG="$with_xml2"
elif test "$with_xml2" = "no" ; then
LIBXML2_CONFIG=no
else
AC_PATH_PROG(LIBXML2_CONFIG, xml2-config, no)
fi
if test "x$with_xml2" = "xyes" -o "x$with_xml2" = "x" ; then
if test "$LIBXML2_CONFIG" != "no" ; then
PKG_PROG_PKG_CONFIG([0.21])
PKG_CHECK_MODULES(LIBXML2,[libxml-2.0], [HAVE_LIBXML2=yes], [HAVE_LIBXML2=no])
AC_CHECK_LIB(xml2,xmlParseDoc,HAVE_LIBXML2=yes,HAVE_LIBXML2=no,`$LIBXML2_CONFIG --libs`)
fi
if test "$HAVE_LIBXML2" = "yes" ; then
LIBXML2_INC=`$LIBXML2_CONFIG --cflags`
LIBXML2_LIB=`$LIBXML2_CONFIG --libs`
if test "${HAVE_LIBXML2}" = "yes"; then
SAVED_LIBS="${LIBS}"
LIBS="${LIBXML2_LIBS}"
AC_CHECK_LIB(xml2,xmlParseDoc,HAVE_LIBXML2=yes,HAVE_LIBXML2=no)
LIBS="${SAVED_LIBS}"
fi
if test "${HAVE_LIBXML2}" = "yes"; then
LIBXML2_INC="${LIBXML2_CFLAGS}"
LIBXML2_LIB="${LIBXML2_LIBS}"
else
if test "x$with_xml2" = "xyes"; then
AC_MSG_ERROR([--with-xml2 was requested, but libxml2 is not available])
fi
fi
elif test "x$with_xml2" != "xno"; then
AC_MSG_ERROR([Only --with-xml2=yes/no supported])
fi
AC_SUBST(HAVE_LIBXML2,$HAVE_LIBXML2)