Skip to content

Commit

Permalink
Merge pull request #4 from remicollet/issue-syslib
Browse files Browse the repository at this point in the history
add support for build with sytem library
  • Loading branch information
kjdev committed Sep 6, 2016
2 parents 9b0357f + 0416fc8 commit 847abc2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
41 changes: 34 additions & 7 deletions config.m4
Expand Up @@ -25,10 +25,40 @@ PHP_ARG_ENABLE(snappy, whether to enable snappy support,
[ --enable-snappy Enable snappy support])

PHP_ARG_WITH(snappy-includedir, for snappy header,
[ --with-snappy-includedir=DIR snappy header files], yes)
[ --with-snappy-includedir=DIR snappy header files], no, no)

if test "$PHP_SNAPPY" != "no"; then

AC_MSG_CHECKING([searching for libsnappy])

if test "$PHP_SNAPPY_INCLUDEDIR" != "no"; then
for i in $PHP_SNAPPY_INCLUDEDIR /usr/local /usr; do
if test -r $i/include/snappy-c.h; then
LIBSNAPPY_CFLAGS="-I$i/include"
LIBSNAPPY_LIBDIR="$i/$PHP_LIBDIR"
AC_MSG_RESULT(found in $i)
break
fi
done
if test -z "$LIBSNAPPY_LIBDIR"; then
AC_MSG_RESULT(not found)
AC_MSG_ERROR(Please reinstall the snappy library distribution)
fi
PHP_CHECK_LIBRARY(snappy, snappy_compress,
[
PHP_ADD_LIBRARY_WITH_PATH(snappy, $LIBSNAPPY_LIBDIR, SNAPPY_SHARED_LIBADD)
AC_DEFINE(HAVE_LIBSNAPPY,1,[ ])
], [
AC_MSG_ERROR(could not find usable libsnappy)
], [
-L$LIBSNAPPY_LIBDIR
])

PHP_SUBST(SNAPPY_SHARED_LIBADD)
PHP_NEW_EXTENSION(snappy, snappy.c, $ext_shared,, $LIBSNAPPY_CFLAGS)
else
AC_MSG_RESULT(use bundled version)

dnl compiler C++:
PHP_REQUIRE_CXX()

Expand Down Expand Up @@ -121,10 +151,7 @@ if test "$PHP_SNAPPY" != "no"; then

PHP_NEW_EXTENSION(snappy, snappy.c $SNAPPY_SOURCES, $ext_shared)

ifdef([PHP_INSTALL_HEADERS],
[
PHP_INSTALL_HEADERS([ext/snappy/], [php_snappy.h])
], [
PHP_ADD_MAKEFILE_FRAGMENT
])
PHP_ADD_BUILD_DIR($ext_builddir/snappy, 1)
PHP_ADD_INCLUDE([$ext_srcdir/snappy])
fi
fi
6 changes: 5 additions & 1 deletion snappy.c
Expand Up @@ -9,7 +9,7 @@
#include "php_snappy.h"

/* snappy */
#include "snappy/snappy-c.h"
#include <snappy-c.h>

static ZEND_FUNCTION(snappy_compress);
static ZEND_FUNCTION(snappy_uncompress);
Expand All @@ -33,7 +33,11 @@ PHP_MINFO_FUNCTION(snappy)
php_info_print_table_start();
php_info_print_table_row(2, "Snappy support", "enabled");
php_info_print_table_row(2, "Extension Version", SNAPPY_EXT_VERSION);
#ifdef HAVE_LIBSNAPPY
php_info_print_table_row(2, "Snappy Version", "system library");
#else
php_info_print_table_row(2, "Snappy Version", SNAPPY_LIB_VERSION);
#endif
php_info_print_table_end();
}

Expand Down
2 changes: 1 addition & 1 deletion tests/info.phpt
Expand Up @@ -14,5 +14,5 @@ snappy

Snappy support => enabled
Extension Version => %d.%d.%d
Snappy Version => %d.%d.%d
Snappy Version => %s
%a

0 comments on commit 847abc2

Please sign in to comment.