Skip to content

Commit 7edb9a0

Browse files
authored
Autotools: Normalize 2nd arg in PHP_ADD_SOURCES_X (#15088)
By using `m4_normalize(m4_expand([...]))`, the arguments can be split into newlines without using backslashes and it makes working with lists of files a bit easier. Tested: - variables inside the argument - M4 macro expansions - dnl comments - any sequence of newlines, backslash-then-newline, multiple spaces, tabs... - quoted/unquoted arguments This now works for PHP_NEW_EXTENSION, PHP_ADD_SOURCES, PHP_ADD_SOURCES_X, and PHP_SELECT_SAPI. The m4_normalize() usage is left in the php-src config.m4 files following the 0a0d2d0 for PECL extensions until phpize will be available on all supported versions (minimum PHP 8.4).
1 parent 8aaedbf commit 7edb9a0

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

UPGRADING.INTERNALS

+4
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ PHP 8.4 INTERNALS UPGRADE NOTES
188188
or backslash-then-newline.
189189
- M4 macro PHP_ADD_BUILD_DIR now also accepts 1st argument as a
190190
blank-or-newline-separated separated list.
191+
- M4 macros PHP_NEW_EXTENSION, PHP_ADD_SOURCES, PHP_ADD_SOURCES_X,
192+
PHP_SELECT_SAPI now have the source files arguments normalized so the list
193+
of files can be passed as blank-or-newline-separated list (including
194+
newlines, backslash-then-newline, or any sequence of spaces or tabs).
191195
- TSRM/tsrm.m4 file and its TSRM_CHECK_PTHREADS M4 macro have been removed.
192196
- Added pkg-config support to find libpq for the pdo_pgsql and pgsql
193197
extensions. The libpq paths can be customized with the PGSQL_CFLAGS and

build/php.m4

+12-9
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,10 @@ dnl
197197
dnl PHP_ADD_SOURCES(source-path, sources [, special-flags [, type]])
198198
dnl
199199
dnl Adds sources which are located relative to source-path to the array of type
200-
dnl type. Sources are processed with optional special-flags which are passed to
201-
dnl the compiler. Sources can be either written in C or C++ (filenames shall end
202-
dnl in .c or .cpp, respectively).
200+
dnl type. The blank-or-newline separated list of "sources" are processed with
201+
dnl optional special-flags which are passed to the compiler. Sources can be
202+
dnl either written in C or C++ (filenames shall end in .c or .cpp,
203+
dnl respectively).
203204
dnl
204205
dnl Note: If source-path begins with a "/", the "/" is removed and the path is
205206
dnl interpreted relative to the top build-directory.
@@ -239,7 +240,8 @@ dnl PHP_ADD_SOURCES_X(source-path, sources[, special-flags[, target-var[, shared
239240
dnl
240241
dnl Additional to PHP_ADD_SOURCES (see above), this lets you set the name of the
241242
dnl array target-var directly, as well as whether shared objects will be built
242-
dnl from the sources. Should not be used directly.
243+
dnl from the blank-or-newline-separated list of "sources". Should not be used
244+
dnl directly.
243245
dnl
244246
AC_DEFUN([PHP_ADD_SOURCES_X],[
245247
dnl Relative to source- or build-directory?
@@ -255,7 +257,7 @@ dnl how to build .. shared or static?
255257
256258
dnl Iterate over the sources.
257259
old_IFS=[$]IFS
258-
for ac_src in $2; do
260+
for ac_src in m4_normalize(m4_expand([$2])); do
259261
260262
dnl Remove the suffix.
261263
IFS=.
@@ -864,8 +866,9 @@ dnl PHP_SELECT_SAPI(name, type[, sources [, extra-cflags]])
864866
dnl
865867
dnl When developing PHP SAPI modules, this macro specifies the SAPI "name" by
866868
dnl its "type", how PHP is supposed to be built (static, shared, bundle, or
867-
dnl program). It optionally adds the source files "sources" and compilation
868-
dnl flags "extra-cflags" to build the SAPI-specific objects. For example:
869+
dnl program). It optionally adds the blank-or-newline-separated source files
870+
dnl "sources" and compilation flags "extra-cflags" to build the SAPI-specific
871+
dnl objects. For example:
869872
dnl PHP_SELECT_SAPI([apache2handler],
870873
dnl [shared],
871874
dnl [<sources...>],
@@ -936,8 +939,8 @@ dnl
936939
dnl Includes an extension in the build.
937940
dnl
938941
dnl "extname" is the name of the extension.
939-
dnl "sources" is a list of files relative to the subdir which are used to build
940-
dnl the extension.
942+
dnl "sources" is a blank-or-newline-separated list of source files relative to
943+
dnl the subdir which are used to build the extension.
941944
dnl "shared" can be set to "shared" or "yes" to build the extension as a
942945
dnl dynamically loadable library. Optional parameter "sapi_class" can be set to
943946
dnl "cli" to mark extension build only with CLI or CGI sapi's. "extra-cflags"

0 commit comments

Comments
 (0)