Browse Source

package/php: backport upstream patch to fix/workaround xxhash issue

Since the bump of xxhash from 0.8.2 to 0.8.3 in Buildroot commit
4b8f2f3a5e45fe2962a9fcdb148d32198929e228, the host of host-php fails
when host-xxhash has been built before.

This is due to the fact that host-xxhash installs
HOST_DIR/include/xxhash.h, and the PHP code has an internal xxhash.h,
but due to the order of CFLAGS, the one from HOST_DIR/include/xxhash.h
gets included instead of the internal xxhash.h from PHP.

We initially tried to fix the order of CFLAGS, but that has proven to
be challenging within the complicated PHP build system. Then, we opted
for renaming the internal xxhash.h header of PHP, which we had
implemented and were about to submit upstream. But while rebasing this
fix on PHP's master, it turned out that PHP has an upstream commit
"Sync headers installation", merged for PHP 8.4.0, which has the side
effect of avoiding the issue. This commit moves xxhash.h into a
subfolder, so it gets included as #include "xxhash/xxhash.h" now,
which avoids the conflict with HOST_DIR/include/xxhash.h. Maybe not
the best fix, but it does fix the issue and it's upstream.

Since this patch is tweaking the PHP build system, we need to do the
equivalent of "autoreconf" but in the PHP world. It was already done
for the target package, we simply add the same logic for the host
package.

Fixes:

  http://autobuild.buildroot.net/results/583c054a564f90b8c884565070c5e17b43b89674/

Cc: James Hilliard <james.hilliard1@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Julien Olivain <ju.o@free.fr>
Thomas Petazzoni 7 months ago
parent
commit
3a20dfb426
2 changed files with 485 additions and 0 deletions
  1. 478 0
      package/php/0006-Sync-headers-installation.patch
  2. 7 0
      package/php/php.mk

+ 478 - 0
package/php/0006-Sync-headers-installation.patch

