summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStewart Brodie <stewart@eh.org>2016-05-09 10:13:12 +0800
committerDaniel Veillard <veillard@redhat.com>2016-05-09 10:13:12 +0800
commit45f0abd4278776e1c12df38672b8d20a3cc471a8 (patch)
tree4847fae8f7b4f562dd52b4a3d82bec9649a89409
parent3d75c2e82806955542a41ff62a5be25e04287d89 (diff)
downloadlibxml2-45f0abd4278776e1c12df38672b8d20a3cc471a8.tar.gz
Use pkg-config to locate zlib when possible
For https://bugzilla.gnome.org/show_bug.cgi?id=765979 This fallback to direct detection if not available, but current situation this is broken for cross compilation
-rw-r--r--configure.ac53
1 files changed, 35 insertions, 18 deletions
diff --git a/configure.ac b/configure.ac
index 579d77b1..267f8afd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -391,24 +391,41 @@ WITH_ZLIB=0
if test "$with_zlib" = "no"; then
echo "Disabling compression support"
else
- AC_CHECK_HEADERS(zlib.h,
- [SAVE_LDFLAGS="${LDFLAGS}"
- LDFLAGS="-L${Z_DIR}/lib"
- AC_CHECK_LIB(z, gzread,[
- AC_DEFINE([HAVE_LIBZ], [1], [Have compression library])
- WITH_ZLIB=1
- if test "x${Z_DIR}" != "x"; then
- Z_CFLAGS="-I${Z_DIR}/include"
- Z_LIBS="-L${Z_DIR}/lib -lz"
- [case ${host} in
- *-*-solaris*)
- Z_LIBS="-L${Z_DIR}/lib -R${Z_DIR}/lib -lz"
- ;;
- esac]
- else
- Z_LIBS="-lz"
- fi])
- LDFLAGS="${SAVE_LDFLAGS}"])
+ # Try pkg-config first so that static linking works.
+ # If this succeeeds, we ignore the WITH_ZLIB directory.
+ PKG_CHECK_MODULES([Z],[zlib],
+ [have_libz=yes],
+ [have_libz=no])
+
+ if test "x$have_libz" = "xno"; then
+ AC_CHECK_HEADERS(zlib.h,
+ [SAVE_LDFLAGS="${LDFLAGS}"
+ LDFLAGS="-L${Z_DIR}/lib"
+ AC_CHECK_LIB(z, gzread,[
+ have_libz=yes
+ if test "x${Z_DIR}" != "x"; then
+ Z_CFLAGS="-I${Z_DIR}/include"
+ Z_LIBS="-L${Z_DIR}/lib -lz"
+ [case ${host} in
+ *-*-solaris*)
+ Z_LIBS="-L${Z_DIR}/lib -R${Z_DIR}/lib -lz"
+ ;;
+ esac]
+ else
+ Z_LIBS="-lz"
+ fi],
+ [have_libz=no])
+ LDFLAGS="${SAVE_LDFLAGS}"])
+ else
+ # we still need to check for zlib.h header
+ AC_CHECK_HEADERS([zlib.h])
+ fi
+
+ # Found the library via either method?
+ if test "x$have_libz" = "xyes"; then
+ AC_DEFINE([HAVE_LIBZ], [1], [Have compression library])
+ WITH_ZLIB=1
+ fi
fi
AC_SUBST(Z_CFLAGS)