[PATCH V3] configure.ac: Fallback to older detection code if pkg-config can't find expat

Peter Hutterer peter.hutterer at who-t.net
Tue Feb 3 13:50:10 PST 2015


On Tue, Feb 03, 2015 at 12:33:35PM -0800, Bill Spitzak wrote:
> This paritally reverts commit a4afd90f9f0c27ed5f3f313b915c260673f8be34.
> 
> On older expat versions (ie the one on Ubuntu 12.04) there is no pkg-config
> file, so fall back to a test for the header and library.

hmm, this is the first time I read this paragraph: 12.04 is almost 2 years
old now, are there any more recent examples that need this patch? If not,
I'd recommend going with "install newer expat in your prefix" than
adding build system workarounds.

> The restored test has been updated to use AC_SEARCH_LIBS.
> ---
>  configure.ac |    9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 0426b53..402de84 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -85,7 +85,14 @@ AC_ARG_WITH(icondir, [  --with-icondir=<dir>    Look for cursor icons here],
>  AC_SUBST([ICONDIR])
>  
>  if test "x$enable_scanner" = "xyes"; then
> -	PKG_CHECK_MODULES(EXPAT, [expat])
> +	PKG_CHECK_MODULES(EXPAT, [expat],,
> +		[AC_CHECK_HEADERS(expat.h,,
> +			[AC_MSG_ERROR([Can't find expat.h. Please install expat.])])
> +		SAVE_LIBS="$LIBS"
> +		AC_SEARCH_LIBS(XML_ParserCreate, expat, [EXPAT_LIBS="$LIBS"],
> +			[AC_MSG_ERROR([Can't find expat library. Please install expat.])])
> +		LIBS="$SAVE_LIBS"
> +		])
>  fi
>  
>  AC_PATH_PROG(XSLTPROC, xsltproc)

that looks correct, but the ,, almost caught me and the nesting is a bit
hard to read. How about:

PKG_CHECK_MODULES(EXPAT, [expat], HAVE_EXPAT="yes", HAVE_EXPAT="no")
if test x$HAVE_EXPAT = "xno"; then
        AC_CHECK_HEADERS
        ...
        AC_SEARCH_LIBS
        ...
        AC_SUBST # I think you should have it explicitly here
fi

Cheers,
   Peter


More information about the wayland-devel mailing list