diff mbox

[2/6] php: fix for external extensions

Message ID 1390944391-3892-2-git-send-email-gustavo@zacarias.com.ar
State Accepted
Commit 3f8b51338432686307f34a1ea44e6ff9a37e6399
Headers show

Commit Message

Gustavo Zacarias Jan. 28, 2014, 9:26 p.m. UTC
Adjust phpize and php-config to make them work for cross-compiled
external extensions.
While at it also fix dl* issues that prevent said extensions from
loading.

Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
---
 package/php/php-02-dlopen.patch | 25 +++++++++++++++++++++++++
 package/php/php.mk              | 25 ++++++++++++++++++++++---
 2 files changed, 47 insertions(+), 3 deletions(-)
 create mode 100644 package/php/php-02-dlopen.patch

Comments

Peter Korsgaard Jan. 30, 2014, 4:09 p.m. UTC | #1
>>>>> "Gustavo" == Gustavo Zacarias <gustavo@zacarias.com.ar> writes:

 > Adjust phpize and php-config to make them work for cross-compiled
 > external extensions.
 > While at it also fix dl* issues that prevent said extensions from
 > loading.

 > Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
 
 > +define PHP_EXTENSIONS_FIXUP
 > +	$(SED) "/prefix/ s:/usr:$(STAGING_DIR)/usr:" \
 > +		$(STAGING_DIR)/usr/bin/phpize

Can't we just add phpize to PHP_CONFIG_SCRIPTS?

 > +	$(SED) "/extension_dir/ s:/usr:$(TARGET_DIR)/usr:" \
 > +		$(STAGING_DIR)/usr/bin/php-config

Shouldn't this be s/TARGET_DIR/STAGING_DIR/?
Gustavo Zacarias Jan. 30, 2014, 4:16 p.m. UTC | #2
On 01/30/2014 01:09 PM, Peter Korsgaard wrote:
>  > +define PHP_EXTENSIONS_FIXUP
>  > +	$(SED) "/prefix/ s:/usr:$(STAGING_DIR)/usr:" \
>  > +		$(STAGING_DIR)/usr/bin/phpize
> 
> Can't we just add phpize to PHP_CONFIG_SCRIPTS?

See below...

>  > +	$(SED) "/extension_dir/ s:/usr:$(TARGET_DIR)/usr:" \
>  > +		$(STAGING_DIR)/usr/bin/php-config
> 
> Shouldn't this be s/TARGET_DIR/STAGING_DIR/?

No, that's where the extensions will be installed (no DESTDIR or similar
override in the Makefile), so just with this at least we can't do
PHP_CONFIG_SCRIPTS.
Regards.
Peter Korsgaard Jan. 30, 2014, 4:40 p.m. UTC | #3
>>>>> "Gustavo" == Gustavo Zacarias <gustavo@zacarias.com.ar> writes:

 > On 01/30/2014 01:09 PM, Peter Korsgaard wrote:
 >> > +define PHP_EXTENSIONS_FIXUP
 >> > +	$(SED) "/prefix/ s:/usr:$(STAGING_DIR)/usr:" \
 >> > +		$(STAGING_DIR)/usr/bin/phpize
 >> 
 >> Can't we just add phpize to PHP_CONFIG_SCRIPTS?

 > See below...

 >> > +	$(SED) "/extension_dir/ s:/usr:$(TARGET_DIR)/usr:" \
 >> > +		$(STAGING_DIR)/usr/bin/php-config
 >> 
 >> Shouldn't this be s/TARGET_DIR/STAGING_DIR/?

 > No, that's where the extensions will be installed (no DESTDIR or similar
 > override in the Makefile), so just with this at least we can't do
 > PHP_CONFIG_SCRIPTS.

Ok - So to conclude, we need the manual php-config change, but the
phpize change can be done with PHP_CONFIG_SCRIPTS?
Gustavo Zacarias Jan. 30, 2014, 5:03 p.m. UTC | #4
On 01/30/2014 01:40 PM, Peter Korsgaard wrote:

> Ok - So to conclude, we need the manual php-config change, but the
> phpize change can be done with PHP_CONFIG_SCRIPTS?

It works... for now... i'm a bit wary of doing so since it's just casual
that it works with _CONFIG_SCRIPTS without it being a config script, if
upstream changes things in a newer php version it may break.
Regards.
Peter Korsgaard Feb. 12, 2014, 6:51 p.m. UTC | #5
>>>>> "Gustavo" == Gustavo Zacarias <gustavo@zacarias.com.ar> writes:

 > Adjust phpize and php-config to make them work for cross-compiled
 > external extensions.
 > While at it also fix dl* issues that prevent said extensions from
 > loading.

 > Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>

