summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Kokot <peterkokot@gmail.com>2019-04-10 01:04:02 +0200
committerPeter Kokot <peterkokot@gmail.com>2019-04-13 07:00:17 +0200
commit69b20f51e15d535da77f830709a4f1b5a682c265 (patch)
treec9819130681eca73f1c9d03dbb3a2dad277c3d15
parent769db42341845544eebd4c939ecdaf87ce711d85 (diff)
downloadphp-git-69b20f51e15d535da77f830709a4f1b5a682c265.tar.gz
Disable PACKAGE_* preprocessor symbols
Autoconf defines PACKAGE_* symbols: - PACKAGE_NAME - PACKAGE_VERSION - PACKAGE_TARNAME - PACKAGE_STRING - PACKAGE_BUGREPORT - PACKAGE_URL and appends them to the generated config.h.in files. With AC_INIT change via afd52f9d9986d92dd0c63832a07ab1a16bf11d53 where package version, URL, bug report location and similar meta data are defined, these preprocessor macros are then non empty strings in the generated configuration header file. When using phpize, PHP shares the config files in extensions, warnings of redefined macros appear, such as: - `warning: 'PACKAGE_NAME' macro redefined` This patch now disables these non utilized symbols in the generated config header files. Better practice would be to include only API specific headers where needed but this would require even more refactorings. Some extensions such as pcre, pgsql, and pdo_pgsql solve this issue by undefining some of these symbols before including the library configuration headers in the code also. Because these symbols can be defined by any library which uses Autotools. Additionally, the unused PACKAGE_* symbols were cleaned for the bundled libmbfl library and with this patch not needed undef code removed.
-rw-r--r--build/build2.mk6
-rw-r--r--ext/mbstring/libmbfl/config.h.in24
-rw-r--r--ext/pcre/pcre2lib/config.h5
-rwxr-xr-xext/pcre/upgrade-pcre.php5
-rw-r--r--ext/pdo_pgsql/pdo_pgsql.c5
-rw-r--r--ext/pdo_pgsql/pgsql_driver.c6
-rw-r--r--ext/pgsql/pgsql.c6
-rw-r--r--scripts/phpize.in4
8 files changed, 8 insertions, 53 deletions
diff --git a/build/build2.mk b/build/build2.mk
index 79824cab8f..690166e887 100644
--- a/build/build2.mk
+++ b/build/build2.mk
@@ -28,11 +28,13 @@ SUPPRESS_WARNINGS ?= 2>&1 | (egrep -v '(AC_PROG_CXXCPP was called before AC_PROG
all: $(targets)
$(config_h_in): configure
-# explicitly remove target since autoheader does not seem to work
-# correctly otherwise (timestamps are not updated)
+# 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.
@echo rebuilding $@
@rm -f $@
$(PHP_AUTOHEADER) $(SUPPRESS_WARNINGS)
+ sed -e 's/^#undef PACKAGE_[^ ]*/\/\* & \*\//g' < $@ > $@.tmp && mv $@.tmp $@
aclocal.m4: configure.ac acinclude.m4
@echo rebuilding $@
diff --git a/ext/mbstring/libmbfl/config.h.in b/ext/mbstring/libmbfl/config.h.in
index fba649b0c4..0dcad471d4 100644
--- a/ext/mbstring/libmbfl/config.h.in
+++ b/ext/mbstring/libmbfl/config.h.in
@@ -42,30 +42,6 @@
*/
#undef LT_OBJDIR
-/* Name of package */
-#undef PACKAGE
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the home page for this package. */
-#undef PACKAGE_URL
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* Version number of package */
-#undef VERSION
-
/* Define to rpl_malloc if the replacement function should be used. */
#undef malloc
diff --git a/ext/pcre/pcre2lib/config.h b/ext/pcre/pcre2lib/config.h
index 439c895e4d..7864897743 100644
--- a/ext/pcre/pcre2lib/config.h
+++ b/ext/pcre/pcre2lib/config.h
@@ -7,11 +7,6 @@
# include <php_config.h>
#endif
-#undef PACKAGE_NAME
-#undef PACKAGE_VERSION
-#undef PACKAGE_TARNAME
-#undef PACKAGE_STRING
-
#define SUPPORT_UNICODE 1
#define SUPPORT_PCRE2_8 1
diff --git a/ext/pcre/upgrade-pcre.php b/ext/pcre/upgrade-pcre.php
index 3b642dfacc..831989253f 100755
--- a/ext/pcre/upgrade-pcre.php
+++ b/ext/pcre/upgrade-pcre.php
@@ -109,11 +109,6 @@ $prepend_config_h = '
# include <php_config.h>
#endif
-#undef PACKAGE_NAME
-#undef PACKAGE_VERSION
-#undef PACKAGE_TARNAME
-#undef PACKAGE_STRING
-
#define SUPPORT_UCP
#define SUPPORT_UTF8
diff --git a/ext/pdo_pgsql/pdo_pgsql.c b/ext/pdo_pgsql/pdo_pgsql.c
index a27c1e85e7..8d60fe420b 100644
--- a/ext/pdo_pgsql/pdo_pgsql.c
+++ b/ext/pdo_pgsql/pdo_pgsql.c
@@ -29,11 +29,6 @@
#include "php_pdo_pgsql_int.h"
#ifdef HAVE_PG_CONFIG_H
-#undef PACKAGE_BUGREPORT
-#undef PACKAGE_NAME
-#undef PACKAGE_STRING
-#undef PACKAGE_TARNAME
-#undef PACKAGE_VERSION
#include <pg_config.h>
#endif
diff --git a/ext/pdo_pgsql/pgsql_driver.c b/ext/pdo_pgsql/pgsql_driver.c
index e61e82c642..e8b748a36f 100644
--- a/ext/pdo_pgsql/pgsql_driver.c
+++ b/ext/pdo_pgsql/pgsql_driver.c
@@ -31,12 +31,6 @@
#include "pdo/php_pdo_driver.h"
#include "pdo/php_pdo_error.h"
#include "ext/standard/file.h"
-
-#undef PACKAGE_BUGREPORT
-#undef PACKAGE_NAME
-#undef PACKAGE_STRING
-#undef PACKAGE_TARNAME
-#undef PACKAGE_VERSION
#include "pg_config.h" /* needed for PG_VERSION */
#include "php_pdo_pgsql.h"
#include "php_pdo_pgsql_int.h"
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index 66539d1c2a..1be592a319 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -38,12 +38,6 @@
#ifdef PHP_WIN32
# include "win32/time.h"
#endif
-
-#undef PACKAGE_BUGREPORT
-#undef PACKAGE_NAME
-#undef PACKAGE_STRING
-#undef PACKAGE_TARNAME
-#undef PACKAGE_VERSION
#include "php_pgsql.h"
#include "php_globals.h"
#include "zend_exceptions.h"
diff --git a/scripts/phpize.in b/scripts/phpize.in
index 57c09555d2..ccb9357574 100644
--- a/scripts/phpize.in
+++ b/scripts/phpize.in
@@ -160,6 +160,10 @@ 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