diff mbox

[v2,2/2] package/php: Add Apache support

Message ID 1423305664-29877-2-git-send-email-bernd.kuhls@t-online.de
State Changes Requested
Headers show

Commit Message

Bernd Kuhls Feb. 7, 2015, 10:41 a.m. UTC
Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
---
v2: - rebased

 package/php/Config.in           |   17 +++++++++++
 package/php/php-04-apache.patch |   63 +++++++++++++++++++++++++++++++++++++++
 package/php/php.mk              |   19 ++++++++++++
 3 files changed, 99 insertions(+)
 create mode 100644 package/php/php-04-apache.patch

Comments

Thomas Petazzoni Feb. 22, 2015, 2:39 p.m. UTC | #1
Dear Bernd Kuhls,

On Sat,  7 Feb 2015 11:41:04 +0100, Bernd Kuhls wrote:

> +-  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)'

What is this used for? What is the impact if the real version of Apache
doesn't match?

> +-    APACHE_THREADED_MPM=`$APXS_HTTPD -V | grep 'threaded:.*yes'`
> ++    APACHE_THREADED_MPM="threaded:     yes (fixed thread count)"

I am not really happy with this because it makes the PHP package assume
that the selected MPM model in apache is "worker". Even though that is
true today, it could be changed later on to also support the prefork
MPM, which I believe doesn't require thread support.

Maybe we could have one BR2_PACKAGE_APACHE_MPM_WORKER option, which the
PHP Apache support could depend on. For now, this option could be
blind and always on, and later on changed to something allowing to also
build support for the prefork MPM.

> +ifeq ($(BR2_PACKAGE_PHP_APACHE),y)
> +ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
> +define PHP_FIX_THREADS_DETECTION
> +	$(SED) 's/pthreads_working\=no/pthreads_working\=yes/' $(@D)/configure
> +endef
> +# PHP assumes pthreads are not working when cross-compiling,
> +# needed for Apache-MPM worker

Even with --enable-pthreads ?

> +PHP_POST_PATCH_HOOKS += PHP_FIX_THREADS_DETECTION
> +endif
> +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 \

Why is passing --oldincludedir necessary? An additional comment in
the code could be useful here.

Could you look into those issues and resend an updated version?

Thanks a lot!

Thomas
diff mbox

Patch

diff --git a/package/php/Config.in b/package/php/Config.in
index 32faa32..f254213 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_STATIC_LIBS # 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_STATIC_LIBS || !BR2_TOOLCHAIN_HAS_THREADS
+
 config BR2_PACKAGE_PHP_SAPI_CGI
 	bool "CGI"
 	# CGI uses fork()
diff --git a/package/php/php-04-apache.patch b/package/php/php-04-apache.patch
new file mode 100644
index 0000000..aa0dc16
--- /dev/null
+++ b/package/php/php-04-apache.patch
@@ -0,0 +1,63 @@ 
+Fix cross-compilation when used as Apache module.
+
+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
+@@ -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="- /.
+ "
diff --git a/package/php/php.mk b/package/php/php.mk
index 4bcbe18..62c0af4 100644
--- a/package/php/php.mk
+++ b/package/php/php.mk
@@ -50,6 +50,25 @@  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)
+ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
+define PHP_FIX_THREADS_DETECTION
+	$(SED) 's/pthreads_working\=no/pthreads_working\=yes/' $(@D)/configure
+endef
+# PHP assumes pthreads are not working when cross-compiling,
+# needed for Apache-MPM worker
+PHP_POST_PATCH_HOOKS += PHP_FIX_THREADS_DETECTION
+endif
+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) \