Skip to content

Commit 8be649d

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
2 parents b290752 + e2edaa0 commit 8be649d

File tree

1 file changed

+71
-37
lines changed

1 file changed

+71
-37
lines changed

acinclude.m4

Lines changed: 71 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2173,50 +2173,84 @@ AC_DEFUN([PHP_SETUP_ICU],[
21732173
PHP_ICU_DIR=DEFAULT
21742174
fi
21752175
2176-
if test "$PHP_ICU_DIR" = "DEFAULT"; then
2177-
dnl Try to find icu-config
2178-
AC_PATH_PROG(ICU_CONFIG, icu-config, no, [$PATH:/usr/local/bin])
2179-
else
2180-
ICU_CONFIG="$PHP_ICU_DIR/bin/icu-config"
2181-
fi
2182-
21832176
AC_MSG_CHECKING([for location of ICU headers and libraries])
2177+
found_icu=no
21842178
2185-
dnl Trust icu-config to know better what the install prefix is..
2186-
icu_install_prefix=`$ICU_CONFIG --prefix 2> /dev/null`
2187-
if test "$?" != "0" || test -z "$icu_install_prefix"; then
2188-
AC_MSG_RESULT([not found])
2189-
AC_MSG_ERROR([Unable to detect ICU prefix or $ICU_CONFIG failed. Please verify ICU install prefix and make sure icu-config works.])
2190-
else
2191-
AC_MSG_RESULT([$icu_install_prefix])
2179+
dnl First try to find pkg-config
2180+
if test -z "$PKG_CONFIG"; then
2181+
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
2182+
fi
21922183
2193-
dnl Check ICU version
2194-
AC_MSG_CHECKING([for ICU 4.0 or greater])
2195-
icu_version_full=`$ICU_CONFIG --version`
2196-
ac_IFS=$IFS
2197-
IFS="."
2198-
set $icu_version_full
2199-
IFS=$ac_IFS
2200-
icu_version=`expr [$]1 \* 1000 + [$]2`
2201-
AC_MSG_RESULT([found $icu_version_full])
2184+
dnl If pkg-config is found try using it
2185+
if test "$PHP_ICU_DIR" = "DEFAULT" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists icu-uc icu-io icu-i18n; then
2186+
if $PKG_CONFIG --atleast-version=40 icu-uc; then
2187+
found_icu=yes
2188+
icu_version_full=`$PKG_CONFIG --modversion icu-uc`
2189+
ac_IFS=$IFS
2190+
IFS="."
2191+
set $icu_version_full
2192+
IFS=$ac_IFS
2193+
icu_version=`expr [$]1 \* 1000 + [$]2`
2194+
AC_MSG_RESULT([found $icu_version_full])
2195+
2196+
ICU_LIBS=`$PKG_CONFIG --libs icu-uc icu-io icu-i18n`
2197+
ICU_INCS=`$PKG_CONFIG --cflags-only-I icu-uc icu-io icu-i18n`
2198+
ICU_CXXFLAGS="-DU_USING_ICU_NAMESPACE=1"
2199+
2200+
AC_MSG_RESULT([found $ICU_VERSION])
2201+
2202+
PHP_EVAL_LIBLINE($ICU_LIBS, $1)
2203+
PHP_EVAL_INCLINE($ICU_INCS)
2204+
else
2205+
AC_MSG_ERROR([ICU version 4.0 or later required.])
2206+
fi
2207+
fi
22022208
2203-
if test "$icu_version" -lt "4000"; then
2204-
AC_MSG_ERROR([ICU version 4.0 or later is required])
2209+
dnl If pkg-config fails for some reason, revert to the old method
2210+
if test "$found_icu" = "no"; then
2211+
if test "$PHP_ICU_DIR" = "DEFAULT"; then
2212+
dnl Try to find icu-config
2213+
AC_PATH_PROG(ICU_CONFIG, icu-config, no, [$PATH:/usr/local/bin])
2214+
else
2215+
ICU_CONFIG="$PHP_ICU_DIR/bin/icu-config"
22052216
fi
22062217
2207-
ICU_VERSION=$icu_version
2208-
ICU_INCS=`$ICU_CONFIG --cppflags-searchpath`
2209-
ICU_LIBS=`$ICU_CONFIG --ldflags --ldflags-icuio`
2210-
PHP_EVAL_INCLINE($ICU_INCS)
2211-
PHP_EVAL_LIBLINE($ICU_LIBS, $1)
2218+
dnl Trust icu-config to know better what the install prefix is..
2219+
icu_install_prefix=`$ICU_CONFIG --prefix 2> /dev/null`
2220+
if test "$?" != "0" || test -z "$icu_install_prefix"; then
2221+
AC_MSG_RESULT([not found])
2222+
AC_MSG_ERROR([Unable to detect ICU prefix or $ICU_CONFIG failed. Please verify ICU install prefix and make sure icu-config works.])
2223+
else
2224+
AC_MSG_RESULT([$icu_install_prefix])
2225+
2226+
dnl Check ICU version
2227+
AC_MSG_CHECKING([for ICU 4.0 or greater])
2228+
icu_version_full=`$ICU_CONFIG --version`
2229+
ac_IFS=$IFS
2230+
IFS="."
2231+
set $icu_version_full
2232+
IFS=$ac_IFS
2233+
icu_version=`expr [$]1 \* 1000 + [$]2`
2234+
AC_MSG_RESULT([found $icu_version_full])
2235+
2236+
if test "$icu_version" -lt "4000"; then
2237+
AC_MSG_ERROR([ICU version 4.0 or later is required])
2238+
fi
22122239
2213-
ICU_CXXFLAGS=`$ICU_CONFIG --cxxflags`
2214-
if test "$icu_version" -ge "49000"; then
2215-
ICU_CXXFLAGS="$ICU_CXXFLAGS -DUNISTR_FROM_CHAR_EXPLICIT=explicit -DUNISTR_FROM_STRING_EXPLICIT=explicit"
2216-
ICU_CFLAGS="-DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1"
2217-
fi
2218-
if test "$icu_version" -ge "60000"; then
2219-
ICU_CFLAGS="$ICU_CFLAGS -DU_HIDE_OBSOLETE_UTF_OLD_H=1"
2240+
ICU_VERSION=$icu_version
2241+
ICU_INCS=`$ICU_CONFIG --cppflags-searchpath`
2242+
ICU_LIBS=`$ICU_CONFIG --ldflags --ldflags-icuio`
2243+
PHP_EVAL_INCLINE($ICU_INCS)
2244+
PHP_EVAL_LIBLINE($ICU_LIBS, $1)
2245+
2246+
ICU_CXXFLAGS=`$ICU_CONFIG --cxxflags`
2247+
if test "$icu_version" -ge "49000"; then
2248+
ICU_CXXFLAGS="$ICU_CXXFLAGS -DUNISTR_FROM_CHAR_EXPLICIT=explicit -DUNISTR_FROM_STRING_EXPLICIT=explicit"
2249+
ICU_CFLAGS="-DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1"
2250+
fi
2251+
if test "$icu_version" -ge "60000"; then
2252+
ICU_CFLAGS="$ICU_CFLAGS -DU_HIDE_OBSOLETE_UTF_OLD_H=1"
2253+
fi
22202254
fi
22212255
fi
22222256
])

0 commit comments

Comments
 (0)