Re: find libxml2 using pkg-config

From: Noah Misch <noah(at)leadboat(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: find libxml2 using pkg-config
Date: 2013-03-01 19:25:52
Message-ID: 20130301192552.GA18584@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jan 14, 2013 at 06:51:05AM -0500, Peter Eisentraut wrote:
> 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.

"./configure XML2_CONFIG=/my/preferred/xml2-config" achieves this today.

> 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.

pthread-config is now quite deep into legacy territory; no concern there.

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

There's a risk to making anything configurable in two places, with one taking
precedence. Some user unaware of $PLACE_1 will scratch his head after
changing $PLACE_2 to no effect. For example, I've been using an override
libxml2 by changing my PATH. With this patch, I will need to also change
PKG_CONFIG_PATH; otherwise, my system libxml2 will quietly take precedence. I
can adapt easily enough, but I wonder whether the patch will be a net win
generally for folks building PostgreSQL.

I'd like this change more if it could be construed as starting us on the road
to use pkg-config, or any one particular configuration discovery method, for
all dependencies. But many dependencies don't ship .pc files at all (perl,
ldap, tcl, pam). Others ship a .pc, but we use neither it nor a -config
script (openssl, gssapi, xslt). I see this patch as adding one more thing for
builders to comprehend without making things notably easier for complex
situations. Adopting this patch wouldn't appal me, but I would rather not.

> + AC_CHECK_PROGS(PKG_CONFIG, pkg-config)

This deserves an AC_ARG_VAR(PKG_CONFIG) somewhere. On the other hand,
AC_ARG_VAR(XML2_CONFIG) is already missing, so perhaps cleaning all that is a
separate change.

> + if test -n "$PKG_CONFIG" && $PKG_CONFIG --exists libxml-2.0; then
> + CPPFLAGS="$CPPFLAGS "`$PKG_CONFIG libxml-2.0 --cflags-only-I`

Under pkg-config, we'll get -I options only, but ...

> + for pgac_option in `$XML2_CONFIG --cflags`; do
> + case $pgac_option in
> + -I*|-D*) CPPFLAGS="$CPPFLAGS $pgac_option";;

... we'll convey both -I and -D options from xml2-config.

--
Noah Misch
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2013-03-01 19:42:24 Re: Support for REINDEX CONCURRENTLY
Previous Message Pavel Stehule 2013-03-01 19:22:04 Re: Re: proposal: a width specification for s specifier (format function), fix behave when positional and ordered placeholders are used