build/autoconf/icu.m4

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial