Skip to content

Commit

Permalink
Autotools: Normalize and quote all PHP_NEW_EXTENSION arguments (php#1…
Browse files Browse the repository at this point in the history
…5144)

This adds Autoconf quote characters to all PHP_NEW_EXTENSION arguments
and syncs the CS across the php-src Autotools build system.
  • Loading branch information
petk authored Jul 28, 2024
1 parent f0788da commit 1ceadae
Show file tree
Hide file tree
Showing 53 changed files with 346 additions and 213 deletions.
4 changes: 2 additions & 2 deletions docs-old/self-contained-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ PHP_ARG_ENABLE([foobar],
[Enable foobar])])
if test "$PHP_FOOBAR" != "no"; then
PHP_NEW_EXTENSION(foobar, foo.c bar.c, $ext_shared)
PHP_NEW_EXTENSION([foobar], [foo.c bar.c], [$ext_shared])
fi
```

Expand Down Expand Up @@ -145,7 +145,7 @@ an existing module called `foo`.
automatically be able to use `--with-foo=shared[,..]` or
`--enable-foo=shared[,..]`.

2. In `config.m4`, use `PHP_NEW_EXTENSION(foo,.., $ext_shared)` to enable
2. In `config.m4`, use `PHP_NEW_EXTENSION([foo],.., [$ext_shared])` to enable
building the extension.

3. Add the following lines to your C source file:
Expand Down
4 changes: 2 additions & 2 deletions docs-old/unix-build-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Makefile.ins are abandoned. The files which are to be compiled are specified in
the `config.m4` now using the following macro:

```m4
PHP_NEW_EXTENSION(foo, foo.c bar.c baz.cpp, $ext_shared)
PHP_NEW_EXTENSION([foo], [foo.c bar.c baz.cpp], [$ext_shared])
```

E.g. this enables the extension foo which consists of three source-code modules,
Expand All @@ -61,7 +61,7 @@ here as well. If you need to specify separate include directories, do it this
way:

```m4
PHP_NEW_EXTENSION(foo, foo.c mylib/bar.c mylib/gregor.c,,,-I@ext_srcdir@/lib)
PHP_NEW_EXTENSION([foo], [foo.c mylib/bar.c mylib/gregor.c],,, [-I@ext_srcdir@/lib])
```

E.g. this builds the three files which are located relative to the extension
Expand Down
52 changes: 26 additions & 26 deletions ext/bcmath/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@ PHP_ARG_ENABLE([bcmath],

if test "$PHP_BCMATH" != "no"; then
PHP_NEW_EXTENSION([bcmath], m4_normalize([
bcmath.c
libbcmath/src/add.c
libbcmath/src/compare.c
libbcmath/src/convert.c
libbcmath/src/div.c
libbcmath/src/divmod.c
libbcmath/src/doaddsub.c
libbcmath/src/floor_or_ceil.c
libbcmath/src/init.c
libbcmath/src/int2num.c
libbcmath/src/nearzero.c
libbcmath/src/neg.c
libbcmath/src/num2long.c
libbcmath/src/num2str.c
libbcmath/src/raise.c
libbcmath/src/raisemod.c
libbcmath/src/recmul.c
libbcmath/src/rmzero.c
libbcmath/src/round.c
libbcmath/src/sqrt.c
libbcmath/src/str2num.c
libbcmath/src/sub.c
libbcmath/src/zero.c
]),
[$ext_shared],,
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
bcmath.c
libbcmath/src/add.c
libbcmath/src/compare.c
libbcmath/src/convert.c
libbcmath/src/div.c
libbcmath/src/divmod.c
libbcmath/src/doaddsub.c
libbcmath/src/floor_or_ceil.c
libbcmath/src/init.c
libbcmath/src/int2num.c
libbcmath/src/nearzero.c
libbcmath/src/neg.c
libbcmath/src/num2long.c
libbcmath/src/num2str.c
libbcmath/src/raise.c
libbcmath/src/raisemod.c
libbcmath/src/recmul.c
libbcmath/src/rmzero.c
libbcmath/src/round.c
libbcmath/src/sqrt.c
libbcmath/src/str2num.c
libbcmath/src/sub.c
libbcmath/src/zero.c
]),
[$ext_shared],,
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
PHP_ADD_BUILD_DIR([$ext_builddir/libbcmath/src])
AC_DEFINE(HAVE_BCMATH, 1, [Whether you have bcmath])
fi
2 changes: 1 addition & 1 deletion ext/bz2/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ if test "$PHP_BZ2" != "no"; then
[AC_MSG_ERROR([bz2 module requires libbz2 >= 1.0.0])],
[-L$BZIP_DIR/$PHP_LIBDIR])

PHP_NEW_EXTENSION(bz2, bz2.c bz2_filter.c, $ext_shared)
PHP_NEW_EXTENSION([bz2], [bz2.c bz2_filter.c], [$ext_shared])
PHP_SUBST([BZ2_SHARED_LIBADD])
fi
4 changes: 3 additions & 1 deletion ext/calendar/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ PHP_ARG_ENABLE([calendar],

if test "$PHP_CALENDAR" = "yes"; then
AC_DEFINE(HAVE_CALENDAR,1,[ ])
PHP_NEW_EXTENSION(calendar, calendar.c dow.c french.c gregor.c jewish.c julian.c easter.c cal_unix.c, $ext_shared)
PHP_NEW_EXTENSION([calendar],
[calendar.c dow.c french.c gregor.c jewish.c julian.c easter.c cal_unix.c],
[$ext_shared])
fi
2 changes: 1 addition & 1 deletion ext/ctype/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ PHP_ARG_ENABLE([ctype],

if test "$PHP_CTYPE" != "no"; then
AC_DEFINE(HAVE_CTYPE, 1, [ ])
PHP_NEW_EXTENSION(ctype, ctype.c, $ext_shared)
PHP_NEW_EXTENSION([ctype], [ctype.c], [$ext_shared])
fi
5 changes: 4 additions & 1 deletion ext/date/config0.m4
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ PHP_DATE_CFLAGS="$PHP_DATE_CFLAGS -I@ext_builddir@/lib -DZEND_ENABLE_STATIC_TSRM
timelib_sources="lib/astro.c lib/dow.c lib/parse_date.c lib/parse_tz.c lib/parse_posix.c
lib/timelib.c lib/tm2unixtime.c lib/unixtime2tm.c lib/parse_iso_intervals.c lib/interval.c"

PHP_NEW_EXTENSION(date, php_date.c $timelib_sources, no,, $PHP_DATE_CFLAGS)
PHP_NEW_EXTENSION([date],
[php_date.c $timelib_sources],
[no],,
[$PHP_DATE_CFLAGS])

PHP_ADD_BUILD_DIR([$ext_builddir/lib], [1])
PHP_ADD_INCLUDE([$ext_builddir/lib])
Expand Down
22 changes: 21 additions & 1 deletion ext/dba/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,27 @@ if test "$HAVE_DBA" = "1"; then
AC_MSG_RESULT([yes])
fi
AC_DEFINE(HAVE_DBA, 1, [ ])
PHP_NEW_EXTENSION(dba, dba.c dba_cdb.c dba_dbm.c dba_gdbm.c dba_ndbm.c dba_db1.c dba_db2.c dba_db3.c dba_db4.c dba_flatfile.c dba_inifile.c dba_qdbm.c dba_tcadb.c dba_lmdb.c $cdb_sources $flat_sources $ini_sources, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
PHP_NEW_EXTENSION([dba], m4_normalize([
dba_cdb.c
dba_db1.c
dba_db2.c
dba_db3.c
dba_db4.c
dba_dbm.c
dba_flatfile.c
dba_gdbm.c
dba_inifile.c
dba_lmdb.c
dba_ndbm.c
dba_qdbm.c
dba_tcadb.c
dba.c
$cdb_sources
$flat_sources
$ini_sources
]),
[$ext_shared],,
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
PHP_ADD_BUILD_DIR([$ext_builddir/libcdb])
PHP_ADD_BUILD_DIR([$ext_builddir/libflatfile])
PHP_ADD_BUILD_DIR([$ext_builddir/libinifile])
Expand Down
5 changes: 4 additions & 1 deletion ext/dl_test/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ PHP_ARG_ENABLE([dl-test],
[Enable dl_test extension])])

if test "$PHP_DL_TEST" != "no"; then
PHP_NEW_EXTENSION(dl_test, dl_test.c, [shared],, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
PHP_NEW_EXTENSION([dl_test],
[dl_test.c],
[shared],,
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
fi
2 changes: 1 addition & 1 deletion ext/enchant/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ if test "$PHP_ENCHANT" != "no"; then

AC_DEFINE(HAVE_ENCHANT, 1, [ ])

PHP_NEW_EXTENSION(enchant, enchant.c, $ext_shared)
PHP_NEW_EXTENSION([enchant], [enchant.c], [$ext_shared])
PHP_SUBST([ENCHANT_SHARED_LIBADD])
fi
5 changes: 4 additions & 1 deletion ext/exif/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ PHP_ARG_ENABLE([exif],

if test "$PHP_EXIF" != "no"; then
AC_DEFINE(HAVE_EXIF, 1, [Whether you want EXIF (metadata from images) support])
PHP_NEW_EXTENSION(exif, exif.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
PHP_NEW_EXTENSION([exif],
[exif.c],
[$ext_shared],,
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
fi
5 changes: 4 additions & 1 deletion ext/ffi/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ if test "$PHP_FFI" != "no"; then
PHP_FFI_CHECK_DECL([FFI_MS_CDECL])
PHP_FFI_CHECK_DECL([FFI_SYSV])

PHP_NEW_EXTENSION(ffi, ffi.c ffi_parser.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
PHP_NEW_EXTENSION([ffi],
[ffi.c ffi_parser.c],
[$ext_shared],,
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
PHP_SUBST([FFI_SHARED_LIBADD])
fi
5 changes: 4 additions & 1 deletion ext/filter/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ PHP_ARG_ENABLE([filter],
[yes])

if test "$PHP_FILTER" != "no"; then
PHP_NEW_EXTENSION(filter, filter.c sanitizing_filters.c logical_filters.c callback_filter.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
PHP_NEW_EXTENSION([filter],
[filter.c sanitizing_filters.c logical_filters.c callback_filter.c],
[$ext_shared],,
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])

PHP_INSTALL_HEADERS([ext/filter], [php_filter.h])
PHP_ADD_EXTENSION_DEP(filter, pcre)
Expand Down
2 changes: 1 addition & 1 deletion ext/ftp/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ PHP_ARG_WITH([ftp-ssl],

if test "$PHP_FTP" = "yes"; then
AC_DEFINE(HAVE_FTP,1,[Whether you want FTP support])
PHP_NEW_EXTENSION(ftp, php_ftp.c ftp.c, $ext_shared)
PHP_NEW_EXTENSION([ftp], [php_ftp.c ftp.c], [$ext_shared])

dnl Empty variable means 'no' (for phpize builds).
test -z "$PHP_OPENSSL" && PHP_OPENSSL=no
Expand Down
2 changes: 1 addition & 1 deletion ext/gettext/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ if test "$PHP_GETTEXT" != "no"; then
[AC_MSG_ERROR([Unable to find required gettext library])])])

AC_DEFINE([HAVE_LIBINTL], [1], [Define to 1 if you have the 'intl' library.])
PHP_NEW_EXTENSION(gettext, gettext.c, $ext_shared)
PHP_NEW_EXTENSION([gettext], [gettext.c], [$ext_shared])
PHP_SUBST([GETTEXT_SHARED_LIBADD])

PHP_ADD_INCLUDE([$GETTEXT_INCDIR])
Expand Down
5 changes: 4 additions & 1 deletion ext/gmp/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ if test "$PHP_GMP" != "no"; then

PHP_INSTALL_HEADERS([ext/gmp], [php_gmp_int.h])

PHP_NEW_EXTENSION(gmp, gmp.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
PHP_NEW_EXTENSION([gmp],
[gmp.c],
[$ext_shared],,
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
PHP_SUBST([GMP_SHARED_LIBADD])
AC_DEFINE(HAVE_GMP, 1, [ ])
fi
5 changes: 4 additions & 1 deletion ext/iconv/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ int main(void) {
LDFLAGS="$save_LDFLAGS"
CFLAGS="$save_CFLAGS"

PHP_NEW_EXTENSION(iconv, iconv.c, $ext_shared,, [-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
PHP_NEW_EXTENSION([iconv],
[iconv.c],
[$ext_shared],,
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
PHP_SUBST([ICONV_SHARED_LIBADD])
PHP_INSTALL_HEADERS([ext/iconv], [php_iconv.h])
fi
103 changes: 54 additions & 49 deletions ext/intl/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,60 @@ if test "$PHP_INTL" != "no"; then
PHP_SETUP_ICU([INTL_SHARED_LIBADD])
PHP_SUBST([INTL_SHARED_LIBADD])
INTL_COMMON_FLAGS="$ICU_CFLAGS -Wno-write-strings -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
PHP_NEW_EXTENSION(intl, php_intl.c \
intl_error.c \
intl_convert.c \
collator/collator_class.c \
collator/collator_sort.c \
collator/collator_convert.c \
collator/collator_locale.c \
collator/collator_compare.c \
collator/collator_attr.c \
collator/collator_create.c \
collator/collator_is_numeric.c \
collator/collator_error.c \
common/common_error.c \
converter/converter.c \
formatter/formatter_main.c \
formatter/formatter_class.c \
formatter/formatter_attr.c \
formatter/formatter_data.c \
formatter/formatter_format.c \
formatter/formatter_parse.c \
normalizer/normalizer_class.c \
normalizer/normalizer_normalize.c \
locale/locale.c \
locale/locale_class.c \
locale/locale_methods.c \
dateformat/dateformat.c \
dateformat/dateformat_class.c \
dateformat/dateformat_attr.c \
dateformat/dateformat_data.c \
dateformat/dateformat_format.c \
dateformat/dateformat_parse.c \
msgformat/msgformat.c \
msgformat/msgformat_attr.c \
msgformat/msgformat_class.c \
msgformat/msgformat_data.c \
msgformat/msgformat_format.c \
msgformat/msgformat_parse.c \
grapheme/grapheme_string.c \
grapheme/grapheme_util.c \
resourcebundle/resourcebundle.c \
resourcebundle/resourcebundle_class.c \
resourcebundle/resourcebundle_iterator.c \
transliterator/transliterator_class.c \
transliterator/transliterator_methods.c \
uchar/uchar.c \
idn/idn.c \
spoofchecker/spoofchecker_class.c \
spoofchecker/spoofchecker_create.c\
spoofchecker/spoofchecker_main.c, $ext_shared,,$INTL_COMMON_FLAGS,cxx)
PHP_NEW_EXTENSION([intl], m4_normalize([
collator/collator_attr.c
collator/collator_class.c
collator/collator_compare.c
collator/collator_convert.c
collator/collator_create.c
collator/collator_error.c
collator/collator_is_numeric.c
collator/collator_locale.c
collator/collator_sort.c
common/common_error.c
converter/converter.c
dateformat/dateformat_attr.c
dateformat/dateformat_class.c
dateformat/dateformat_data.c
dateformat/dateformat_format.c
dateformat/dateformat_parse.c
dateformat/dateformat.c
formatter/formatter_attr.c
formatter/formatter_class.c
formatter/formatter_data.c
formatter/formatter_format.c
formatter/formatter_main.c
formatter/formatter_parse.c
grapheme/grapheme_string.c
grapheme/grapheme_util.c
idn/idn.c
intl_convert.c
intl_error.c
locale/locale_class.c
locale/locale_methods.c
locale/locale.c
msgformat/msgformat_attr.c
msgformat/msgformat_class.c
msgformat/msgformat_data.c
msgformat/msgformat_format.c
msgformat/msgformat_parse.c
msgformat/msgformat.c
normalizer/normalizer_class.c
normalizer/normalizer_normalize.c
php_intl.c
resourcebundle/resourcebundle_class.c
resourcebundle/resourcebundle_iterator.c
resourcebundle/resourcebundle.c
spoofchecker/spoofchecker_class.c
spoofchecker/spoofchecker_create.c
spoofchecker/spoofchecker_main.c
transliterator/transliterator_class.c
transliterator/transliterator_methods.c
uchar/uchar.c
]),
[$ext_shared],,
[$INTL_COMMON_FLAGS],
[cxx])

PHP_INTL_CXX_SOURCES="intl_convertcpp.cpp \
common/common_enum.cpp \
Expand Down
14 changes: 8 additions & 6 deletions ext/json/config.m4
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
PHP_NEW_EXTENSION(json,
json.c \
json_encoder.c \
json_parser.tab.c \
json_scanner.c,
no,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
PHP_NEW_EXTENSION([json], m4_normalize([
json_encoder.c
json_parser.tab.c
json_scanner.c
json.c
]),
[no],,
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
PHP_INSTALL_HEADERS([ext/json], [php_json.h php_json_parser.h php_json_scanner.h])
PHP_ADD_MAKEFILE_FRAGMENT
5 changes: 4 additions & 1 deletion ext/ldap/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ PHP_ARG_WITH([ldap-sasl],

if test "$PHP_LDAP" != "no"; then

PHP_NEW_EXTENSION(ldap, ldap.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
PHP_NEW_EXTENSION([ldap],
[ldap.c],
[$ext_shared],,
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])

if test "$PHP_LDAP" = "yes"; then
for i in /usr/local /usr; do
Expand Down
Loading

0 comments on commit 1ceadae

Please sign in to comment.