Skip to content

Commit c79e723

Browse files
authored
Autotools: Check re2c version with AS_VERSION_COMPARE (#15465)
This simplifies the version check a bit.
1 parent 1b3c204 commit c79e723

File tree

1 file changed

+15
-38
lines changed

1 file changed

+15
-38
lines changed

build/php.m4

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,54 +1739,31 @@ dnl
17391739
AC_DEFUN([PHP_PROG_RE2C],[
17401740
AC_CHECK_PROG([RE2C], [re2c], [re2c])
17411741
1742-
ifelse($1,,php_re2c_required_version='',php_re2c_required_version="$1")
1743-
1744-
if test -n "$RE2C"; then
1742+
php_re2c_check=
1743+
AS_VAR_IF([RE2C],,, [
17451744
AC_MSG_CHECKING([for re2c version])
17461745
17471746
php_re2c_version=$($RE2C --version | cut -d ' ' -f 2 2>/dev/null)
1748-
if test -z "$php_re2c_version"; then
1749-
php_re2c_version=0.0.0
1750-
fi
1751-
ac_IFS=$IFS; IFS="."
1752-
set $php_re2c_version
1753-
IFS=$ac_IFS
1754-
php_re2c_num=`expr [$]{1:-0} \* 10000 + [$]{2:-0} \* 100 + [$]{3:-0}`
1755-
php_re2c_check=ok
17561747
1757-
if test -z "$php_re2c_required_version" && test -z "$php_re2c_num"; then
1758-
php_re2c_check=invalid
1759-
elif test -n "$php_re2c_required_version"; then
1760-
ac_IFS=$IFS; IFS="."
1761-
set $php_re2c_required_version
1762-
IFS=$ac_IFS
1763-
php_re2c_required_num=`expr [$]{1:-0} \* 10000 + [$]{2:-0} \* 100 + [$]{3:-0}`
1764-
php_re2c_required_version="$php_re2c_required_version or later"
1765-
1766-
if test -z "$php_re2c_num" || test "$php_re2c_num" -lt "$php_re2c_required_num"; then
1767-
php_re2c_check=invalid
1768-
fi
1769-
fi
1748+
php_re2c_check=ok
1749+
AS_VERSION_COMPARE([$php_re2c_version], [$1],
1750+
[php_re2c_check=invalid])
17701751
1771-
if test "$php_re2c_check" != "invalid"; then
1772-
AC_MSG_RESULT([$php_re2c_version (ok)])
1773-
else
1774-
AC_MSG_RESULT([$php_re2c_version (too old)])
1775-
fi
1776-
fi
1752+
AS_VAR_IF([php_re2c_check], [invalid],
1753+
[AC_MSG_RESULT([$php_re2c_version (too old)])],
1754+
[AC_MSG_RESULT([$php_re2c_version (ok)])])
1755+
])
17771756
1778-
case $php_re2c_check in
1779-
""|invalid[)]
1780-
if test ! -f "$abs_srcdir/Zend/zend_language_scanner.c"; then
1757+
AS_CASE([$php_re2c_check],
1758+
[""|invalid], [
1759+
AS_IF([test ! -f "$abs_srcdir/Zend/zend_language_scanner.c"], [
17811760
AC_MSG_ERROR(m4_text_wrap([
1782-
re2c $php_re2c_required_version or newer is required to generate PHP
1783-
lexers.
1761+
re2c $1 or newer is required to generate PHP lexers.
17841762
]))
1785-
fi
1763+
])
17861764
17871765
RE2C="exit 0;"
1788-
;;
1789-
esac
1766+
])
17901767
17911768
PHP_SUBST([RE2C])
17921769
AS_VAR_SET([RE2C_FLAGS], m4_normalize(["$2"]))

0 commit comments

Comments
 (0)