diff mbox

[8/8] package/php: Add Apache support

Message ID 1412516718-12597-8-git-send-email-bernd.kuhls@t-online.de
State Superseded
Headers show

Commit Message

Bernd Kuhls Oct. 5, 2014, 1:45 p.m. UTC
Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
---
 package/php/Config.in                            |   17 +++
 package/php/php-04-cross-compile.only-for-apache |  131 ++++++++++++++++++++++
 package/php/php.mk                               |   16 +++
 3 files changed, 164 insertions(+)
 create mode 100644 package/php/php-04-cross-compile.only-for-apache

Comments

Yann E. MORIN Oct. 5, 2014, 3:56 p.m. UTC | #1
Bernd, All,

On 2014-10-05 15:45 +0200, Bernd Kuhls spake thusly:
> 
> Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
> ---
>  package/php/Config.in                            |   17 +++
>  package/php/php-04-cross-compile.only-for-apache |  131 ++++++++++++++++++++++
>  package/php/php.mk                               |   16 +++
>  3 files changed, 164 insertions(+)
>  create mode 100644 package/php/php-04-cross-compile.only-for-apache
> 
> diff --git a/package/php/Config.in b/package/php/Config.in
> index 32faa32..db4e647 100644
> --- a/package/php/Config.in
> +++ b/package/php/Config.in
> @@ -11,6 +11,9 @@ if BR2_PACKAGE_PHP
>  
>  source "package/php/Config.ext"
>  
> +config BR2_PACKAGE_PHP_APACHE
> +	bool
> +
>  config BR2_PACKAGE_PHP_CLI
>  	bool
>  
> @@ -26,6 +29,20 @@ choice
>  	help
>  	  Select the PHP interface(s).
>  
> +config BR2_PACKAGE_PHP_SAPI_APACHE
> +	bool "Apache"
> +	select BR2_PACKAGE_APACHE
> +	select BR2_PACKAGE_PHP_APACHE
> +	depends on !BR2_PREFER_STATIC_LIB # apache
> +	depends on BR2_TOOLCHAIN_HAS_THREADS # apache
> +	depends on BR2_USE_MMU # apr
> +	help
> +	  Apache module
> +
> +comment "apache module needs a toolchain w/ dynamic library, threads"
> +	depends on BR2_USE_MMU
> +	depends on BR2_PREFER_STATIC_LIB || !BR2_TOOLCHAIN_HAS_THREADS
> +

Unrelated to your patch, but this choice is getting ugly. Maybe we should
switch to something like:

    config BR2_PACKAGE_PHP
        bool "php"
        select BR2_PACKAGE_PHP_SAPI_CGI if !BR2_PACKAGE_PHP_HAS_SAPI

    config BR2_PACKAGE_PHP_HAS_SAPI
        bool

    config BR2_PACKAGE_PHP_SAPI_CGI
        bool "CGI"

    config BR2_PACKAGE_PHP_SAPI_CLI
        bool "CLI"
        select BR2_PACKAGE_PHP_HAS_SAPI

    config BR2_PACKAGE_PHP_SAPI_APACHE
        bool "Apache"
        select BR2_PACKAGE_PHP_HAS_SAPI

    config BR2_PACKAGE_PHP_SAPI_FPM
        bool "FPM"
        select BR2_PACKAGE_PHP_HAS_SAPI

That way, we ensure at least one is selected, which was the initial
reason for the choice, while stil allowing multiple to be selected.

Then, if some are incompatible, we could do, for example:

    config BR2_PACKAGE_PHP_SAPI_APACHE
        bool "Apache"
        depends on !BR2_PACKAGE_PHP_SAPI_CLI
        select BR2_PACKAGE_PHP_HAS_SAPI

>  config BR2_PACKAGE_PHP_SAPI_CGI
>  	bool "CGI"
>  	# CGI uses fork()
> diff --git a/package/php/php-04-cross-compile.only-for-apache b/package/php/php-04-cross-compile.only-for-apache
> new file mode 100644
> index 0000000..a72befc
> --- /dev/null
> +++ b/package/php/php-04-cross-compile.only-for-apache
> @@ -0,0 +1,131 @@
> +Fix cross-compilation when used as Apache module.
> +
> +Apache is configured to use the worker MPM which depends on threads.
> +As PHP´s phtread detection is broken in a cross-compile environment, it is not
> +possible to apply this patch unconditionally, since php itself works without
> +thread support,

