Skip to content

Autotools: Quote and fix PHP_SELECT_SAPI arguments #15118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions build/php.m4
Original file line number Diff line number Diff line change
Expand Up @@ -843,10 +843,16 @@ EOF
])

dnl
dnl PHP_SELECT_SAPI(name, type[, sources [, extra-cflags [, build-target]]])
dnl
dnl Selects the SAPI name and type (static, shared, bundle, program) and
dnl optionally also the source-files for the SAPI-specific objects.
dnl PHP_SELECT_SAPI(name, type[, sources [, extra-cflags]])
dnl
dnl When developing PHP SAPI modules, this macro specifies the SAPI "name" by
dnl its "type", how PHP is supposed to be built (static, shared, bundle, or
dnl program). It optionally adds the source files "sources" and compilation
dnl flags "extra-cflags" to build the SAPI-specific objects. For example:
dnl PHP_SELECT_SAPI([apache2handler],
dnl [shared],
dnl [<sources...>],
dnl [-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
dnl
AC_DEFUN([PHP_SELECT_SAPI],[
if test "$2" = "program"; then
Expand Down
17 changes: 0 additions & 17 deletions docs-old/unix-build-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,6 @@ Make sure to prefix *all* relative paths correctly with either `$(builddir)` or
anymore, we must use either absolute paths or relative ones to the top
build-directory. Correct prefixing ensures that.

### SAPI developers

Instead of using `PHP_SAPI=foo/PHP_BUILD_XYZ`, you will need to type

```m4
PHP_SELECT_SAPI(name, type, sources.c)
```

I.e. specify the source-code files as above and also pass the information
regarding how PHP is supposed to be built (shared module, program, etc).

For example for APXS:

```m4
PHP_SELECT_SAPI(apache, shared, sapi_apache.c mod_php.c php_apache.c)
```

## General info

The foundation for the new system is the flexible handling of sources and their
Expand Down
15 changes: 12 additions & 3 deletions sapi/apache2handler/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ if test "$PHP_APXS2" != "no"; then
case $host_alias in
*aix*)
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-brtl -Wl,-bI:$APXS_LIBEXECDIR/httpd.exp"
PHP_SELECT_SAPI(apache2handler, shared, mod_php.c sapi_apache2.c apache_config.c php_functions.c, $APACHE_CFLAGS)
PHP_SELECT_SAPI([apache2handler],
[shared],
[mod_php.c sapi_apache2.c apache_config.c php_functions.c],
[$APACHE_CFLAGS])
INSTALL_IT="$INSTALL_IT $SAPI_LIBTOOL"
;;
*darwin*)
Expand All @@ -100,12 +103,18 @@ if test "$PHP_APXS2" != "no"; then
fi
MH_BUNDLE_FLAGS="-bundle -bundle_loader $APXS_HTTPD $MH_BUNDLE_FLAGS"
PHP_SUBST([MH_BUNDLE_FLAGS])
PHP_SELECT_SAPI(apache2handler, bundle, mod_php.c sapi_apache2.c apache_config.c php_functions.c, $APACHE_CFLAGS)
PHP_SELECT_SAPI([apache2handler],
[bundle],
[mod_php.c sapi_apache2.c apache_config.c php_functions.c],
[$APACHE_CFLAGS])
SAPI_SHARED=libs/libphp.so
INSTALL_IT="$INSTALL_IT $SAPI_SHARED"
;;
*)
PHP_SELECT_SAPI(apache2handler, shared, mod_php.c sapi_apache2.c apache_config.c php_functions.c, $APACHE_CFLAGS)
PHP_SELECT_SAPI([apache2handler],
[shared],
[mod_php.c sapi_apache2.c apache_config.c php_functions.c],
[$APACHE_CFLAGS])
INSTALL_IT="$INSTALL_IT $SAPI_LIBTOOL"
;;
esac
Expand Down
5 changes: 4 additions & 1 deletion sapi/cgi/config9.m4
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ if test "$PHP_CGI" != "no"; then
esac

dnl Select SAPI.
PHP_SELECT_SAPI(cgi, program, cgi_main.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1, '$(SAPI_CGI_PATH)')
PHP_SELECT_SAPI([cgi],
[program],
[cgi_main.c],
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])

