Skip to content

Commit 20fa2e7

Browse files
hughmcmasternikic
authored andcommitted
ext/intl: Use pkg-config to detect icu
The developers of icu recommend using pkg-config to detect icu, because icu-config is deprecated.
1 parent 02513f1 commit 20fa2e7

File tree

2 files changed

+8
-47
lines changed

2 files changed

+8
-47
lines changed

acinclude.m4

+7-46
Original file line numberDiff line numberDiff line change
@@ -2119,55 +2119,16 @@ dnl
21192119
dnl Common setup macro for ICU
21202120
dnl
21212121
AC_DEFUN([PHP_SETUP_ICU],[
2122-
PHP_ARG_WITH(icu-dir,,
2123-
[ --with-icu-dir=DIR Specify where ICU libraries and headers can be found], DEFAULT, no)
2122+
PKG_CHECK_MODULES([ICU], [icu-io >= 50.1])
21242123
2125-
if test "$PHP_ICU_DIR" = "no"; then
2126-
PHP_ICU_DIR=DEFAULT
2127-
fi
2128-
2129-
if test "$PHP_ICU_DIR" = "DEFAULT"; then
2130-
dnl Try to find icu-config
2131-
AC_PATH_PROG(ICU_CONFIG, icu-config, no, [$PATH:/usr/local/bin])
2132-
else
2133-
ICU_CONFIG="$PHP_ICU_DIR/bin/icu-config"
2134-
fi
2135-
2136-
AC_MSG_CHECKING([for location of ICU headers and libraries])
2137-
2138-
dnl Trust icu-config to know better what the install prefix is..
2139-
icu_install_prefix=`$ICU_CONFIG --prefix 2> /dev/null`
2140-
if test "$?" != "0" || test -z "$icu_install_prefix"; then
2141-
AC_MSG_RESULT([not found])
2142-
AC_MSG_ERROR([Unable to detect ICU prefix or $ICU_CONFIG failed. Please verify ICU install prefix and make sure icu-config works.])
2143-
else
2144-
AC_MSG_RESULT([$icu_install_prefix])
2124+
PHP_EVAL_INCLINE($ICU_CFLAGS)
2125+
PHP_EVAL_LIBLINE($ICU_LIBS, $1)
21452126
2146-
dnl Check ICU version
2147-
AC_MSG_CHECKING([for ICU 50.1 or greater])
2148-
icu_version_full=`$ICU_CONFIG --version`
2149-
ac_IFS=$IFS
2150-
IFS="."
2151-
set $icu_version_full
2152-
IFS=$ac_IFS
2153-
icu_version=`expr [$]1 \* 1000 + [$]2`
2154-
AC_MSG_RESULT([found $icu_version_full])
2127+
ICU_CFLAGS="$ICU_CFLAGS -DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1"
2128+
ICU_CXXFLAGS="$ICU_CXXFLAGS -DUNISTR_FROM_CHAR_EXPLICIT=explicit -DUNISTR_FROM_STRING_EXPLICIT=explicit"
21552129
2156-
if test "$icu_version" -lt "50001"; then
2157-
AC_MSG_ERROR([ICU version 50.1 or later is required])
2158-
fi
2159-
2160-
ICU_VERSION=$icu_version
2161-
ICU_INCS=`$ICU_CONFIG --cppflags-searchpath`
2162-
ICU_LIBS=`$ICU_CONFIG --ldflags --ldflags-icuio`
2163-
PHP_EVAL_INCLINE($ICU_INCS)
2164-
PHP_EVAL_LIBLINE($ICU_LIBS, $1)
2165-
2166-
ICU_CXXFLAGS="$ICU_CXXFLAGS -DUNISTR_FROM_CHAR_EXPLICIT=explicit -DUNISTR_FROM_STRING_EXPLICIT=explicit"
2167-
ICU_CFLAGS="-DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1"
2168-
if test "$icu_version" -ge "60000"; then
2169-
ICU_CFLAGS="$ICU_CFLAGS -DU_HIDE_OBSOLETE_UTF_OLD_H=1"
2170-
fi
2130+
if test "$PKG_CONFIG icu-io --atleast-version=60"; then
2131+
ICU_CFLAGS="$ICU_CFLAGS -DU_HIDE_OBSOLETE_UTF_OLD_H=1"
21712132
fi
21722133
])
21732134

ext/intl/config.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ PHP_ARG_ENABLE(intl, whether to enable internationalization support,
88
if test "$PHP_INTL" != "no"; then
99
PHP_SETUP_ICU(INTL_SHARED_LIBADD)
1010
PHP_SUBST(INTL_SHARED_LIBADD)
11-
INTL_COMMON_FLAGS="$ICU_INCS $ICU_CFLAGS -Wno-write-strings -D__STDC_LIMIT_MACROS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
11+
INTL_COMMON_FLAGS="$ICU_CFLAGS -Wno-write-strings -D__STDC_LIMIT_MACROS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
1212
PHP_NEW_EXTENSION(intl, php_intl.c \
1313
intl_error.c \
1414
intl_convert.c \

0 commit comments

Comments
 (0)