I have to say I do not like this much. How complex would it be to have a
proper patch that would work both with apache enabled or disabled?

We should try to have such a patch, and push it upstream.

[--SNIP--]
> diff --git a/package/php/php.mk b/package/php/php.mk
> index 2e97c9a..0b32bca 100644
> --- a/package/php/php.mk
> +++ b/package/php/php.mk
> @@ -50,6 +50,22 @@ PHP_CONF_OPTS += $(if $(BR2_PACKAGE_PHP_CLI),,--disable-cli)
>  PHP_CONF_OPTS += $(if $(BR2_PACKAGE_PHP_CGI),,--disable-cgi)
>  PHP_CONF_OPTS += $(if $(BR2_PACKAGE_PHP_FPM),--enable-fpm,--disable-fpm)
>  
> +ifeq ($(BR2_PACKAGE_PHP_APACHE),y)
> +# this patchset is only needed when cross-compiling mod_php for Apache
> +define PHP_PATCH_FOR_APACHE
> +	patch -d $(@D) -p1 -E -i $(TOPDIR)/$(PKGDIR)php-04-cross-compile.only-for-apache

Yes, $(PKGDIR) already has a trailing '/', for for readability, I'd
prefer we add one here. Multiple '/' in a path are innocuous.

Regards,
Yann E. MORIN.

> +endef
> +PHP_POST_PATCH_HOOKS += PHP_PATCH_FOR_APACHE
> +PHP_CONF_OPTS += \
> +	--with-apxs2=$(STAGING_DIR)/usr/bin/apxs \
> +	--with-config-file-path=/etc/apache2 \
> +	--with-config-file-scan-dir=/etc/apache2/php \
> +	--oldincludedir=$(STAGING_DIR)/usr/include \
> +	--enable-pthreads \
> +	--localstatedir=/var
> +PHP_DEPENDENCIES += apache
> +endif
> +
>  ### Extensions
>  PHP_CONF_OPTS += $(if $(BR2_PACKAGE_PHP_EXT_SOCKETS),--enable-sockets) \
>  		$(if $(BR2_PACKAGE_PHP_EXT_POSIX),--enable-posix) \
> -- 
> 1.7.10.4
> 
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
Gustavo Zacarias Oct. 5, 2014, 4:48 p.m. UTC | #2
On 10/05/2014 12:56 PM, Yann E. MORIN wrote:
> Unrelated to your patch, but this choice is getting ugly. Maybe we should
> switch to something like:
> 
>     config BR2_PACKAGE_PHP
>         bool "php"
>         select BR2_PACKAGE_PHP_SAPI_CGI if !BR2_PACKAGE_PHP_HAS_SAPI
> 
>     config BR2_PACKAGE_PHP_HAS_SAPI
>         bool
> 
>     config BR2_PACKAGE_PHP_SAPI_CGI
>         bool "CGI"
> 
>     config BR2_PACKAGE_PHP_SAPI_CLI
>         bool "CLI"
>         select BR2_PACKAGE_PHP_HAS_SAPI
> 
>     config BR2_PACKAGE_PHP_SAPI_APACHE
>         bool "Apache"
>         select BR2_PACKAGE_PHP_HAS_SAPI
> 
>     config BR2_PACKAGE_PHP_SAPI_FPM
>         bool "FPM"
>         select BR2_PACKAGE_PHP_HAS_SAPI
> 
> That way, we ensure at least one is selected, which was the initial
> reason for the choice, while stil allowing multiple to be selected.

+1 the choice is going wild.

> Then, if some are incompatible, we could do, for example:

AFAIK you can combine anything the way you like as long as the
dependencies are met since the php build system rebuilds for each case.
Regards.
diff mbox

Patch

