Skip to content

Commit

Permalink
- Implemented FR #53271, FR #52410 (Building multiple PHP binary SAPI…
Browse files Browse the repository at this point in the history
…s and one SAPI module the same time)

# Bug #53271, Bug #52410
  • Loading branch information
Jani Taskinen committed Nov 13, 2010
1 parent 200dcee commit 25aee9c
Show file tree
Hide file tree
Showing 14 changed files with 148 additions and 105 deletions.
4 changes: 4 additions & 0 deletions Makefile.global
Expand Up @@ -13,6 +13,8 @@ all: $(all_targets)

build-modules: $(PHP_MODULES) $(PHP_ZEND_EX)

build-binaries: $(PHP_BINARIES)

libphp$(PHP_MAJOR_VERSION).la: $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
$(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -rpath $(phptempdir) $(EXTRA_LDFLAGS) $(LDFLAGS) $(PHP_RPATHS) $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@
-@$(LIBTOOL) --silent --mode=install cp $@ $(phptempdir)/$@ >/dev/null 2>&1
Expand All @@ -35,6 +37,8 @@ install-sapi: $(OVERALL_TARGET)
fi
@$(INSTALL_IT)

install-binaries: build-binaries $(install_binary_targets)

install-modules: build-modules
@test -d modules && \
$(mkinstalldirs) $(INSTALL_ROOT)$(EXTENSION_DIR)
Expand Down
2 changes: 2 additions & 0 deletions NEWS
Expand Up @@ -136,6 +136,8 @@ PHP NEWS

- Deprecated mysql_list_dbs() (Request #50667). (Andrey)

- Implemented FR #53271, FR #52410 (Building multiple PHP binary SAPIs and
one SAPI module the same time). (Jani)
- Implemented FR #53238 (Make third parameter of preg_match_all optional).
(Adam)
- Implemented FR #53213 (Adler32 algorithm is very slow).
Expand Down
50 changes: 37 additions & 13 deletions acinclude.m4
Expand Up @@ -194,7 +194,7 @@ dnl the path is interpreted relative to the top build-directory.
dnl
dnl which array to append to?
AC_DEFUN([PHP_ADD_SOURCES],[
PHP_ADD_SOURCES_X($1, $2, $3, ifelse($4,cli,PHP_CLI_OBJS,ifelse($4,sapi,PHP_SAPI_OBJS,PHP_GLOBAL_OBJS)))
PHP_ADD_SOURCES_X($1, $2, $3, ifelse($4,sapi,PHP_SAPI_OBJS,PHP_GLOBAL_OBJS))
])

dnl
Expand Down Expand Up @@ -777,7 +777,7 @@ dnl
AC_DEFUN([PHP_BUILD_SHARED],[
PHP_BUILD_PROGRAM
OVERALL_TARGET=libphp[]$PHP_MAJOR_VERSION[.la]
php_build_target=shared
php_sapi_module=shared
php_c_pre=$shared_c_pre
php_c_meta=$shared_c_meta
Expand All @@ -794,7 +794,7 @@ dnl
AC_DEFUN([PHP_BUILD_STATIC],[
PHP_BUILD_PROGRAM
OVERALL_TARGET=libphp[]$PHP_MAJOR_VERSION[.la]
php_build_target=static
php_sapi_module=static
])

dnl
Expand All @@ -803,14 +803,13 @@ dnl
AC_DEFUN([PHP_BUILD_BUNDLE],[
PHP_BUILD_PROGRAM
OVERALL_TARGET=libs/libphp[]$PHP_MAJOR_VERSION[.bundle]
php_build_target=static
php_sapi_module=static
])

dnl
dnl PHP_BUILD_PROGRAM
dnl
AC_DEFUN([PHP_BUILD_PROGRAM],[
OVERALL_TARGET=[]ifelse($1,,php,$1)
php_c_pre='$(LIBTOOL) --mode=compile $(CC)'
php_c_meta='$(COMMON_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS)'
php_c_post=
Expand All @@ -832,7 +831,7 @@ AC_DEFUN([PHP_BUILD_PROGRAM],[
shared_cxx_post=
shared_lo=lo
php_build_target=program
php_sapi_module=program
])

dnl
Expand Down Expand Up @@ -878,21 +877,46 @@ EOF
dnl
dnl PHP_SELECT_SAPI(name, type[, sources [, extra-cflags [, build-target]]])
dnl
dnl Selects the SAPI name and type (static, shared, programm)
dnl Selects the SAPI name and type (static, shared, bundle, program)
dnl and optionally also the source-files for the SAPI-specific
dnl objects.
dnl
AC_DEFUN([PHP_SELECT_SAPI],[
PHP_SAPI=$1
if test "$2" = "program"; then
PHP_BINARIES="$PHP_BINARIES $1"
elif test "$PHP_SAPI" != "none"; then
AC_MSG_ERROR([
+--------------------------------------------------------------------+
| *** ATTENTION *** |
| |
| You've configured multiple SAPIs to be build. You can build only |
| one SAPI module plus CGI, CLI and FPM binaries at the same time. |

This comment has been minimized.

Copy link
@andypost

andypost Aug 19, 2021

Contributor

It still does not allow build using --enable-embed=program --with-apxs2

+--------------------------------------------------------------------+
])
else
PHP_SAPI=$1
fi
PHP_ADD_BUILD_DIR([sapi/$1])
PHP_INSTALLED_SAPIS="$PHP_INSTALLED_SAPIS $1"
case "$2" in
static[)] PHP_BUILD_STATIC;;
shared[)] PHP_BUILD_SHARED;;
bundle[)] PHP_BUILD_BUNDLE;;
program[)] PHP_BUILD_PROGRAM($5);;
program[)] PHP_BUILD_PROGRAM;;
esac
ifelse($3,,,[PHP_ADD_SOURCES([sapi/$1],[$3],[$4],[sapi])])
ifelse($2,program,[
install_binaries="install-binaries"
install_binary_targets="$install_binary_targets install-$1"
PHP_SUBST(PHP_[]translit($1,a-z0-9-,A-Z0-9_)[]_OBJS)
ifelse($3,,,[PHP_ADD_SOURCES_X([sapi/$1],[$3],[$4],PHP_[]translit($1,a-z0-9-,A-Z0-9_)[]_OBJS)])
],[
install_sapi="install-sapi"
ifelse($3,,,[PHP_ADD_SOURCES([sapi/$1],[$3],[$4],[sapi])])
])
])

