summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Kokot <peterkokot@gmail.com>2019-07-11 02:00:51 +0200
committerPeter Kokot <peterkokot@gmail.com>2019-07-11 02:00:51 +0200
commita6daded1a4b7d715d9b1585fe9df269ca73e2bac (patch)
treef08e3176c249071793c35fdc76568c3e870d3a0b
parentd63fdced2e9bc2aa6c0e07958b8991e7f222de50 (diff)
downloadphp-git-a6daded1a4b7d715d9b1585fe9df269ca73e2bac.tar.gz
Refactor undefining PACKAGE_* symbols
Instead of patching configuration headers template generated by the given tools - autoheader, this moves patching these symbols to the configure step before creating and invoking the config.status and before the configuration header file is generated from the patched template. Closes GH-4374
-rw-r--r--build/build.mk4
-rw-r--r--build/php.m416
-rw-r--r--configure.ac4
-rw-r--r--scripts/phpize.in4
-rw-r--r--scripts/phpize.m42
5 files changed, 23 insertions, 7 deletions
diff --git a/build/build.mk b/build/build.mk
index 909b71637e..741857a5f2 100644
--- a/build/build.mk
+++ b/build/build.mk
@@ -34,9 +34,7 @@ configure: configure.ac $(PHP_M4_FILES)
$(config_h_in): configure
# Explicitly remove target since autoheader does not seem to work correctly
-# otherwise (timestamps are not updated). Also disable PACKAGE_* symbols in the
-# generated php_config.h.in template.
+# otherwise (timestamps are not updated).
@echo rebuilding $@
@rm -f $@
@$(PHP_AUTOHEADER) $(PHP_AUTOCONF_FLAGS)
- @sed -e 's/^#undef PACKAGE_[^ ]*/\/\* & \*\//g' < $@ > $@.tmp && mv $@.tmp $@
diff --git a/build/php.m4 b/build/php.m4
index db8c9beb38..a17a4b9b60 100644
--- a/build/php.m4
+++ b/build/php.m4
@@ -2715,3 +2715,19 @@ int main() {
AC_DEFINE_UNQUOTED(AS_TR_CPP([PHP_HAVE_$1_INSTRUCTIONS]),
[$have_ext_instructions], [Whether the compiler supports $1 instructions])
])
+
+dnl
+dnl PHP_PATCH_CONFIG_HEADERS([FILE])
+dnl
+dnl PACKAGE_* symbols are automatically defined by Autoconf. When including
+dnl configuration header, warnings about redefined symbols are emitted for such
+dnl symbols if they are defined by multiple libraries. This disables all
+dnl PACKAGE_* symbols in the generated configuration header template FILE. For
+dnl example, main/php_config.h.in for PHP or config.h.in for PHP extensions.
+dnl
+AC_DEFUN([PHP_PATCH_CONFIG_HEADERS], [
+ AC_MSG_NOTICE([patching $1])
+
+ $SED -e 's/^#undef PACKAGE_[^ ]*/\/\* & \*\//g' < $srcdir/$1 \
+ > $srcdir/$1.tmp && mv $srcdir/$1.tmp $srcdir/$1
+])
diff --git a/configure.ac b/configure.ac
index bed45e7bfe..e4ff616306 100644
--- a/configure.ac
+++ b/configure.ac
@@ -27,6 +27,7 @@ PHP_CONFIG_NICE(config.nice)
PHP_CANONICAL_HOST_TARGET
AC_CONFIG_HEADERS([main/php_config.h])
+
AH_TOP([
#ifndef PHP_CONFIG_H
#define PHP_CONFIG_H
@@ -1585,6 +1586,9 @@ $PHP_OUTPUT_FILES"
dnl Generate build files.
AC_CONFIG_FILES([$ALL_OUTPUT_FILES])
+
+AC_CONFIG_COMMANDS_PRE([PHP_PATCH_CONFIG_HEADERS([main/php_config.h.in])])
+
AC_CONFIG_COMMANDS([default],[
cat <<X
diff --git a/scripts/phpize.in b/scripts/phpize.in
index 0d89341a75..04864733ae 100644
--- a/scripts/phpize.in
+++ b/scripts/phpize.in
@@ -163,10 +163,6 @@ phpize_autotools()
$PHP_AUTOCONF || exit 1
$PHP_AUTOHEADER || exit 1
-
- # Disable PACKAGE_* symbols in config.h.in
- $SED -e 's/^#undef PACKAGE_[^ ]*/\/\* & \*\//g' < config.h.in > config.h.in.tmp
- mv config.h.in.tmp config.h.in
}
# Main script
diff --git a/scripts/phpize.m4 b/scripts/phpize.m4
index f583a52146..cdd0e12989 100644
--- a/scripts/phpize.m4
+++ b/scripts/phpize.m4
@@ -210,4 +210,6 @@ test -d modules || $php_shtool mkdir modules
AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_COMMANDS_PRE([PHP_PATCH_CONFIG_HEADERS([config.h.in])])
+
AC_OUTPUT