Browse Source

allow to build using system shared library

Remi Collet 6 years ago
parent
commit
7a902667ab

+ 44 - 11
config.m4

@@ -1,15 +1,25 @@
 PHP_ARG_WITH(xlsxwriter, xlswriter support,
-[  --with-xlswriter           Include xlswriter support])
+[  --with-xlswriter           Include xlswriter support], yes)
+
+PHP_ARG_WITH(libxlsxwriter, system libxlsswriter,
+[  --with-libxlsxwriter=DIR Use system library], no, no)
 
 if test "$PHP_XLSWRITER" != "no"; then
     xls_writer_sources="
+    xls_writer.c \
+    kernel/exception.c \
+    kernel/resource.c \
+    kernel/common.c \
+    kernel/excel.c \
+    kernel/write.c \
+    kernel/format.c \
+    "
+    libxlsxwriter_sources="
     library/third_party/minizip/ioapi.c \
     library/third_party/minizip/mztools.c \
     library/third_party/minizip/unzip.c \
     library/third_party/minizip/zip.c \
-
     library/third_party/tmpfileplus/tmpfileplus.c \
-
     library/src/app.c \
     library/src/chart.c \
     library/src/content_types.c \
@@ -27,20 +37,43 @@ if test "$PHP_XLSWRITER" != "no"; then
     library/src/workbook.c \
     library/src/worksheet.c \
     library/src/xmlwriter.c \
+    "
 
-    xls_writer.c \
-    kernel/exception.c \
-    kernel/resource.c \
-    kernel/common.c \
-    kernel/excel.c \
-    kernel/write.c \
-    kernel/format.c"
+    AC_MSG_CHECKING([Check libxlsxwriter library])
+    if test "$PHP_LIBXLSXWRITER" != "no"; then
+
+        for i in $PHP_LIBXLSXWRITER /usr/local /usr; do
+            if test -r $i/include/xlsxwriter.h; then
+                XLSXWRITER_DIR=$i
+                AC_MSG_RESULT([found in $i])
+                break
+            fi
+        done
+        if test -z "$XLSXWRITER_DIR"; then
+            AC_MSG_ERROR([libxlsxwriter library not found])
+        else
+            PHP_ADD_INCLUDE($XLSXWRITER_DIR/include)
+            PHP_CHECK_LIBRARY(xlsxwriter, worksheet_write_string,
+            [
+                PHP_ADD_LIBRARY_WITH_PATH(xlsxwriter, $i/$PHP_LIBDIR, XLSWRITER_SHARED_LIBADD)
+            ],[
+                AC_MSG_ERROR([Wrong libxlsxwriter version or library not found])
+            ],[
+                -L$XLSXWRITER_DIR/$PHP_LIBDIR -lm
+            ])
+        fi
+        AC_DEFINE(HAVE_LIBXLSXWRITER,1,[ ])
+    else
+        AC_MSG_RESULT([use the bundled library])
+        xls_writer_sources="$xls_writer_sources $libxlsxwriter_sources"
+        PHP_ADD_INCLUDE([$srcdir/library/include])
+    fi
 
     if test -z "$PHP_DEBUG"; then
         AC_ARG_ENABLE(debug, [--enable-debug compile with debugging system], [PHP_DEBUG=$enableval],[PHP_DEBUG=no])
     fi
 
-    PHP_ADD_INCLUDE($XLSWRITER_DIR/include)
+    PHP_SUBST(XLSWRITER_SHARED_LIBADD)
 
     PHP_NEW_EXTENSION(xlswriter, $xls_writer_sources, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
 

+ 0 - 0
include/crypt.h → library/include/crypt.h


+ 0 - 0
include/ioapi.h → library/include/ioapi.h


+ 0 - 0
include/iowin32.h → library/include/iowin32.h


+ 0 - 0
include/mztools.h → library/include/mztools.h


+ 0 - 0
include/tmpfileplus.h → library/include/tmpfileplus.h


+ 0 - 0
include/unzip.h → library/include/unzip.h


+ 0 - 0
include/xlsxwriter.h → library/include/xlsxwriter.h


+ 0 - 0
include/xlsxwriter/app.h → library/include/xlsxwriter/app.h


+ 0 - 0
include/xlsxwriter/chart.h → library/include/xlsxwriter/chart.h


+ 0 - 0
include/xlsxwriter/common.h → library/include/xlsxwriter/common.h


+ 0 - 0
include/xlsxwriter/content_types.h → library/include/xlsxwriter/content_types.h


+ 0 - 0
include/xlsxwriter/core.h → library/include/xlsxwriter/core.h


+ 0 - 0
include/xlsxwriter/custom.h → library/include/xlsxwriter/custom.h


+ 0 - 0
include/xlsxwriter/drawing.h → library/include/xlsxwriter/drawing.h


+ 0 - 0
include/xlsxwriter/format.h → library/include/xlsxwriter/format.h


+ 0 - 0
include/xlsxwriter/hash_table.h → library/include/xlsxwriter/hash_table.h


+ 0 - 0
include/xlsxwriter/packager.h → library/include/xlsxwriter/packager.h


+ 0 - 0
include/xlsxwriter/relationships.h → library/include/xlsxwriter/relationships.h


+ 0 - 0
include/xlsxwriter/shared_strings.h → library/include/xlsxwriter/shared_strings.h


+ 0 - 0
include/xlsxwriter/styles.h → library/include/xlsxwriter/styles.h


+ 0 - 0
include/xlsxwriter/theme.h → library/include/xlsxwriter/theme.h


+ 0 - 0
include/xlsxwriter/third_party/ioapi.h → library/include/xlsxwriter/third_party/ioapi.h


+ 0 - 0
include/xlsxwriter/third_party/queue.h → library/include/xlsxwriter/third_party/queue.h


+ 0 - 0
include/xlsxwriter/third_party/tmpfileplus.h → library/include/xlsxwriter/third_party/tmpfileplus.h


+ 0 - 0
include/xlsxwriter/third_party/tree.h → library/include/xlsxwriter/third_party/tree.h


+ 0 - 0
include/xlsxwriter/third_party/zip.h → library/include/xlsxwriter/third_party/zip.h


+ 0 - 0
include/xlsxwriter/utility.h → library/include/xlsxwriter/utility.h


+ 0 - 0
include/xlsxwriter/workbook.h → library/include/xlsxwriter/workbook.h


+ 0 - 0
include/xlsxwriter/worksheet.h → library/include/xlsxwriter/worksheet.h


+ 0 - 0
include/xlsxwriter/xmlwriter.h → library/include/xlsxwriter/xmlwriter.h


+ 0 - 0
include/zip.h → library/include/zip.h


+ 7 - 0
xls_writer.c

@@ -71,6 +71,13 @@ PHP_MINFO_FUNCTION(xlswriter)
 	php_info_print_table_header(2, "xlswriter support", "enabled");
 #if defined(PHP_XLSWRITER_VERSION)
     php_info_print_table_row(2, "Version", PHP_XLSWRITER_VERSION);
+#endif
+#ifdef LXW_VERSION
+#ifdef HAVE_LIBXLSXWRITER
+    php_info_print_table_row(2, "system libxlsxwriter version", LXW_VERSION);
+#else
+    php_info_print_table_row(2, "bundled libxlsxwriter version", LXW_VERSION);
+#endif
 #endif
 	php_info_print_table_end();
 }