dnl deprecated
Expand Down Expand Up @@ -2912,7 +2936,7 @@ dnl DTrace objects
PHP_DTRACE_OBJS="[$]PHP_DTRACE_OBJS [$]ac_bdir[$]ac_obj.lo"
done;
case [$]php_build_target in
case [$]php_sapi_module in
program|static)
dtrace_objs='$(PHP_DTRACE_OBJS:.lo=.o)'
;;
Expand Down
64 changes: 30 additions & 34 deletions configure.in
Expand Up @@ -304,8 +304,8 @@ dnl -------------------------------------------------------------------------
PTHREADS_CHECK
PHP_HELP_SEPARATOR([SAPI modules:])
PHP_SHLIB_SUFFIX_NAMES
PHP_SAPI=default
PHP_BUILD_PROGRAM
PHP_SAPI=none


dnl SAPI configuration.
Expand All @@ -324,6 +324,20 @@ dnl Show which main SAPI was selected
AC_MSG_CHECKING([for chosen SAPI module])
AC_MSG_RESULT([$PHP_SAPI])

dnl Show which binaries were selected
AC_MSG_CHECKING([for executable SAPI binaries])
if test "$PHP_BINARIES"; then
AC_MSG_RESULT([$PHP_BINARIES])
else
AC_MSG_RESULT([none])
fi

dnl Exit early
if test -z "$PHP_INSTALLED_SAPIS"; then
AC_MSG_ERROR([Nothing to build.])
fi

dnl force ZTS
if test "$enable_maintainer_zts" = "yes"; then
PTHREADS_ASSIGN_VARS
PTHREADS_FLAGS
Expand Down Expand Up @@ -954,14 +968,8 @@ dnl -------------------------------------------------------------------------
enable_shared=yes
enable_static=yes

case $php_build_target in
program|static)
standard_libtool_flag='-prefer-non-pic -static'
if test -z "$PHP_MODULES" && test -z "$PHP_ZEND_EX"; then
enable_shared=no
fi
;;
shared)
case $php_sapi_module in
shared[)]
enable_static=no
case $with_pic in
yes)
Expand All @@ -973,6 +981,12 @@ case $php_build_target in
esac
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -avoid-version -module"
;;
*[)]
standard_libtool_flag='-prefer-non-pic -static'
if test -z "$PHP_MODULES" && test -z "$PHP_ZEND_EX"; then
enable_shared=no
fi
;;
esac

EXTRA_LIBS="$EXTRA_LIBS $DLIBS $LIBS"
Expand Down Expand Up @@ -1208,24 +1222,15 @@ case $host_alias in
;;
esac

if test "$PHP_CLI" != "no"; then
PHP_CLI_TARGET="\$(SAPI_CLI_PATH)"
PHP_INSTALL_CLI_TARGET="install-cli"
PHP_ADD_SOURCES(sapi/cli, php_cli.c php_cli_readline.c,, cli)
PHP_INSTALLED_SAPIS="cli $PHP_SAPI"
PHP_EXECUTABLE="\$(top_builddir)/\$(SAPI_CLI_PATH)"
else
PHP_INSTALLED_SAPIS="$PHP_SAPI"
fi

