mirror of
https://github.com/php/php-src.git
synced 2026-04-27 10:16:41 +02:00
add ability to detect zlib library when zlib ext is disabled
This commit is contained in:
+51
-39
@@ -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
|
||||
|
||||
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)
|
||||
|
||||
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_ZLIB_DIR=$PHAR_ZLIB_DIR
|
||||
PHP_ADD_LIBRARY(z,, PHAR_SHARED_LIBADD)
|
||||
PHP_ADD_INCLUDE($PHAR_ZLIB_INCDIR)
|
||||
])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -z "$ZLIB_DIR"; then
|
||||
AC_MSG_WARN(Cannot find libz)
|
||||
fi
|
||||
|
||||
if test "$ZLIB_DIR"; then
|
||||
case $ZLIB_DIR in
|
||||
/usr) ac_extra= ;;
|
||||
*) ac_extra=-L$ZLIB_DIR/$PHP_LIBDIR ;;
|
||||
esac
|
||||
|
||||
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_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
|
||||
+11
-1
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -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)) {
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@
|
||||
#ifndef PHP_PHAR_H
|
||||
#define PHP_PHAR_H
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
#ifdef HAVE_PHAR_ZLIB
|
||||
#include <zlib.h>
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user