diff --git a/package/php/Config.in b/package/php/Config.in
index 32faa32..db4e647 100644
--- a/package/php/Config.in
+++ b/package/php/Config.in
@@ -11,6 +11,9 @@  if BR2_PACKAGE_PHP
 
 source "package/php/Config.ext"
 
+config BR2_PACKAGE_PHP_APACHE
+	bool
+
 config BR2_PACKAGE_PHP_CLI
 	bool
 
@@ -26,6 +29,20 @@  choice
 	help
 	  Select the PHP interface(s).
 
+config BR2_PACKAGE_PHP_SAPI_APACHE
+	bool "Apache"
+	select BR2_PACKAGE_APACHE
+	select BR2_PACKAGE_PHP_APACHE
+	depends on !BR2_PREFER_STATIC_LIB # apache
+	depends on BR2_TOOLCHAIN_HAS_THREADS # apache
+	depends on BR2_USE_MMU # apr
+	help
+	  Apache module
+
+comment "apache module needs a toolchain w/ dynamic library, threads"
+	depends on BR2_USE_MMU
+	depends on BR2_PREFER_STATIC_LIB || !BR2_TOOLCHAIN_HAS_THREADS
+
 config BR2_PACKAGE_PHP_SAPI_CGI
 	bool "CGI"
 	# CGI uses fork()
