Skip to content

Commit 5022f5c

Browse files
committed
Autotools: Normalize 2nd arg in PHP_ADD_SOURCES_X
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
1 parent 2b97c84 commit 5022f5c

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

UPGRADING.INTERNALS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ PHP 8.4 INTERNALS UPGRADE NOTES
173173
checks.
174174
- M4 macro PHP_SETUP_LIBXML doesn't define the redundant HAVE_LIBXML symbol
175175
anymore.
176+
- M4 macros PHP_NEW_EXTENSION, PHP_ADD_SOURCES, PHP_ADD_SOURCES_X,
177+
PHP_SELECT_SAPI now have the source files arguments normalized so the list
178+
of files can be passed as blank-or-newline-separated list (including
179+
newlines, backslash-then-newline, or any sequence of spaces or tabs).
176180
- TSRM/tsrm.m4 file and its TSRM_CHECK_PTHREADS M4 macro have been removed.
177181
- Added pkg-config support to find libpq for the pdo_pgsql and pgsql
178182
extensions. The libpq paths can be customized with the PGSQL_CFLAGS and

build/php.m4

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,10 @@ dnl
181181
dnl PHP_ADD_SOURCES(source-path, sources [, special-flags [, type]])
182182
dnl
183183
dnl Adds sources which are located relative to source-path to the array of type
184-
dnl type. Sources are processed with optional special-flags which are passed to
185-
dnl the compiler. Sources can be either written in C or C++ (filenames shall end
186-
dnl in .c or .cpp, respectively).
184+
dnl type. The blank-or-newline separated list of "sources" are processed with
185+
dnl optional special-flags which are passed to the compiler. Sources can be
186+
dnl either written in C or C++ (filenames shall end in .c or .cpp,
187+
dnl respectively).
187188
dnl
188189
dnl Note: If source-path begins with a "/", the "/" is removed and the path is
189190
dnl interpreted relative to the top build-directory.
@@ -223,7 +224,8 @@ dnl PHP_ADD_SOURCES_X(source-path, sources[, special-flags[, target-var[, shared
223224
dnl
224225
dnl Additional to PHP_ADD_SOURCES (see above), this lets you set the name of the
225226
dnl array target-var directly, as well as whether shared objects will be built
226-
dnl from the sources. Should not be used directly.
227+
dnl from the blank-or-newline-separated list of "sources". Should not be used
228+
dnl directly.
227229
dnl
228230
AC_DEFUN([PHP_ADD_SOURCES_X],[
229231
dnl Relative to source- or build-directory?
@@ -239,7 +241,7 @@ dnl how to build .. shared or static?
239241
240242
dnl Iterate over the sources.
241243
old_IFS=[$]IFS
242-
for ac_src in $2; do
244+
for ac_src in m4_normalize(m4_expand([$2])); do
243245
244246
dnl Remove the suffix.
245247
IFS=.
@@ -848,8 +850,9 @@ dnl PHP_SELECT_SAPI(name, type[, sources [, extra-cflags]])
848850
dnl
849851
dnl When developing PHP SAPI modules, this macro specifies the SAPI "name" by
850852
dnl its "type", how PHP is supposed to be built (static, shared, bundle, or
851-
dnl program). It optionally adds the source files "sources" and compilation
852-
dnl flags "extra-cflags" to build the SAPI-specific objects. For example:
853+
dnl program). It optionally adds the blank-or-newline-separated source files
854+
dnl "sources" and compilation flags "extra-cflags" to build the SAPI-specific
855+
dnl objects. For example:
853856
dnl PHP_SELECT_SAPI([apache2handler],
854857
dnl [shared],
855858
dnl [<sources...>],
@@ -917,8 +920,8 @@ dnl
917920
dnl Includes an extension in the build.
918921
dnl
919922
dnl "extname" is the name of the extension.
920-
dnl "sources" is a list of files relative to the subdir which are used to build
921-
dnl the extension.
923+
dnl "sources" is a blank-or-newline-separated list of source files relative to
924+
dnl the subdir which are used to build the extension.
922925
dnl "shared" can be set to "shared" or "yes" to build the extension as a
923926
dnl dynamically loadable library. Optional parameter "sapi_class" can be set to
924927
dnl "cli" to mark extension build only with CLI or CGI sapi's. "extra-cflags"

0 commit comments

Comments
 (0)