1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/build/autoconf/icu.m4 Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,327 @@ 1.4 +dnl This Source Code Form is subject to the terms of the Mozilla Public 1.5 +dnl License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 +dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.7 + 1.8 +dnl Set the MOZ_ICU_VERSION variable to denote the current version of the 1.9 +dnl ICU library, and also the MOZ_SHARED_ICU which would be true if we are 1.10 +dnl linking against a shared library of ICU, either one that we build from 1.11 +dnl our copy of ICU or the system provided library. 1.12 + 1.13 +AC_DEFUN([MOZ_CONFIG_ICU], [ 1.14 + 1.15 +ICU_LIB_NAMES= 1.16 +MOZ_NATIVE_ICU= 1.17 +MOZ_ARG_WITH_BOOL(system-icu, 1.18 +[ --with-system-icu 1.19 + Use system ICU (located with pkgconfig)], 1.20 + MOZ_NATIVE_ICU=1) 1.21 + 1.22 +if test -n "$MOZ_NATIVE_ICU"; then 1.23 + PKG_CHECK_MODULES(MOZ_ICU, icu-i18n >= 50.1) 1.24 + MOZ_SHARED_ICU=1 1.25 +else 1.26 + MOZ_ICU_CFLAGS='-I$(topsrcdir)/intl/icu/source/common -I$(topsrcdir)/intl/icu/source/i18n' 1.27 + AC_SUBST(MOZ_ICU_CFLAGS) 1.28 +fi 1.29 + 1.30 +AC_SUBST(MOZ_NATIVE_ICU) 1.31 + 1.32 +MOZ_ARG_WITH_STRING(intl-api, 1.33 +[ --with-intl-api, --with-intl-api=build, --without-intl-api 1.34 + Determine the status of the ECMAScript Internationalization API. The first 1.35 + (or lack of any of these) builds and exposes the API. The second builds it 1.36 + but doesn't use ICU or expose the API to script. The third doesn't build 1.37 + ICU at all.], 1.38 + _INTL_API=$withval) 1.39 + 1.40 +ENABLE_INTL_API= 1.41 +EXPOSE_INTL_API= 1.42 +case "$_INTL_API" in 1.43 +no) 1.44 + ;; 1.45 +build) 1.46 + ENABLE_INTL_API=1 1.47 + ;; 1.48 +yes) 1.49 + ENABLE_INTL_API=1 1.50 + EXPOSE_INTL_API=1 1.51 + ;; 1.52 +*) 1.53 + AC_MSG_ERROR([Invalid value passed to --with-intl-api: $_INTL_API]) 1.54 + ;; 1.55 +esac 1.56 + 1.57 +if test -n "$EXPOSE_INTL_API"; then 1.58 + AC_DEFINE(EXPOSE_INTL_API) 1.59 +fi 1.60 + 1.61 +dnl Settings for the implementation of the ECMAScript Internationalization API 1.62 +if test -n "$ENABLE_INTL_API"; then 1.63 + AC_DEFINE(ENABLE_INTL_API) 1.64 + 1.65 + icudir="$_topsrcdir/intl/icu/source" 1.66 + if test ! -d "$icudir"; then 1.67 + icudir="$_topsrcdir/../../intl/icu/source" 1.68 + if test ! -d "$icudir"; then 1.69 + AC_MSG_ERROR([Cannot find the ICU directory]) 1.70 + fi 1.71 + fi 1.72 + 1.73 + version=`sed -n 's/^[[:space:]]*#[[:space:]]*define[[:space:]][[:space:]]*U_ICU_VERSION_MAJOR_NUM[[:space:]][[:space:]]*\([0-9][0-9]*\)[[:space:]]*$/\1/p' "$icudir/common/unicode/uvernum.h"` 1.74 + if test x"$version" = x; then 1.75 + AC_MSG_ERROR([cannot determine icu version number from uvernum.h header file $lineno]) 1.76 + fi 1.77 + MOZ_ICU_VERSION="$version" 1.78 + 1.79 + if test -z "${JS_STANDALONE}" -a -n "${JS_SHARED_LIBRARY}${MOZ_NATIVE_ICU}"; then 1.80 + MOZ_SHARED_ICU=1 1.81 + fi 1.82 + 1.83 + AC_SUBST(MOZ_ICU_VERSION) 1.84 + AC_SUBST(MOZ_SHARED_ICU) 1.85 + 1.86 + if test -z "$MOZ_NATIVE_ICU"; then 1.87 + case "$OS_TARGET" in 1.88 + WINNT) 1.89 + ICU_LIB_NAMES="icuin icuuc icudt" 1.90 + if test -n "$MOZ_SHARED_ICU"; then 1.91 + DBG_SUFFIX= 1.92 + if test -n "$MOZ_DEBUG"; then 1.93 + DBG_SUFFIX=d 1.94 + fi 1.95 + MOZ_ICU_LIBS='$(foreach lib,$(ICU_LIB_NAMES),$(DEPTH)/intl/icu/target/lib/$(LIB_PREFIX)$(lib)$(DBG_SUFFIX).$(LIB_SUFFIX))' 1.96 + fi 1.97 + ;; 1.98 + Darwin) 1.99 + ICU_LIB_NAMES="icui18n icuuc icudata" 1.100 + if test -n "$MOZ_SHARED_ICU"; then 1.101 + MOZ_ICU_LIBS='$(foreach lib,$(ICU_LIB_NAMES),$(DEPTH)/intl/icu/target/lib/$(DLL_PREFIX)$(lib).$(MOZ_ICU_VERSION)$(DLL_SUFFIX))' 1.102 + fi 1.103 + ;; 1.104 + Linux|DragonFly|FreeBSD|NetBSD|OpenBSD|GNU/kFreeBSD) 1.105 + ICU_LIB_NAMES="icui18n icuuc icudata" 1.106 + if test -n "$MOZ_SHARED_ICU"; then 1.107 + MOZ_ICU_LIBS='$(foreach lib,$(ICU_LIB_NAMES),$(DEPTH)/intl/icu/target/lib/$(DLL_PREFIX)$(lib)$(DLL_SUFFIX).$(MOZ_ICU_VERSION))' 1.108 + fi 1.109 + ;; 1.110 + *) 1.111 + AC_MSG_ERROR([ECMAScript Internationalization API is not yet supported on this platform]) 1.112 + esac 1.113 + if test -z "$MOZ_SHARED_ICU"; then 1.114 + MOZ_ICU_LIBS='$(call EXPAND_LIBNAME_PATH,$(ICU_LIB_NAMES),$(DEPTH)/intl/icu/target/lib)' 1.115 + fi 1.116 + fi 1.117 +fi 1.118 + 1.119 +AC_SUBST(DBG_SUFFIX) 1.120 +AC_SUBST(ENABLE_INTL_API) 1.121 +AC_SUBST(ICU_LIB_NAMES) 1.122 +AC_SUBST(MOZ_ICU_LIBS) 1.123 + 1.124 +if test -n "$ENABLE_INTL_API" -a -z "$MOZ_NATIVE_ICU"; then 1.125 + dnl We build ICU as a static library for non-shared js builds and as a shared library for shared js builds. 1.126 + if test -z "$MOZ_SHARED_ICU"; then 1.127 + AC_DEFINE(U_STATIC_IMPLEMENTATION) 1.128 + fi 1.129 + dnl Source files that use ICU should have control over which parts of the ICU 1.130 + dnl namespace they want to use. 1.131 + AC_DEFINE(U_USING_ICU_NAMESPACE,0) 1.132 +fi 1.133 + 1.134 + 1.135 +]) 1.136 + 1.137 +AC_DEFUN([MOZ_SUBCONFIGURE_ICU], [ 1.138 + 1.139 +if test -z "$BUILDING_JS" -o -n "$JS_STANDALONE"; then 1.140 + 1.141 + if test -n "$ENABLE_INTL_API" -a -z "$MOZ_NATIVE_ICU"; then 1.142 + # Set ICU compile options 1.143 + ICU_CPPFLAGS="" 1.144 + # don't use icu namespace automatically in client code 1.145 + ICU_CPPFLAGS="$ICU_CPPFLAGS -DU_USING_ICU_NAMESPACE=0" 1.146 + # don't include obsolete header files 1.147 + ICU_CPPFLAGS="$ICU_CPPFLAGS -DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1" 1.148 + # remove chunks of the library that we don't need (yet) 1.149 + ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_LEGACY_CONVERSION" 1.150 + ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_TRANSLITERATION" 1.151 + ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_REGULAR_EXPRESSIONS" 1.152 + ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_BREAK_ITERATION" 1.153 + # make sure to not accidentally pick up system-icu headers 1.154 + ICU_CPPFLAGS="$ICU_CPPFLAGS -I$icudir/common -I$icudir/i18n" 1.155 + 1.156 + ICU_CROSS_BUILD_OPT="" 1.157 + ICU_SRCDIR="" 1.158 + if test "$HOST_OS_ARCH" = "WINNT"; then 1.159 + ICU_SRCDIR="--srcdir=$(cd $srcdir/intl/icu/source; pwd -W)" 1.160 + fi 1.161 + 1.162 + if test "$CROSS_COMPILE"; then 1.163 + # Building host tools. It is necessary to build target binary. 1.164 + case "$HOST_OS_ARCH" in 1.165 + Darwin) 1.166 + ICU_TARGET=MacOSX 1.167 + ;; 1.168 + Linux) 1.169 + ICU_TARGET=Linux 1.170 + ;; 1.171 + WINNT) 1.172 + ICU_TARGET=MSYS/MSVC 1.173 + ;; 1.174 + DragonFly|FreeBSD|NetBSD|OpenBSD|GNU_kFreeBSD) 1.175 + ICU_TARGET=BSD 1.176 + ;; 1.177 + esac 1.178 + # Remove _DEPEND_CFLAGS from HOST_FLAGS to avoid configure error 1.179 + HOST_ICU_CFLAGS="$HOST_CFLAGS" 1.180 + HOST_ICU_CXXFLAGS="$HOST_CXXFLAGS" 1.181 + 1.182 + HOST_ICU_CFLAGS=`echo $HOST_ICU_CFLAGS | sed "s|$_DEPEND_CFLAGS||g"` 1.183 + HOST_ICU_CXXFLAGS=`echo $HOST_ICU_CFXXLAGS | sed "s|$_DEPEND_CFLAGS||g"` 1.184 + 1.185 + # ICU requires RTTI 1.186 + if test "$GNU_CC"; then 1.187 + HOST_ICU_CXXFLAGS=`echo $HOST_ICU_CXXFLAGS | sed 's|-fno-rtti|-frtti|g'` 1.188 + elif test "$_MSC_VER"; then 1.189 + HOST_ICU_CXXFLAGS=`echo $HOST_ICU_CXXFLAGS | sed 's|-GR-|-GR|g'` 1.190 + fi 1.191 + 1.192 + HOST_ICU_BUILD_OPTS="" 1.193 + if test -n "$MOZ_DEBUG"; then 1.194 + HOST_ICU_BUILD_OPTS="$HOST_ICU_BUILD_OPTS --enable-debug" 1.195 + fi 1.196 + 1.197 + abs_srcdir=`(cd $srcdir; pwd)` 1.198 + mkdir -p $_objdir/intl/icu/host 1.199 + (cd $_objdir/intl/icu/host 1.200 + MOZ_SUBCONFIGURE_WRAP([.],[ 1.201 + AR="$HOST_AR" RANLIB="$HOST_RANLIB" \ 1.202 + CC="$HOST_CC" CXX="$HOST_CXX" LD="$HOST_LD" \ 1.203 + CFLAGS="$HOST_ICU_CFLAGS $HOST_OPTIMIZE_FLAGS" \ 1.204 + CPPFLAGS="$ICU_CPPFLAGS" \ 1.205 + CXXFLAGS="$HOST_ICU_CXXFLAGS $HOST_OPTIMIZE_FLAGS" \ 1.206 + LDFLAGS="$HOST_LDFLAGS" \ 1.207 + $SHELL $abs_srcdir/intl/icu/source/runConfigureICU \ 1.208 + $HOST_ICU_BUILD_OPTS \ 1.209 + $ICU_TARGET \ 1.210 + dnl Shell quoting is fun. 1.211 + ${ICU_SRCDIR+"$ICU_SRCDIR"} \ 1.212 + --enable-static --disable-shared \ 1.213 + --enable-extras=no --enable-icuio=no --enable-layout=no \ 1.214 + --enable-tests=no --enable-samples=no || exit 1 1.215 + ]) 1.216 + ) || exit 1 1.217 + # generate config/icucross.mk 1.218 + $GMAKE -C $_objdir/intl/icu/host/ config/icucross.mk 1.219 + 1.220 + # --with-cross-build requires absolute path 1.221 + ICU_HOST_PATH=`cd $_objdir/intl/icu/host && pwd` 1.222 + ICU_CROSS_BUILD_OPT="--with-cross-build=$ICU_HOST_PATH" 1.223 + ICU_TARGET_OPT="--build=$build --host=$target" 1.224 + else 1.225 + # CROSS_COMPILE isn't set build and target are i386 and x86-64. 1.226 + # So we must set target for --build and --host. 1.227 + ICU_TARGET_OPT="--build=$target --host=$target" 1.228 + fi 1.229 + 1.230 + if test -z "$MOZ_SHARED_ICU"; then 1.231 + # To reduce library size, use static linking 1.232 + ICU_LINK_OPTS="--enable-static --disable-shared" 1.233 + else 1.234 + ICU_LINK_OPTS="--disable-static --enable-shared" 1.235 + fi 1.236 + # Force the ICU static libraries to be position independent code 1.237 + ICU_CFLAGS="$DSO_PIC_CFLAGS $CFLAGS" 1.238 + ICU_CXXFLAGS="$DSO_PIC_CFLAGS $CXXFLAGS" 1.239 + 1.240 + ICU_BUILD_OPTS="" 1.241 + if test -n "$MOZ_DEBUG" -o "MOZ_DEBUG_SYMBOLS"; then 1.242 + ICU_CFLAGS="$ICU_CFLAGS $MOZ_DEBUG_FLAGS" 1.243 + ICU_CXXFLAGS="$ICU_CXXFLAGS $MOZ_DEBUG_FLAGS" 1.244 + if test -n "$CROSS_COMPILE" -a "$OS_TARGET" = "Darwin" \ 1.245 + -a "$HOST_OS_ARCH" != "Darwin" 1.246 + then 1.247 + # Bug 951758: Cross-OSX builds with non-Darwin hosts have issues 1.248 + # with -g and friends (like -gdwarf and -gfull) because they try 1.249 + # to run dsymutil 1.250 + changequote(,) 1.251 + ICU_CFLAGS=`echo $ICU_CFLAGS | sed 's|-g[^ \t]*||g'` 1.252 + ICU_CXXFLAGS=`echo $ICU_CXXFLAGS | sed 's|-g[^ \t]*||g'` 1.253 + changequote([,]) 1.254 + fi 1.255 + 1.256 + ICU_LDFLAGS="$MOZ_DEBUG_LDFLAGS" 1.257 + if test -z "$MOZ_DEBUG"; then 1.258 + # To generate debug symbols, it requires MOZ_DEBUG_FLAGS. 1.259 + # But, not debug build. 1.260 + ICU_CFLAGS="$ICU_CFLAGS -UDEBUG -DNDEBUG" 1.261 + ICU_CXXFLAGS="$ICU_CXXFLAGS -UDEBUG -DNDEBUG" 1.262 + else 1.263 + ICU_BUILD_OPTS="$ICU_BUILD_OPTS --enable-debug" 1.264 + fi 1.265 + fi 1.266 + if test -z "$MOZ_OPTIMIZE"; then 1.267 + ICU_BUILD_OPTS="$ICU_BUILD_OPTS --disable-release" 1.268 + else 1.269 + ICU_CFLAGS="$ICU_CFLAGS $MOZ_OPTIMIZE_FLAGS" 1.270 + ICU_CXXFLAGS="$ICU_CXXFLAGS $MOZ_OPTIMIZE_FLAGS" 1.271 + fi 1.272 + 1.273 + if test "$am_cv_langinfo_codeset" = "no"; then 1.274 + # ex. Android 1.275 + ICU_CPPFLAGS="$ICU_CPPFLAGS -DU_HAVE_NL_LANGINFO_CODESET=0" 1.276 + fi 1.277 + 1.278 + # ICU requires RTTI 1.279 + if test "$GNU_CC"; then 1.280 + ICU_CXXFLAGS=`echo $ICU_CXXFLAGS | sed 's|-fno-rtti|-frtti|g'` 1.281 + else 1.282 + if test "$_MSC_VER"; then 1.283 + ICU_CXXFLAGS=`echo $ICU_CXXFLAGS | sed 's|-GR-|-GR|g'` 1.284 + fi 1.285 + 1.286 + # Add RTL flags for MSVCRT.DLL 1.287 + if test -n "$MOZ_DEBUG"; then 1.288 + ICU_CFLAGS="$ICU_CFLAGS -MDd" 1.289 + ICU_CXXFLAGS="$ICU_CXXFLAGS -MDd" 1.290 + else 1.291 + ICU_CFLAGS="$ICU_CFLAGS -MD" 1.292 + ICU_CXXFLAGS="$ICU_CXXFLAGS -MD" 1.293 + fi 1.294 + 1.295 + # add disable optimize flag for workaround for bug 899948 1.296 + if test -z "$MOZ_OPTIMIZE"; then 1.297 + ICU_CFLAGS="$ICU_CFLAGS -Od" 1.298 + ICU_CXXFLAGS="$ICU_CXXFLAGS -Od" 1.299 + fi 1.300 + fi 1.301 + 1.302 + # We cannot use AC_OUTPUT_SUBDIRS since ICU tree is out of spidermonkey. 1.303 + # When using AC_OUTPUT_SUBDIRS, objdir of ICU is out of objdir 1.304 + # due to relative path. 1.305 + # If building ICU moves into root of mozilla tree, we can use 1.306 + # AC_OUTPUT_SUBDIR instead. 1.307 + mkdir -p $_objdir/intl/icu/target 1.308 + (cd $_objdir/intl/icu/target 1.309 + MOZ_SUBCONFIGURE_WRAP([.],[ 1.310 + AR="$AR" CC="$CC" CXX="$CXX" LD="$LD" \ 1.311 + ARFLAGS="$ARFLAGS" \ 1.312 + CPPFLAGS="$ICU_CPPFLAGS $CPPFLAGS" \ 1.313 + CFLAGS="$ICU_CFLAGS" \ 1.314 + CXXFLAGS="$ICU_CXXFLAGS" \ 1.315 + LDFLAGS="$ICU_LDFLAGS $LDFLAGS" \ 1.316 + $SHELL $_topsrcdir/intl/icu/source/configure \ 1.317 + $ICU_BUILD_OPTS \ 1.318 + $ICU_CROSS_BUILD_OPT \ 1.319 + $ICU_LINK_OPTS \ 1.320 + ${ICU_SRCDIR+"$ICU_SRCDIR"} \ 1.321 + $ICU_TARGET_OPT \ 1.322 + --disable-extras --disable-icuio --disable-layout \ 1.323 + --disable-tests --disable-samples || exit 1 1.324 + ]) 1.325 + ) || exit 1 1.326 + fi 1.327 + 1.328 +fi 1.329 + 1.330 +])