In multi-arch OS installations, using a single foo-config script to find
libraries is problematic, because you don't know which architecture it
will point to, and you can't choose which one you want.  Using
pkg-config is better in that situation, because you can use its
environment variables to point to your preferred version
of /usr/lib*/pkgconfig or similar.

In configure, we use xml2-config and pthread-config.  The latter doesn't
exist on my system, so I'm just dealing with xml2-config now.

The attached patch looks for pkg-config first, and finds libxml2 using
that if available.  Otherwise it falls back to using xml2-config.

diff --git a/configure.in b/configure.in
index 2dee4b3..9f8b0f9 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"; 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 6e43bcb..ef32bca 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.  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