Skip to content

Commit 1b3c204

Browse files
authored
Autotools: Add min-version argument to PHP_PROG_PHP macro (#15477)
This makes a bit simpler to use this macro by optionally passing the required minimum PHP version. If version is not passed it falls back to 7.4 as before. Minimum version also added to configure.ac.
1 parent 4e193b4 commit 1b3c204

File tree

3 files changed

+24
-23
lines changed

3 files changed

+24
-23
lines changed

UPGRADING.INTERNALS

+2
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ PHP 8.4 INTERNALS UPGRADE NOTES
181181
anymore.
182182
- M4 macro PHP_SETUP_ICONV doesn't define the HAVE_ICONV symbol anymore.
183183
- M4 macro PHP_OUTPUT is obsolete (use AC_CONFIG_FILES).
184+
- M4 macro PHP_PROG_SETUP now accepts an argument to set the minimum required
185+
PHP version during the build.
184186
- TSRM/tsrm.m4 file and its TSRM_CHECK_PTHREADS M4 macro have been removed.
185187
- Added pkg-config support to find libpq for the pdo_pgsql and pgsql
186188
extensions. The libpq paths can be customized with the PGSQL_CFLAGS and

build/php.m4

+20-22
Original file line numberDiff line numberDiff line change
@@ -1793,28 +1793,26 @@ AC_DEFUN([PHP_PROG_RE2C],[
17931793
PHP_SUBST([RE2C_FLAGS])
17941794
])
17951795

1796-
AC_DEFUN([PHP_PROG_PHP],[
1797-
AC_CHECK_PROG([PHP], [php], [php])
1798-
1799-
if test -n "$PHP"; then
1800-
AC_MSG_CHECKING([for php version])
1801-
php_version=$($PHP -v | head -n1 | cut -d ' ' -f 2 | cut -d '-' -f 1)
1802-
if test -z "$php_version"; then
1803-
php_version=0.0.0
1804-
fi
1805-
ac_IFS=$IFS; IFS="."
1806-
set $php_version
1807-
IFS=$ac_IFS
1808-
php_version_num=`expr [$]{1:-0} \* 10000 + [$]{2:-0} \* 100 + [$]{3:-0}`
1809-
dnl Minimum supported version for gen_stub.php is PHP 7.4.
1810-
if test "$php_version_num" -lt 70400; then
1811-
AC_MSG_RESULT([$php_version (too old)])
1812-
unset PHP
1813-
else
1814-
AC_MSG_RESULT([$php_version (ok)])
1815-
fi
1816-
fi
1817-
PHP_SUBST([PHP])
1796+
dnl
1797+
dnl PHP_PROG_PHP([min-version])
1798+
dnl
1799+
dnl Find PHP command-line interface SAPI on the system and check if version is
1800+
dnl greater or equal to "min-version". If suitable version is found, the PHP
1801+
dnl variable is set and substituted to a Makefile variable. Used for generating
1802+
dnl files and running PHP utilities during the build.
1803+
dnl
1804+
AC_DEFUN([PHP_PROG_PHP],
1805+
[m4_if([$1],, [php_required_version=7.4], [php_required_version=$1])
1806+
AC_CHECK_PROG([PHP], [php], [php])
1807+
AS_VAR_IF([PHP],,, [
1808+
AC_MSG_CHECKING([for php version])
1809+
php_version=$($PHP -v | head -n1 | cut -d ' ' -f 2)
1810+
AS_VERSION_COMPARE([$php_version], [$php_required_version], [unset PHP])
1811+
AS_VAR_IF([PHP],,
1812+
[AC_MSG_RESULT([$php_version (too old, install $php_required_version or later)])],
1813+
[AC_MSG_RESULT([$php_version (ok)])])
1814+
])
1815+
PHP_SUBST([PHP])
18181816
])
18191817

18201818
dnl ----------------------------------------------------------------------------

configure.ac

+2-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ PHP_RUNPATH_SWITCH
148148
dnl Checks for some support/generator progs.
149149
PHP_PROG_BISON([3.0.0])
150150
PHP_PROG_RE2C([1.0.3], [--no-generation-date])
151-
PHP_PROG_PHP()
151+
dnl Find installed PHP. Minimum supported version for gen_stub.php is PHP 7.4.
152+
PHP_PROG_PHP([7.4])
152153

153154
PHP_ARG_ENABLE([re2c-cgoto],
154155
[whether to enable computed goto extension with re2c],

0 commit comments

Comments
 (0)