8000 Check for php program in autoconf · php/php-src@fa9e2b3 · GitHub
[go: up one dir, main page]

Skip to content

Commit fa9e2b3

Browse files
committed
Check for php program in autoconf
Use the detected PHP (minimum 7.1) to run gen_stubs, and other code generation scripts in the future.
1 parent 9140c90 commit fa9e2b3

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

build/Makefile.global

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,11 @@ prof-clean:
142142
prof-use:
143143
CCACHE_DISABLE=1 $(MAKE) PROF_FLAGS=-fprofile-use all
144144

145-
# only php above 7.1.0 supports nullable return type
146145
%_arginfo.h: %.stub.php
147146
@if test -e "$(top_srcdir)/build/gen_stub.php"; then \
148-
if test ! -z "$(PHP_EXECUTABLE)" && test -x "$(PHP_EXECUTABLE)"; then \
147+
if test ! -z "$(PHP)" && test -x "$(PHP)"; then \
149148
echo Parse $< to generate $@;\
150-
$(PHP_EXECUTABLE) $(top_srcdir)/build/gen_stub.php $<; \
151-
elif type php >/dev/null 2>/dev/null; then \
152-
if test `php -v | head -n1 | cut -d" " -f 2 | sed "s/$$/\n7.0.99/" | sort -rV | head -n1` != "7.0.99"; then \
153-
echo Parse $< to generate $@;\
154-
php $(top_srcdir)/build/gen_stub.php $<; \
155-
fi; \
149+
$(PHP) $(top_srcdir)/build/gen_stub.php $<; \
156150
fi; \
157151
fi;
158152

build/php.m4

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,6 +1876,30 @@ AC_DEFUN([PHP_PROG_RE2C],[
18761876
PHP_SUBST(RE2C)
18771877
])
18781878

1879+
AC_DEFUN([PHP_PROG_PHP],[
1880+
AC_CHECK_PROG(PHP, php, php)
1881+
1882+
if test -n "$PHP"; then
1883+
AC_MSG_CHECKING([for php version])
1884+
php_version=$($PHP -v | head -n1 | cut -d ' ' -f 2)
1885+
if test -z "$php_version"; then
1886+
php_version=0.0.0
1887+
fi
1888+
ac_IFS=$IFS; IFS="."
1889+
set $php_version
1890+
IFS=$ac_IFS
1891+
php_version_num=`expr [$]{1:-0} \* 10000 + [$]{2:-0} \* 100 + [$]{3:-0}`
1892+
dnl Minimum supported version for gen_stubs.php is PHP 7.1.
1893+
if test "$php_version_num" -lt 70100; then
1894+
AC_MSG_RESULT([$php_version (too old)])
1895+
unset PHP
1896+
else
1897+
AC_MSG_RESULT([$php_version (ok)])
1898+
fi
1899+
fi
1900+
PHP_SUBST(PHP)
1901+
])
1902+
18791903
dnl ----------------------------------------------------------------------------
18801904
dnl Common setup macros: PHP_SETUP_<what>
18811905
dnl ----------------------------------------------------------------------------

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ dnl Checks for some support/generator progs.
155155
PHP_PROG_AWK
156156
PHP_PROG_BISON([3.0.0])
157157
PHP_PROG_RE2C([0.13.4])
158+
PHP_PROG_PHP()
158159

159160
PHP_ARG_ENABLE([re2c-cgoto],
160161
[whether to enable computed goto gcc extension with re2c],

0 commit comments

Comments
 (0)
0