]> granicus.if.org Git - php/commitdiff
Check for php program in autoconf
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 16 Mar 2021 11:28:47 +0000 (12:28 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 16 Mar 2021 11:30:56 +0000 (12:30 +0100)
Use the detected PHP (minimum 7.1) to run gen_stubs, and other
code generation scripts in the future.

build/Makefile.global
build/php.m4
configure.ac

index 9a8779d56d09209fe1844b8c5e220e2a85edc0b3..cc21973f184af8437a363826a5d81a62006214d8 100644 (file)
@@ -142,17 +142,11 @@ prof-clean:
 prof-use:
        CCACHE_DISABLE=1 $(MAKE) PROF_FLAGS=-fprofile-use all
 
-# only php above 7.1.0 supports nullable return type
 %_arginfo.h: %.stub.php
        @if test -e "$(top_srcdir)/build/gen_stub.php"; then \
-               if test ! -z "$(PHP_EXECUTABLE)" && test -x "$(PHP_EXECUTABLE)"; then \
+               if test ! -z "$(PHP)" && test -x "$(PHP)"; then \
                        echo Parse $< to generate $@;\
-                       $(PHP_EXECUTABLE) $(top_srcdir)/build/gen_stub.php $<; \
-               elif type php >/dev/null 2>/dev/null; then \
-                       if test `php -v | head -n1 | cut -d" " -f 2 | sed "s/$$/\n7.0.99/" | sort -rV | head -n1` != "7.0.99"; then \
-                               echo Parse $< to generate $@;\
-                               php $(top_srcdir)/build/gen_stub.php $<; \
-                       fi; \
+                       $(PHP) $(top_srcdir)/build/gen_stub.php $<; \
                fi; \
        fi;
 
index 04651f01e2d2cf50f4746c13ca06d968f709835e..8994e1fe6a938d0a2398506cc5056b66f21688aa 100644 (file)
@@ -1876,6 +1876,30 @@ AC_DEFUN([PHP_PROG_RE2C],[
   PHP_SUBST(RE2C)
 ])
 
+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)
+    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_stubs.php is PHP 7.1.
+    if test "$php_version_num" -lt 70100; then
+      AC_MSG_RESULT([$php_version (too old)])
+      unset PHP
+    else
+      AC_MSG_RESULT([$php_version (ok)])
+    fi
+  fi
+  PHP_SUBST(PHP)
+])
+
 dnl ----------------------------------------------------------------------------
 dnl Common setup macros: PHP_SETUP_<what>
 dnl ----------------------------------------------------------------------------
index 11515574467b82ef78041d1f921e376ea9346555..37300041b7db3d0f2b67c82c846a5f8d8ac5817e 100644 (file)
@@ -155,6 +155,7 @@ dnl Checks for some support/generator progs.
 PHP_PROG_AWK
 PHP_PROG_BISON([3.0.0])
 PHP_PROG_RE2C([0.13.4])
+PHP_PROG_PHP()
 
 PHP_ARG_ENABLE([re2c-cgoto],
   [whether to enable computed goto gcc extension with re2c],