xref: /PHP-7.3/ext/zip/config.m4 (revision a0c9d084)
1dnl config.m4 for extension zip
2
3PHP_ARG_ENABLE(zip, for zip archive read/writesupport,
4[  --enable-zip            Include Zip read/write support])
5
6if test -z "$PHP_ZLIB_DIR"; then
7  PHP_ARG_WITH(zlib-dir, for the location of libz,
8  [  --with-zlib-dir[=DIR]     ZIP: Set the path to libz install prefix], no, no)
9fi
10
11PHP_ARG_WITH(pcre-dir, pcre install prefix,
12[  --with-pcre-dir         ZIP: pcre install prefix], no, no)
13
14PHP_ARG_WITH(libzip, libzip,
15[  --with-libzip[=DIR]       ZIP: use libzip], yes, no)
16
17if test "$PHP_ZIP" != "no"; then
18
19  dnl libzip, depends on zlib
20  if test "$PHP_ZLIB_DIR" != "no" && test "$PHP_ZLIB_DIR" != "yes"; then
21    if test -f "$PHP_ZLIB_DIR/include/zlib/zlib.h"; then
22      PHP_ZLIB_DIR="$PHP_ZLIB_DIR"
23      PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include/zlib"
24    elif test -f "$PHP_ZLIB_DIR/include/zlib.h"; then
25      PHP_ZLIB_DIR="$PHP_ZLIB_DIR"
26      PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include"
27    else
28      AC_MSG_ERROR([Can not find zlib headers under "$PHP_ZLIB_DIR"])
29    fi
30  else
31    for i in /usr/local /usr; do
32      if test -f "$i/include/zlib/zlib.h"; then
33        PHP_ZLIB_DIR="$i"
34        PHP_ZLIB_INCDIR="$i/include/zlib"
35      elif test -f "$i/include/zlib.h"; then
36        PHP_ZLIB_DIR="$i"
37        PHP_ZLIB_INCDIR="$i/include"
38      fi
39    done
40  fi
41
42  dnl # zlib
43  AC_MSG_CHECKING([for the location of zlib])
44  if test "$PHP_ZLIB_DIR" = "no"; then
45    AC_MSG_ERROR([zip support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located])
46  else
47    AC_MSG_RESULT([$PHP_ZLIB_DIR])
48    PHP_ADD_LIBRARY_WITH_PATH(z, $PHP_ZLIB_DIR/$PHP_LIBDIR, ZIP_SHARED_LIBADD)
49    PHP_ADD_INCLUDE($PHP_ZLIB_INCDIR)
50  fi
51
52  if test "$PHP_LIBZIP" != "no"; then
53
54    AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
55
56    dnl system libzip, depends on libzip
57    AC_MSG_CHECKING(for libzip)
58    if test -r $PHP_LIBZIP/include/zip.h; then
59      LIBZIP_CFLAGS="-I$PHP_LIBZIP/include"
60      LIBZIP_LIBDIR="$PHP_LIBZIP/$PHP_LIBDIR"
61      AC_MSG_RESULT(from option: found in $PHP_LIBZIP)
62
63    elif test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libzip; then
64      if $PKG_CONFIG libzip --atleast-version 0.11; then
65        LIBZIP_CFLAGS=`$PKG_CONFIG libzip --cflags`
66        LIBZIP_LIBDIR=`$PKG_CONFIG libzip --variable=libdir`
67        LIBZIP_VERSON=`$PKG_CONFIG libzip --modversion`
68        AC_MSG_RESULT(from pkgconfig: version $LIBZIP_VERSON found in $LIBZIP_LIBDIR)
69      else
70        AC_MSG_ERROR(system libzip must be upgraded to version >= 0.11)
71      fi
72
73    else
74      for i in /usr/local /usr; do
75        if test -r $i/include/zip.h; then
76          LIBZIP_CFLAGS="-I$i/include"
77          LIBZIP_LIBDIR="$i/$PHP_LIBDIR"
78          AC_MSG_RESULT(in default path: found in $i)
79          break
80        fi
81      done
82    fi
83
84    if test -z "$LIBZIP_LIBDIR"; then
85      AC_MSG_RESULT(not found)
86      AC_MSG_ERROR(Please reinstall the libzip distribution)
87    fi
88
89    dnl Could not think of a simple way to check libzip for overwrite support
90    PHP_CHECK_LIBRARY(zip, zip_open,
91    [
92      PHP_ADD_LIBRARY_WITH_PATH(zip, $LIBZIP_LIBDIR, ZIP_SHARED_LIBADD)
93      AC_DEFINE(HAVE_LIBZIP,1,[ ])
94    ], [
95      AC_MSG_ERROR(could not find usable libzip)
96    ], [
97      -L$LIBZIP_LIBDIR
98    ])
99
100    PHP_CHECK_LIBRARY(zip, zip_file_set_encryption,
101    [
102      PHP_ADD_LIBRARY_WITH_PATH(zip, $LIBZIP_LIBDIR, ZIP_SHARED_LIBADD)
103      AC_DEFINE(HAVE_ENCRYPTION, 1, [Libzip >= 1.2.0 with encryption support])
104    ], [
105      AC_MSG_WARN(Libzip >= 1.2.0 needed for encryption support)
106    ], [
107      -L$LIBZIP_LIBDIR
108    ])
109
110    PHP_CHECK_LIBRARY(zip, zip_libzip_version,
111    [
112      AC_DEFINE(HAVE_LIBZIP_VERSION, 1, [Libzip >= 1.3.1 with zip_libzip_version function])
113    ], [
114    ], [
115      -L$LIBZIP_LIBDIR
116    ])
117
118    AC_DEFINE(HAVE_ZIP,1,[ ])
119    PHP_EVAL_INCLINE($LIBZIP_CFLAGS)
120    PHP_NEW_EXTENSION(zip, php_zip.c zip_stream.c, $ext_shared)
121    PHP_SUBST(ZIP_SHARED_LIBADD)
122  else
123    AC_MSG_WARN(========================================================)
124    AC_MSG_WARN(Use of bundled libzip is deprecated and will be removed.)
125    AC_MSG_WARN(Some features such as encryption and bzip2 are not available.)
126    AC_MSG_WARN(Use system library and --with-libzip is recommended.)
127    AC_MSG_WARN(========================================================)
128
129
130  PHP_ZIP_SOURCES="$PHP_ZIP_SOURCES lib/zip_add.c lib/zip_add_dir.c lib/zip_add_entry.c\
131			lib/zip_buffer.c lib/zip_file_set_mtime.c lib/zip_io_util.c lib/zip_source_begin_write.c \
132			lib/zip_source_call.c lib/zip_source_commit_write.c lib/zip_source_is_deleted.c \
133			lib/zip_source_remove.c lib/zip_source_rollback_write.c lib/zip_source_seek.c \
134			lib/zip_source_seek_write.c lib/zip_source_supports.c lib/zip_source_tell.c \
135			lib/zip_source_tell_write.c lib/zip_source_write.c \
136			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\
137			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\
138			lib/zip_error_strerror.c lib/zip_error_to_str.c lib/zip_extra_field.c lib/zip_extra_field_api.c\
139			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\
140			lib/zip_file_get_comment.c lib/zip_file_get_offset.c lib/zip_file_rename.c lib/zip_file_replace.c\
141			lib/zip_file_set_comment.c lib/zip_file_strerror.c lib/zip_filerange_crc.c lib/zip_fopen.c\
142			lib/zip_file_get_external_attributes.c lib/zip_file_set_external_attributes.c \
143			lib/zip_fopen_encrypted.c lib/zip_fopen_index.c lib/zip_fopen_index_encrypted.c lib/zip_fread.c\
144			lib/zip_get_archive_comment.c lib/zip_get_archive_flag.c lib/zip_get_compression_implementation.c\
145			lib/zip_get_encryption_implementation.c lib/zip_get_file_comment.c lib/zip_get_name.c lib/zip_get_num_entries.c \
146			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\
147			lib/zip_hash.c \
148			lib/zip_set_archive_comment.c lib/zip_set_archive_flag.c lib/zip_set_default_password.c lib/zip_set_file_comment.c\
149			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\
150			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\
151			lib/zip_source_function.c lib/zip_source_layered.c lib/zip_source_open.c lib/zip_source_pkware.c \
152			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\
153			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\
154			lib/zip_unchange_archive.c lib/zip_unchange_data.c lib/zip_utf-8.c lib/mkstemp.c"
155
156  AC_DEFINE(HAVE_ZIP,1,[ ])
157  PHP_NEW_EXTENSION(zip, php_zip.c zip_stream.c $PHP_ZIP_SOURCES, $ext_shared)
158  PHP_ADD_BUILD_DIR($ext_builddir/lib, 1)
159  PHP_ADD_INCLUDE([$ext_srcdir/lib])
160  PHP_SUBST(ZIP_SHARED_LIBADD)
161fi
162
163AC_CHECK_HEADERS(stdbool.h)
164AC_CHECK_HEADERS(fts.h)
165
166AC_CHECK_TYPES([int8_t])
167AC_CHECK_TYPES([int16_t])
168AC_CHECK_TYPES([int32_t])
169AC_CHECK_TYPES([int64_t])
170AC_CHECK_TYPES([uint8_t])
171AC_CHECK_TYPES([uint16_t])
172AC_CHECK_TYPES([uint32_t])
173AC_CHECK_TYPES([uint64_t])
174AC_CHECK_TYPES([ssize_t])
175
176AC_CHECK_SIZEOF([short])
177AC_CHECK_SIZEOF([int])
178AC_CHECK_SIZEOF([long])
179AC_CHECK_SIZEOF([long long])
180AC_CHECK_SIZEOF([off_t])
181if test "$ac_cv_sizeof_off_t" = "0" ; then
182  AC_MSG_ERROR(off_t undefined; check your library configuration)
183fi
184AC_CHECK_SIZEOF([size_t])
185
186AC_PATH_PROG([TOUCH], [touch])
187AC_PATH_PROG([UNZIP], [unzip])
188
189AC_STRUCT_TIMEZONE
190
191case $host_os
192in
193    *bsd*) MANFMT=mdoc;;
194    *) MANFMT=man;;
195esac
196AC_SUBST([MANFMT])
197
198  dnl so we always include the known-good working hack.
199  PHP_ADD_MAKEFILE_FRAGMENT
200fi
201