On Mon, 2013-01-14 at 10:25 -0500, Tom Lane wrote:
> Peter Eisentraut <pete...@gmx.net> writes:
> > The attached patch looks for pkg-config first, and finds libxml2 using
> > that if available.  Otherwise it falls back to using xml2-config.
> 
> What happens if pkg-config is installed but doesn't know anything about
> xml2?  I'd expect the code to fall back to the old method, but this
> patch doesn't appear to have any sanity check whatsoever on pkg-config's
> output.

Updated patch to that effect

diff --git a/configure.in b/configure.in
index f31f7ef..81ac837 100644
--- a/configure.in
+++ b/configure.in
@@ -706,18 +706,24 @@ PGAC_ARG_BOOL(with, libxml, no, [build with XML support],
               [AC_DEFINE([USE_LIBXML], 1, [Define to 1 to build with XML support. (--with-libxml)])])
 
 if test "$with_libxml" = yes ; then
-  AC_CHECK_PROGS(XML2_CONFIG, xml2-config)
-  if test -n "$XML2_CONFIG"; then
-    for pgac_option in `$XML2_CONFIG --cflags`; do
-      case $pgac_option in
-        -I*|-D*) CPPFLAGS="$CPPFLAGS $pgac_option";;
-      esac
-    done
-    for pgac_option in `$XML2_CONFIG --libs`; do
-      case $pgac_option in
-        -L*) LDFLAGS="$LDFLAGS $pgac_option";;
-      esac
-    done
+  AC_CHECK_PROGS(PKG_CONFIG, pkg-config)
+  if test -n "$PKG_CONFIG" && $PKG_CONFIG --exists libxml-2.0; then
+    CPPFLAGS="$CPPFLAGS "`$PKG_CONFIG libxml-2.0 --cflags-only-I`
+    LDFLAGS="$LDFLAGS "`$PKG_CONFIG libxml-2.0 --libs-only-L`
+  else
+    AC_CHECK_PROGS(XML2_CONFIG, xml2-config)
+    if test -n "$XML2_CONFIG"; then
+      for pgac_option in `$XML2_CONFIG --cflags`; do
+        case $pgac_option in
+          -I*|-D*) CPPFLAGS="$CPPFLAGS $pgac_option";;
+        esac
+      done
+      for pgac_option in `$XML2_CONFIG --libs`; do
+        case $pgac_option in
+          -L*) LDFLAGS="$LDFLAGS $pgac_option";;
+        esac
+      done
+    fi
   fi
 fi
 
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index 22e6cf1..09c1d09 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -892,11 +892,18 @@ <title>Configuration</title>
         </para>
 
         <para>
-         Libxml installs a program <command>xml2-config</command> that
-         can be used to detect the required compiler and linker
-         options.  PostgreSQL will use it automatically if found.  To
-         specify a libxml installation at an unusual location, you can
-         either set the environment variable
+         To detect the required compiler and linker options, PostgreSQL will
+         query <command>pkg-config</command>, if it is installed and knows
+         about libxml2.  Otherwise the program <command>xml2-config</command>,
+         which is installed by libxml, will be used if it is found.  Use
+         of <command>pkg-config</command> is preferred, because it can deal
+         with multi-arch installations better.
+        </para>
+
+        <para>
+         To specify a libxml installation at an unusual location, you can
+         either set <command>pkg-config</command>-related environment variables
+         (see its documentation), or set the environment variable
          <envar>XML2_CONFIG</envar> to point to the
          <command>xml2-config</command> program belonging to the
          installation, or use the options
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to