1dnl 2dnl $Id$ 3dnl 4 5PHP_ARG_ENABLE(zip, for zip archive read/writesupport, 6[ --enable-zip Include Zip read/write support]) 7 8if test -z "$PHP_ZLIB_DIR"; then 9 PHP_ARG_WITH(zlib-dir, for the location of libz, 10 [ --with-zlib-dir[=DIR] ZIP: Set the path to libz install prefix], no, no) 11fi 12 13PHP_ARG_WITH(pcre-dir, pcre install prefix, 14[ --with-pcre-dir ZIP: pcre install prefix], no, no) 15 16PHP_ARG_WITH(libzip, libzip, 17[ --with-libzip[=DIR] ZIP: use libzip], no, no) 18 19if test "$PHP_ZIP" != "no"; then 20 21 dnl libzip, depends on zlib 22 if test "$PHP_ZLIB_DIR" != "no" && test "$PHP_ZLIB_DIR" != "yes"; then 23 if test -f "$PHP_ZLIB_DIR/include/zlib/zlib.h"; then 24 PHP_ZLIB_DIR="$PHP_ZLIB_DIR" 25 PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include/zlib" 26 elif test -f "$PHP_ZLIB_DIR/include/zlib.h"; then 27 PHP_ZLIB_DIR="$PHP_ZLIB_DIR" 28 PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include" 29 else 30 AC_MSG_ERROR([Can not find zlib headers under "$PHP_ZLIB_DIR"]) 31 fi 32 else 33 for i in /usr/local /usr; do 34 if test -f "$i/include/zlib/zlib.h"; then 35 PHP_ZLIB_DIR="$i" 36 PHP_ZLIB_INCDIR="$i/include/zlib" 37 elif test -f "$i/include/zlib.h"; then 38 PHP_ZLIB_DIR="$i" 39 PHP_ZLIB_INCDIR="$i/include" 40 fi 41 done 42 fi 43 44 dnl # zlib 45 AC_MSG_CHECKING([for the location of zlib]) 46 if test "$PHP_ZLIB_DIR" = "no"; then 47 AC_MSG_ERROR([zip support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located]) 48 else 49 AC_MSG_RESULT([$PHP_ZLIB_DIR]) 50 PHP_ADD_LIBRARY_WITH_PATH(z, $PHP_ZLIB_DIR/$PHP_LIBDIR, ZIP_SHARED_LIBADD) 51 PHP_ADD_INCLUDE($PHP_ZLIB_INCDIR) 52 fi 53 54 if test "$PHP_LIBZIP" != "no"; then 55 56 AC_PATH_PROG(PKG_CONFIG, pkg-config, no) 57 58 dnl system libzip, depends on libzip 59 AC_MSG_CHECKING(for libzip) 60 if test -r $PHP_LIBZIP/include/zip.h; then 61 LIBZIP_CFLAGS="-I$PHP_LIBZIP/include" 62 LIBZIP_LIBDIR="$PHP_LIBZIP/$PHP_LIBDIR" 63 AC_MSG_RESULT(from option: found in $PHP_LIBZIP) 64 65 elif test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libzip; then 66 if $PKG_CONFIG libzip --atleast-version 0.11; then 67 LIBZIP_CFLAGS=`$PKG_CONFIG libzip --cflags` 68 LIBZIP_LIBDIR=`$PKG_CONFIG libzip --variable=libdir` 69 LIBZIP_VERSON=`$PKG_CONFIG libzip --modversion` 70 AC_MSG_RESULT(from pkgconfig: version $LIBZIP_VERSON found in $LIBZIP_LIBDIR) 71 else 72 AC_MSG_ERROR(system libzip must be upgraded to version >= 0.11) 73 fi 74 75 else 76 for i in /usr/local /usr; do 77 if test -r $i/include/zip.h; then 78 LIBZIP_CFLAGS="-I$i/include" 79 LIBZIP_LIBDIR="$i/$PHP_LIBDIR" 80 AC_MSG_RESULT(in default path: found in $i) 81 break 82 fi 83 done 84 fi 85 86 if test -z "$LIBZIP_LIBDIR"; then 87 AC_MSG_RESULT(not found) 88 AC_MSG_ERROR(Please reinstall the libzip distribution) 89 fi 90 91 dnl Could not think of a simple way to check libzip for overwrite support 92 PHP_CHECK_LIBRARY(zip, zip_open, 93 [ 94 PHP_ADD_LIBRARY_WITH_PATH(zip, $LIBZIP_LIBDIR, ZIP_SHARED_LIBADD) 95 AC_DEFINE(HAVE_LIBZIP,1,[ ]) 96 ], [ 97 AC_MSG_ERROR(could not find usable libzip) 98 ], [ 99 -L$LIBZIP_LIBDIR 100 ]) 101 102 AC_DEFINE(HAVE_ZIP,1,[ ]) 103 PHP_NEW_EXTENSION(zip, php_zip.c zip_stream.c, $ext_shared,, $LIBZIP_CFLAGS) 104 PHP_SUBST(ZIP_SHARED_LIBADD) 105 else 106 107 108 PHP_ZIP_SOURCES="$PHP_ZIP_SOURCES lib/zip_add.c lib/zip_add_dir.c lib/zip_add_entry.c\ 109 lib/zip_close.c lib/zip_delete.c lib/zip_dir_add.c lib/zip_dirent.c lib/zip_discard.c lib/zip_entry.c\ 110 lib/zip_err_str.c lib/zip_error.c lib/zip_error_clear.c lib/zip_error_get.c lib/zip_error_get_sys_type.c\ 111 lib/zip_error_strerror.c lib/zip_error_to_str.c lib/zip_extra_field.c lib/zip_extra_field_api.c\ 112 lib/zip_fclose.c lib/zip_fdopen.c lib/zip_file_add.c lib/zip_file_error_clear.c lib/zip_file_error_get.c\ 113 lib/zip_file_get_comment.c lib/zip_file_get_offset.c lib/zip_file_rename.c lib/zip_file_replace.c\ 114 lib/zip_file_set_comment.c lib/zip_file_strerror.c lib/zip_filerange_crc.c lib/zip_fopen.c\ 115 lib/zip_file_get_external_attributes.c lib/zip_file_set_external_attributes.c \ 116 lib/zip_fopen_encrypted.c lib/zip_fopen_index.c lib/zip_fopen_index_encrypted.c lib/zip_fread.c\ 117 lib/zip_get_archive_comment.c lib/zip_get_archive_flag.c lib/zip_get_compression_implementation.c\ 118 lib/zip_get_encryption_implementation.c lib/zip_get_file_comment.c lib/zip_get_name.c lib/zip_get_num_entries.c \ 119 lib/zip_get_num_files.c lib/zip_memdup.c lib/zip_name_locate.c lib/zip_new.c lib/zip_open.c lib/zip_rename.c lib/zip_replace.c\ 120 lib/zip_set_archive_comment.c lib/zip_set_archive_flag.c lib/zip_set_default_password.c lib/zip_set_file_comment.c\ 121 lib/zip_set_file_compression.c lib/zip_set_name.c lib/zip_source_buffer.c lib/zip_source_close.c lib/zip_source_crc.c\ 122 lib/zip_source_deflate.c lib/zip_source_error.c lib/zip_source_file.c lib/zip_source_filep.c lib/zip_source_free.c\ 123 lib/zip_source_function.c lib/zip_source_layered.c lib/zip_source_open.c lib/zip_source_pkware.c lib/zip_source_pop.c\ 124 lib/zip_source_read.c lib/zip_source_stat.c lib/zip_source_window.c lib/zip_source_zip.c lib/zip_source_zip_new.c\ 125 lib/zip_stat.c lib/zip_stat_index.c lib/zip_stat_init.c lib/zip_strerror.c lib/zip_string.c lib/zip_unchange.c lib/zip_unchange_all.c\ 126 lib/zip_unchange_archive.c lib/zip_unchange_data.c lib/zip_utf-8.c lib/mkstemp.c" 127 128 AC_DEFINE(HAVE_ZIP,1,[ ]) 129 PHP_NEW_EXTENSION(zip, php_zip.c zip_stream.c $PHP_ZIP_SOURCES, $ext_shared) 130 PHP_ADD_BUILD_DIR($ext_builddir/lib, 1) 131 PHP_ADD_INCLUDE([$ext_srcdir/lib]) 132 PHP_SUBST(ZIP_SHARED_LIBADD) 133fi 134 135 136AC_CHECK_TYPES([int8_t]) 137AC_CHECK_TYPES([int16_t]) 138AC_CHECK_TYPES([int32_t]) 139AC_CHECK_TYPES([int64_t]) 140AC_CHECK_TYPES([uint8_t]) 141AC_CHECK_TYPES([uint16_t]) 142AC_CHECK_TYPES([uint32_t]) 143AC_CHECK_TYPES([uint64_t]) 144AC_CHECK_TYPES([ssize_t]) 145 146AC_CHECK_SIZEOF([short]) 147AC_CHECK_SIZEOF([int]) 148AC_CHECK_SIZEOF([long]) 149AC_CHECK_SIZEOF([long long]) 150AC_CHECK_SIZEOF([off_t]) 151if test "$ac_cv_sizeof_off_t" = "0" ; then 152 AC_MSG_ERROR(off_t undefined; check your library configuration) 153fi 154AC_CHECK_SIZEOF([size_t]) 155 156AC_PATH_PROG([TOUCH], [touch]) 157AC_PATH_PROG([UNZIP], [unzip]) 158 159AC_STRUCT_TIMEZONE 160 161case $host_os 162in 163 *bsd*) MANFMT=mdoc;; 164 *) MANFMT=man;; 165esac 166AC_SUBST([MANFMT]) 167 168AH_BOTTOM([ 169#ifndef HAVE_SSIZE_T 170# if SIZEOF_SIZE_T == SIZEOF_INT 171typedef int ssize_t; 172# elif SIZEOF_SIZE_T == SIZEOF_LONG 173typedef long ssize_t; 174# elif SIZEOF_SIZE_T == SIZEOF_LONG_LONG 175typedef long long ssize_t; 176# else 177#error no suitable type for ssize_t found 178# endif 179#endif 180]) 181 182 183 dnl so we always include the known-good working hack. 184 PHP_ADD_MAKEFILE_FRAGMENT 185fi 186