From 02215c3b2b605eff71e14109056199c68bdca2e3 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sat, 7 Sep 2024 05:47:26 +0200 Subject: [PATCH] Autotools: Simplify PHP_ADD_BUILD_DIR and ext_* variables usage The ext_builddir, ext_srdir, and ext_dir variables for the current extension are set after the PHP_NEW_EXTENSION is called. This now assignes them in config-stubs and phpize before including the extension's or SAPI+'s config m4 file' For example, this enables calling PHP_ADD_BUILD_DIR and some other macros before the PHP_NEW_EXTENSION and removes some redundant conditions. This also fixes missed bug in gd extension include flag. --- UPGRADING.INTERNALS | 3 +++ build/config-stubs | 9 ++++++--- build/php.m4 | 4 ---- ext/hash/config.m4 | 3 +-- ext/mbstring/config.m4 | 26 +++++++++++--------------- ext/opcache/config.m4 | 14 +++++++------- scripts/phpize.m4 | 14 ++++++++------ 7 files changed, 36 insertions(+), 37 deletions(-) diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS index ea0be872843a3..c2fadaa23e1d5 100644 --- a/UPGRADING.INTERNALS +++ b/UPGRADING.INTERNALS @@ -227,6 +227,9 @@ PHP 8.4 INTERNALS UPGRADE NOTES - ac_cv_write_stdout -> php_cv_have_write_stdout and all other checks wrapped with their belonging cache variables (see *.m4 source files for details). + - The ext_builddir, ext_srcdir, and ext_dir variables are now set before + calling the PHP_NEW_EXTENSION macro, enabling their usage anywhere in the + current config.m4 file. c. Windows build system changes - The configure options --with-oci8-11g, --with-oci8-12c, --with-oci8-19, diff --git a/build/config-stubs b/build/config-stubs index 6d8d3c1ea1e7e..e8a1ad9daae42 100755 --- a/build/config-stubs +++ b/build/config-stubs @@ -3,8 +3,11 @@ dir=$1; shift for stubfile in $dir/*/config0.m4 $dir/*/config.m4 $dir/*/config9.m4; do echo "dnl Define where extension directories are located in the configure context -AC_DEFUN([PHP_EXT_BUILDDIR], [$(dirname $stubfile)]) -AC_DEFUN([PHP_EXT_DIR], [$(dirname $stubfile)]) -AC_DEFUN([PHP_EXT_SRCDIR], [\$abs_srcdir/$(dirname $stubfile)]) +ext_builddir=$(dirname $stubfile) +ext_dir=$(dirname $stubfile) +ext_srcdir=\$abs_srcdir/$(dirname $stubfile) +AC_DEFUN([PHP_EXT_BUILDDIR], [\$ext_builddir]) +AC_DEFUN([PHP_EXT_DIR], [\$ext_dir]) +AC_DEFUN([PHP_EXT_SRCDIR], [\$ext_srcdir]) sinclude($stubfile)" done diff --git a/build/php.m4 b/build/php.m4 index aa8057fa5ff52..9f51c317bf601 100644 --- a/build/php.m4 +++ b/build/php.m4 @@ -936,10 +936,6 @@ dnl substituted. dnl "cxx" can be used to indicate that a C++ shared module is desired. dnl "zend_ext" indicates a zend extension. AC_DEFUN([PHP_NEW_EXTENSION],[ - ext_builddir=[]PHP_EXT_BUILDDIR() - ext_srcdir=[]PHP_EXT_SRCDIR() - ext_dir=[]PHP_EXT_DIR() - ifelse($5,,ac_extra=,[ac_extra=$(echo "m4_normalize(m4_expand([$5]))"|$SED s#@ext_srcdir@#$ext_srcdir#g|$SED s#@ext_builddir@#$ext_builddir#g)]) if test "$3" != "shared" && test "$3" != "yes" && test "$4" != "cli"; then diff --git a/ext/hash/config.m4 b/ext/hash/config.m4 index 1eef801a2fea8..8a23b86920767 100644 --- a/ext/hash/config.m4 +++ b/ext/hash/config.m4 @@ -13,7 +13,6 @@ AS_VAR_IF([ac_cv_c_bigendian_php], [yes], [ AC_DEFINE([HAVE_SLOW_HASH3], [1], [Define to 1 if the PHP hash extension uses the slow SHA3 algorithm.]) AC_MSG_WARN([Using SHA3 slow implementation on bigendian]) - SHA3_DIR= ], [ AC_CHECK_SIZEOF([long]) AC_MSG_CHECKING([if we're at 64-bit platform]) @@ -32,6 +31,7 @@ AS_VAR_IF([ac_cv_c_bigendian_php], [yes], [ ]) EXT_HASH_SHA3_SOURCES="$SHA3_OPT_SRC $SHA3_DIR/KeccakHash.c $SHA3_DIR/KeccakSponge.c" PHP_HASH_CFLAGS="$PHP_HASH_CFLAGS -I@ext_srcdir@/$SHA3_DIR -DKeccakP200_excluded -DKeccakP400_excluded -DKeccakP800_excluded -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1" + PHP_ADD_BUILD_DIR([$ext_builddir/$SHA3_DIR]) ]) PHP_NEW_EXTENSION([hash], m4_normalize([ @@ -60,7 +60,6 @@ PHP_NEW_EXTENSION([hash], m4_normalize([ [no],, [$PHP_HASH_CFLAGS]) PHP_ADD_BUILD_DIR([$ext_builddir/murmur]) -AS_VAR_IF([SHA3_DIR],,, [PHP_ADD_BUILD_DIR([$ext_builddir/$SHA3_DIR])]) PHP_INSTALL_HEADERS([ext/hash], m4_normalize([ php_hash_adler32.h php_hash_crc32.h diff --git a/ext/mbstring/config.m4 b/ext/mbstring/config.m4 index b526db0b200c0..413ffb96327bb 100644 --- a/ext/mbstring/config.m4 +++ b/ext/mbstring/config.m4 @@ -6,10 +6,6 @@ AC_DEFUN([PHP_MBSTRING_ADD_BASE_SOURCES], [ PHP_MBSTRING_BASE_SOURCES="$PHP_MBSTRING_BASE_SOURCES $1" ]) -AC_DEFUN([PHP_MBSTRING_ADD_BUILD_DIR], [ - PHP_MBSTRING_EXTRA_BUILD_DIRS="$PHP_MBSTRING_EXTRA_BUILD_DIRS $1" -]) - AC_DEFUN([PHP_MBSTRING_ADD_INCLUDE], [ PHP_MBSTRING_EXTRA_INCLUDES="$PHP_MBSTRING_EXTRA_INCLUDES $1" ]) @@ -25,10 +21,6 @@ AC_DEFUN([PHP_MBSTRING_EXTENSION], [ [$PHP_MBSTRING_CFLAGS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1]) PHP_SUBST([MBSTRING_SHARED_LIBADD]) - for dir in $PHP_MBSTRING_EXTRA_BUILD_DIRS; do - PHP_ADD_BUILD_DIR([$ext_builddir/$dir], [1]) - done - for dir in $PHP_MBSTRING_EXTRA_INCLUDES; do PHP_ADD_INCLUDE([$ext_srcdir/$dir]) PHP_ADD_INCLUDE([$ext_builddir/$dir]) @@ -83,14 +75,18 @@ AC_DEFUN([PHP_MBSTRING_SETUP_MBREGEX], [ fi ]) +dnl +dnl PHP_MBSTRING_SETUP_LIBMBFL +dnl +dnl Setup the required bundled libmbfl. +dnl AC_DEFUN([PHP_MBSTRING_SETUP_LIBMBFL], [ - dnl - dnl Bundled libmbfl is required and can not be disabled - dnl - PHP_MBSTRING_ADD_BUILD_DIR([libmbfl]) - PHP_MBSTRING_ADD_BUILD_DIR([libmbfl/mbfl]) - PHP_MBSTRING_ADD_BUILD_DIR([libmbfl/filters]) - PHP_MBSTRING_ADD_BUILD_DIR([libmbfl/nls]) + PHP_ADD_BUILD_DIR([$ext_builddir/libmbfl], [1]) + PHP_ADD_BUILD_DIR([ + $ext_builddir/libmbfl/filters + $ext_builddir/libmbfl/mbfl + $ext_builddir/libmbfl/nls + ]) PHP_MBSTRING_ADD_INCLUDE([libmbfl]) PHP_MBSTRING_ADD_INCLUDE([libmbfl/mbfl]) diff --git a/ext/opcache/config.m4 b/ext/opcache/config.m4 index 8f6d5ab711b28..027e76499ab1d 100644 --- a/ext/opcache/config.m4 +++ b/ext/opcache/config.m4 @@ -102,6 +102,11 @@ if test "$PHP_OPCACHE" != "no"; then JIT_CFLAGS="-I@ext_builddir@/jit/ir -D$IR_TARGET -DIR_PHP" AS_VAR_IF([ZEND_DEBUG], [yes], [JIT_CFLAGS="$JIT_CFLAGS -DIR_DEBUG"]) + + PHP_ADD_BUILD_DIR([ + $ext_builddir/jit + $ext_builddir/jit/ir + ]) ]) AC_CHECK_FUNCS([mprotect shm_create_largepage]) @@ -353,12 +358,7 @@ int main(void) { ])) fi - AS_VAR_IF([PHP_OPCACHE_JIT], [yes], [ - PHP_ADD_BUILD_DIR([ - $ext_builddir/jit - $ext_builddir/jit/ir - ]) - PHP_ADD_MAKEFILE_FRAGMENT([$ext_srcdir/jit/Makefile.frag]) - ]) + AS_VAR_IF([PHP_OPCACHE_JIT], [yes], + [PHP_ADD_MAKEFILE_FRAGMENT([$ext_srcdir/jit/Makefile.frag])]) PHP_SUBST([OPCACHE_SHARED_LIBADD]) fi diff --git a/scripts/phpize.m4 b/scripts/phpize.m4 index e59a1c03a5789..b536ce5d83322 100644 --- a/scripts/phpize.m4 +++ b/scripts/phpize.m4 @@ -16,18 +16,20 @@ AC_CONFIG_AUX_DIR([build]) AC_PRESERVE_HELP_ORDER PHP_CONFIG_NICE([config.nice]) +PHP_INIT_BUILD_SYSTEM -AC_DEFUN([PHP_EXT_BUILDDIR],[.])dnl -AC_DEFUN([PHP_EXT_DIR],[""])dnl -AC_DEFUN([PHP_EXT_SRCDIR],[$abs_srcdir])dnl -AC_DEFUN([PHP_ALWAYS_SHARED],[ +ext_builddir=. +ext_dir="" +ext_srcdir=$abs_srcdir +AC_DEFUN([PHP_EXT_BUILDDIR], [$ext_builddir])dnl +AC_DEFUN([PHP_EXT_DIR], [$ext_dir])dnl +AC_DEFUN([PHP_EXT_SRCDIR], [$ext_srcdir])dnl +AC_DEFUN([PHP_ALWAYS_SHARED], [ ext_output="yes, shared" ext_shared=yes test "[$]$1" = "no" && $1=yes ])dnl -PHP_INIT_BUILD_SYSTEM - PKG_PROG_PKG_CONFIG AC_PROG_CC([cc gcc]) PHP_DETECT_ICC