PHP_SUBST_OLD(PHP_INSTALLED_SAPIS)

PHP_SUBST(PHP_EXECUTABLE)
PHP_SUBST(PHP_CLI_TARGET)

PHP_SUBST(PHP_SAPI_OBJS)
PHP_SUBST(PHP_CLI_OBJS)
PHP_SUBST(PHP_BINARY_OBJS)
PHP_SUBST(PHP_GLOBAL_OBJS)

PHP_SUBST(PHP_BINARIES)
PHP_SUBST(PHP_MODULES)
PHP_SUBST(PHP_ZEND_EX)

Expand Down Expand Up @@ -1369,20 +1374,12 @@ else
pharcmd_install=
fi;

all_targets="$lcov_target \$(OVERALL_TARGET) \$(PHP_MODULES) \$(PHP_ZEND_EX) \$(PHP_CLI_TARGET) $pharcmd"
install_targets="$install_modules install-build install-headers install-programs $install_pear $pharcmd_install"

case $PHP_SAPI in
cli)
install_targets="$PHP_INSTALL_CLI_TARGET $install_targets"
;;
*)
install_targets="install-sapi $PHP_INSTALL_CLI_TARGET $install_targets"
;;
esac
all_targets="$lcov_target \$(OVERALL_TARGET) \$(PHP_MODULES) \$(PHP_ZEND_EX) \$(PHP_BINARIES) $pharcmd"
install_targets="$install_sapi $install_modules $install_binaries install-build install-headers install-programs $install_pear $pharcmd_install"

PHP_SUBST(all_targets)
PHP_SUBST(install_targets)
PHP_SUBST(install_binary_targets)

PHP_INSTALL_HEADERS([Zend/ TSRM/ include/ main/ main/streams/])

Expand All @@ -1407,7 +1404,7 @@ case $host_alias in
PHP_ADD_BUILD_DIR(netware)
;;
*)
PHP_ADD_SOURCES(/main, internal_functions_cli.c,, cli)
PHP_ADD_SOURCES_X(/main, internal_functions_cli.c,, PHP_BINARY_OBJS)
;;
esac

Expand Down Expand Up @@ -1438,7 +1435,6 @@ fi
PHP_ADD_SOURCES_X(Zend, zend_execute.c,,PHP_GLOBAL_OBJS,,$flag)

PHP_ADD_BUILD_DIR(main main/streams)
PHP_ADD_BUILD_DIR(sapi/$PHP_SAPI sapi/cli)
PHP_ADD_BUILD_DIR(TSRM)
PHP_ADD_BUILD_DIR(Zend)

Expand Down
9 changes: 8 additions & 1 deletion sapi/cgi/Makefile.frag
@@ -1,2 +1,9 @@
$(SAPI_CGI_PATH): $(PHP_GLOBAL_OBJS) $(PHP_SAPI_OBJS)
cgi: $(SAPI_CGI_PATH)

$(SAPI_CGI_PATH): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_CGI_OBJS)
$(BUILD_CGI)

install-cgi: $(SAPI_CGI_PATH)
@echo "Installing PHP CGI binary: $(INSTALL_ROOT)$(bindir)/"
@$(INSTALL) -m 0755 $(SAPI_CGI_PATH) $(INSTALL_ROOT)$(bindir)/$(program_prefix)php-cgi$(program_suffix)$(EXEEXT)

