xref: /PHP-5.5/ext/zip/config.m4 (revision c6d977dd)
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
16if test "$PHP_ZIP" != "no"; then
17
18  if test "$PHP_ZLIB_DIR" != "no" && test "$PHP_ZLIB_DIR" != "yes"; then
19    if test -f "$PHP_ZLIB_DIR/include/zlib/zlib.h"; then
20      PHP_ZLIB_DIR="$PHP_ZLIB_DIR"
21      PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include/zlib"
22    elif test -f "$PHP_ZLIB_DIR/include/zlib.h"; then
23      PHP_ZLIB_DIR="$PHP_ZLIB_DIR"
24      PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include"
25    else
26      AC_MSG_ERROR([Can not find zlib headers under "$PHP_ZLIB_DIR"])
27    fi
28  else
29    for i in /usr/local /usr; do
30      if test -f "$i/include/zlib/zlib.h"; then
31        PHP_ZLIB_DIR="$i"
32        PHP_ZLIB_INCDIR="$i/include/zlib"
33      elif test -f "$i/include/zlib.h"; then
34        PHP_ZLIB_DIR="$i"
35        PHP_ZLIB_INCDIR="$i/include"
36      fi
37    done
38  fi
39
40  dnl # zlib
41  AC_MSG_CHECKING([for the location of zlib])
42  if test "$PHP_ZLIB_DIR" = "no"; then
43    AC_MSG_ERROR([zip support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located])
44  else
45    AC_MSG_RESULT([$PHP_ZLIB_DIR])
46    PHP_ADD_LIBRARY_WITH_PATH(z, $PHP_ZLIB_DIR/$PHP_LIBDIR, ZIP_SHARED_LIBADD)
47    PHP_ADD_INCLUDE($PHP_ZLIB_INCDIR)
48  fi
49
50  dnl This is PECL build, check if bundled PCRE library is used
51  old_CPPFLAGS=$CPPFLAGS
52  CPPFLAGS=$INCLUDES
53  AC_EGREP_CPP(yes,[
54#include <main/php_config.h>
55#if defined(HAVE_BUNDLED_PCRE) && !defined(COMPILE_DL_PCRE)
56yes
57#endif
58  ],[
59    PHP_PCRE_REGEX=yes
60  ],[
61    AC_EGREP_CPP(yes,[
62#include <main/php_config.h>
63#if defined(HAVE_PCRE) && !defined(COMPILE_DL_PCRE)
64yes
65#endif
66    ],[
67      PHP_PCRE_REGEX=pecl
68    ],[
69      PHP_PCRE_REGEX=no
70    ])
71  ])
72  CPPFLAGS=$old_CPPFLAGS
73
74  PHP_ZIP_SOURCES="$PHP_ZIP_SOURCES lib/zip_add.c lib/zip_error.c lib/zip_fclose.c \
75                         lib/zip_fread.c lib/zip_open.c lib/zip_source_filep.c  \
76                         lib/zip_strerror.c lib/zip_close.c lib/zip_error_get.c \
77                         lib/zip_file_error_get.c lib/zip_free.c lib/zip_rename.c \
78                         lib/zip_source_free.c lib/zip_unchange_all.c lib/zip_delete.c \
79                         lib/zip_error_get_sys_type.c lib/zip_file_get_offset.c \
80                         lib/zip_get_name.c lib/zip_replace.c lib/zip_source_function.c \
81                         lib/zip_unchange.c lib/zip_dirent.c lib/zip_error_strerror.c \
82                         lib/zip_filerange_crc.c lib/zip_file_strerror.c lib/zip_get_num_files.c \
83                         lib/zip_get_archive_flag.c lib/zip_set_archive_flag.c \
84                         lib/zip_set_name.c lib/zip_source_zip.c lib/zip_unchange_data.c \
85                         lib/zip_entry_free.c lib/zip_error_to_str.c lib/zip_fopen.c \
86                         lib/zip_name_locate.c lib/zip_source_buffer.c lib/zip_stat.c \
87                         lib/zip_entry_new.c lib/zip_err_str.c lib/zip_fopen_index.c \
88                         lib/zip_get_archive_comment.c lib/zip_get_file_comment.c \
89                         lib/zip_new.c lib/zip_source_file.c lib/zip_stat_index.c \
90                         lib/zip_set_archive_comment.c lib/zip_set_file_comment.c \
91                         lib/zip_unchange_archive.c lib/zip_memdup.c lib/zip_stat_init.c lib/zip_add_dir.c \
92                         lib/zip_error_clear.c lib/zip_file_error_clear.c \
93						 lib/zip_fdopen.c lib/zip_fopen_encrypted.c lib/zip_fopen_index_encrypted.c \
94						 lib/zip_get_compression_implementation.c lib/zip_get_encryption_implementation.c \
95						 lib/zip_get_file_extra.c lib/zip_get_num_entries.c lib/zip_set_default_password.c \
96						 lib/zip_set_file_extra.c lib/zip_source_close.c lib/zip_source_crc.c \
97						 lib/zip_source_deflate.c lib/zip_source_error.c lib/zip_source_layered.c \
98						 lib/zip_source_open.c lib/zip_source_pkware.c lib/zip_source_pop.c \
99						 lib/zip_source_read.c lib/zip_source_stat.c"
100
101  AC_DEFINE(HAVE_ZIP,1,[ ])
102  PHP_NEW_EXTENSION(zip, php_zip.c zip_stream.c $PHP_ZIP_SOURCES, $ext_shared)
103  PHP_ADD_BUILD_DIR($ext_builddir/lib, 1)
104  PHP_SUBST(ZIP_SHARED_LIBADD)
105
106  dnl so we always include the known-good working hack.
107  PHP_ADD_MAKEFILE_FRAGMENT
108fi
109