summaryrefslogtreecommitdiffstats
path: root/yac-fastlz.patch
blob: 5a5ec3a85e0828172898b8bf81b6629be6486f5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
From 2ee980d2718b91aa44422221ae8cf2526bafec73 Mon Sep 17 00:00:00 2001
From: Remi Collet <fedora@famillecollet.com>
Date: Sat, 6 Sep 2014 07:12:14 +0200
Subject: [PATCH] add --with-system-fastlz option

---
 config.m4 | 16 +++++++++++++++-
 yac.c     |  4 ++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/config.m4 b/config.m4
index 73750d2..a810957 100644
--- a/config.m4
+++ b/config.m4
@@ -4,6 +4,9 @@ dnl config.m4 for extension yac
 PHP_ARG_ENABLE(yac, whether to enable yac support,
     [  --enable-yac           Enable yac support])
 
+PHP_ARG_WITH(system-fastlz, wheter to use system FastLZ bibrary,
+    [  --with-system-fastlz   Use system FastLZ bibrary], no, no)
+
 dnl PHP_ARG_ENABLE(yac, whether to use msgpack as serializer,
 dnl    [  --enable-msgpack       Use Messagepack as serializer])
 
@@ -193,6 +196,17 @@ dnl    PHP_ADD_EXTENSION_DEP(yac, msgpack, true)
 dnl    ])
 dnl  fi
 
+  YAC_FILES="yac.c storage/yac_storage.c storage/allocator/yac_allocator.c storage/allocator/allocators/shm.c storage/allocator/allocators/mmap.c serializer/php.c serializer/msgpack.c"
+  if test "$PHP_SYSTEM_FASTLZ" != "no"; then
+    AC_CHECK_HEADERS([fastlz.h])
+    PHP_CHECK_LIBRARY(fastlz, fastlz_compress,
+        [PHP_ADD_LIBRARY(fastlz, 1, YAC_SHARED_LIBADD)],
+        [AC_MSG_ERROR(FastLZ library not found)])
+  else
+    YAC_FILES="${YAC_FILES} compressor/fastlz/fastlz.c"
+  fi
+
   if test "$PHP_YAC" != "no"; then
-  PHP_NEW_EXTENSION(yac, yac.c storage/yac_storage.c storage/allocator/yac_allocator.c storage/allocator/allocators/shm.c storage/allocator/allocators/mmap.c serializer/php.c serializer/msgpack.c compressor/fastlz/fastlz.c, $ext_shared)
+    PHP_SUBST(YAC_SHARED_LIBADD)
+    PHP_NEW_EXTENSION(yac, ${YAC_FILES}, $ext_shared)
 fi
diff --git a/yac.c b/yac.c
index 4362b26..20a0abb 100644
--- a/yac.c
+++ b/yac.c
@@ -33,7 +33,11 @@
 #include "php_yac.h"
 #include "storage/yac_storage.h"
 #include "serializer/yac_serializer.h"
+#ifdef HAVE_FASTLZ_H
+#include <fastlz.h>
+#else
 #include "compressor/fastlz/fastlz.h"
+#endif
 
 zend_class_entry *yac_class_ce;