Prefer to find icu via pkg-config instead of icu-config. Honor the CXXFLAGS that are indicated by either of those tools. Work around new ICU requirement that a namespace be used by specifying the flag that overrides that requirement. Includes relevant parts of the following upstream commits: DateFormat plays nice with Calendar, TimeZone (just the part that fixes the extern "C" issues) https://github.com/php/php-src/commit/eb346ef0f419b90739aadfb6cc7b7436c5b521d9 fix typo https://github.com/php/php-src/commit/977974f95fa5b76f7e0e9d29e39c0dc52dfaa913 Fix typo https://github.com/php/php-src/commit/50b38322b96416b0a5609591a52178f6100768da Fix #73956 Link use CC instead of CXX https://github.com/php/php-src/commit/6af22d0d3ed224d89be1d1e9e53ff7e2e2e5439d Fixed bug #76153 Intl compilation fails with icu4c 61.1 https://github.com/php/php-src/commit/710284cbc4a54cac0a9ec4ea29a7486e0d99a33b Fix clang build, ref buf #76153 https://github.com/php/php-src/commit/8b104d789317d96f6d3e23e635f0ca288c0a23ee Fix shared ext/intl compilation https://github.com/php/php-src/commit/2bd299f7318492fd7e5cafffa562d76ba60e69d4 Rename var https://github.com/php/php-src/commit/ed5aabe8b78d8487ffc6091e0670753d59bb7f5a Group common flags https://github.com/php/php-src/commit/09d7ffabcd99fe9b99c4206f321fecc506635072 --- ext/intl/collator/collator.h.orig 2015-09-01 15:09:37.000000000 -0500 +++ ext/intl/collator/collator.h 2019-10-23 19:13:42.000000000 -0500 @@ -16,7 +16,7 @@ */ #ifndef COLLATOR_COLLATOR_H -#define CCOLLATOR_COLLATOR_H +#define COLLATOR_COLLATOR_H #include --- ext/intl/collator/collator_attr.h.orig 2015-09-01 15:09:37.000000000 -0500 +++ ext/intl/collator/collator_attr.h 2019-10-23 19:13:42.000000000 -0500 @@ -16,7 +16,7 @@ */ #ifndef COLLATOR_ATTR_H -#define CCOLLATOR_ATTR_H +#define COLLATOR_ATTR_H #include --- ext/intl/config.m4.orig 2015-09-01 15:09:37.000000000 -0500 +++ ext/intl/config.m4 2019-10-23 19:13:42.000000000 -0500 @@ -9,6 +9,7 @@ PHP_SETUP_ICU(INTL_SHARED_LIBADD) PHP_SUBST(INTL_SHARED_LIBADD) PHP_REQUIRE_CXX() + INTL_COMMON_FLAGS="$ICU_INCS" if test "$icu_version" -ge "4002"; then icu_spoof_src=" spoofchecker/spoofchecker_class.c \ spoofchecker/spoofchecker.c\ @@ -55,7 +56,6 @@ msgformat/msgformat_class.c \ msgformat/msgformat_data.c \ msgformat/msgformat_format.c \ - msgformat/msgformat_helpers.cpp \ msgformat/msgformat_parse.c \ grapheme/grapheme_string.c \ grapheme/grapheme_util.c \ @@ -66,7 +66,16 @@ transliterator/transliterator_class.c \ transliterator/transliterator_methods.c \ idn/idn.c \ - $icu_spoof_src, $ext_shared,,$ICU_INCS) + $icu_spoof_src, $ext_shared,,$INTL_COMMON_FLAGS,cxx) + + PHP_INTL_CXX_SOURCES="msgformat/msgformat_helpers.cpp" + PHP_INTL_CXX_FLAGS="$INTL_COMMON_FLAGS $ICU_CXXFLAGS" + if test "$ext_shared" = "no"; then + PHP_ADD_SOURCES(PHP_EXT_DIR(intl), $PHP_INTL_CXX_SOURCES, $PHP_INTL_CXX_FLAGS) + else + PHP_ADD_SOURCES_X(PHP_EXT_DIR(intl), $PHP_INTL_CXX_SOURCES, $PHP_INTL_CXX_FLAGS, shared_objects_intl, yes) + fi + PHP_ADD_BUILD_DIR($ext_builddir/collator) PHP_ADD_BUILD_DIR($ext_builddir/common) PHP_ADD_BUILD_DIR($ext_builddir/formatter) --- ext/intl/grapheme/grapheme.h.orig 2015-09-01 15:09:37.000000000 -0500 +++ ext/intl/grapheme/grapheme.h 2019-10-23 19:13:35.000000000 -0500 @@ -19,7 +19,6 @@ #include #include -#include PHP_FUNCTION(grapheme_strlen); PHP_FUNCTION(grapheme_strpos); --- ext/intl/php_intl.c.orig 2015-09-01 15:09:37.000000000 -0500 +++ ext/intl/php_intl.c 2019-10-23 19:13:35.000000000 -0500 @@ -41,6 +41,8 @@ #include "formatter/formatter_main.h" #include "formatter/formatter_parse.h" +#include "grapheme/grapheme.h" + #include "msgformat/msgformat.h" #include "msgformat/msgformat_class.h" #include "msgformat/msgformat_attr.h" --- ext/intl/php_intl.h.orig 2015-09-01 15:09:37.000000000 -0500 +++ ext/intl/php_intl.h 2019-10-23 19:13:35.000000000 -0500 @@ -22,8 +22,13 @@ #include +/* Even if we're included from C++, don't introduce C++ definitions + * because we were included with extern "C". The effect would be that + * when the headers defined any method, they would do so with C linkage */ +#undef U_SHOW_CPLUSPLUS_API +#define U_SHOW_CPLUSPLUS_API 0 #include "collator/collator_sort.h" -#include "grapheme/grapheme.h" +#include #include "intl_error.h" extern zend_module_entry intl_module_entry;