Committed this and the rest of the series to next, thanks.
diff mbox

Patch

diff --git a/package/php/php-02-dlopen.patch b/package/php/php-02-dlopen.patch
new file mode 100644
index 0000000..1dd009f
--- /dev/null
+++ b/package/php/php-02-dlopen.patch
@@ -0,0 +1,25 @@ 
+PHP can't be AUTORECONF with any modern autotools and the dl tests are
+pretty bad for cross-compilation, so just kill the needed ac_cv value unsets
+so they can flow through from the package makefile.
+
+Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
+
+diff -Nura php-5.5.8.orig/configure php-5.5.8/configure
+--- php-5.5.8.orig/configure	2014-01-28 17:41:33.943851727 -0300
++++ php-5.5.8/configure	2014-01-28 17:42:53.785493795 -0300
+@@ -16985,7 +16985,6 @@
+ 
+ 
+ 
+-  unset ac_cv_func_dlopen
+   unset ac_cv_func___dlopen
+   unset found
+ 
+@@ -17013,7 +17012,6 @@
+ 
+     *)
+ 
+-  unset ac_cv_lib_dl_dlopen
+   unset ac_cv_lib_dl___dlopen
+   unset found
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
diff --git a/package/php/php.mk b/package/php/php.mk
index de02f4b..2f6280f 100644
--- a/package/php/php.mk
+++ b/package/php/php.mk
@@ -19,15 +19,25 @@  PHP_CONF_OPT =  --mandir=/usr/share/man \
 		--with-config-file-path=/etc \
 		--localstatedir=/var \
 		--disable-rpath
+PHP_CONF_ENV = EXTRA_LIBS="$(PHP_EXTRA_LIBS)"
+
 ifeq ($(BR2_ENDIAN),"BIG")
-PHP_CONF_ENV = ac_cv_c_bigendian_php=yes
+PHP_CONF_ENV += ac_cv_c_bigendian_php=yes
 else
-PHP_CONF_ENV = ac_cv_c_bigendian_php=no
+PHP_CONF_ENV += ac_cv_c_bigendian_php=no
 endif
 PHP_CONFIG_SCRIPTS = php-config
 
 PHP_CFLAGS = $(TARGET_CFLAGS)
 
+# We need to force dl "detection"
+ifeq ($(BR2_PREFER_STATIC_LIB),)
+PHP_CONF_ENV += ac_cv_func_dlopen=yes ac_cv_lib_dl_dlopen=yes
+PHP_EXTRA_LIBS += -ldl
+else
+PHP_CONF_ENV += ac_cv_func_dlopen=no ac_cv_lib_dl_dlopen=no
+endif
+
 # Workaround for non-IPv6 uClibc toolchain
 ifeq ($(BR2_TOOLCHAIN_USES_UCLIBC),y)
 ifneq ($(BR2_INET_IPV6),y)
@@ -116,7 +126,7 @@  ifeq ($(BR2_PACKAGE_PHP_EXT_INTL),y)
 	# The intl module is implemented in C++, but PHP fails to use
 	# g++ as the compiler for the final link. As a workaround,
 	# tell it to link libstdc++.
-	PHP_CONF_ENV += EXTRA_LIBS="-lstdc++"
+	PHP_EXTRA_LIBS + = -lstdc++
 endif
 
 ifeq ($(BR2_PACKAGE_PHP_EXT_GMP),y)
@@ -200,6 +210,15 @@  ifeq ($(BR2_PACKAGE_PHP_EXT_SNMP),y)
 	PHP_DEPENDENCIES += netsnmp
 endif
 
+define PHP_EXTENSIONS_FIXUP
+	$(SED) "/prefix/ s:/usr:$(STAGING_DIR)/usr:" \
+		$(STAGING_DIR)/usr/bin/phpize
+	$(SED) "/extension_dir/ s:/usr:$(TARGET_DIR)/usr:" \
+		$(STAGING_DIR)/usr/bin/php-config
+endef
+
+PHP_POST_INSTALL_TARGET_HOOKS += PHP_EXTENSIONS_FIXUP
+
 define PHP_INSTALL_FIXUP
 	rm -rf $(TARGET_DIR)/usr/lib/php
 	rm -f $(TARGET_DIR)/usr/bin/phpize