Skip to content

Commit b12ccb3

Browse files
authored
Add PHP_SETUP_ZLIB M4 macro (#14591)
This enables the zlib library (https://zlib.net/) from a single place to match the minimum required version across the php-src. This provides a possible simpler version bump in the future. Macro's 2nd and 3rd arguments can pass additional actions whether zlib library is found or not for the possible future adjustments in the ext/standard where also zlib might be required. Support for pkg-config was introduced in 1.2.3.1. The minimum zlib version has been bumped to 1.2.3.1 * Bump minimum zlib version to 1.2.11 This is aligned with CentOS 8, which has 1.2.11 in the default packages. * [skip ci] Move zlib version change to UPGRADING This matches the OpenSSL style version change notice already done in this file.
1 parent 5a6f07e commit b12ccb3

File tree

7 files changed

+32
-27
lines changed

7 files changed

+32
-27
lines changed

UPGRADING

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,9 @@ PHP 8.4 UPGRADE NOTES
701701
. The typed properties XSLTProcessor::$cloneDocument and
702702
XSLTProcessor::$doXInclude are now declared.
703703

704+
- zlib:
705+
. The zlib extension now requires at least zlib 1.2.11.
706+
704707
========================================
705708
10. New Global Constants
706709
========================================

build/php.m4

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,6 +1929,20 @@ PKG_CHECK_MODULES([SQLITE], [sqlite3 >= 3.7.7], [
19291929
])
19301930
])
19311931

1932+
dnl
1933+
dnl PHP_SETUP_ZLIB(shared-add [, action-found, [action-not-found]])
1934+
dnl
1935+
dnl Common setup macro for zlib library. If zlib is not found on the system, the
1936+
dnl default error by PKG_CHECK_MODULES is emitted, unless the action-not-found
1937+
dnl is given.
1938+
dnl
1939+
AC_DEFUN([PHP_SETUP_ZLIB], [dnl
1940+
PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.11], [dnl
1941+
PHP_EVAL_INCLINE([$ZLIB_CFLAGS])
1942+
PHP_EVAL_LIBLINE([$ZLIB_LIBS], [$1])
1943+
$2], [$3])dnl
1944+
])
1945+
19321946
dnl ----------------------------------------------------------------------------
19331947
dnl Misc. macros
19341948
dnl ----------------------------------------------------------------------------

ext/gd/config.m4

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,6 @@ dnl
6565
dnl Checks for the configure options
6666
dnl
6767

