Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 1 | From: Hugh McMaster <hugh.mcmaster@outlook.com> |
| 2 | Date: Wed, 5 Dec 2018 23:27:30 +1100 |
| 3 | Subject: ext/intl: Use pkg-config to detect icu |
| 4 | |
| 5 | The developers of icu recommend using pkg-config to detect icu, |
| 6 | because icu-config is deprecated. |
| 7 | --- |
| 8 | acinclude.m4 | 56 +++++++----------------------------------------------- |
| 9 | ext/intl/config.m4 | 16 ++++++---------- |
| 10 | 2 files changed, 13 insertions(+), 59 deletions(-) |
| 11 | |
| 12 | --- php7.3.orig/acinclude.m4 |
| 13 | +++ php7.3/acinclude.m4 |
| 14 | @@ -2168,58 +2168,16 @@ dnl |
| 15 | dnl Common setup macro for ICU |
| 16 | dnl |
| 17 | AC_DEFUN([PHP_SETUP_ICU],[ |
| 18 | - PHP_ARG_WITH(icu-dir,, |
| 19 | - [ --with-icu-dir=DIR Specify where ICU libraries and headers can be found], DEFAULT, no) |
| 20 | + PKG_CHECK_MODULES([ICU], [icu-io >= 50.1]) |
| 21 | |
| 22 | - if test "$PHP_ICU_DIR" = "no"; then |
| 23 | - PHP_ICU_DIR=DEFAULT |
| 24 | - fi |
| 25 | - |
| 26 | - if test "$PHP_ICU_DIR" = "DEFAULT"; then |
| 27 | - dnl Try to find icu-config |
| 28 | - AC_PATH_PROG(ICU_CONFIG, icu-config, no, [$PATH:/usr/local/bin]) |
| 29 | - else |
| 30 | - ICU_CONFIG="$PHP_ICU_DIR/bin/icu-config" |
| 31 | - fi |
| 32 | - |
| 33 | - AC_MSG_CHECKING([for location of ICU headers and libraries]) |
| 34 | - |
| 35 | - dnl Trust icu-config to know better what the install prefix is.. |
| 36 | - icu_install_prefix=`$ICU_CONFIG --prefix 2> /dev/null` |
| 37 | - if test "$?" != "0" || test -z "$icu_install_prefix"; then |
| 38 | - AC_MSG_RESULT([not found]) |
| 39 | - AC_MSG_ERROR([Unable to detect ICU prefix or $ICU_CONFIG failed. Please verify ICU install prefix and make sure icu-config works.]) |
| 40 | - else |
| 41 | - AC_MSG_RESULT([$icu_install_prefix]) |
| 42 | - |
| 43 | - dnl Check ICU version |
| 44 | - AC_MSG_CHECKING([for ICU 4.0 or greater]) |
| 45 | - icu_version_full=`$ICU_CONFIG --version` |
| 46 | - ac_IFS=$IFS |
| 47 | - IFS="." |
| 48 | - set $icu_version_full |
| 49 | - IFS=$ac_IFS |
| 50 | - icu_version=`expr [$]1 \* 1000 + [$]2` |
| 51 | - AC_MSG_RESULT([found $icu_version_full]) |
| 52 | - |
| 53 | - if test "$icu_version" -lt "4000"; then |
| 54 | - AC_MSG_ERROR([ICU version 4.0 or later is required]) |
| 55 | - fi |
| 56 | + PHP_EVAL_INCLINE($ICU_CFLAGS) |
| 57 | + PHP_EVAL_LIBLINE($ICU_LIBS, $1) |
| 58 | |
| 59 | - ICU_VERSION=$icu_version |
| 60 | - ICU_INCS=`$ICU_CONFIG --cppflags-searchpath` |
| 61 | - ICU_LIBS=`$ICU_CONFIG --ldflags --ldflags-icuio` |
| 62 | - PHP_EVAL_INCLINE($ICU_INCS) |
| 63 | - PHP_EVAL_LIBLINE($ICU_LIBS, $1) |
| 64 | + ICU_CFLAGS="$ICU_CFLAGS -DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1" |
| 65 | + ICU_CXXFLAGS="$ICU_CXXFLAGS -DUNISTR_FROM_CHAR_EXPLICIT=explicit -DUNISTR_FROM_STRING_EXPLICIT=explicit" |
| 66 | |
| 67 | - ICU_CXXFLAGS=`$ICU_CONFIG --cxxflags` |
| 68 | - if test "$icu_version" -ge "49000"; then |
| 69 | - ICU_CXXFLAGS="$ICU_CXXFLAGS -DUNISTR_FROM_CHAR_EXPLICIT=explicit -DUNISTR_FROM_STRING_EXPLICIT=explicit" |
| 70 | - ICU_CFLAGS="-DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1" |
| 71 | - fi |
| 72 | - if test "$icu_version" -ge "60000"; then |
| 73 | - ICU_CFLAGS="$ICU_CFLAGS -DU_HIDE_OBSOLETE_UTF_OLD_H=1" |
| 74 | - fi |
| 75 | + if $PKG_CONFIG icu-io --atleast-version=60; then |
| 76 | + ICU_CFLAGS="$ICU_CFLAGS -DU_HIDE_OBSOLETE_UTF_OLD_H=1" |
| 77 | fi |
| 78 | ]) |
| 79 | |
| 80 | --- php7.3.orig/ext/intl/config.m4 |
| 81 | +++ php7.3/ext/intl/config.m4 |
| 82 | @@ -9,15 +9,7 @@ if test "$PHP_INTL" != "no"; then |
| 83 | PHP_SETUP_ICU(INTL_SHARED_LIBADD) |
| 84 | PHP_SUBST(INTL_SHARED_LIBADD) |
| 85 | PHP_REQUIRE_CXX() |
| 86 | - INTL_COMMON_FLAGS="$ICU_INCS $ICU_CFLAGS -Wno-write-strings -D__STDC_LIMIT_MACROS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1" |
| 87 | - if test "$icu_version" -ge "4002"; then |
| 88 | - icu_spoof_src=" spoofchecker/spoofchecker_class.c \ |
| 89 | - spoofchecker/spoofchecker.c\ |
| 90 | - spoofchecker/spoofchecker_create.c\ |
| 91 | - spoofchecker/spoofchecker_main.c" |
| 92 | - else |
| 93 | - icu_spoof_src="" |
| 94 | - fi |
| 95 | + INTL_COMMON_FLAGS="$ICU_CFLAGS -Wno-write-strings -D__STDC_LIMIT_MACROS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1" |
| 96 | PHP_NEW_EXTENSION(intl, php_intl.c \ |
| 97 | intl_error.c \ |
| 98 | intl_convert.c \ |
| 99 | @@ -68,7 +60,11 @@ if test "$PHP_INTL" != "no"; then |
| 100 | transliterator/transliterator_methods.c \ |
| 101 | uchar/uchar.c \ |
| 102 | idn/idn.c \ |
| 103 | - $icu_spoof_src, $ext_shared,,$INTL_COMMON_FLAGS,cxx) |
| 104 | + spoofchecker/spoofchecker_class.c \ |
| 105 | + spoofchecker/spoofchecker.c\ |
| 106 | + spoofchecker/spoofchecker_create.c\ |
| 107 | + spoofchecker/spoofchecker_main.c \ |
| 108 | + , $ext_shared,,$INTL_COMMON_FLAGS,cxx) |
| 109 | |
| 110 | PHP_INTL_CXX_SOURCES="intl_convertcpp.cpp \ |
| 111 | common/common_enum.cpp \ |