@@ -0,0 +1,478 @@
+From e77015d6e5a15d9ec7e30cba73465adc30861355 Mon Sep 17 00:00:00 2001
+From: Peter Kokot <peterkokot@gmail.com>
+Date: Sun, 28 Jan 2024 19:50:55 +0100
+Subject: [PATCH] Sync headers installation
+
+This syncs the installed sapi and extension headers on *nix and Windows
+systems by installing only what is intended outside of php-src.
+
+- ext/gd: without gd_arginfo.h and gd_compat.h
+- ext/hash: php_hash_joaat.h and php_hash_fnv.h added also on Windows
+  installation; xxhash/xxhash.h added on both installations as it is
+  included in php_hash_xxhash.h; Include path for xxhash.h changed to
+  relative so the php_hash_xxhash.h can be included outside of php-src;
+  Redundant include flags removed
+- ext/iconv: without iconv_arginfo.h
+- ext/mysqli: mysqli_mysqlnd.h was missing on Windows
+- ext/phar: php_phar.h was missing on Windows
+- ext/sodium: php_libsodium.h was missing on *nix
+- ext/xml: without xml_arginfo.h
+- sapi/cli: cli.h was missing on Windows
+
+Closes GH-13210
+Closes GH-13213
+
+[Thomas: minor backporting tweaks]
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
+Upstream: https://github.com/php/php-src/commit/52dba99d47563f38d8ed5f84690a3cb2c1785475
+---
+ ext/date/config.w32        |  2 +-
+ ext/dom/config.m4          |  2 +-
+ ext/filter/config.m4       |  2 +-
+ ext/gd/config.m4           |  5 ++---
+ ext/gd/config.w32          |  2 +-
+ ext/gmp/config.m4          |  2 +-
+ ext/hash/config.m4         |  3 +--
+ ext/hash/config.w32        | 10 +++-------
+ ext/hash/php_hash_xxhash.h |  2 +-
+ ext/iconv/config.m4        |  2 +-
+ ext/iconv/config.w32       |  2 +-
+ ext/json/config.w32        |  2 +-
+ ext/libxml/config.w32      |  2 +-
+ ext/libxml/config0.m4      |  2 +-
+ ext/mysqli/config.m4       |  8 ++------
+ ext/mysqli/config.w32      |  2 +-
+ ext/pdo/config.m4          |  2 +-
+ ext/phar/config.w32        |  1 +
+ ext/session/config.m4      |  4 ++--
+ ext/session/config.w32     |  2 +-
+ ext/simplexml/config.m4    |  2 +-
+ ext/simplexml/config.w32   |  2 +-
+ ext/sockets/config.m4      |  2 +-
+ ext/sodium/config.m4       |  1 +
+ ext/sodium/config.w32      |  2 +-
+ ext/xml/config.m4          |  2 +-
+ ext/xml/config.w32         |  2 +-
+ sapi/cli/config.m4         |  2 +-
+ sapi/cli/config.w32        |  1 +
+ sapi/embed/config.m4       |  2 +-
+ 30 files changed, 35 insertions(+), 42 deletions(-)
+
+diff --git a/ext/date/config.w32 b/ext/date/config.w32
+index cf9e220c558..23af2f7d658 100644
+--- a/ext/date/config.w32
++++ b/ext/date/config.w32
+@@ -19,5 +19,5 @@ tl_config.WriteLine("#define timelib_strndup estrndup");
+ tl_config.WriteLine("#define timelib_free    efree");
+ tl_config.Close();
+ 
+-PHP_INSTALL_HEADERS("ext/date/", "php_date.h lib/timelib.h lib/timelib_config.h");
++PHP_INSTALL_HEADERS("ext/date", "php_date.h lib/timelib.h lib/timelib_config.h");
+ AC_DEFINE('HAVE_TIMELIB_CONFIG_H', 1, 'Have timelib_config.h')
+diff --git a/ext/dom/config.m4 b/ext/dom/config.m4
+index 6a83d10c8e2..27fef334794 100644
+--- a/ext/dom/config.m4
++++ b/ext/dom/config.m4
+@@ -24,7 +24,7 @@ if test "$PHP_DOM" != "no"; then
+                             namednodemap.c],
+                             $ext_shared)
+     PHP_SUBST(DOM_SHARED_LIBADD)
+-    PHP_INSTALL_HEADERS([ext/dom/xml_common.h])
++    PHP_INSTALL_HEADERS([ext/dom], [xml_common.h])
+     PHP_ADD_EXTENSION_DEP(dom, libxml)
+   ])
+ fi
+diff --git a/ext/filter/config.m4 b/ext/filter/config.m4
+index 0108a17fb7a..b7934701bb6 100644
+--- a/ext/filter/config.m4
++++ b/ext/filter/config.m4
+@@ -8,6 +8,6 @@ if test "$PHP_FILTER" != "no"; then
+   PHP_NEW_EXTENSION(filter, filter.c sanitizing_filters.c logical_filters.c callback_filter.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
+   PHP_SUBST(FILTER_SHARED_LIBADD)
+ 
+-  PHP_INSTALL_HEADERS([ext/filter/php_filter.h])
++  PHP_INSTALL_HEADERS([ext/filter], [php_filter.h])
+   PHP_ADD_EXTENSION_DEP(filter, pcre)
+ fi
+diff --git a/ext/gd/config.m4 b/ext/gd/config.m4
+index b31c9b2c0bd..ef55212d1ee 100644
+--- a/ext/gd/config.m4
++++ b/ext/gd/config.m4
+@@ -238,7 +238,7 @@ dnl Various checks for GD features
+     PHP_NEW_EXTENSION(gd, gd.c $extra_sources, $ext_shared,, \\$(GD_CFLAGS))
+     PHP_ADD_BUILD_DIR($ext_builddir/libgd)
+     GD_CFLAGS="-Wno-strict-prototypes -I$ext_srcdir/libgd $GD_CFLAGS"
+-    GD_HEADER_DIRS="ext/gd/ ext/gd/libgd/"
++    PHP_INSTALL_HEADERS([ext/gd], [php_gd.h libgd/])
+ 
+     PHP_TEST_BUILD(foobar, [], [
+       AC_MSG_ERROR([GD build test failed. Please check the config.log for details.])
+@@ -253,13 +253,12 @@ dnl Various checks for GD features
+     PHP_GD_CHECK_VERSION
+ 
+     PHP_NEW_EXTENSION(gd, gd.c $extra_sources, $ext_shared)
+-    GD_HEADER_DIRS="ext/gd/"
++    PHP_INSTALL_HEADERS([ext/gd], [php_gd.h])
+     PHP_CHECK_LIBRARY(gd, gdImageCreate, [], [
+       AC_MSG_ERROR([GD build test failed. Please check the config.log for details.])
+     ], [ $GD_SHARED_LIBADD ])
+   fi
+ 
+-  PHP_INSTALL_HEADERS([$GD_HEADER_DIRS])
+   PHP_SUBST(GD_CFLAGS)
+   PHP_SUBST(GDLIB_CFLAGS)
+   PHP_SUBST(GDLIB_LIBS)
+diff --git a/ext/gd/config.w32 b/ext/gd/config.w32
+index 09b09df95d3..b779df48e91 100644
+--- a/ext/gd/config.w32
++++ b/ext/gd/config.w32
+@@ -75,7 +75,7 @@ if (PHP_GD != "no") {
+ 			ADD_FLAG("LDFLAGS_GD", "/nodefaultlib:libcmt");
+ 		}
+ 
+-		PHP_INSTALL_HEADERS("", "ext/gd ext/gd/libgd" );
++		PHP_INSTALL_HEADERS("ext/gd", "php_gd.h libgd/");
+ 	} else {
+ 		WARNING("gd not enabled; libraries and headers not found");
+ 	}
+diff --git a/ext/gmp/config.m4 b/ext/gmp/config.m4
+index fa55751cf16..657e43b407f 100644
+--- a/ext/gmp/config.m4
++++ b/ext/gmp/config.m4
+@@ -27,7 +27,7 @@ if test "$PHP_GMP" != "no"; then
+     PHP_ADD_INCLUDE($PHP_GMP/include)
+   fi
+ 
+-  PHP_INSTALL_HEADERS([ext/gmp/php_gmp_int.h])
++  PHP_INSTALL_HEADERS([ext/gmp], [php_gmp_int.h])
+ 
+   PHP_NEW_EXTENSION(gmp, gmp.c, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
+   PHP_SUBST(GMP_SHARED_LIBADD)
+diff --git a/ext/hash/config.m4 b/ext/hash/config.m4
+index 46e66aa9f8c..1e1d2e3f698 100644
+--- a/ext/hash/config.m4
++++ b/ext/hash/config.m4
+@@ -36,7 +36,6 @@ else
+ fi
+ 
+ PHP_ADD_BUILD_DIR(ext/hash/murmur, 1)
+-PHP_HASH_CFLAGS="$PHP_HASH_CFLAGS -I@ext_srcdir@/xxhash"
+ 
+ EXT_HASH_SOURCES="hash.c hash_md.c hash_sha.c hash_ripemd.c hash_haval.c \
+   hash_tiger.c hash_gost.c hash_snefru.c hash_whirlpool.c hash_adler32.c \
+@@ -46,7 +45,7 @@ EXT_HASH_HEADERS="php_hash.h php_hash_md.h php_hash_sha.h php_hash_ripemd.h \
+   php_hash_haval.h php_hash_tiger.h php_hash_gost.h php_hash_snefru.h \
+   php_hash_whirlpool.h php_hash_adler32.h php_hash_crc32.h \
+   php_hash_fnv.h php_hash_joaat.h php_hash_sha3.h php_hash_murmur.h \
+-  php_hash_xxhash.h"
++  php_hash_xxhash.h xxhash/xxhash.h"
+ 
+ PHP_NEW_EXTENSION(hash, $EXT_HASH_SOURCES, 0,,$PHP_HASH_CFLAGS)
+ PHP_INSTALL_HEADERS(ext/hash, $EXT_HASH_HEADERS)
+diff --git a/ext/hash/config.w32 b/ext/hash/config.w32
+index d38b032efd3..bafbd0b9f8d 100644
+--- a/ext/hash/config.w32
++++ b/ext/hash/config.w32
+@@ -34,13 +34,9 @@ if (!CHECK_HEADER_ADD_INCLUDE('PMurHash.h', 'CFLAGS_HASH', hash_murmur_dir)) {
+ }
+ ADD_SOURCES(hash_murmur_dir, 'PMurHash.c PMurHash128.c', 'hash');
+ 
+-var hash_xxhash_dir = 'ext/hash/xxhash';
+-if (!CHECK_HEADER_ADD_INCLUDE('xxhash.h', 'CFLAGS_HASH', hash_xxhash_dir)) {
+-	ERROR('Unable to locate xxhash headers');
+-}
+-
+-PHP_INSTALL_HEADERS('ext/hash/',	'php_hash.h php_hash_md.h php_hash_sha.h ' +
++PHP_INSTALL_HEADERS('ext/hash',	'php_hash.h php_hash_md.h php_hash_sha.h ' +
+ 									'php_hash_ripemd.h php_hash_haval.h php_hash_tiger.h ' +
+ 									'php_hash_gost.h php_hash_snefru.h php_hash_whirlpool.h ' +
+ 									'php_hash_adler32.h php_hash_crc32.h php_hash_sha3.h ' +
+-									'php_hash_murmur.h php_hash_xxhash.h');
++									'php_hash_murmur.h php_hash_xxhash.h php_hash_fnv.h ' +
++									'php_hash_joaat.h xxhash/xxhash.h');
+diff --git a/ext/hash/php_hash_xxhash.h b/ext/hash/php_hash_xxhash.h
+index a1e8840ce27..ace70deedb0 100644
+--- a/ext/hash/php_hash_xxhash.h
++++ b/ext/hash/php_hash_xxhash.h
+@@ -18,7 +18,7 @@
+ #define PHP_HASH_XXHASH_H
+ 
+ #define XXH_INLINE_ALL 1
+-#include "xxhash.h"
++#include "xxhash/xxhash.h"
+ 
+ typedef struct {
+ 	XXH32_state_t s;
+diff --git a/ext/iconv/config.m4 b/ext/iconv/config.m4
+index 3cf400fe962..63221eddb0b 100644
+--- a/ext/iconv/config.m4
++++ b/ext/iconv/config.m4
+@@ -149,7 +149,7 @@ int main(void) {
+ 
+     PHP_NEW_EXTENSION(iconv, iconv.c, $ext_shared,, [-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
+     PHP_SUBST(ICONV_SHARED_LIBADD)
+-    PHP_INSTALL_HEADERS([ext/iconv/])
++    PHP_INSTALL_HEADERS([ext/iconv], [php_iconv.h])
+   else
+     AC_MSG_ERROR(Please reinstall the iconv library.)
+   fi
+diff --git a/ext/iconv/config.w32 b/ext/iconv/config.w32
+index 31423dd121e..0087df54fe5 100644
+--- a/ext/iconv/config.w32
++++ b/ext/iconv/config.w32
+@@ -17,7 +17,7 @@ if (PHP_ICONV != "no") {
+ 		if (!PHP_ICONV_SHARED) {
+ 			ADD_DEF_FILE("ext\\iconv\\php_iconv.def");
+ 		}
+-		PHP_INSTALL_HEADERS("", "ext/iconv");
++		PHP_INSTALL_HEADERS("ext/iconv", "php_iconv.h");
+ 	} else {
+ 		WARNING("iconv support can't be enabled, libraries or headers are missing")
+ 		PHP_ICONV = "no";
+diff --git a/ext/json/config.w32 b/ext/json/config.w32
+index 255f2787728..84f77b6f8c9 100644
+--- a/ext/json/config.w32
++++ b/ext/json/config.w32
+@@ -6,4 +6,4 @@ ADD_SOURCES(configure_module_dirname, "json_encoder.c json_parser.tab.c json_sca
+ 
+ ADD_MAKEFILE_FRAGMENT();
+ 
+-PHP_INSTALL_HEADERS("ext/json/", "php_json.h php_json_parser.h php_json_scanner.h");
++PHP_INSTALL_HEADERS("ext/json", "php_json.h php_json_parser.h php_json_scanner.h");
+diff --git a/ext/libxml/config.w32 b/ext/libxml/config.w32
+index b11c57bc44a..e890ee4fc4e 100644
+--- a/ext/libxml/config.w32
++++ b/ext/libxml/config.w32
+@@ -15,7 +15,7 @@ if (PHP_LIBXML == "yes") {
+ 		if (!PHP_LIBXML_SHARED) {
+ 			ADD_DEF_FILE("ext\\libxml\\php_libxml2.def");
+ 		}
+-		PHP_INSTALL_HEADERS("ext/libxml/", "php_libxml.h");
++		PHP_INSTALL_HEADERS("ext/libxml", "php_libxml.h");
+ 	} else {
+ 		WARNING("libxml support can't be enabled, iconv or libxml are missing")
+ 		PHP_LIBXML = "no"
+diff --git a/ext/libxml/config0.m4 b/ext/libxml/config0.m4
+index 044a58fa624..7bee0126378 100644
+--- a/ext/libxml/config0.m4
++++ b/ext/libxml/config0.m4
+@@ -12,6 +12,6 @@ if test "$PHP_LIBXML" != "no"; then
+   PHP_SETUP_LIBXML(LIBXML_SHARED_LIBADD, [
+     AC_DEFINE(HAVE_LIBXML,1,[ ])
+     PHP_NEW_EXTENSION(libxml, [libxml.c], $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
+-    PHP_INSTALL_HEADERS([ext/libxml/php_libxml.h])
++    PHP_INSTALL_HEADERS([ext/libxml], [php_libxml.h])
+   ])
+ fi
+diff --git a/ext/mysqli/config.m4 b/ext/mysqli/config.m4
+index ad7fb7f6bfa..ab060ebc4f1 100644
+--- a/ext/mysqli/config.m4
++++ b/ext/mysqli/config.m4
+@@ -65,10 +65,6 @@ if test "$PHP_MYSQLI" != "no"; then
+                   mysqli_exception.c mysqli_result_iterator.c"
+   PHP_NEW_EXTENSION(mysqli, $mysqli_sources, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
+   PHP_SUBST(MYSQLI_SHARED_LIBADD)
+-  PHP_INSTALL_HEADERS([ext/mysqli/php_mysqli_structs.h])
+-
+-  if test "$PHP_MYSQLI" = "yes" || test "$PHP_MYSQLI" = "mysqlnd"; then
+-    PHP_ADD_EXTENSION_DEP(mysqli, mysqlnd)
+-    PHP_INSTALL_HEADERS([ext/mysqli/mysqli_mysqlnd.h])
+-  fi
++  PHP_INSTALL_HEADERS([ext/mysqli], [php_mysqli_structs.h mysqli_mysqlnd.h])
++  PHP_ADD_EXTENSION_DEP(mysqli, mysqlnd)
+ fi
+diff --git a/ext/mysqli/config.w32 b/ext/mysqli/config.w32
+index c2c4781dd36..141f993afda 100644
+--- a/ext/mysqli/config.w32
++++ b/ext/mysqli/config.w32
+@@ -22,6 +22,6 @@ if (PHP_MYSQLI != "no") {
+ 	if (PHP_MYSQLI != "no") {
+ 		EXTENSION("mysqli", mysqli_source, PHP_MYSQLI_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
+ 		ADD_EXTENSION_DEP('mysqli', 'mysqlnd', true);
+-		PHP_INSTALL_HEADERS("ext/mysqli", "php_mysqli_structs.h");
++		PHP_INSTALL_HEADERS("ext/mysqli", "php_mysqli_structs.h mysqli_mysqlnd.h");
+ 	}
+ }
+diff --git a/ext/pdo/config.m4 b/ext/pdo/config.m4
+index 9b9a3e36df7..2b182d1e516 100644
+--- a/ext/pdo/config.m4
++++ b/ext/pdo/config.m4
+@@ -11,7 +11,7 @@ if test "$PHP_PDO" != "no"; then
+ 
+   PHP_NEW_EXTENSION(pdo, pdo.c pdo_dbh.c pdo_stmt.c pdo_sql_parser.c pdo_sqlstate.c, $ext_shared)
+   PHP_ADD_EXTENSION_DEP(pdo, spl, true)
+-  PHP_INSTALL_HEADERS(ext/pdo, [php_pdo.h php_pdo_driver.h php_pdo_error.h])
++  PHP_INSTALL_HEADERS([ext/pdo], [php_pdo.h php_pdo_driver.h php_pdo_error.h])
+ 
+   dnl so we always include the known-good working hack.
+   PHP_ADD_MAKEFILE_FRAGMENT
+diff --git a/ext/phar/config.w32 b/ext/phar/config.w32
+index c68ba08f2ca..16432165167 100644
+--- a/ext/phar/config.w32
++++ b/ext/phar/config.w32
+@@ -35,6 +35,7 @@ if (PHP_PHAR != "no") {
+ 		}
+ 	}
+ 	ADD_EXTENSION_DEP('phar', 'spl', true);
++	PHP_INSTALL_HEADERS("ext/phar", "php_phar.h");
+ 
+ 	ADD_MAKEFILE_FRAGMENT();
+ }
+diff --git a/ext/session/config.m4 b/ext/session/config.m4
+index da31bbde86c..f356102ac46 100644
+--- a/ext/session/config.m4
++++ b/ext/session/config.m4
+@@ -18,7 +18,7 @@ if test "$PHP_SESSION" != "no"; then
+   PHP_ADD_EXTENSION_DEP(session, hash, true)
+   PHP_ADD_EXTENSION_DEP(session, spl)
+   PHP_SUBST(SESSION_SHARED_LIBADD)
+-  PHP_INSTALL_HEADERS(ext/session, [php_session.h mod_files.h mod_user.h])
++  PHP_INSTALL_HEADERS([ext/session], [php_session.h mod_files.h mod_user.h])
+   AC_DEFINE(HAVE_PHP_SESSION,1,[ ])
+ fi
+ 
+@@ -38,6 +38,6 @@ if test "$PHP_MM" != "no"; then
+ 
+   PHP_ADD_LIBRARY_WITH_PATH(mm, $MM_DIR/$PHP_LIBDIR, SESSION_SHARED_LIBADD)
+   PHP_ADD_INCLUDE($MM_DIR/include)
+-  PHP_INSTALL_HEADERS([ext/session/mod_mm.h])
++  PHP_INSTALL_HEADERS([ext/session], [mod_mm.h])
+   AC_DEFINE(HAVE_LIBMM, 1, [Whether you have libmm])
+ fi
+diff --git a/ext/session/config.w32 b/ext/session/config.w32
+index aff34f3c847..bb3df15ac29 100644
+--- a/ext/session/config.w32
++++ b/ext/session/config.w32
+@@ -5,5 +5,5 @@ ARG_ENABLE("session", "session support", "yes");
+ if (PHP_SESSION == "yes") {
+ 	EXTENSION("session", "mod_user_class.c session.c mod_files.c mod_mm.c mod_user.c", false /* never shared */, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
+ 	AC_DEFINE("HAVE_PHP_SESSION", 1, "Session support");
+-	PHP_INSTALL_HEADERS("ext/session/", "mod_mm.h php_session.h mod_files.h mod_user.h");
++	PHP_INSTALL_HEADERS("ext/session", "mod_mm.h php_session.h mod_files.h mod_user.h");
+ }
+diff --git a/ext/simplexml/config.m4 b/ext/simplexml/config.m4
+index 8b8a6f814a1..734aa080fde 100644
+--- a/ext/simplexml/config.m4
++++ b/ext/simplexml/config.m4
+@@ -13,7 +13,7 @@ if test "$PHP_SIMPLEXML" != "no"; then
+   PHP_SETUP_LIBXML(SIMPLEXML_SHARED_LIBADD, [
+     AC_DEFINE(HAVE_SIMPLEXML,1,[ ])
+     PHP_NEW_EXTENSION(simplexml, simplexml.c, $ext_shared)
+-    PHP_INSTALL_HEADERS([ext/simplexml/php_simplexml.h ext/simplexml/php_simplexml_exports.h])
++    PHP_INSTALL_HEADERS([ext/simplexml], [php_simplexml.h php_simplexml_exports.h])
+     PHP_SUBST(SIMPLEXML_SHARED_LIBADD)
+   ])
+   PHP_ADD_EXTENSION_DEP(simplexml, libxml)
+diff --git a/ext/simplexml/config.w32 b/ext/simplexml/config.w32
+index a6011fedc20..8a1190d5272 100644
+--- a/ext/simplexml/config.w32
++++ b/ext/simplexml/config.w32
+@@ -21,7 +21,7 @@ if (PHP_SIMPLEXML == "yes") {
+ 			MESSAGE("\tSPL support in simplexml disabled");
+ 		}
+ 		ADD_FLAG("CFLAGS_SIMPLEXML", "/D PHP_SIMPLEXML_EXPORTS ");
+-		PHP_INSTALL_HEADERS("ext/simplexml/", "php_simplexml.h php_simplexml_exports.h");
++		PHP_INSTALL_HEADERS("ext/simplexml", "php_simplexml.h php_simplexml_exports.h");
+ 	} else {
+ 		PHP_SIMPLEXML = "no";
+ 		WARNING("simplexml not enabled; libraries and headers not found");
+diff --git a/ext/sockets/config.m4 b/ext/sockets/config.m4
+index d0fad902114..0fb11e773f2 100644
+--- a/ext/sockets/config.m4
++++ b/ext/sockets/config.m4
+@@ -103,5 +103,5 @@ if test "$PHP_SOCKETS" != "no"; then
+     [sockets.c multicast.c conversions.c sockaddr_conv.c sendrecvmsg.c],
+     [$ext_shared],,
+     $PHP_SOCKETS_CFLAGS)
+-  PHP_INSTALL_HEADERS([ext/sockets/], [php_sockets.h])
++  PHP_INSTALL_HEADERS([ext/sockets], [php_sockets.h])
+ fi
+diff --git a/ext/sodium/config.m4 b/ext/sodium/config.m4
+index 05d9ebd5a13..a7a9131602e 100644
+--- a/ext/sodium/config.m4
++++ b/ext/sodium/config.m4
+@@ -15,5 +15,6 @@ if test "$PHP_SODIUM" != "no"; then
+   SODIUM_COMPILER_FLAGS="$LIBSODIUM_CFLAGS -Wno-type-limits"
+   AX_CHECK_COMPILE_FLAG([-Wno-logical-op], SODIUM_COMPILER_FLAGS="$SODIUM_COMPILER_FLAGS -Wno-logical-op", , [-Werror])
+   PHP_NEW_EXTENSION(sodium, libsodium.c sodium_pwhash.c, $ext_shared, , $SODIUM_COMPILER_FLAGS)
++  PHP_INSTALL_HEADERS([ext/sodium], [php_libsodium.h])
+   PHP_SUBST(SODIUM_SHARED_LIBADD)
+ fi
+diff --git a/ext/sodium/config.w32 b/ext/sodium/config.w32
+index 2ff8b998d2d..738ef666eb0 100644
+--- a/ext/sodium/config.w32
++++ b/ext/sodium/config.w32
+@@ -6,7 +6,7 @@ if (PHP_SODIUM != "no") {
+ 	if (CHECK_LIB("libsodium.lib", "sodium", PHP_SODIUM) && CHECK_HEADER_ADD_INCLUDE("sodium.h", "CFLAGS_SODIUM")) {
+ 		EXTENSION("sodium", "libsodium.c sodium_pwhash.c");
+ 		AC_DEFINE('HAVE_LIBSODIUMLIB', 1 , 'Have the Sodium library');
+-		PHP_INSTALL_HEADERS("ext/sodium/", "php_libsodium.h");
++		PHP_INSTALL_HEADERS("ext/sodium", "php_libsodium.h");
+ 	} else {
+ 		WARNING("libsodium not enabled; libraries and headers not found");
+ 	}
+diff --git a/ext/xml/config.m4 b/ext/xml/config.m4
+index 208f9e4c160..5c07ce079de 100644
+--- a/ext/xml/config.m4
++++ b/ext/xml/config.m4
+@@ -32,6 +32,6 @@ if test "$PHP_XML" != "no"; then
+ 
+   PHP_NEW_EXTENSION(xml, xml.c $xml_extra_sources, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
+   PHP_SUBST(XML_SHARED_LIBADD)
+-  PHP_INSTALL_HEADERS([ext/xml/])
++  PHP_INSTALL_HEADERS([ext/xml], [expat_compat.h php_xml.h])
+   AC_DEFINE(HAVE_XML, 1, [ ])
+ fi
+diff --git a/ext/xml/config.w32 b/ext/xml/config.w32
+index c0bb3168e88..f4fec691909 100644
+--- a/ext/xml/config.w32
++++ b/ext/xml/config.w32
+@@ -13,7 +13,7 @@ if (PHP_XML == "yes") {
+ 		if (!PHP_XML_SHARED) {
+ 			ADD_FLAG("CFLAGS_XML", "/D LIBXML_STATIC ");
+ 		}
+-		PHP_INSTALL_HEADERS("", "ext/xml");
++		PHP_INSTALL_HEADERS("ext/xml", "expat_compat.h php_xml.h");
+ 	} else {
+ 		WARNING("xml support can't be enabled, libraries or headers are missing")
+ 		PHP_XML = "no"
+diff --git a/sapi/cli/config.m4 b/sapi/cli/config.m4
+index 1b8e67f0b39..3e58a9aeb74 100644
+--- a/sapi/cli/config.m4
++++ b/sapi/cli/config.m4
+@@ -56,6 +56,6 @@ if test "$PHP_CLI" != "no"; then
+ 
+   PHP_OUTPUT(sapi/cli/php.1)
+ 
+-  PHP_INSTALL_HEADERS([sapi/cli/cli.h])
++  PHP_INSTALL_HEADERS([sapi/cli], [cli.h])
+ fi
+ AC_MSG_RESULT($PHP_CLI)
+diff --git a/sapi/cli/config.w32 b/sapi/cli/config.w32
+index 28bb2fd4c6d..2a3475e5de6 100644
+--- a/sapi/cli/config.w32
++++ b/sapi/cli/config.w32
+@@ -8,6 +8,7 @@ if (PHP_CLI == "yes") {
+ 	ADD_FLAG("LIBS_CLI", "ws2_32.lib");
+ 	ADD_FLAG("LIBS_CLI", "shell32.lib");
+ 	ADD_FLAG("LDFLAGS_CLI", "/stack:67108864");
++	PHP_INSTALL_HEADERS("sapi/cli", "cli.h");
+ 
+ 	if (CHECK_LIB("edit_a.lib;edit.lib", "cli", PHP_CLI) &&
+ 		CHECK_HEADER_ADD_INCLUDE("editline/readline.h", "CFLAGS_CLI")) {
+diff --git a/sapi/embed/config.m4 b/sapi/embed/config.m4
+index 39d7dcf0a3f..1b44ee94120 100644
+--- a/sapi/embed/config.m4
++++ b/sapi/embed/config.m4
+@@ -26,7 +26,7 @@ if test "$PHP_EMBED" != "no"; then
+   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_INSTALL_HEADERS([sapi/embed/php_embed.h])
++    PHP_INSTALL_HEADERS([sapi/embed], [php_embed.h])
+   fi
+   AC_MSG_RESULT([$PHP_EMBED_TYPE])
+ else
+-- 
+2.47.1
+

+ 7 - 0
package/php/php.mk

@@ -379,5 +379,12 @@ HOST_PHP_DEPENDENCIES = \
 	host-pcre2 \
 	host-pkgconf
 
+# PHP can't be AUTORECONFed the standard way unfortunately
+HOST_PHP_DEPENDENCIES += host-autoconf host-automake host-libtool
+define HOST_PHP_BUILDCONF
+	cd $(@D) ; $(HOST_MAKE_ENV) ./buildconf --force
+endef
+HOST_PHP_PRE_CONFIGURE_HOOKS += HOST_PHP_BUILDCONF
+
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))