68-
dnl zlib is always required
69-
AC_DEFUN([PHP_GD_ZLIB],[
70-
PKG_CHECK_MODULES([ZLIB], [zlib])
71-
PHP_EVAL_LIBLINE($ZLIB_LIBS, GD_SHARED_LIBADD)
72-
PHP_EVAL_INCLINE($ZLIB_CFLAGS)
73-
])
74-
7568
dnl libpng is always required
7669
AC_DEFUN([PHP_GD_PNG],[
7770
PKG_CHECK_MODULES([PNG], [libpng])
@@ -224,7 +217,7 @@ dnl These are always available with bundled library
224217
AC_DEFINE(HAVE_GD_TGA, 1, [ ])
225218

226219
dnl Various checks for GD features
227-
PHP_GD_ZLIB
220+
PHP_SETUP_ZLIB([GD_SHARED_LIBADD])
228221
PHP_GD_PNG
229222
PHP_GD_AVIF
230223
PHP_GD_WEBP

ext/mysqlnd/config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ if (PHP_MYSQLND != "no") {
3434
CHECK_HEADER_ADD_INCLUDE("zlib.h", "CFLAGS", "..\\zlib;" + php_usual_include_suspects)
3535
)
3636
{
37-
AC_DEFINE("MYSQLND_COMPRESSION_ENABLED", 1, "Compression support");
37+
AC_DEFINE("MYSQLND_COMPRESSION_ENABLED", 1, "Define to 1 if mysqlnd has compressed protocol support.");
3838
AC_DEFINE("MYSQLND_SSL_SUPPORTED", 1, "SSL support");
3939
if (CHECK_LIB("crypt32.lib", "mysqlnd")) {
4040
AC_DEFINE("MYSQLND_HAVE_SSL", 1, "Extended SSL support");

ext/mysqlnd/config9.m4

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,10 @@ if test "$PHP_MYSQLND" != "no" || test "$PHP_MYSQLND_ENABLED" = "yes"; then
3131
mysqlnd_result.c mysqlnd_result_meta.c mysqlnd_debug.c mysqlnd_commands.c \
3232
mysqlnd_block_alloc.c mysqlnd_read_buffer.c mysqlnd_plugin.c php_mysqlnd.c"
3333

34-
35-
if test "$PHP_MYSQLND_COMPRESSION_SUPPORT" != "no"; then
36-
PKG_CHECK_MODULES([ZLIB], [zlib])
37-
PHP_EVAL_LIBLINE($ZLIB_LIBS, MYSQLND_SHARED_LIBADD)
38-
PHP_EVAL_INCLINE($ZLIB_CFLAGS)
39-
AC_DEFINE([MYSQLND_COMPRESSION_ENABLED], 1, [Enable compressed protocol support])
40-
fi
34+
AS_VAR_IF([PHP_MYSQLND_COMPRESSION_SUPPORT], [no],,
35+
[PHP_SETUP_ZLIB([MYSQLND_SHARED_LIBADD],
36+
[AC_DEFINE([MYSQLND_COMPRESSION_ENABLED], [1],
37+
[Define to 1 if mysqlnd has compressed protocol support.])])])
4138

4239
AC_DEFINE([MYSQLND_SSL_SUPPORTED], 1, [Enable core mysqlnd SSL code])
4340

ext/zlib/config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if (PHP_ZLIB == "yes") {
77
CHECK_HEADER_ADD_INCLUDE("zlib.h", "CFLAGS", "..\\zlib;" + php_usual_include_suspects)) {
88

99
EXTENSION("zlib", "zlib.c zlib_fopen_wrapper.c zlib_filter.c", PHP_ZLIB_SHARED, "/D ZLIB_EXPORTS /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
10-
AC_DEFINE("HAVE_ZLIB", 1, "ZLIB support");
10+
AC_DEFINE("HAVE_ZLIB", 1, "Define to 1 if zlib extension is available.");
1111

1212
if (!PHP_ZLIB_SHARED) {
1313
ADD_DEF_FILE("ext\\zlib\\php_zlib.def");

ext/zlib/config0.m4

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
PHP_ARG_WITH([zlib],
22
[for ZLIB support],
33
[AS_HELP_STRING([--with-zlib],
4-
[Include ZLIB support (requires zlib >= 1.2.0.4)])])
4+
[Include ZLIB support (requires zlib library)])])
55

66
if test "$PHP_ZLIB" != "no"; then
7-
PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0.4])
8-
9-
PHP_EVAL_LIBLINE($ZLIB_LIBS, ZLIB_SHARED_LIBADD)
10-
PHP_EVAL_INCLINE($ZLIB_CFLAGS)
11-
12-
AC_DEFINE(HAVE_ZLIB,1,[ ])
13-
14-
PHP_NEW_EXTENSION(zlib, zlib.c zlib_fopen_wrapper.c zlib_filter.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
15-
PHP_SUBST(ZLIB_SHARED_LIBADD)
7+
PHP_SETUP_ZLIB([ZLIB_SHARED_LIBADD], [dnl
8+
AC_DEFINE([HAVE_ZLIB], [1], [Define to 1 if zlib extension is available.])
9+
PHP_NEW_EXTENSION([zlib],
10+
[zlib.c zlib_fopen_wrapper.c zlib_filter.c],
11+
[$ext_shared],,
12+
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
13+
PHP_SUBST([ZLIB_SHARED_LIBADD])])
1614
fi

0 commit comments

Comments
 (0)