]> granicus.if.org Git - php/commitdiff
Refactor undefining PACKAGE_* symbols
authorPeter Kokot <peterkokot@gmail.com>
Thu, 11 Jul 2019 00:00:51 +0000 (02:00 +0200)
committerPeter Kokot <peterkokot@gmail.com>
Thu, 11 Jul 2019 00:00:51 +0000 (02:00 +0200)
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

build/build.mk
build/php.m4
configure.ac
scripts/phpize.in
scripts/phpize.m4

index 909b71637ef9f407859678fe961a257d46252625..741857a5f214f03e3b4b427b6861409c29fc7c65 100644 (file)
@@ -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 $@
index db8c9beb385a596b2e41afddd3fe256f9e74688d..a17a4b9b6066e4c5bb89a81c19639d9dbd30b1d3 100644 (file)
@@ -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
+])
index bed45e7bfe0751ae2441c1472ac0875d4bb39c9f..e4ff616306df1319c3ad5e305e2553047c42aba3 100644 (file)
@@ -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
 
index 0d89341a75f7b2f14ec83a3d41f9955ff03e406a..04864733aef40cd4002bba5691eb208111a452de 100644 (file)
@@ -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
index f583a521469f957c31847d72bd0d69a18f96d5e2..cdd0e12989c6223b3e0cc3f0172e7a8d54c4fb7f 100644 (file)
@@ -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