php-src/buildconf
Peter Kokot 4e7064d173 Move acinclude.m4 to build/php.m4
The acinclude.m4 file is in a usual Autotools build processed with
Automake's aclocal tool. Since PHP currently doesn't use Automake and
aclocal this file can be moved into the build directory. PHP build
system currently generates a combined aclocal.m4 file that Autoconf
can processes automatically.

However, a newer practice is writing all local macros in separate
dedicated files prefixed with package name, in PHP's case PHP_MACRO_NAME
and putting them in a common `m4` directory. PHP uses currently `build`
directory for this purpose.

Name `php.m4` probably most resembles such file for PHP's case.

PHP manually created the aclocal.m4 file from acinclude.m4 and
build/libtool.m4. Which is also not a particularly good practice [1], so
this patch also removes the generated alocal.m4 usage and uses
m4_include() calls manually in the configure.ac and phpize.m4 files
manually.

- sort order is not important but can be alphabetical
- list of *.m4 files prerequisites for configure script generation
  updated
- Moving m4_include() before AC_INIT also removes all comments starting
  with hash character (`#`) in the included files.

[1] https://autotools.io/autoconf/macros.html
2019-04-23 20:28:45 +02:00

107 lines
2.8 KiB
Bash
Executable File

#!/bin/sh
#
# A wrapper around Autoconf that generates files to build PHP on *nix systems.
MAKE=${MAKE:-make}
PHP_AUTOCONF=${PHP_AUTOCONF:-autoconf}
PHP_AUTOHEADER=${PHP_AUTOHEADER:-autoheader}
force=0
debug=0
# Go to project root.
cd $(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)
php_extra_version=$(grep '^AC_INIT(' configure.ac)
case "$php_extra_version" in
*-dev*)
dev=1
;;
*)
dev=0
;;
esac
while test $# -gt 0; do
if test "$1" = "-h" || test "$1" = "--help"; then
cat << HELP
PHP buildconf
A wrapper around the autoconf and autoheader that generate files for building
PHP on *nix systems (configure and main/php_config.h.in). The configure script
is used to customize the PHP build based on the provided options and system. PHP
releases downloaded from PHP.net already include the configure script so
installing Autoconf and running buildconf is not needed. For the PHP sources
from the Git repository, buildconf is used for generating a new configure script
and required files.
SYNOPSIS:
buildconf [<options>]
OPTIONS:
--force Clean cache and overwrite configure files.
--debug Display warnings emitted by Autoconf.
-h, --help Display this help.
ENVIRONMENT:
The following optional variables are supported:
MAKE Overrides the path to make tool.
MAKE=/path/to/make ./buildconf
PHP_AUTOCONF Overrides the path to autoconf tool.
PHP_AUTOCONF=/path/to/autoconf ./buildconf
PHP_AUTOHEADER Overrides the path to autoheader tool.
PHP_AUTOHEADER=/path/to/autoheader ./buildconf
HELP
exit 0
fi
if test "$1" = "--force"; then
force=1
fi
if test "$1" = "--debug"; then
debug=1
fi
shift
done
if test "$dev" = "0" -a "$force" = "0"; then
if test -f "configure"; then
echo "The configure script has already been built for you. All done."
echo "Run ./configure to proceed with customizing the PHP build."
exit 0
else
echo "Configure script is missing." >&2
echo "Run ./buildconf --force to create a configure script." >&2
exit 1
fi
fi
# Check if make exists.
if ! test -x "$(command -v $MAKE)"; then
echo "buildconf: make not found." >&2
echo " You need to have make installed to build PHP." >&2
exit 1
fi
if test "$force" = "1"; then
echo "buildconf: Forcing buildconf"
echo "buildconf: Removing configure caches"
rm -rf autom4te.cache config.cache
fi
echo "buildconf: Building configure files"
if test "$debug" = "1"; then
autoconf_flags="-f -Wall"
else
autoconf_flags="-f"
fi
$MAKE -s -f build/build.mk \
PHP_AUTOCONF="$PHP_AUTOCONF" \
PHP_AUTOHEADER="$PHP_AUTOHEADER" \
PHP_AUTOCONF_FLAGS="$autoconf_flags" \
PHP_M4_FILES="$(echo TSRM/*.m4 Zend/Zend.m4 build/*.m4 ext/*/config*.m4 sapi/*/config*.m4)"