build/autoconf/icu.m4

Wed, 31 Dec 2014 07:16:47 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:16:47 +0100
branch
TOR_BUG_9701
changeset 3
141e0f1194b1
permissions
-rw-r--r--

Revert simplistic fix pending revisit of Mozilla integration attempt.

     1 dnl This Source Code Form is subject to the terms of the Mozilla Public
     2 dnl License, v. 2.0. If a copy of the MPL was not distributed with this
     3 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
     5 dnl Set the MOZ_ICU_VERSION variable to denote the current version of the
     6 dnl ICU library, and also the MOZ_SHARED_ICU which would be true if we are
     7 dnl linking against a shared library of ICU, either one that we build from
     8 dnl our copy of ICU or the system provided library.
    10 AC_DEFUN([MOZ_CONFIG_ICU], [
    12 ICU_LIB_NAMES=
    13 MOZ_NATIVE_ICU=
    14 MOZ_ARG_WITH_BOOL(system-icu,
    15 [  --with-system-icu
    16                           Use system ICU (located with pkgconfig)],
    17     MOZ_NATIVE_ICU=1)
    19 if test -n "$MOZ_NATIVE_ICU"; then
    20     PKG_CHECK_MODULES(MOZ_ICU, icu-i18n >= 50.1)
    21     MOZ_SHARED_ICU=1
    22 else
    23     MOZ_ICU_CFLAGS='-I$(topsrcdir)/intl/icu/source/common -I$(topsrcdir)/intl/icu/source/i18n'
    24     AC_SUBST(MOZ_ICU_CFLAGS)
    25 fi
    27 AC_SUBST(MOZ_NATIVE_ICU)
    29 MOZ_ARG_WITH_STRING(intl-api,
    30 [  --with-intl-api, --with-intl-api=build, --without-intl-api
    31     Determine the status of the ECMAScript Internationalization API.  The first
    32     (or lack of any of these) builds and exposes the API.  The second builds it
    33     but doesn't use ICU or expose the API to script.  The third doesn't build
    34     ICU at all.],
    35     _INTL_API=$withval)
    37 ENABLE_INTL_API=
    38 EXPOSE_INTL_API=
    39 case "$_INTL_API" in
    40 no)
    41     ;;
    42 build)
    43     ENABLE_INTL_API=1
    44     ;;
    45 yes)
    46     ENABLE_INTL_API=1
    47     EXPOSE_INTL_API=1
    48     ;;
    49 *)
    50     AC_MSG_ERROR([Invalid value passed to --with-intl-api: $_INTL_API])
    51     ;;
    52 esac
    54 if test -n "$EXPOSE_INTL_API"; then
    55     AC_DEFINE(EXPOSE_INTL_API)
    56 fi
    58 dnl Settings for the implementation of the ECMAScript Internationalization API
    59 if test -n "$ENABLE_INTL_API"; then
    60     AC_DEFINE(ENABLE_INTL_API)
    62     icudir="$_topsrcdir/intl/icu/source"
    63     if test ! -d "$icudir"; then
    64         icudir="$_topsrcdir/../../intl/icu/source"
    65         if test ! -d "$icudir"; then
    66             AC_MSG_ERROR([Cannot find the ICU directory])
    67         fi
    68     fi
    70     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"`
    71     if test x"$version" = x; then
    72        AC_MSG_ERROR([cannot determine icu version number from uvernum.h header file $lineno])
    73     fi
    74     MOZ_ICU_VERSION="$version"
    76     if test -z "${JS_STANDALONE}" -a -n "${JS_SHARED_LIBRARY}${MOZ_NATIVE_ICU}"; then
    77         MOZ_SHARED_ICU=1
    78     fi
    80     AC_SUBST(MOZ_ICU_VERSION)
    81     AC_SUBST(MOZ_SHARED_ICU)
    83     if test -z "$MOZ_NATIVE_ICU"; then
    84         case "$OS_TARGET" in
    85             WINNT)
    86                 ICU_LIB_NAMES="icuin icuuc icudt"
    87                 if test -n "$MOZ_SHARED_ICU"; then
    88                     DBG_SUFFIX=
    89                     if test -n "$MOZ_DEBUG"; then
    90                         DBG_SUFFIX=d
    91                     fi
    92                     MOZ_ICU_LIBS='$(foreach lib,$(ICU_LIB_NAMES),$(DEPTH)/intl/icu/target/lib/$(LIB_PREFIX)$(lib)$(DBG_SUFFIX).$(LIB_SUFFIX))'
    93                 fi
    94                 ;;
    95             Darwin)
    96                 ICU_LIB_NAMES="icui18n icuuc icudata"
    97                 if test -n "$MOZ_SHARED_ICU"; then
    98                    MOZ_ICU_LIBS='$(foreach lib,$(ICU_LIB_NAMES),$(DEPTH)/intl/icu/target/lib/$(DLL_PREFIX)$(lib).$(MOZ_ICU_VERSION)$(DLL_SUFFIX))'
    99                 fi
   100                 ;;
   101             Linux|DragonFly|FreeBSD|NetBSD|OpenBSD|GNU/kFreeBSD)
   102                 ICU_LIB_NAMES="icui18n icuuc icudata"
   103                 if test -n "$MOZ_SHARED_ICU"; then
   104                    MOZ_ICU_LIBS='$(foreach lib,$(ICU_LIB_NAMES),$(DEPTH)/intl/icu/target/lib/$(DLL_PREFIX)$(lib)$(DLL_SUFFIX).$(MOZ_ICU_VERSION))'
   105                 fi
   106                 ;;
   107             *)
   108                 AC_MSG_ERROR([ECMAScript Internationalization API is not yet supported on this platform])
   109         esac
   110         if test -z "$MOZ_SHARED_ICU"; then
   111             MOZ_ICU_LIBS='$(call EXPAND_LIBNAME_PATH,$(ICU_LIB_NAMES),$(DEPTH)/intl/icu/target/lib)'
   112         fi
   113     fi
   114 fi
   116 AC_SUBST(DBG_SUFFIX)
   117 AC_SUBST(ENABLE_INTL_API)
   118 AC_SUBST(ICU_LIB_NAMES)
   119 AC_SUBST(MOZ_ICU_LIBS)
   121 if test -n "$ENABLE_INTL_API" -a -z "$MOZ_NATIVE_ICU"; then
   122     dnl We build ICU as a static library for non-shared js builds and as a shared library for shared js builds.
   123     if test -z "$MOZ_SHARED_ICU"; then
   124         AC_DEFINE(U_STATIC_IMPLEMENTATION)
   125     fi
   126     dnl Source files that use ICU should have control over which parts of the ICU
   127     dnl namespace they want to use.
   128     AC_DEFINE(U_USING_ICU_NAMESPACE,0)
   129 fi
   132 ])
   134 AC_DEFUN([MOZ_SUBCONFIGURE_ICU], [
   136 if test -z "$BUILDING_JS" -o -n "$JS_STANDALONE"; then
   138     if test -n "$ENABLE_INTL_API" -a -z "$MOZ_NATIVE_ICU"; then
   139         # Set ICU compile options
   140         ICU_CPPFLAGS=""
   141         # don't use icu namespace automatically in client code
   142         ICU_CPPFLAGS="$ICU_CPPFLAGS -DU_USING_ICU_NAMESPACE=0"
   143         # don't include obsolete header files
   144         ICU_CPPFLAGS="$ICU_CPPFLAGS -DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1"
   145         # remove chunks of the library that we don't need (yet)
   146         ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_LEGACY_CONVERSION"
   147         ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_TRANSLITERATION"
   148         ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_REGULAR_EXPRESSIONS"
   149         ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_BREAK_ITERATION"
   150         # make sure to not accidentally pick up system-icu headers
   151         ICU_CPPFLAGS="$ICU_CPPFLAGS -I$icudir/common -I$icudir/i18n"
   153         ICU_CROSS_BUILD_OPT=""
   154         ICU_SRCDIR=""
   155         if test "$HOST_OS_ARCH" = "WINNT"; then
   156     	ICU_SRCDIR="--srcdir=$(cd $srcdir/intl/icu/source; pwd -W)"
   157         fi
   159         if test "$CROSS_COMPILE"; then
   160     	# Building host tools.  It is necessary to build target binary.
   161     	case "$HOST_OS_ARCH" in
   162     	    Darwin)
   163     		ICU_TARGET=MacOSX
   164     		;;
   165     	    Linux)
   166     		ICU_TARGET=Linux
   167     		;;
   168     	    WINNT)
   169     		ICU_TARGET=MSYS/MSVC
   170     		;;
   171             DragonFly|FreeBSD|NetBSD|OpenBSD|GNU_kFreeBSD)
   172     		ICU_TARGET=BSD
   173     		;;
   174     	esac
   175     	# Remove _DEPEND_CFLAGS from HOST_FLAGS to avoid configure error
   176     	HOST_ICU_CFLAGS="$HOST_CFLAGS"
   177     	HOST_ICU_CXXFLAGS="$HOST_CXXFLAGS"
   179     	HOST_ICU_CFLAGS=`echo $HOST_ICU_CFLAGS | sed "s|$_DEPEND_CFLAGS||g"`
   180     	HOST_ICU_CXXFLAGS=`echo $HOST_ICU_CFXXLAGS | sed "s|$_DEPEND_CFLAGS||g"`
   182     	# ICU requires RTTI
   183     	if test "$GNU_CC"; then
   184     	    HOST_ICU_CXXFLAGS=`echo $HOST_ICU_CXXFLAGS | sed 's|-fno-rtti|-frtti|g'`
   185     	elif test "$_MSC_VER"; then
   186     	    HOST_ICU_CXXFLAGS=`echo $HOST_ICU_CXXFLAGS | sed 's|-GR-|-GR|g'`
   187     	fi
   189     	HOST_ICU_BUILD_OPTS=""
   190     	if test -n "$MOZ_DEBUG"; then
   191     	    HOST_ICU_BUILD_OPTS="$HOST_ICU_BUILD_OPTS --enable-debug"
   192     	fi
   194     	abs_srcdir=`(cd $srcdir; pwd)`
   195     	mkdir -p $_objdir/intl/icu/host
   196     	(cd $_objdir/intl/icu/host
   197     	 MOZ_SUBCONFIGURE_WRAP([.],[
   198     	 AR="$HOST_AR" RANLIB="$HOST_RANLIB" \
   199     	 CC="$HOST_CC" CXX="$HOST_CXX" LD="$HOST_LD" \
   200     	 CFLAGS="$HOST_ICU_CFLAGS $HOST_OPTIMIZE_FLAGS" \
   201     	 CPPFLAGS="$ICU_CPPFLAGS" \
   202     	 CXXFLAGS="$HOST_ICU_CXXFLAGS $HOST_OPTIMIZE_FLAGS" \
   203     	 LDFLAGS="$HOST_LDFLAGS" \
   204     		$SHELL $abs_srcdir/intl/icu/source/runConfigureICU \
   205     		$HOST_ICU_BUILD_OPTS \
   206     		$ICU_TARGET \
   207     	dnl Shell quoting is fun.
   208     		${ICU_SRCDIR+"$ICU_SRCDIR"} \
   209     		--enable-static --disable-shared \
   210     		--enable-extras=no --enable-icuio=no --enable-layout=no \
   211     		--enable-tests=no --enable-samples=no || exit 1
   212     	 ])
   213     	) || exit 1
   214     	# generate config/icucross.mk
   215     	$GMAKE -C $_objdir/intl/icu/host/ config/icucross.mk
   217     	# --with-cross-build requires absolute path
   218     	ICU_HOST_PATH=`cd $_objdir/intl/icu/host && pwd`
   219     	ICU_CROSS_BUILD_OPT="--with-cross-build=$ICU_HOST_PATH"
   220     	ICU_TARGET_OPT="--build=$build --host=$target"
   221         else
   222     	# CROSS_COMPILE isn't set build and target are i386 and x86-64.
   223     	# So we must set target for --build and --host.
   224     	ICU_TARGET_OPT="--build=$target --host=$target"
   225         fi
   227         if test -z "$MOZ_SHARED_ICU"; then
   228     	# To reduce library size, use static linking
   229     	ICU_LINK_OPTS="--enable-static --disable-shared"
   230         else
   231     	ICU_LINK_OPTS="--disable-static --enable-shared"
   232         fi
   233         # Force the ICU static libraries to be position independent code
   234         ICU_CFLAGS="$DSO_PIC_CFLAGS $CFLAGS"
   235         ICU_CXXFLAGS="$DSO_PIC_CFLAGS $CXXFLAGS"
   237         ICU_BUILD_OPTS=""
   238         if test -n "$MOZ_DEBUG" -o "MOZ_DEBUG_SYMBOLS"; then
   239     	ICU_CFLAGS="$ICU_CFLAGS $MOZ_DEBUG_FLAGS"
   240     	ICU_CXXFLAGS="$ICU_CXXFLAGS $MOZ_DEBUG_FLAGS"
   241     	if test -n "$CROSS_COMPILE" -a "$OS_TARGET" = "Darwin" \
   242     		-a "$HOST_OS_ARCH" != "Darwin"
   243     	then
   244     	    # Bug 951758: Cross-OSX builds with non-Darwin hosts have issues
   245     	    # with -g and friends (like -gdwarf and -gfull) because they try
   246     	    # to run dsymutil
   247     	    changequote(,)
   248     	    ICU_CFLAGS=`echo $ICU_CFLAGS | sed 's|-g[^ \t]*||g'`
   249     	    ICU_CXXFLAGS=`echo $ICU_CXXFLAGS | sed 's|-g[^ \t]*||g'`
   250     	    changequote([,])
   251     	fi
   253     	ICU_LDFLAGS="$MOZ_DEBUG_LDFLAGS"
   254     	if test -z "$MOZ_DEBUG"; then
   255     	    # To generate debug symbols, it requires MOZ_DEBUG_FLAGS.
   256     	    # But, not debug build.
   257     	    ICU_CFLAGS="$ICU_CFLAGS -UDEBUG -DNDEBUG"
   258     	    ICU_CXXFLAGS="$ICU_CXXFLAGS -UDEBUG -DNDEBUG"
   259     	else
   260     	    ICU_BUILD_OPTS="$ICU_BUILD_OPTS --enable-debug"
   261     	fi
   262         fi
   263         if test -z "$MOZ_OPTIMIZE"; then
   264     	ICU_BUILD_OPTS="$ICU_BUILD_OPTS --disable-release"
   265         else
   266     	ICU_CFLAGS="$ICU_CFLAGS $MOZ_OPTIMIZE_FLAGS"
   267     	ICU_CXXFLAGS="$ICU_CXXFLAGS $MOZ_OPTIMIZE_FLAGS"
   268         fi
   270         if test "$am_cv_langinfo_codeset" = "no"; then
   271     	# ex. Android
   272     	ICU_CPPFLAGS="$ICU_CPPFLAGS -DU_HAVE_NL_LANGINFO_CODESET=0"
   273         fi
   275         # ICU requires RTTI
   276         if test "$GNU_CC"; then
   277     	ICU_CXXFLAGS=`echo $ICU_CXXFLAGS | sed 's|-fno-rtti|-frtti|g'`
   278         else
   279     	if test "$_MSC_VER"; then
   280     	    ICU_CXXFLAGS=`echo $ICU_CXXFLAGS | sed 's|-GR-|-GR|g'`
   281     	fi
   283     	# Add RTL flags for MSVCRT.DLL
   284     	if test -n "$MOZ_DEBUG"; then
   285     	    ICU_CFLAGS="$ICU_CFLAGS -MDd"
   286     	    ICU_CXXFLAGS="$ICU_CXXFLAGS -MDd"
   287     	else
   288     	    ICU_CFLAGS="$ICU_CFLAGS -MD"
   289     	    ICU_CXXFLAGS="$ICU_CXXFLAGS -MD"
   290     	fi
   292     	# add disable optimize flag for workaround for bug 899948
   293     	if test -z "$MOZ_OPTIMIZE"; then
   294     	    ICU_CFLAGS="$ICU_CFLAGS -Od"
   295     	    ICU_CXXFLAGS="$ICU_CXXFLAGS -Od"
   296     	fi
   297         fi
   299         # We cannot use AC_OUTPUT_SUBDIRS since ICU tree is out of spidermonkey.
   300         # When using AC_OUTPUT_SUBDIRS, objdir of ICU is out of objdir
   301         # due to relative path.
   302         # If building ICU moves into root of mozilla tree, we can use
   303         # AC_OUTPUT_SUBDIR instead.
   304         mkdir -p $_objdir/intl/icu/target
   305         (cd $_objdir/intl/icu/target
   306          MOZ_SUBCONFIGURE_WRAP([.],[
   307            AR="$AR" CC="$CC" CXX="$CXX" LD="$LD" \
   308            ARFLAGS="$ARFLAGS" \
   309            CPPFLAGS="$ICU_CPPFLAGS $CPPFLAGS" \
   310            CFLAGS="$ICU_CFLAGS" \
   311            CXXFLAGS="$ICU_CXXFLAGS" \
   312            LDFLAGS="$ICU_LDFLAGS $LDFLAGS" \
   313            $SHELL $_topsrcdir/intl/icu/source/configure \
   314     		$ICU_BUILD_OPTS \
   315     		$ICU_CROSS_BUILD_OPT \
   316     		$ICU_LINK_OPTS \
   317     		${ICU_SRCDIR+"$ICU_SRCDIR"} \
   318     		$ICU_TARGET_OPT \
   319     		--disable-extras --disable-icuio --disable-layout \
   320     		--disable-tests --disable-samples || exit 1
   321            ])
   322         ) || exit 1
   323     fi
   325 fi
   327 ])

mercurial