case $host_alias in
*aix*)
Expand Down
5 changes: 4 additions & 1 deletion sapi/cli/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ if test "$PHP_CLI" != "no"; then
SAPI_CLI_PATH=sapi/cli/php

dnl Select SAPI.
PHP_SELECT_SAPI(cli, program, php_cli.c php_http_parser.c php_cli_server.c ps_title.c php_cli_process_title.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1, '$(SAPI_CLI_PATH)')
PHP_SELECT_SAPI([cli],
[program],
[php_cli.c php_http_parser.c php_cli_server.c ps_title.c php_cli_process_title.c],
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])

case $host_alias in
*aix*)
Expand Down
5 changes: 4 additions & 1 deletion sapi/embed/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ if test "$PHP_EMBED" != "no"; then
esac
if test "$PHP_EMBED_TYPE" != "no"; then
PHP_SUBST([LIBPHP_CFLAGS])
PHP_SELECT_SAPI(embed, $PHP_EMBED_TYPE, php_embed.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
PHP_SELECT_SAPI([embed],
[$PHP_EMBED_TYPE],
[php_embed.c],
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
PHP_INSTALL_HEADERS([sapi/embed], [php_embed.h])
fi
AC_MSG_RESULT([$PHP_EMBED_TYPE])
Expand Down
5 changes: 4 additions & 1 deletion sapi/fpm/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,10 @@ if test "$PHP_FPM" != "no"; then
fpm/events/port.c \
"

PHP_SELECT_SAPI(fpm, program, $PHP_FPM_FILES $PHP_FPM_TRACE_FILES $PHP_FPM_SD_FILES, $PHP_FPM_CFLAGS, '$(SAPI_FPM_PATH)')
PHP_SELECT_SAPI([fpm],
[program],
[$PHP_FPM_FILES $PHP_FPM_TRACE_FILES $PHP_FPM_SD_FILES],
[$PHP_FPM_CFLAGS])

case $host_alias in
*aix*)
Expand Down
2 changes: 1 addition & 1 deletion sapi/fuzzer/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ if test "$PHP_FUZZER" != "no"; then
PHP_SUBST([FUZZING_LIB])
PHP_SUBST([FUZZING_CC])

dnl PHP_SELECT_SAPI(fuzzer-parser, program, $FUZZER_SOURCES, , '$(SAPI_FUZZER_PATH)')
dnl PHP_SELECT_SAPI([fuzzer-parser], [program], [$FUZZER_SOURCES])

PHP_ADD_BUILD_DIR([sapi/fuzzer])
PHP_FUZZER_BINARIES=""
Expand Down
2 changes: 1 addition & 1 deletion sapi/litespeed/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if test "$PHP_LITESPEED" != "no"; then
[$abs_srcdir/sapi/litespeed],
[sapi/litespeed])
SAPI_LITESPEED_PATH=sapi/litespeed/php
PHP_SELECT_SAPI(litespeed, program, lsapi_main.c lsapilib.c, "", '$(SAPI_LITESPEED_PATH)')
PHP_SELECT_SAPI([litespeed], [program], [lsapi_main.c lsapilib.c])
case $host_alias in
*darwin*)
BUILD_LITESPEED="\$(CC) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(NATIVE_RPATHS) \$(PHP_GLOBAL_OBJS:.lo=.o) \$(PHP_BINARY_OBJS:.lo=.o) \$(PHP_LITESPEED_OBJS:.lo=.o) \$(PHP_FRAMEWORKS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_LITESPEED_PATH)"
Expand Down
5 changes: 4 additions & 1 deletion sapi/phpdbg/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ if test "$PHP_PHPDBG" != "no"; then
PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/phpdbg/Makefile.frag],
[$abs_srcdir/sapi/phpdbg],
[$abs_builddir/sapi/phpdbg])
PHP_SELECT_SAPI(phpdbg, program, $PHP_PHPDBG_FILES, $PHP_PHPDBG_CFLAGS, [$(SAPI_PHPDBG_PATH)])
PHP_SELECT_SAPI([phpdbg],
[program],
[$PHP_PHPDBG_FILES],
[$PHP_PHPDBG_CFLAGS])

BUILD_BINARY="sapi/phpdbg/phpdbg"
BUILD_SHARED="sapi/phpdbg/libphpdbg.la"
Expand Down