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.
This commit is contained in:
Peter Kokot 2024-08-22 17:30:08 +02:00 committed by GitHub
parent 4e193b4113
commit 1b3c204033
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 23 deletions

View File

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

View File

@ -1793,28 +1793,26 @@ AC_DEFUN([PHP_PROG_RE2C],[
PHP_SUBST([RE2C_FLAGS])
])
AC_DEFUN([PHP_PROG_PHP],[
AC_CHECK_PROG([PHP], [php], [php])
if test -n "$PHP"; then
AC_MSG_CHECKING([for php version])
php_version=$($PHP -v | head -n1 | cut -d ' ' -f 2 | cut -d '-' -f 1)
if test -z "$php_version"; then
php_version=0.0.0
fi
ac_IFS=$IFS; IFS="."
set $php_version
IFS=$ac_IFS
php_version_num=`expr [$]{1:-0} \* 10000 + [$]{2:-0} \* 100 + [$]{3:-0}`
dnl Minimum supported version for gen_stub.php is PHP 7.4.
if test "$php_version_num" -lt 70400; then
AC_MSG_RESULT([$php_version (too old)])
unset PHP
else
AC_MSG_RESULT([$php_version (ok)])
fi
fi
PHP_SUBST([PHP])
dnl
dnl PHP_PROG_PHP([min-version])
dnl
dnl Find PHP command-line interface SAPI on the system and check if version is
dnl greater or equal to "min-version". If suitable version is found, the PHP
dnl variable is set and substituted to a Makefile variable. Used for generating
dnl files and running PHP utilities during the build.
dnl
AC_DEFUN([PHP_PROG_PHP],
[m4_if([$1],, [php_required_version=7.4], [php_required_version=$1])
AC_CHECK_PROG([PHP], [php], [php])
AS_VAR_IF([PHP],,, [
AC_MSG_CHECKING([for php version])
php_version=$($PHP -v | head -n1 | cut -d ' ' -f 2)
AS_VERSION_COMPARE([$php_version], [$php_required_version], [unset PHP])
AS_VAR_IF([PHP],,
[AC_MSG_RESULT([$php_version (too old, install $php_required_version or later)])],
[AC_MSG_RESULT([$php_version (ok)])])
])
PHP_SUBST([PHP])
])
dnl ----------------------------------------------------------------------------

View File

@ -148,7 +148,8 @@ PHP_RUNPATH_SWITCH
dnl Checks for some support/generator progs.
PHP_PROG_BISON([3.0.0])
PHP_PROG_RE2C([1.0.3], [--no-generation-date])
PHP_PROG_PHP()
dnl Find installed PHP. Minimum supported version for gen_stub.php is PHP 7.4.
PHP_PROG_PHP([7.4])
PHP_ARG_ENABLE([re2c-cgoto],
[whether to enable computed goto extension with re2c],