Skip to content

Autotools: Check re2c version with AS_VERSION_COMPARE #15465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 15 additions & 38 deletions build/php.m4
Original file line number Diff line number Diff line change
Expand Up @@ -1724,54 +1724,31 @@ dnl
AC_DEFUN([PHP_PROG_RE2C],[
AC_CHECK_PROG([RE2C], [re2c], [re2c])

ifelse($1,,php_re2c_required_version='',php_re2c_required_version="$1")

if test -n "$RE2C"; then
php_re2c_check=
AS_VAR_IF([RE2C],,, [
AC_MSG_CHECKING([for re2c version])

php_re2c_version=$($RE2C --version | cut -d ' ' -f 2 2>/dev/null)
if test -z "$php_re2c_version"; then
php_re2c_version=0.0.0
fi
ac_IFS=$IFS; IFS="."
set $php_re2c_version
IFS=$ac_IFS
php_re2c_num=`expr [$]{1:-0} \* 10000 + [$]{2:-0} \* 100 + [$]{3:-0}`
php_re2c_check=ok

if test -z "$php_re2c_required_version" && test -z "$php_re2c_num"; then
php_re2c_check=invalid
elif test -n "$php_re2c_required_version"; then
ac_IFS=$IFS; IFS="."
set $php_re2c_required_version
IFS=$ac_IFS
php_re2c_required_num=`expr [$]{1:-0} \* 10000 + [$]{2:-0} \* 100 + [$]{3:-0}`
php_re2c_required_version="$php_re2c_required_version or later"

if test -z "$php_re2c_num" || test "$php_re2c_num" -lt "$php_re2c_required_num"; then
php_re2c_check=invalid
fi
fi
php_re2c_check=ok
AS_VERSION_COMPARE([$php_re2c_version], [$1],
[php_re2c_check=invalid])

if test "$php_re2c_check" != "invalid"; then
AC_MSG_RESULT([$php_re2c_version (ok)])
else
AC_MSG_RESULT([$php_re2c_version (too old)])
fi
fi
AS_VAR_IF([php_re2c_check], [invalid],
[AC_MSG_RESULT([$php_re2c_version (too old)])],
[AC_MSG_RESULT([$php_re2c_version (ok)])])
])

case $php_re2c_check in
""|invalid[)]
if test ! -f "$abs_srcdir/Zend/zend_language_scanner.c"; then
AS_CASE([$php_re2c_check],
[""|invalid], [
AS_IF([test ! -f "$abs_srcdir/Zend/zend_language_scanner.c"], [
AC_MSG_ERROR(m4_text_wrap([
re2c $php_re2c_required_version or newer is required to generate PHP
lexers.
re2c $1 or newer is required to generate PHP lexers.
]))
fi
])

RE2C="exit 0;"
;;
esac
])

PHP_SUBST([RE2C])
AS_VAR_SET([RE2C_FLAGS], m4_normalize(["$2"]))
Expand Down
Loading