Re: horde_lz4 with system liblz4

Remi Collet <[email protected]>
Newsgroups gmane.comp.horde.devel
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Patch refresh, when liblz4.pc not available
(it seems r119 don't provide it)


Remi.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlQXD2YACgkQYUppBSnxahh6sQCgpb8ZYHmkLCxPv2k5IhOvJBFs
RMYAn1Y5IABDfVfl9WUx4WlmHXuZdBKR
=sNHe
-----END PGP SIGNATURE-----

-- 
dev mailing list
Frequently Asked Questions: http://wiki.horde.org/FAQ
To unsubscribe, mail: [email protected]
horde-lz4-systemlib.patch (text/x-patch, 1.9 KB)
diff -up ./config.m4.old ./config.m4
--- ./config.m4.old	2014-09-15 17:01:16.231167165 +0200
+++ ./config.m4	2014-09-15 18:09:13.730717415 +0200
@@ -24,9 +24,38 @@ fi
 PHP_ARG_ENABLE(horde_lz4, whether to enable horde_lz4 support,
 [  --enable-horde_lz4           Enable horde_lz4 support])
 
+PHP_ARG_WITH(liblz4, whether to use system liblz4,
+[  --with-liblz4                Use system liblz4], no, no)
+
 if test "$PHP_HORDE_LZ4" != "no"; then
 
-  PHP_NEW_EXTENSION(horde_lz4, horde_lz4.c lz4.c lz4hc.c, $ext_shared)
+  sources=horde_lz4.c
+
+  if test "$PHP_LIBLZ4" != "no"; then
+    AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
+    AC_MSG_CHECKING(liblz4 version)
+    if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists liblz4; then
+      LIBLZ4_INCLUDE=`$PKG_CONFIG liblz4 --cflags`
+      LIBLZ4_LIBRARY=`$PKG_CONFIG liblz4 --libs`
+      LIBLZ4_VERSION=`$PKG_CONFIG liblz4 --modversion`
+    fi
+
+    if test -z "$LIBLZ4_VERSION"; then
+      AC_MSG_RESULT(liblz4.pc not found)
+      AC_CHECK_HEADERS([lz4.h])
+      PHP_CHECK_LIBRARY(lz4, LZ4_decompress_fast,
+        [PHP_ADD_LIBRARY(lz4, 1, HORDE_LZ4_SHARED_LIBADD)],
+        [AC_MSG_ERROR(lz4 library not found)])
+    else
+      AC_MSG_RESULT($LIBLZ4_VERSION)
+      PHP_EVAL_INCLINE($LIBLZ4_INCLUDE)
+      PHP_EVAL_LIBLINE($LIBLZ4_LIBRARY, HORDE_LZ4_SHARED_LIBADD)
+    fi
+  else
+    sources="$sources lz4.c lz4hc.c"
+  fi
+  PHP_NEW_EXTENSION(horde_lz4, $sources, $ext_shared)
+  PHP_SUBST(HORDE_LZ4_SHARED_LIBADD)
 
   ifdef([PHP_INSTALL_HEADERS],
   [
diff -up ./horde_lz4.c.old ./horde_lz4.c
--- ./horde_lz4.c.old	2014-09-15 17:24:33.521673922 +0200
+++ ./horde_lz4.c	2014-09-15 17:25:24.225908322 +0200
@@ -150,7 +150,7 @@ PHP_FUNCTION(horde_lz4_uncompress)
         RETURN_FALSE;
     }
 
-    output_len = LZ4_uncompress(p + header_offset, output, data_len);
+    output_len = LZ4_decompress_fast(p + header_offset, output, data_len);
 
     if (output_len <= 0) {
         RETVAL_FALSE;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.