32 changes: 14 additions & 18 deletions sapi/cgi/config9.m4
Expand Up @@ -8,11 +8,9 @@ PHP_ARG_ENABLE(cgi,,
dnl
dnl CGI setup
dnl
if test "$PHP_SAPI" = "default"; then
AC_MSG_CHECKING(whether to build CGI binary)
if test "$PHP_CGI" != "no"; then
AC_MSG_CHECKING(for CGI build)
if test "$PHP_CGI" != "no"; then
AC_MSG_RESULT(yes)

AC_MSG_CHECKING([for socklen_t in sys/socket.h])
AC_EGREP_HEADER([socklen_t], [sys/socket.h],
[AC_MSG_RESULT([yes])
Expand Down Expand Up @@ -50,31 +48,29 @@ if test "$PHP_SAPI" = "default"; then
SAPI_CGI_PATH=sapi/cgi/php-cgi
;;
esac
PHP_SUBST(SAPI_CGI_PATH)

dnl Set install target and select SAPI
INSTALL_IT="@echo \"Installing PHP CGI binary: \$(INSTALL_ROOT)\$(bindir)/\"; \$(INSTALL) -m 0755 \$(SAPI_CGI_PATH) \$(INSTALL_ROOT)\$(bindir)/\$(program_prefix)php-cgi\$(program_suffix)\$(EXEEXT)"
dnl Select SAPI
PHP_SELECT_SAPI(cgi, program, cgi_main.c fastcgi.c,, '$(SAPI_CGI_PATH)')

case $host_alias in
*aix*)
BUILD_CGI="echo '\#! .' > php.sym && echo >>php.sym && nm -BCpg \`echo \$(PHP_GLOBAL_OBJS) \$(PHP_SAPI_OBJS) | sed 's/\([A-Za-z0-9_]*\)\.lo/\1.o/g'\` | \$(AWK) '{ if (((\$\$2 == \"T\") || (\$\$2 == \"D\") || (\$\$2 == \"B\")) && (substr(\$\$3,1,1) != \".\")) { print \$\$3 } }' | sort -u >> php.sym && \$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) -Wl,-brtl -Wl,-bE:php.sym \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_SAPI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CGI_PATH)"
if test "$php_sapi_module" = "shared"; then
BUILD_CGI="echo '\#! .' > php.sym && echo >>php.sym && nm -BCpg \`echo \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_CGI_OBJS) | sed 's/\([A-Za-z0-9_]*\)\.lo/.libs\/\1.o/g'\` | \$(AWK) '{ if (((\$\$2 == \"T\") || (\$\$2 == \"D\") || (\$\$2 == \"B\")) && (substr(\$\$3,1,1) != \".\")) { print \$\$3 } }' | sort -u >> php.sym && \$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) -Wl,-brtl -Wl,-bE:php.sym \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_CGI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CGI_PATH)"
else
BUILD_CGI="echo '\#! .' > php.sym && echo >>php.sym && nm -BCpg \`echo \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_CGI_OBJS) | sed 's/\([A-Za-z0-9_]*\)\.lo/\1.o/g'\` | \$(AWK) '{ if (((\$\$2 == \"T\") || (\$\$2 == \"D\") || (\$\$2 == \"B\")) && (substr(\$\$3,1,1) != \".\")) { print \$\$3 } }' | sort -u >> php.sym && \$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) -Wl,-brtl -Wl,-bE:php.sym \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_CGI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CGI_PATH)"
fi
;;
*darwin*)
BUILD_CGI="\$(CC) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(NATIVE_RPATHS) \$(PHP_GLOBAL_OBJS:.lo=.o) \$(PHP_SAPI_OBJS:.lo=.o) \$(PHP_FRAMEWORKS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CGI_PATH)"
BUILD_CGI="\$(CC) \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(NATIVE_RPATHS) \$(PHP_GLOBAL_OBJS:.lo=.o) \$(PHP_BINARY_OBJS:.lo=.o) \$(PHP_CGI_OBJS:.lo=.o) \$(PHP_FRAMEWORKS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CGI_PATH)"
;;
*)
BUILD_CGI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_SAPI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CGI_PATH)"
BUILD_CGI="\$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_CGI_OBJS) \$(EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_CGI_PATH)"
;;
esac

dnl Expose to Makefile
PHP_SUBST(SAPI_CGI_PATH)
PHP_SUBST(BUILD_CGI)

elif test "$PHP_CLI" != "no"; then
AC_MSG_RESULT(no)
OVERALL_TARGET=
PHP_SAPI=cli
else
AC_MSG_ERROR([No SAPIs selected.])
fi
else
AC_MSG_RESULT(yes)
fi
7 changes: 4 additions & 3 deletions sapi/cli/Makefile.frag
@@ -1,11 +1,12 @@
cli: $(SAPI_CLI_PATH)

$(SAPI_CLI_PATH): $(PHP_GLOBAL_OBJS) $(PHP_CLI_OBJS)
$(SAPI_CLI_PATH): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_CLI_OBJS)
$(BUILD_CLI)

install-cli: $(SAPI_CLI_PATH)
@echo "Installing PHP CLI binary: $(INSTALL_ROOT)$(bindir)/"
@$(INSTALL_CLI)
@$(INSTALL) -m 0755 $(SAPI_CLI_PATH) $(INSTALL_ROOT)$(bindir)/$(program_prefix)php$(program_suffix)$(EXEEXT)
@echo "Installing PHP CLI man page: $(INSTALL_ROOT)$(mandir)/man1/"
@$(mkinstalldirs) $(INSTALL_ROOT)$(mandir)/man1
@$(INSTALL_DATA) $(builddir)/php.1 $(INSTALL_ROOT)$(mandir)/man1/$(program_prefix)php$(program_suffix).1
@$(INSTALL_DATA) sapi/cli/php.1 $(INSTALL_ROOT)$(mandir)/man1/$(program_prefix)php$(program_suffix).1

0 comments on commit 25aee9c

Please sign in to comment.