Skip to content

Commit e2edaa0

Browse files
committed
Use pkg-config for ICU, as the old icu-config has been deprecated
1 parent cf56832 commit e2edaa0

File tree

1 file changed

+66
-32
lines changed

1 file changed

+66
-32
lines changed

acinclude.m4

Lines changed: 66 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2201,45 +2201,79 @@ AC_DEFUN([PHP_SETUP_ICU],[
22012201
PHP_ICU_DIR=DEFAULT
22022202
fi
22032203
2204-
if test "$PHP_ICU_DIR" = "DEFAULT"; then
2205-
dnl Try to find icu-config
2206-
AC_PATH_PROG(ICU_CONFIG, icu-config, no, [$PATH:/usr/local/bin])
2207-
else
2208-
ICU_CONFIG="$PHP_ICU_DIR/bin/icu-config"
2209-
fi
2210-
22112204
AC_MSG_CHECKING([for location of ICU headers and libraries])
2205+
found_icu=no
22122206
2213-
dnl Trust icu-config to know better what the install prefix is..
2214-
icu_install_prefix=`$ICU_CONFIG --prefix 2> /dev/null`
2215-
if test "$?" != "0" || test -z "$icu_install_prefix"; then
2216-
AC_MSG_RESULT([not found])
2217-
AC_MSG_ERROR([Unable to detect ICU prefix or $ICU_CONFIG failed. Please verify ICU install prefix and make sure icu-config works.])
2218-
else
2219-
AC_MSG_RESULT([$icu_install_prefix])
2207+
dnl First try to find pkg-config
2208+
if test -z "$PKG_CONFIG"; then
2209+
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
2210+
fi
22202211
2221-
dnl Check ICU version
2222-
AC_MSG_CHECKING([for ICU 4.0 or greater])
2223-
icu_version_full=`$ICU_CONFIG --version`
2224-
ac_IFS=$IFS
2225-
IFS="."
2226-
set $icu_version_full
2227-
IFS=$ac_IFS
2228-
icu_version=`expr [$]1 \* 1000 + [$]2`
2229-
AC_MSG_RESULT([found $icu_version_full])
2212+
dnl If pkg-config is found try using it
2213+
if test "$PHP_ICU_DIR" = "DEFAULT" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists icu-uc icu-io icu-i18n; then
2214+
if $PKG_CONFIG --atleast-version=40 icu-uc; then
2215+
found_icu=yes
2216+
icu_version_full=`$PKG_CONFIG --modversion icu-uc`
2217+
ac_IFS=$IFS
2218+
IFS="."
2219+
set $icu_version_full
2220+
IFS=$ac_IFS
2221+
icu_version=`expr [$]1 \* 1000 + [$]2`
2222+
AC_MSG_RESULT([found $icu_version_full])
2223+
2224+
ICU_LIBS=`$PKG_CONFIG --libs icu-uc icu-io icu-i18n`
2225+
ICU_INCS=`$PKG_CONFIG --cflags-only-I icu-uc icu-io icu-i18n`
2226+
ICU_CXXFLAGS="-DU_USING_ICU_NAMESPACE=1"
2227+
2228+
AC_MSG_RESULT([found $ICU_VERSION])
2229+
2230+
PHP_EVAL_LIBLINE($ICU_LIBS, $1)
2231+
PHP_EVAL_INCLINE($ICU_INCS)
2232+
else
2233+
AC_MSG_ERROR([ICU version 4.0 or later required.])
2234+
fi
2235+
fi
22302236
2231-
if test "$icu_version" -lt "4000"; then
2232-
AC_MSG_ERROR([ICU version 4.0 or later is required])
2237+
dnl If pkg-config fails for some reason, revert to the old method
2238+
if test "$found_icu" = "no"; then
2239+
if test "$PHP_ICU_DIR" = "DEFAULT"; then
2240+
dnl Try to find icu-config
2241+
AC_PATH_PROG(ICU_CONFIG, icu-config, no, [$PATH:/usr/local/bin])
2242+
else
2243+
ICU_CONFIG="$PHP_ICU_DIR/bin/icu-config"
22332244
fi
22342245
2235-
ICU_VERSION=$icu_version
2236-
ICU_INCS=`$ICU_CONFIG --cppflags-searchpath`
2237-
ICU_LIBS=`$ICU_CONFIG --ldflags --ldflags-icuio`
2238-
PHP_EVAL_INCLINE($ICU_INCS)
2239-
PHP_EVAL_LIBLINE($ICU_LIBS, $1)
2246+
dnl Trust icu-config to know better what the install prefix is..
2247+
icu_install_prefix=`$ICU_CONFIG --prefix 2> /dev/null`
2248+
if test "$?" != "0" || test -z "$icu_install_prefix"; then
2249+
AC_MSG_RESULT([not found])
2250+
AC_MSG_ERROR([Unable to detect ICU prefix or $ICU_CONFIG failed. Please verify ICU install prefix and make sure icu-config works.])
2251+
else
2252+
AC_MSG_RESULT([$icu_install_prefix])
2253+
2254+
dnl Check ICU version
2255+
AC_MSG_CHECKING([for ICU 4.0 or greater])
2256+
icu_version_full=`$ICU_CONFIG --version`
2257+
ac_IFS=$IFS
2258+
IFS="."
2259+
set $icu_version_full
2260+
IFS=$ac_IFS
2261+
icu_version=`expr [$]1 \* 1000 + [$]2`
2262+
AC_MSG_RESULT([found $icu_version_full])
2263+
2264+
if test "$icu_version" -lt "4000"; then
2265+
AC_MSG_ERROR([ICU version 4.0 or later is required])
2266+
fi
22402267
2241-
ICU_CXXFLAGS=`$ICU_CONFIG --cxxflags`
2242-
ICU_CXXFLAGS="$ICU_CXXFLAGS -DU_USING_ICU_NAMESPACE=1"
2268+
ICU_VERSION=$icu_version
2269+
ICU_INCS=`$ICU_CONFIG --cppflags-searchpath`
2270+
ICU_LIBS=`$ICU_CONFIG --ldflags --ldflags-icuio`
2271+
PHP_EVAL_INCLINE($ICU_INCS)
2272+
PHP_EVAL_LIBLINE($ICU_LIBS, $1)
2273+
2274+
ICU_CXXFLAGS=`$ICU_CONFIG --cxxflags`
2275+
ICU_CXXFLAGS="$ICU_CXXFLAGS -DU_USING_ICU_NAMESPACE=1"
2276+
fi
22432277
fi
22442278
])
22452279

0 commit comments

Comments
 (0)