Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e2b117d

Browse files
committed
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 4dd7177 commit e2b117d

File tree

2 files changed

+18
-60
lines changed

2 files changed

+18
-60
lines changed

acinclude.m4

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,64 +2113,6 @@ dnl -------------------------------------------------------------------------
21132113
dnl Common setup macros: PHP_SETUP_<what>
21142114
dnl -------------------------------------------------------------------------
21152115

2116-
dnl
2117-
dnl PHP_SETUP_ICU([shared-add])
2118-
dnl
2119-
dnl Common setup macro for ICU
2120-
dnl
2121-
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)
2124-
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])
2145-
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])
2155-
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
2171-
fi
2172-
])
2173-
21742116
dnl
21752117
dnl PHP_SETUP_KERBEROS(shared-add [, action-found [, action-not-found]])
21762118
dnl

ext/intl/config.m4

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,25 @@ PHP_ARG_ENABLE(intl, whether to enable internationalization support,
66
[ --enable-intl Enable internationalization support])
77

88
if test "$PHP_INTL" != "no"; then
9-
PHP_SETUP_ICU(INTL_SHARED_LIBADD)
9+
PKG_CHECK_MODULES([ICU], [icu-io >= 50.1],
10+
[ICU_FOUND=true], [ICU_FOUND=false])
11+
12+
if test "$ICU_FOUND" = false; then
13+
AC_MSG_ERROR([icu version 50.1 or later is required for internationalization support.])
14+
fi
15+
16+
PHP_EVAL_INCLINE($ICU_CFLAGS)
17+
PHP_EVAL_LIBLINE($ICU_LIBS, $1)
18+
19+
ICU_CFLAGS="$ICU_CFLAGS -DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1"
20+
ICU_CXXFLAGS="$ICU_CXXFLAGS -DUNISTR_FROM_CHAR_EXPLICIT=explicit -DUNISTR_FROM_STRING_EXPLICIT=explicit"
21+
22+
if test "$PKG_CONFIG icu-io --atleast-version=60"; then
23+
ICU_CFLAGS="$ICU_CFLAGS -DU_HIDE_OBSOLETE_UTF_OLD_H=1"
24+
fi
25+
1026
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"
27+
INTL_COMMON_FLAGS="$ICU_CFLAGS -Wno-write-strings -D__STDC_LIMIT_MACROS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
1228
PHP_NEW_EXTENSION(intl, php_intl.c \
1329
intl_error.c \
1430
intl_convert.c \

0 commit comments

Comments
 (0)