Commit f3f86ff4 authored by Philip Withnall's avatar Philip Withnall Committed by Daniel Veillard

build: Use pkg-config to find liblzma in preference to AC_CHECK_LIB

This means that liblzma’s Libs.private will be included in LZMA_LIBS if
linking the libraries statically, ensuring that there are no undefined
symbol errors from liblzma’s private libraries.

If pkg-config isn’t installed, or if liblzma.pc couldn’t be found, fall
back to using AC_CHECK_LIB as before. This will cause static linking to
fail, but that’s not a regression.

This does not introduce a compile time dependency on pkg-config.

https://bugzilla.gnome.org/show_bug.cgi?id=711026
parent f859d9a7
......@@ -68,6 +68,7 @@ AC_PATH_PROG(PERL, perl, /usr/bin/perl)
AC_PATH_PROG(WGET, wget, /usr/bin/wget)
AC_PATH_PROG(XMLLINT, xmllint, /usr/bin/xmllint)
AC_PATH_PROG(XSLTPROC, xsltproc, /usr/bin/xsltproc)
PKG_PROG_PKG_CONFIG
LT_INIT
......@@ -414,16 +415,33 @@ WITH_LZMA=0
if test "$with_lzma" = "no"; then
echo "Disabling compression support"
else
AC_CHECK_HEADERS(lzma.h,
AC_CHECK_LIB(lzma, lzma_code,[
AC_DEFINE([HAVE_LIBLZMA], [1], [Have compression library])
WITH_LZMA=1
if test "x${LZMA_DIR}" != "x"; then
LZMA_CFLAGS="-I${LZMA_DIR}/include"
LZMA_LIBS="-L${LZMA_DIR}/lib -llzma"
else
LZMA_LIBS="-llzma"
fi]))
# Try pkg-config first so that static linking works.
# If this succeeeds, we ignore the WITH_LZMA directory.
PKG_CHECK_MODULES([LZMA],[liblzma],
[have_liblzma=yes],
[have_liblzma=no])
# If pkg-config failed, fall back to AC_CHECK_LIB. This
# will not pick up the necessary LIBS flags for liblzma's
# private dependencies, though, so static linking may fail.
if test "x$have_liblzma" = "xno"; then
AC_CHECK_HEADERS(lzma.h,
AC_CHECK_LIB(lzma, lzma_code,[
have_liblzma=yes
if test "x${LZMA_DIR}" != "x"; then
LZMA_CFLAGS="-I${LZMA_DIR}/include"
LZMA_LIBS="-L${LZMA_DIR}/lib -llzma"
else
LZMA_LIBS="-llzma"
fi],
[have_liblzma=no]))
fi
# Found the library via either method?
if test "x$have_liblzma" = "xyes"; then
AC_DEFINE([HAVE_LIBLZMA], [1], [Have compression library])
WITH_LZMA=1
fi
fi
AC_SUBST(LZMA_CFLAGS)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment