Skip to content

Commit 02215c3

Browse files
committed
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.
1 parent 047f0c9 commit 02215c3

File tree

7 files changed

+36
-37
lines changed

7 files changed

+36
-37
lines changed

UPGRADING.INTERNALS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ PHP 8.4 INTERNALS UPGRADE NOTES
227227
- ac_cv_write_stdout -> php_cv_have_write_stdout
228228
and all other checks wrapped with their belonging cache variables (see *.m4
229229
source files for details).
230+
- The ext_builddir, ext_srcdir, and ext_dir variables are now set before
231+
calling the PHP_NEW_EXTENSION macro, enabling their usage anywhere in the
232+
current config.m4 file.
230233

231234
c. Windows build system changes
232235
- The configure options --with-oci8-11g, --with-oci8-12c, --with-oci8-19,

build/config-stubs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
dir=$1; shift
44
for stubfile in $dir/*/config0.m4 $dir/*/config.m4 $dir/*/config9.m4; do
55
echo "dnl Define where extension directories are located in the configure context
6-
AC_DEFUN([PHP_EXT_BUILDDIR], [$(dirname $stubfile)])
7-
AC_DEFUN([PHP_EXT_DIR], [$(dirname $stubfile)])
8-
AC_DEFUN([PHP_EXT_SRCDIR], [\$abs_srcdir/$(dirname $stubfile)])
6+
ext_builddir=$(dirname $stubfile)
7+
ext_dir=$(dirname $stubfile)
8+
ext_srcdir=\$abs_srcdir/$(dirname $stubfile)
9+
AC_DEFUN([PHP_EXT_BUILDDIR], [\$ext_builddir])
10+
AC_DEFUN([PHP_EXT_DIR], [\$ext_dir])
11+
AC_DEFUN([PHP_EXT_SRCDIR], [\$ext_srcdir])
912
sinclude($stubfile)"
1013
done

build/php.m4

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -936,10 +936,6 @@ dnl substituted.
936936
dnl "cxx" can be used to indicate that a C++ shared module is desired.
937937
dnl "zend_ext" indicates a zend extension.
938938
AC_DEFUN([PHP_NEW_EXTENSION],[
939-
ext_builddir=[]PHP_EXT_BUILDDIR()
940-
ext_srcdir=[]PHP_EXT_SRCDIR()
941-
ext_dir=[]PHP_EXT_DIR()
942-
943939
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)])
944940
945941
if test "$3" != "shared" && test "$3" != "yes" && test "$4" != "cli"; then

ext/hash/config.m4

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ AS_VAR_IF([ac_cv_c_bigendian_php], [yes], [
1313
AC_DEFINE([HAVE_SLOW_HASH3], [1],
1414
[Define to 1 if the PHP hash extension uses the slow SHA3 algorithm.])
1515
AC_MSG_WARN([Using SHA3 slow implementation on bigendian])
16-
SHA3_DIR=
1716
], [
1817
AC_CHECK_SIZEOF([long])
1918
AC_MSG_CHECKING([if we're at 64-bit platform])
@@ -32,6 +31,7 @@ AS_VAR_IF([ac_cv_c_bigendian_php], [yes], [
3231
])
3332
EXT_HASH_SHA3_SOURCES="$SHA3_OPT_SRC $SHA3_DIR/KeccakHash.c $SHA3_DIR/KeccakSponge.c"
3433
PHP_HASH_CFLAGS="$PHP_HASH_CFLAGS -I@ext_srcdir@/$SHA3_DIR -DKeccakP200_excluded -DKeccakP400_excluded -DKeccakP800_excluded -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
34+
PHP_ADD_BUILD_DIR([$ext_builddir/$SHA3_DIR])
3535
])
3636

3737
PHP_NEW_EXTENSION([hash], m4_normalize([
@@ -60,7 +60,6 @@ PHP_NEW_EXTENSION([hash], m4_normalize([
6060
[no],,
6161
[$PHP_HASH_CFLAGS])
6262
PHP_ADD_BUILD_DIR([$ext_builddir/murmur])
63-
AS_VAR_IF([SHA3_DIR],,, [PHP_ADD_BUILD_DIR([$ext_builddir/$SHA3_DIR])])
6463
PHP_INSTALL_HEADERS([ext/hash], m4_normalize([
6564
php_hash_adler32.h
6665
php_hash_crc32.h

ext/mbstring/config.m4

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ AC_DEFUN([PHP_MBSTRING_ADD_BASE_SOURCES], [
66
PHP_MBSTRING_BASE_SOURCES="$PHP_MBSTRING_BASE_SOURCES $1"
77
])
88

9-
AC_DEFUN([PHP_MBSTRING_ADD_BUILD_DIR], [
10-
PHP_MBSTRING_EXTRA_BUILD_DIRS="$PHP_MBSTRING_EXTRA_BUILD_DIRS $1"
11-
])
12-
139
AC_DEFUN([PHP_MBSTRING_ADD_INCLUDE], [
1410
PHP_MBSTRING_EXTRA_INCLUDES="$PHP_MBSTRING_EXTRA_INCLUDES $1"
1511
])
@@ -25,10 +21,6 @@ AC_DEFUN([PHP_MBSTRING_EXTENSION], [
2521
[$PHP_MBSTRING_CFLAGS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
2622
PHP_SUBST([MBSTRING_SHARED_LIBADD])
2723
28-
for dir in $PHP_MBSTRING_EXTRA_BUILD_DIRS; do
29-
PHP_ADD_BUILD_DIR([$ext_builddir/$dir], [1])
30-
done
31-
3224
for dir in $PHP_MBSTRING_EXTRA_INCLUDES; do
3325
PHP_ADD_INCLUDE([$ext_srcdir/$dir])
3426
PHP_ADD_INCLUDE([$ext_builddir/$dir])
@@ -83,14 +75,18 @@ AC_DEFUN([PHP_MBSTRING_SETUP_MBREGEX], [
8375
fi
8476
])
8577

78+
dnl
79+
dnl PHP_MBSTRING_SETUP_LIBMBFL
80+
dnl
81+
dnl Setup the required bundled libmbfl.
82+
dnl
8683
AC_DEFUN([PHP_MBSTRING_SETUP_LIBMBFL], [
87-
dnl
88-
dnl Bundled libmbfl is required and can not be disabled
89-
dnl
90-
PHP_MBSTRING_ADD_BUILD_DIR([libmbfl])
91-
PHP_MBSTRING_ADD_BUILD_DIR([libmbfl/mbfl])
92-
PHP_MBSTRING_ADD_BUILD_DIR([libmbfl/filters])
93-
PHP_MBSTRING_ADD_BUILD_DIR([libmbfl/nls])
84+
PHP_ADD_BUILD_DIR([$ext_builddir/libmbfl], [1])
85+
PHP_ADD_BUILD_DIR([
86+
$ext_builddir/libmbfl/filters
87+
$ext_builddir/libmbfl/mbfl
88+
$ext_builddir/libmbfl/nls
89+
])
9490
PHP_MBSTRING_ADD_INCLUDE([libmbfl])
9591
PHP_MBSTRING_ADD_INCLUDE([libmbfl/mbfl])
9692

ext/opcache/config.m4

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ if test "$PHP_OPCACHE" != "no"; then
102102
103103
JIT_CFLAGS="-I@ext_builddir@/jit/ir -D$IR_TARGET -DIR_PHP"
104104
AS_VAR_IF([ZEND_DEBUG], [yes], [JIT_CFLAGS="$JIT_CFLAGS -DIR_DEBUG"])
105+
106+
PHP_ADD_BUILD_DIR([
107+
$ext_builddir/jit
108+
$ext_builddir/jit/ir
109+
])
105110
])
106111

107112
AC_CHECK_FUNCS([mprotect shm_create_largepage])
@@ -353,12 +358,7 @@ int main(void) {
353358
]))
354359
fi
355360

356-
AS_VAR_IF([PHP_OPCACHE_JIT], [yes], [
357-
PHP_ADD_BUILD_DIR([
358-
$ext_builddir/jit
359-
$ext_builddir/jit/ir
360-
])
361-
PHP_ADD_MAKEFILE_FRAGMENT([$ext_srcdir/jit/Makefile.frag])
362-
])
361+
AS_VAR_IF([PHP_OPCACHE_JIT], [yes],
362+
[PHP_ADD_MAKEFILE_FRAGMENT([$ext_srcdir/jit/Makefile.frag])])
363363
PHP_SUBST([OPCACHE_SHARED_LIBADD])
364364
fi

scripts/phpize.m4

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,20 @@ AC_CONFIG_AUX_DIR([build])
1616
AC_PRESERVE_HELP_ORDER
1717

1818
PHP_CONFIG_NICE([config.nice])
19+
PHP_INIT_BUILD_SYSTEM
1920

20-
AC_DEFUN([PHP_EXT_BUILDDIR],[.])dnl
21-
AC_DEFUN([PHP_EXT_DIR],[""])dnl
22-
AC_DEFUN([PHP_EXT_SRCDIR],[$abs_srcdir])dnl
23-
AC_DEFUN([PHP_ALWAYS_SHARED],[
21+
ext_builddir=.
22+
ext_dir=""
23+
ext_srcdir=$abs_srcdir
24+
AC_DEFUN([PHP_EXT_BUILDDIR], [$ext_builddir])dnl
25+
AC_DEFUN([PHP_EXT_DIR], [$ext_dir])dnl
26+
AC_DEFUN([PHP_EXT_SRCDIR], [$ext_srcdir])dnl
27+
AC_DEFUN([PHP_ALWAYS_SHARED], [
2428
ext_output="yes, shared"
2529
ext_shared=yes
2630
test "[$]$1" = "no" && $1=yes
2731
])dnl
2832

29-
PHP_INIT_BUILD_SYSTEM
30-
3133
PKG_PROG_PKG_CONFIG
3234
AC_PROG_CC([cc gcc])
3335
PHP_DETECT_ICC

0 commit comments

Comments
 (0)