summaryrefslogtreecommitdiffstats
path: root/couchbase-fastlz.patch
blob: e40f2e25e3429e362e763a43e35627317bb834c8 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
From 8e3c76129ff52964d6043076ed2e1c443ceb262c Mon Sep 17 00:00:00 2001
From: Remi Collet <fedora@famillecollet.com>
Date: Sat, 6 Sep 2014 08:45:03 +0200
Subject: [PATCH] add --with-system-fastlz option

---
 config.m4  | 27 +++++++++++++++++++++------
 internal.h |  4 ++++
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/config.m4 b/config.m4
index fc730d6..b3661f5 100644
--- a/config.m4
+++ b/config.m4
@@ -1,6 +1,9 @@
 PHP_ARG_WITH([couchbase], [for Couchbase support],
              [  --with-couchbase          Include Couchbase support])
 
+PHP_ARG_WITH(system-fastlz, wheter to use system FastLZ bibrary,
+             [  --with-system-fastlz      Use system FastLZ bibrary], no, no)
+
 if test "$PHP_COUCHBASE" != "no"; then
   dnl PCBC-180 Add support for igbinary.
   dnl The PHP include directories is not searched by default, so
@@ -25,9 +28,7 @@ if test "$PHP_COUCHBASE" != "no"; then
           PHP_ADD_EXTENSION_DEP(couchbase, igbinary)
           ])
 
-  PHP_SUBST(COUCHBASE_SHARED_LIBADD)
-  PHP_NEW_EXTENSION([couchbase],
-                    [ \
+  COUCHBASE_FILES="\
                      apidecl.c \
                      arithmetic.c \
                      ccache.c \
@@ -38,7 +39,6 @@ if test "$PHP_COUCHBASE" != "no"; then
                      designdoc.c \
                      error.c \
                      exceptions.c \
-                     fastlz/fastlz.c \
                      flush.c \
                      get.c \
                      ht.c \
@@ -60,7 +60,22 @@ if test "$PHP_COUCHBASE" != "no"; then
                      version.c \
                      viewopts.c \
                      views.c \
-                    ], [$ext_shared])
+                     "
+  if test "$PHP_SYSTEM_FASTLZ" != "no"; then
+    AC_CHECK_HEADERS([fastlz.h], [have_fastlz="yes"], [have_fastlz="no"])
+    PHP_CHECK_LIBRARY(fastlz, fastlz_compress,
+        [PHP_ADD_LIBRARY(fastlz, 1, COUCHBASE_SHARED_LIBADD)],
+        [AC_MSG_ERROR(FastLZ library not found)])
+  else
+    have_fastlz="no"
+    COUCHBASE_FILES="${COUCHBASE_FILES} fastlz/fastlz.c"
+  fi
+  PHP_SUBST(COUCHBASE_SHARED_LIBADD)
+
+  PHP_NEW_EXTENSION([couchbase],
+                    [ $COUCHBASE_FILES ], [$ext_shared])
+  if test "have_fastlz" != "yes"; then
     PHP_ADD_BUILD_DIR($ext_builddir/fastlz, 1)
-    PHP_ADD_BUILD_DIR($ext_builddir/management, 1)
+  fi
+  PHP_ADD_BUILD_DIR($ext_builddir/management, 1)
 fi
diff --git a/internal.h b/internal.h
index 8939d9c..56cab92 100644
--- a/internal.h
+++ b/internal.h
@@ -56,7 +56,11 @@
 #include "ext/standard/php_var.h"
 #include <libcouchbase/couchbase.h>
 #include "php_couchbase.h"
+#ifdef HAVE_FASTLZ_H
+#include <fastlz.h>
+#else
 #include "fastlz/fastlz.h"
+#endif
 
 #ifdef PHP_WIN32
 #ifndef PRIu64