diff options
-rw-r--r-- | ext/phar/config.m4 | 84 | ||||
-rw-r--r-- | ext/phar/config.w32 | 12 | ||||
-rw-r--r-- | ext/phar/phar.c | 6 | ||||
-rw-r--r-- | ext/phar/php_phar.h | 2 |
4 files changed, 63 insertions, 41 deletions
diff --git a/ext/phar/config.m4 b/ext/phar/config.m4 index 8c765423a1..5ce6034b68 100644 --- a/ext/phar/config.m4 +++ b/ext/phar/config.m4 @@ -1,49 +1,61 @@ dnl $Id$ dnl config.m4 for extension phar -PHP_ARG_WITH(phar, enable phar support (only specify ZLIB_DIR for --with-zlib=no), -[ --with-phar[=ZLIB_DIR] Enable phar support]) +PHP_ARG_WITH(phar, for phar support/phar zlib support, +[ --with-phar[=ZLIB_DIR] Enable phar support, use ZLIB_DIR if zlib detection fails]) -if test "$PHP_PHAR" != "no"; then +if test "$PHP_ZLIB" != "no" -o "$PHP_ZLIB_DIR" != "no"; then + if test "$PHP_PHAR" != "no"; then + AC_MSG_RESULT(PHAR: using zlib ext) + PHP_NEW_EXTENSION(phar, phar.c, $ext_shared) + AC_DEFINE(HAVE_PHAR_ZLIB,1,[ ]) + fi +elif test "$PHP_PHAR" != "no"; then PHP_NEW_EXTENSION(phar, phar.c, $ext_shared) - - dnl use zlib extension data if specified, otherwise try to find our own zlib - if test "$PHP_ZLIB" = "no" -a "$PHP_ZLIB_DIR" = "no" - PHP_SUBST(PHAR_SHARED_LIBADD) - for i in /usr/local /usr $PHP_PHAR; do + PHP_SUBST(ZLIB_SHARED_LIBADD) + + if test "$PHP_PHAR" != "yes" -a "$PHP_PHAR" != "no"; then + if test -f $PHP_PHAR/include/zlib/zlib.h; then + ZLIB_DIR=$PHP_PHAR + ZLIB_INCDIR=$ZLIB_DIR/include/zlib + elif test -f $PHP_PHAR/include/zlib.h; then + ZLIB_DIR=$PHP_PHAR + ZLIB_INCDIR=$ZLIB_DIR/include + fi + else + for i in /usr/local /usr; do if test -f $i/include/zlib/zlib.h; then - PHAR_ZLIB_DIR=$i - PHAR_ZLIB_INCDIR=$i/include/zlib + ZLIB_DIR=$i + ZLIB_INCDIR=$i/include/zlib elif test -f $i/include/zlib.h; then - PHAR_ZLIB_DIR=$i - PHAR_ZLIB_INCDIR=$i/include + ZLIB_DIR=$i + ZLIB_INCDIR=$i/include fi done + fi + + if test -z "$ZLIB_DIR"; then + AC_MSG_WARN(Cannot find libz) + fi - if test -z "$PHAR_ZLIB_DIR"; then - AC_MSG_WARN(Cannot find libz, zlib support disabled for phar extension) - elif - PHP_CHECK_LIBRARY(z, gzgets, [ - AC_DEFINE(HAVE_PHAR_ZLIB,1,[ ]) - PHP_ADD_LIBPATH($PHAR_ZLIB_DIR/$PHAR_ZLIB_DIR, PHAR_SHARED_LIBADD) + if test "$ZLIB_DIR"; then + case $ZLIB_DIR in + /usr) ac_extra= ;; + *) ac_extra=-L$ZLIB_DIR/$PHP_LIBDIR ;; + esac - PHP_ZLIB_DIR=$PHAR_ZLIB_DIR - PHP_ADD_LIBRARY(z,, PHAR_SHARED_LIBADD) - PHP_ADD_INCLUDE($PHAR_ZLIB_INCDIR) - ],[ - AC_MSG_WARN(PHAR extension requires zlib >= 1.0.9, zlib support disabled for phar extension) - ],[ - case $PHAR_ZLIB_DIR in - /usr) ac_extra= ;; - *) ac_extra=-L$PHAR_ZLIB_DIR/$PHP_LIBDIR ;; - esac - $ac_extra - PHP_ADD_LIBPATH($PHAR_ZLIB_DIR/$PHP_LIBDIR, PHAR_SHARED_LIBADD) + PHP_CHECK_LIBRARY(z, gzgets, [ + AC_DEFINE(HAVE_PHAR_ZLIB,1,[ ]) + AC_MSG_RESULT(PHAR: using native zlib) + PHP_ADD_LIBPATH($ZLIB_DIR/$PHP_LIBDIR, ZLIB_SHARED_LIBADD) - PHP_ZLIB_DIR=$PHAR_ZLIB_DIR - PHP_ADD_LIBRARY(z,, PHAR_SHARED_LIBADD) - PHP_ADD_INCLUDE($PHAR_ZLIB_INCDIR) - ]) - fi + PHP_PHAR_DIR=$ZLIB_DIR + PHP_ADD_LIBRARY(z,, ZLIB_SHARED_LIBADD) + PHP_ADD_INCLUDE($ZLIB_INCDIR) + ],[ + AC_MSG_WARN(PHAR extension requires zlib >= 1.0.9) + ],[ + $ac_extra + ]) fi -fi +fi
\ No newline at end of file diff --git a/ext/phar/config.w32 b/ext/phar/config.w32 index 15281e419b..f6fa461c46 100644 --- a/ext/phar/config.w32 +++ b/ext/phar/config.w32 @@ -4,6 +4,16 @@ ARG_ENABLE("phar", "enable phar support", "no"); if (PHP_PHAR != "no") { - EXTENSION("phar", "phar.c"); + if (PHP_ZLIB != "no") { + EXTENSION("phar", "phar.c"); + } else { + EXTENSION("phar", "phar.c", null, "/D ZLIB_EXPORTS"); + AC_DEFINE("HAVE_PHAR_ZLIB", 1, "ZLIB support in phar"); + CHECK_LIB("zlib.lib", "zlib", PHP_ZLIB); + CHECK_HEADER_ADD_INCLUDE("zlib.h", "CFLAGS", "..\\zlib;" + php_usual_include_suspects); + if (!PHP_ZLIB_SHARED) { + ADD_DEF_FILE("ext\\zlib\\php_zlib.def"); + } + } } diff --git a/ext/phar/phar.c b/ext/phar/phar.c index 4b3eff29a8..337e718520 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -113,7 +113,7 @@ PHP_METHOD(PHP_Archive, mapPhar) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zsb|z", &unused1, &alias, &alias_len, &compressed, &unused2) == FAILURE) { return; } -#ifndef HAVE_ZLIB +#ifndef HAVE_PHAR_ZLIB if (compressed) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error: zlib extension is required for compressed .phar files"); } @@ -459,7 +459,7 @@ PHP_PHAR_API php_stream * php_stream_phar_url_wrapper(php_stream_wrapper *wrappe php_url *resource = NULL; FILE *fp; struct stat st; -#ifdef HAVE_ZLIB +#ifdef HAVE_PHAR_ZLIB /* borrowed from zlib.c gzinflate() function */ int status; unsigned long length; @@ -501,7 +501,7 @@ PHP_PHAR_API php_stream * php_stream_phar_url_wrapper(php_stream_wrapper *wrappe /* seek to start of internal file and read it */ fseek(fp, idata->data->internal_file_start + idata->internal_file->offset_within_phar, SEEK_SET); if (idata->data->is_compressed) { -#ifdef HAVE_ZLIB +#ifdef HAVE_PHAR_ZLIB buffer = (char *) emalloc(idata->internal_file->compressed_filesize); if (idata->internal_file->compressed_filesize != fread(buffer, 1, idata->internal_file->compressed_filesize, fp)) { diff --git a/ext/phar/php_phar.h b/ext/phar/php_phar.h index d5021dc54d..01969a3020 100644 --- a/ext/phar/php_phar.h +++ b/ext/phar/php_phar.h @@ -21,7 +21,7 @@ #ifndef PHP_PHAR_H #define PHP_PHAR_H -#ifdef HAVE_ZLIB +#ifdef HAVE_PHAR_ZLIB #include <zlib.h> #endif |