diff --git a/package/php/php-04-cross-compile.only-for-apache b/package/php/php-04-cross-compile.only-for-apache
new file mode 100644
index 0000000..a72befc
--- /dev/null
+++ b/package/php/php-04-cross-compile.only-for-apache
@@ -0,0 +1,131 @@ 
+Fix cross-compilation when used as Apache module.
+
+Apache is configured to use the worker MPM which depends on threads.
+As PHP´s phtread detection is broken in a cross-compile environment, it is not
+possible to apply this patch unconditionally, since php itself works without
+thread support,
+
+Also avoid calling the Apache httpd target binary to check for its presence.
+
+Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
+
+diff -uNr php-5.5.17.org/configure php-5.5.17/configure
+--- php-5.5.17.org/configure	2014-09-16 14:53:57.000000000 +0200
++++ php-5.5.17/configure	2014-10-05 15:06:12.162625672 +0200
+@@ -4062,7 +4062,7 @@
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
+ $as_echo_n "checking whether we are cross compiling... " >&6; }
+ if test "$cross_compiling" != yes; then
+-  { { ac_try="$ac_link"
++  { { ac_try="false"
+ case "(($ac_try" in
+   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+   *) ac_try_echo=$ac_try;;
+@@ -5772,7 +5772,7 @@
+ 
+ if test "$cross_compiling" = yes; then :
+ 
+-    pthreads_working=no
++    pthreads_working=yes
+   case $host_alias in
+   *netware*)
+     pthreads_working=yes
+@@ -5828,7 +5828,7 @@
+ 
+ if test "$cross_compiling" = yes; then :
+ 
+-    pthreads_working=no
++    pthreads_working=yes
+   case $host_alias in
+   *netware*)
+     pthreads_working=yes
+@@ -5894,7 +5894,7 @@
+ 
+ if test "$cross_compiling" = yes; then :
+ 
+-    pthreads_working=no
++    pthreads_working=yes
+   case $host_alias in
+   *netware*)
+     pthreads_working=yes
+@@ -6342,7 +6342,7 @@
+ 
+   # Test that we're trying to configure with apache 1.x
+ 
+-  ac_output=`$APXS_HTTPD -v 2>&1 | grep version | $SED -e 's/Oracle-HTTP-//'`
++  ac_output='Server version: Apache/2.4.10 (Unix)'
+   ac_IFS=$IFS
+ IFS="- /.
+ "
+@@ -7626,7 +7626,7 @@
+ 
+   # Test that we're trying to configure with apache 2.x
+ 
+-  ac_output=`$APXS_HTTPD -v 2>&1 | grep version | $SED -e 's/Oracle-HTTP-//'`
++  ac_output='Server version: Apache/2.4.10 (Unix)'
+   ac_IFS=$IFS
+ IFS="- /.
+ "
+@@ -8332,7 +8332,7 @@
+ 
+     fi
+   else
+-    APACHE_THREADED_MPM=`$APXS_HTTPD -V | grep 'threaded:.*yes'`
++    APACHE_THREADED_MPM="threaded:     yes (fixed thread count)"
+     if test -n "$APACHE_THREADED_MPM"; then
+ 
+   enable_maintainer_zts=yes
+@@ -8450,7 +8450,7 @@
+ 
+   # Test that we're trying to configure with apache 2.x
+ 
+-  ac_output=`$APXS_HTTPD -v 2>&1 | grep version | $SED -e 's/Oracle-HTTP-//'`
++  ac_output='Server version: Apache/2.4.10 (Unix)'
+   ac_IFS=$IFS
+ IFS="- /.
+ "
+@@ -9156,7 +9156,7 @@
+ 
+     fi
+   else
+-    APACHE_THREADED_MPM=`$APXS_HTTPD -V | grep 'threaded:.*yes'`
++    APACHE_THREADED_MPM="threaded:     yes (fixed thread count)"
+     if test -n "$APACHE_THREADED_MPM"; then
+ 
+   enable_maintainer_zts=yes
+@@ -9255,7 +9255,7 @@
+ 
+   # Test that we're trying to configure with apache 1.x
+ 
+-  ac_output=`$APXS_HTTPD -v 2>&1 | grep version | $SED -e 's/Oracle-HTTP-//'`
++  ac_output='Server version: Apache/2.4.10 (Unix)'
+   ac_IFS=$IFS
+ IFS="- /.
+ "
+@@ -104127,7 +104127,7 @@
+ 
+ if test "$cross_compiling" = yes; then :
+ 
+-    pthreads_working=no
++    pthreads_working=yes
+   case $host_alias in
+   *netware*)
+     pthreads_working=yes
+@@ -104183,7 +104183,7 @@
+ 
+ if test "$cross_compiling" = yes; then :
+ 
+-    pthreads_working=no
++    pthreads_working=yes
+   case $host_alias in
+   *netware*)
+     pthreads_working=yes
+@@ -104249,7 +104249,7 @@
+ 
+ if test "$cross_compiling" = yes; then :
+ 
+-    pthreads_working=no
++    pthreads_working=yes
+   case $host_alias in
+   *netware*)
+     pthreads_working=yes
diff --git a/package/php/php.mk b/package/php/php.mk
index 2e97c9a..0b32bca 100644
--- a/package/php/php.mk
+++ b/package/php/php.mk
@@ -50,6 +50,22 @@  PHP_CONF_OPTS += $(if $(BR2_PACKAGE_PHP_CLI),,--disable-cli)
 PHP_CONF_OPTS += $(if $(BR2_PACKAGE_PHP_CGI),,--disable-cgi)
 PHP_CONF_OPTS += $(if $(BR2_PACKAGE_PHP_FPM),--enable-fpm,--disable-fpm)
 
+ifeq ($(BR2_PACKAGE_PHP_APACHE),y)
+# this patchset is only needed when cross-compiling mod_php for Apache
+define PHP_PATCH_FOR_APACHE
+	patch -d $(@D) -p1 -E -i $(TOPDIR)/$(PKGDIR)php-04-cross-compile.only-for-apache
+endef
+PHP_POST_PATCH_HOOKS += PHP_PATCH_FOR_APACHE
+PHP_CONF_OPTS += \
+	--with-apxs2=$(STAGING_DIR)/usr/bin/apxs \
+	--with-config-file-path=/etc/apache2 \
+	--with-config-file-scan-dir=/etc/apache2/php \
+	--oldincludedir=$(STAGING_DIR)/usr/include \
+	--enable-pthreads \
+	--localstatedir=/var
+PHP_DEPENDENCIES += apache
+endif
+
 ### Extensions
 PHP_CONF_OPTS += $(if $(BR2_PACKAGE_PHP_EXT_SOCKETS),--enable-sockets) \
 		$(if $(BR2_PACKAGE_PHP_EXT_POSIX),--enable-posix) \