Skip to content

Commit 09b9e77

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Enhance Autoconf version checking
2 parents 54fdf6d + 8b94042 commit 09b9e77

File tree

1 file changed

+43
-19
lines changed

1 file changed

+43
-19
lines changed

build/buildcheck.sh

+43-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#! /bin/sh
1+
#!/bin/sh
2+
#
23
# +----------------------------------------------------------------------+
34
# | PHP Version 7 |
45
# +----------------------------------------------------------------------+
@@ -15,34 +16,57 @@
1516
# | Authors: Stig Bakken <[email protected]> |
1617
# | Sascha Schumann <[email protected]> |
1718
# +----------------------------------------------------------------------+
19+
#
20+
# Check PHP build system tools such as autoconf and their versions.
21+
#
22+
# SYNOPSIS:
23+
# buildcheck.sh [stampfile]
24+
#
25+
# DESCRIPTION:
26+
# Optional stampfile is for Makefile to check build system only once.
27+
#
28+
# ENVIRONMENT:
29+
# The following optional variables are supported:
30+
#
31+
# PHP_AUTOCONF Overrides the path to autoconf tool.
32+
# PHP_AUTOCONF=/path/to/autoconf buildcheck.sh
1833

1934
echo "buildconf: checking installation..."
2035

2136
stamp=$1
2237

2338
# Allow the autoconf executable to be overridden by $PHP_AUTOCONF.
24-
if test -z "$PHP_AUTOCONF"; then
25-
PHP_AUTOCONF='autoconf'
26-
fi
39+
PHP_AUTOCONF=${PHP_AUTOCONF:-autoconf}
40+
41+
# Go to project root.
42+
cd $(CDPATH= cd -- "$(dirname -- "$0")/../" && pwd -P)
43+
44+
# Get minimum required autoconf version from the configure.ac file.
45+
min_version=$(sed -n 's/AC_PREREQ(\[\(.*\)\])/\1/p' configure.ac)
46+
47+
# Check if autoconf exists.
48+
ac_version=$($PHP_AUTOCONF --version 2>/dev/null|head -n 1|sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//')
2749

28-
# autoconf 2.68 or newer
29-
ac_version=`$PHP_AUTOCONF --version 2>/dev/null|head -n 1|sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
3050
if test -z "$ac_version"; then
31-
echo "buildconf: autoconf not found." >&2
32-
echo " You need autoconf version 2.68 or newer installed" >&2
33-
echo " to build PHP from Git." >&2
34-
exit 1
51+
echo "buildconf: autoconf not found." >&2
52+
echo " You need autoconf version $min_version or newer installed" >&2
53+
echo " to build PHP from Git." >&2
54+
exit 1
3555
fi
36-
IFS=.; set $ac_version; IFS=' '
37-
if test "$1" = "2" -a "$2" -lt "68" || test "$1" -lt "2"; then
38-
echo "buildconf: autoconf version $ac_version found." >&2
39-
echo " You need autoconf version 2.68 or newer installed" >&2
40-
echo " to build PHP from Git." >&2
41-
exit 1
56+
57+
# Check autoconf version.
58+
set -f; IFS='.'; set -- $ac_version; set +f; IFS=' '
59+
ac_version_num="$(expr ${1} \* 10000 + ${2} \* 100)"
60+
set -f; IFS='.'; set -- $min_version; set +f; IFS=' '
61+
min_version_num="$(expr ${1} \* 10000 + ${2} \* 100)"
62+
63+
if test "$ac_version_num" -lt "$min_version_num"; then
64+
echo "buildconf: autoconf version $ac_version found." >&2
65+
echo " You need autoconf version $min_version or newer installed" >&2
66+
echo " to build PHP from Git." >&2
67+
exit 1
4268
else
43-
echo "buildconf: autoconf version $ac_version (ok)"
69+
echo "buildconf: autoconf version $ac_version (ok)"
4470
fi
4571

4672
test -n "$stamp" && touch $stamp
47-
48-
exit 0

0 commit comments

Comments
 (0)