Skip to content

Commit 78ab79b

Browse files
committed
Enhance the buildconf script
Changes: - Added a short introduction what this script does - Added usually the expected -h and --help options with explanation for a reason for this script and its usage. - Messages changed a bit so the PHP installation procedure becomes simpler without needing to constantly remind the reader what to run and what not in the documentations and installation instructions. - cd into current working directory of the buildconf (this enables running the script from other locations and inside other scripts). - check if make exists
1 parent 2619b13 commit 78ab79b

File tree

1 file changed

+69
-15
lines changed

1 file changed

+69
-15
lines changed

Diff for: buildconf

+69-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
#!/bin/sh
2+
#
3+
# A wrapper around Autoconf that generates files to build PHP on *nix systems.
24

3-
eval `grep '^PHP_EXTRA_VERSION=' configure.ac`
5+
MAKE=${MAKE:-make}
6+
force=0
7+
debug=0
8+
9+
# Go to project root.
10+
cd $(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)
11+
12+
eval $(grep '^PHP_EXTRA_VERSION=' configure.ac)
413
case "$PHP_EXTRA_VERSION" in
514
*-dev)
615
dev=1
@@ -10,37 +19,82 @@ case "$PHP_EXTRA_VERSION" in
1019
;;
1120
esac
1221

13-
devok=0
14-
debug=no
15-
1622
while test $# -gt 0; do
23+
if test "$1" = "-h" || test "$1" = "--help"; then
24+
cat << HELP
25+
PHP buildconf
26+
27+
A wrapper around the autoconf and autoheader that generate files for building
28+
PHP on *nix systems (configure, main/php_config.h.in, aclocal.m4...). The
29+
configure script is used to customize the PHP build based on the provided
30+
options and system. PHP releases downloaded from PHP.net already include the
31+
configure script so installing Autoconf and running buildconf is not needed. For
32+
the PHP sources from the Git repository, buildconf is used for generating a new
33+
configure script and required files.
34+
35+
SYNOPSIS:
36+
buildconf [<options>]
37+
38+
OPTIONS:
39+
--force Clean cache and overwrite configure files.
40+
--debug Display warnings emitted by Autoconf.
41+
-h, --help Display this help.
42+
43+
ENVIRONMENT:
44+
The following optional variables are supported:
45+
46+
MAKE Overrides the path to make tool.
47+
MAKE=/path/to/make ./buildconf
48+
PHP_AUTOCONF Overrides the path to autoconf tool.
49+
PHP_AUTOCONF=/path/to/autoconf ./buildconf
50+
PHP_AUTOHEADER Overrides the path to autoheader tool.
51+
PHP_AUTOHEADER=/path/to/autoheader ./buildconf
52+
HELP
53+
exit 0
54+
fi
55+
1756
if test "$1" = "--force"; then
18-
devok=1
19-
echo "Forcing buildconf"
57+
force=1
2058
fi
2159

2260
if test "$1" = "--debug"; then
23-
debug=yes
61+
debug=1
2462
fi
2563

2664
shift
2765
done
2866

29-
if test "$dev" = "0" -a "$devok" = "0"; then
30-
echo "You should not run buildconf in a release package." >&2
31-
echo "use buildconf --force to override this check." >&2
67+
if test "$dev" = "0" -a "$force" = "0"; then
68+
if test -f "configure"; then
69+
echo "The configure script has already been built for you. All done."
70+
echo "Run ./configure to proceed with customizing the PHP build."
71+
exit 0
72+
else
73+
echo "Configure script is missing." >&2
74+
echo "Run ./buildconf --force to create a configure script." >&2
75+
exit 1
76+
fi
77+
fi
78+
79+
# Check if make exists.
80+
if ! test -x "$(command -v $MAKE)"; then
81+
echo "buildconf: make not found." >&2
82+
echo " You need to have make installed to build PHP." >&2
3283
exit 1
3384
fi
3485

35-
if test "$devok" = "1"; then
36-
echo "Removing configure caches"
86+
if test "$force" = "1"; then
87+
echo "buildconf: Forcing buildconf"
88+
echo "buildconf: Removing configure caches"
3789
rm -rf autom4te.cache config.cache
3890
fi
3991

92+
echo "buildconf: Building configure files"
93+
4094
rm -f generated_lists
4195

42-
if test "$debug" = "yes"; then
43-
${MAKE:-make} -s -f build/build.mk SUPPRESS_WARNINGS=""
96+
if test "$debug" = "1"; then
97+
$MAKE -s -f build/build.mk SUPPRESS_WARNINGS=""
4498
else
45-
${MAKE:-make} -s -f build/build.mk
99+
$MAKE -s -f build/build.mk
46100
fi

0 commit comments

Comments
 (0)