summaryrefslogtreecommitdiffstats
path: root/165.patch
blob: 49f98daef9699878d87fb483a626c8617a8072f1 (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
From 8139123b63f5a7885466e5450aba502f77a9a592 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Mon, 16 Sep 2019 12:04:08 +0200
Subject: [PATCH 1/2] allow to build with system libxlsxio

---
 config.m4 | 61 ++++++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 47 insertions(+), 14 deletions(-)

diff --git a/config.m4 b/config.m4
index 2c5f9be..f3fb280 100644
--- a/config.m4
+++ b/config.m4
@@ -1,8 +1,11 @@
 PHP_ARG_WITH(xlswriter, xlswriter support,
-[  --with-xlswriter           Include xlswriter support], yes)
+[  --with-xlswriter         Include xlswriter support], yes)
 
-PHP_ARG_WITH(libxlsxwriter, system libxlsswriter,
-[  --with-libxlsxwriter=DIR Use system library], no, no)
+PHP_ARG_WITH(libxlsxwriter, system libxlsxwriter,
+[  --with-libxlsxwriter=DIR Use system libxlsxwriter], no, no)
+
+PHP_ARG_WITH(libxlsxio, system libxlsxio,
+[  --with-libxlsxio=DIR     Use system libxlsxio], no, no)
 
 PHP_ARG_ENABLE(reader, enable xlsx reader support,
 [  --enable-reader          Enable xlsx reader?], no, no)
@@ -135,22 +138,52 @@ if test "$PHP_XLSWRITER" != "no"; then
     fi
 
     if test "$PHP_READER" = "yes"; then
-        xls_writer_sources="$xls_writer_sources $xls_read_sources"
+        AC_MSG_CHECKING([Check libxlsxwriter library])
+        if test "$PHP_LIBXLSXIO" != "no"; then
+
+            for i in $PHP_LIBXLSXIO /usr/local /usr; do
+                if test -r $i/include/xlsxio_read.h; then
+                    XLSXIO_DIR=$i
+                    AC_MSG_RESULT([found in $i])
+                    break
+                fi
+            done
+
+            if test -z "$XLSXIO_DIR"; then
+                AC_MSG_ERROR([libxlsxio library not found])
+            else
+                PHP_ADD_INCLUDE($XLSXIO_DIR/include)
+                PHP_CHECK_LIBRARY(xlsxio_read, xlsxioread_sheet_open,
+                [
+                    PHP_ADD_LIBRARY_WITH_PATH(xlsxio_read, $i/$PHP_LIBDIR, XLSWRITER_SHARED_LIBADD)
+                ],[
+                    AC_MSG_ERROR([Wrong libxlsxio version or library not found])
+                ],[
+                    -L$XLSXWRITER_DIR/$PHP_LIBDIR -lm
+                ])
+            fi
 
-        AC_DEFINE(ENABLE_READER, 1, [enable reader])
+            AC_DEFINE(HAVE_LIBXLSXIO, 1, [ use system libxlsxwriter ])
+        else
+            AC_MSG_RESULT([use the bundled library])
 
-        xls_writer_sources="$xls_writer_sources $libexpat"
-        PHP_ADD_INCLUDE([$srcdir/library/libexpat/expat/lib])
-        PHP_ADD_BUILD_DIR([$abs_builddir/library/libexpat/expat/lib])
-        LIBOPT="$LIBOPT -DXML_POOR_ENTROPY"
+            xls_writer_sources="$xls_writer_sources $libexpat"
+            PHP_ADD_INCLUDE([$srcdir/library/libexpat/expat/lib])
+            PHP_ADD_BUILD_DIR([$abs_builddir/library/libexpat/expat/lib])
+            LIBOPT="$LIBOPT -DXML_POOR_ENTROPY"
 
-        xls_writer_sources="$xls_writer_sources $libxlsxio"
-        PHP_ADD_INCLUDE([$srcdir/library/libxlsxio/include])
-        PHP_ADD_BUILD_DIR([$abs_builddir/library/libxlsxio/lib])
-        LIBOPT="$LIBOPT -DUSE_MINIZIP"
+            xls_writer_sources="$xls_writer_sources $libxlsxio"
+            PHP_ADD_INCLUDE([$srcdir/library/libxlsxio/include])
+            PHP_ADD_BUILD_DIR([$abs_builddir/library/libxlsxio/lib])
+            LIBOPT="$LIBOPT -DUSE_MINIZIP"
+
+        fi
+
+        xls_writer_sources="$xls_writer_sources $xls_read_sources"
+        AC_DEFINE(ENABLE_READER, 1, [enable reader])
     fi
 
-    if test "$PHP_READER" = "yes" || test "$PHP_LIBXLSXWRITER" = "no"; then
+    if test "$PHP_LIBXLSXIO" = "no" || test "$PHP_LIBXLSXWRITER" = "no"; then
         xls_writer_sources="$xls_writer_sources $minizip_sources"
     fi
 

From feb5b1a4c963d06ee70ab3eb74401160ccc201e1 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Mon, 16 Sep 2019 12:04:21 +0200
Subject: [PATCH 2/2] report libxlsxio in phpinfo

---
 xlswriter.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/xlswriter.c b/xlswriter.c
index 8faa7f6..7b223c3 100644
--- a/xlswriter.c
+++ b/xlswriter.c
@@ -18,6 +18,11 @@
 #include "ext/standard/info.h"
 #include "xlswriter.h"
 
+#if ENABLE_READER
+#include <xlsxio_version.h>
+#include <xlsxio_read.h>
+#endif
+
 int le_xls_writer;
 
 /* {{{ PHP_MINIT_FUNCTION
@@ -85,6 +90,18 @@ PHP_MINFO_FUNCTION(xlswriter)
     php_info_print_table_row(2, "bundled libxlsxwriter version", LXW_VERSION);
 #endif
 #endif
+
+#if ENABLE_READER
+#if HAVE_LIBXLSXIO
+    /* Build time */
+    php_info_print_table_row(2, "libxlsxio headers version", XLSXIO_VERSION_STRING);
+    /* Run time */
+    php_info_print_table_row(2, "libxlsxio library version", xlsxioread_get_version_string());
+#else
+    php_info_print_table_row(2, "bundled libxlsxio version", XLSXIO_VERSION_STRING);
+#endif
+#endif
+
 	php_info_print_table_end();
 }
 /* }}} */