michael@0: dnl This Source Code Form is subject to the terms of the Mozilla Public michael@0: dnl License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: dnl Set the MOZ_ICU_VERSION variable to denote the current version of the michael@0: dnl ICU library, and also the MOZ_SHARED_ICU which would be true if we are michael@0: dnl linking against a shared library of ICU, either one that we build from michael@0: dnl our copy of ICU or the system provided library. michael@0: michael@0: AC_DEFUN([MOZ_CONFIG_ICU], [ michael@0: michael@0: ICU_LIB_NAMES= michael@0: MOZ_NATIVE_ICU= michael@0: MOZ_ARG_WITH_BOOL(system-icu, michael@0: [ --with-system-icu michael@0: Use system ICU (located with pkgconfig)], michael@0: MOZ_NATIVE_ICU=1) michael@0: michael@0: if test -n "$MOZ_NATIVE_ICU"; then michael@0: PKG_CHECK_MODULES(MOZ_ICU, icu-i18n >= 50.1) michael@0: MOZ_SHARED_ICU=1 michael@0: else michael@0: MOZ_ICU_CFLAGS='-I$(topsrcdir)/intl/icu/source/common -I$(topsrcdir)/intl/icu/source/i18n' michael@0: AC_SUBST(MOZ_ICU_CFLAGS) michael@0: fi michael@0: michael@0: AC_SUBST(MOZ_NATIVE_ICU) michael@0: michael@0: MOZ_ARG_WITH_STRING(intl-api, michael@0: [ --with-intl-api, --with-intl-api=build, --without-intl-api michael@0: Determine the status of the ECMAScript Internationalization API. The first michael@0: (or lack of any of these) builds and exposes the API. The second builds it michael@0: but doesn't use ICU or expose the API to script. The third doesn't build michael@0: ICU at all.], michael@0: _INTL_API=$withval) michael@0: michael@0: ENABLE_INTL_API= michael@0: EXPOSE_INTL_API= michael@0: case "$_INTL_API" in michael@0: no) michael@0: ;; michael@0: build) michael@0: ENABLE_INTL_API=1 michael@0: ;; michael@0: yes) michael@0: ENABLE_INTL_API=1 michael@0: EXPOSE_INTL_API=1 michael@0: ;; michael@0: *) michael@0: AC_MSG_ERROR([Invalid value passed to --with-intl-api: $_INTL_API]) michael@0: ;; michael@0: esac michael@0: michael@0: if test -n "$EXPOSE_INTL_API"; then michael@0: AC_DEFINE(EXPOSE_INTL_API) michael@0: fi michael@0: michael@0: dnl Settings for the implementation of the ECMAScript Internationalization API michael@0: if test -n "$ENABLE_INTL_API"; then michael@0: AC_DEFINE(ENABLE_INTL_API) michael@0: michael@0: icudir="$_topsrcdir/intl/icu/source" michael@0: if test ! -d "$icudir"; then michael@0: icudir="$_topsrcdir/../../intl/icu/source" michael@0: if test ! -d "$icudir"; then michael@0: AC_MSG_ERROR([Cannot find the ICU directory]) michael@0: fi michael@0: fi michael@0: michael@0: 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"` michael@0: if test x"$version" = x; then michael@0: AC_MSG_ERROR([cannot determine icu version number from uvernum.h header file $lineno]) michael@0: fi michael@0: MOZ_ICU_VERSION="$version" michael@0: michael@0: if test -z "${JS_STANDALONE}" -a -n "${JS_SHARED_LIBRARY}${MOZ_NATIVE_ICU}"; then michael@0: MOZ_SHARED_ICU=1 michael@0: fi michael@0: michael@0: AC_SUBST(MOZ_ICU_VERSION) michael@0: AC_SUBST(MOZ_SHARED_ICU) michael@0: michael@0: if test -z "$MOZ_NATIVE_ICU"; then michael@0: case "$OS_TARGET" in michael@0: WINNT) michael@0: ICU_LIB_NAMES="icuin icuuc icudt" michael@0: if test -n "$MOZ_SHARED_ICU"; then michael@0: DBG_SUFFIX= michael@0: if test -n "$MOZ_DEBUG"; then michael@0: DBG_SUFFIX=d michael@0: fi michael@0: MOZ_ICU_LIBS='$(foreach lib,$(ICU_LIB_NAMES),$(DEPTH)/intl/icu/target/lib/$(LIB_PREFIX)$(lib)$(DBG_SUFFIX).$(LIB_SUFFIX))' michael@0: fi michael@0: ;; michael@0: Darwin) michael@0: ICU_LIB_NAMES="icui18n icuuc icudata" michael@0: if test -n "$MOZ_SHARED_ICU"; then michael@0: MOZ_ICU_LIBS='$(foreach lib,$(ICU_LIB_NAMES),$(DEPTH)/intl/icu/target/lib/$(DLL_PREFIX)$(lib).$(MOZ_ICU_VERSION)$(DLL_SUFFIX))' michael@0: fi michael@0: ;; michael@0: Linux|DragonFly|FreeBSD|NetBSD|OpenBSD|GNU/kFreeBSD) michael@0: ICU_LIB_NAMES="icui18n icuuc icudata" michael@0: if test -n "$MOZ_SHARED_ICU"; then michael@0: MOZ_ICU_LIBS='$(foreach lib,$(ICU_LIB_NAMES),$(DEPTH)/intl/icu/target/lib/$(DLL_PREFIX)$(lib)$(DLL_SUFFIX).$(MOZ_ICU_VERSION))' michael@0: fi michael@0: ;; michael@0: *) michael@0: AC_MSG_ERROR([ECMAScript Internationalization API is not yet supported on this platform]) michael@0: esac michael@0: if test -z "$MOZ_SHARED_ICU"; then michael@0: MOZ_ICU_LIBS='$(call EXPAND_LIBNAME_PATH,$(ICU_LIB_NAMES),$(DEPTH)/intl/icu/target/lib)' michael@0: fi michael@0: fi michael@0: fi michael@0: michael@0: AC_SUBST(DBG_SUFFIX) michael@0: AC_SUBST(ENABLE_INTL_API) michael@0: AC_SUBST(ICU_LIB_NAMES) michael@0: AC_SUBST(MOZ_ICU_LIBS) michael@0: michael@0: if test -n "$ENABLE_INTL_API" -a -z "$MOZ_NATIVE_ICU"; then michael@0: dnl We build ICU as a static library for non-shared js builds and as a shared library for shared js builds. michael@0: if test -z "$MOZ_SHARED_ICU"; then michael@0: AC_DEFINE(U_STATIC_IMPLEMENTATION) michael@0: fi michael@0: dnl Source files that use ICU should have control over which parts of the ICU michael@0: dnl namespace they want to use. michael@0: AC_DEFINE(U_USING_ICU_NAMESPACE,0) michael@0: fi michael@0: michael@0: michael@0: ]) michael@0: michael@0: AC_DEFUN([MOZ_SUBCONFIGURE_ICU], [ michael@0: michael@0: if test -z "$BUILDING_JS" -o -n "$JS_STANDALONE"; then michael@0: michael@0: if test -n "$ENABLE_INTL_API" -a -z "$MOZ_NATIVE_ICU"; then michael@0: # Set ICU compile options michael@0: ICU_CPPFLAGS="" michael@0: # don't use icu namespace automatically in client code michael@0: ICU_CPPFLAGS="$ICU_CPPFLAGS -DU_USING_ICU_NAMESPACE=0" michael@0: # don't include obsolete header files michael@0: ICU_CPPFLAGS="$ICU_CPPFLAGS -DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1" michael@0: # remove chunks of the library that we don't need (yet) michael@0: ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_LEGACY_CONVERSION" michael@0: ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_TRANSLITERATION" michael@0: ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_REGULAR_EXPRESSIONS" michael@0: ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_BREAK_ITERATION" michael@0: # make sure to not accidentally pick up system-icu headers michael@0: ICU_CPPFLAGS="$ICU_CPPFLAGS -I$icudir/common -I$icudir/i18n" michael@0: michael@0: ICU_CROSS_BUILD_OPT="" michael@0: ICU_SRCDIR="" michael@0: if test "$HOST_OS_ARCH" = "WINNT"; then michael@0: ICU_SRCDIR="--srcdir=$(cd $srcdir/intl/icu/source; pwd -W)" michael@0: fi michael@0: michael@0: if test "$CROSS_COMPILE"; then michael@0: # Building host tools. It is necessary to build target binary. michael@0: case "$HOST_OS_ARCH" in michael@0: Darwin) michael@0: ICU_TARGET=MacOSX michael@0: ;; michael@0: Linux) michael@0: ICU_TARGET=Linux michael@0: ;; michael@0: WINNT) michael@0: ICU_TARGET=MSYS/MSVC michael@0: ;; michael@0: DragonFly|FreeBSD|NetBSD|OpenBSD|GNU_kFreeBSD) michael@0: ICU_TARGET=BSD michael@0: ;; michael@0: esac michael@0: # Remove _DEPEND_CFLAGS from HOST_FLAGS to avoid configure error michael@0: HOST_ICU_CFLAGS="$HOST_CFLAGS" michael@0: HOST_ICU_CXXFLAGS="$HOST_CXXFLAGS" michael@0: michael@0: HOST_ICU_CFLAGS=`echo $HOST_ICU_CFLAGS | sed "s|$_DEPEND_CFLAGS||g"` michael@0: HOST_ICU_CXXFLAGS=`echo $HOST_ICU_CFXXLAGS | sed "s|$_DEPEND_CFLAGS||g"` michael@0: michael@0: # ICU requires RTTI michael@0: if test "$GNU_CC"; then michael@0: HOST_ICU_CXXFLAGS=`echo $HOST_ICU_CXXFLAGS | sed 's|-fno-rtti|-frtti|g'` michael@0: elif test "$_MSC_VER"; then michael@0: HOST_ICU_CXXFLAGS=`echo $HOST_ICU_CXXFLAGS | sed 's|-GR-|-GR|g'` michael@0: fi michael@0: michael@0: HOST_ICU_BUILD_OPTS="" michael@0: if test -n "$MOZ_DEBUG"; then michael@0: HOST_ICU_BUILD_OPTS="$HOST_ICU_BUILD_OPTS --enable-debug" michael@0: fi michael@0: michael@0: abs_srcdir=`(cd $srcdir; pwd)` michael@0: mkdir -p $_objdir/intl/icu/host michael@0: (cd $_objdir/intl/icu/host michael@0: MOZ_SUBCONFIGURE_WRAP([.],[ michael@0: AR="$HOST_AR" RANLIB="$HOST_RANLIB" \ michael@0: CC="$HOST_CC" CXX="$HOST_CXX" LD="$HOST_LD" \ michael@0: CFLAGS="$HOST_ICU_CFLAGS $HOST_OPTIMIZE_FLAGS" \ michael@0: CPPFLAGS="$ICU_CPPFLAGS" \ michael@0: CXXFLAGS="$HOST_ICU_CXXFLAGS $HOST_OPTIMIZE_FLAGS" \ michael@0: LDFLAGS="$HOST_LDFLAGS" \ michael@0: $SHELL $abs_srcdir/intl/icu/source/runConfigureICU \ michael@0: $HOST_ICU_BUILD_OPTS \ michael@0: $ICU_TARGET \ michael@0: dnl Shell quoting is fun. michael@0: ${ICU_SRCDIR+"$ICU_SRCDIR"} \ michael@0: --enable-static --disable-shared \ michael@0: --enable-extras=no --enable-icuio=no --enable-layout=no \ michael@0: --enable-tests=no --enable-samples=no || exit 1 michael@0: ]) michael@0: ) || exit 1 michael@0: # generate config/icucross.mk michael@0: $GMAKE -C $_objdir/intl/icu/host/ config/icucross.mk michael@0: michael@0: # --with-cross-build requires absolute path michael@0: ICU_HOST_PATH=`cd $_objdir/intl/icu/host && pwd` michael@0: ICU_CROSS_BUILD_OPT="--with-cross-build=$ICU_HOST_PATH" michael@0: ICU_TARGET_OPT="--build=$build --host=$target" michael@0: else michael@0: # CROSS_COMPILE isn't set build and target are i386 and x86-64. michael@0: # So we must set target for --build and --host. michael@0: ICU_TARGET_OPT="--build=$target --host=$target" michael@0: fi michael@0: michael@0: if test -z "$MOZ_SHARED_ICU"; then michael@0: # To reduce library size, use static linking michael@0: ICU_LINK_OPTS="--enable-static --disable-shared" michael@0: else michael@0: ICU_LINK_OPTS="--disable-static --enable-shared" michael@0: fi michael@0: # Force the ICU static libraries to be position independent code michael@0: ICU_CFLAGS="$DSO_PIC_CFLAGS $CFLAGS" michael@0: ICU_CXXFLAGS="$DSO_PIC_CFLAGS $CXXFLAGS" michael@0: michael@0: ICU_BUILD_OPTS="" michael@0: if test -n "$MOZ_DEBUG" -o "MOZ_DEBUG_SYMBOLS"; then michael@0: ICU_CFLAGS="$ICU_CFLAGS $MOZ_DEBUG_FLAGS" michael@0: ICU_CXXFLAGS="$ICU_CXXFLAGS $MOZ_DEBUG_FLAGS" michael@0: if test -n "$CROSS_COMPILE" -a "$OS_TARGET" = "Darwin" \ michael@0: -a "$HOST_OS_ARCH" != "Darwin" michael@0: then michael@0: # Bug 951758: Cross-OSX builds with non-Darwin hosts have issues michael@0: # with -g and friends (like -gdwarf and -gfull) because they try michael@0: # to run dsymutil michael@0: changequote(,) michael@0: ICU_CFLAGS=`echo $ICU_CFLAGS | sed 's|-g[^ \t]*||g'` michael@0: ICU_CXXFLAGS=`echo $ICU_CXXFLAGS | sed 's|-g[^ \t]*||g'` michael@0: changequote([,]) michael@0: fi michael@0: michael@0: ICU_LDFLAGS="$MOZ_DEBUG_LDFLAGS" michael@0: if test -z "$MOZ_DEBUG"; then michael@0: # To generate debug symbols, it requires MOZ_DEBUG_FLAGS. michael@0: # But, not debug build. michael@0: ICU_CFLAGS="$ICU_CFLAGS -UDEBUG -DNDEBUG" michael@0: ICU_CXXFLAGS="$ICU_CXXFLAGS -UDEBUG -DNDEBUG" michael@0: else michael@0: ICU_BUILD_OPTS="$ICU_BUILD_OPTS --enable-debug" michael@0: fi michael@0: fi michael@0: if test -z "$MOZ_OPTIMIZE"; then michael@0: ICU_BUILD_OPTS="$ICU_BUILD_OPTS --disable-release" michael@0: else michael@0: ICU_CFLAGS="$ICU_CFLAGS $MOZ_OPTIMIZE_FLAGS" michael@0: ICU_CXXFLAGS="$ICU_CXXFLAGS $MOZ_OPTIMIZE_FLAGS" michael@0: fi michael@0: michael@0: if test "$am_cv_langinfo_codeset" = "no"; then michael@0: # ex. Android michael@0: ICU_CPPFLAGS="$ICU_CPPFLAGS -DU_HAVE_NL_LANGINFO_CODESET=0" michael@0: fi michael@0: michael@0: # ICU requires RTTI michael@0: if test "$GNU_CC"; then michael@0: ICU_CXXFLAGS=`echo $ICU_CXXFLAGS | sed 's|-fno-rtti|-frtti|g'` michael@0: else michael@0: if test "$_MSC_VER"; then michael@0: ICU_CXXFLAGS=`echo $ICU_CXXFLAGS | sed 's|-GR-|-GR|g'` michael@0: fi michael@0: michael@0: # Add RTL flags for MSVCRT.DLL michael@0: if test -n "$MOZ_DEBUG"; then michael@0: ICU_CFLAGS="$ICU_CFLAGS -MDd" michael@0: ICU_CXXFLAGS="$ICU_CXXFLAGS -MDd" michael@0: else michael@0: ICU_CFLAGS="$ICU_CFLAGS -MD" michael@0: ICU_CXXFLAGS="$ICU_CXXFLAGS -MD" michael@0: fi michael@0: michael@0: # add disable optimize flag for workaround for bug 899948 michael@0: if test -z "$MOZ_OPTIMIZE"; then michael@0: ICU_CFLAGS="$ICU_CFLAGS -Od" michael@0: ICU_CXXFLAGS="$ICU_CXXFLAGS -Od" michael@0: fi michael@0: fi michael@0: michael@0: # We cannot use AC_OUTPUT_SUBDIRS since ICU tree is out of spidermonkey. michael@0: # When using AC_OUTPUT_SUBDIRS, objdir of ICU is out of objdir michael@0: # due to relative path. michael@0: # If building ICU moves into root of mozilla tree, we can use michael@0: # AC_OUTPUT_SUBDIR instead. michael@0: mkdir -p $_objdir/intl/icu/target michael@0: (cd $_objdir/intl/icu/target michael@0: MOZ_SUBCONFIGURE_WRAP([.],[ michael@0: AR="$AR" CC="$CC" CXX="$CXX" LD="$LD" \ michael@0: ARFLAGS="$ARFLAGS" \ michael@0: CPPFLAGS="$ICU_CPPFLAGS $CPPFLAGS" \ michael@0: CFLAGS="$ICU_CFLAGS" \ michael@0: CXXFLAGS="$ICU_CXXFLAGS" \ michael@0: LDFLAGS="$ICU_LDFLAGS $LDFLAGS" \ michael@0: $SHELL $_topsrcdir/intl/icu/source/configure \ michael@0: $ICU_BUILD_OPTS \ michael@0: $ICU_CROSS_BUILD_OPT \ michael@0: $ICU_LINK_OPTS \ michael@0: ${ICU_SRCDIR+"$ICU_SRCDIR"} \ michael@0: $ICU_TARGET_OPT \ michael@0: --disable-extras --disable-icuio --disable-layout \ michael@0: --disable-tests --disable-samples || exit 1 michael@0: ]) michael@0: ) || exit 1 michael@0: fi michael@0: michael@0: fi michael@0: michael@0: ])