edits
[c11concurrency-benchmarks.git] / firefox-related / icu.m4
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/.
4
5 dnl Set the MOZ_ICU_VERSION variable to denote the current version of the
6 dnl ICU library, as well as a few other things.
7
8 AC_DEFUN([MOZ_CONFIG_ICU], [
9
10 ICU_LIB_NAMES=
11 MOZ_SYSTEM_ICU=
12 MOZ_ARG_WITH_BOOL(system-icu,
13 [  --with-system-icu
14                           Use system ICU (located with pkgconfig)],
15     MOZ_SYSTEM_ICU=1)
16
17 if test -n "$MOZ_SYSTEM_ICU"; then
18     PKG_CHECK_MODULES(MOZ_ICU, icu-i18n >= 50.1)
19     CFLAGS="$CFLAGS $MOZ_ICU_CFLAGS"
20     CXXFLAGS="$CXXFLAGS $MOZ_ICU_CFLAGS"
21 fi
22
23 AC_SUBST(MOZ_SYSTEM_ICU)
24
25 MOZ_ARG_WITH_STRING(intl-api,
26 [  --with-intl-api, --with-intl-api=build, --without-intl-api
27     Determine the status of the ECMAScript Internationalization API.  The first
28     (or lack of any of these) builds and exposes the API.  The second builds it
29     but doesn't use ICU or expose the API to script.  The third doesn't build
30     ICU at all.],
31     _INTL_API=$withval)
32
33 ENABLE_INTL_API=
34 EXPOSE_INTL_API=
35 case "$_INTL_API" in
36 no)
37     ;;
38 build)
39     ENABLE_INTL_API=1
40     ;;
41 yes)
42     ENABLE_INTL_API=1
43     EXPOSE_INTL_API=1
44     ;;
45 *)
46     AC_MSG_ERROR([Invalid value passed to --with-intl-api: $_INTL_API])
47     ;;
48 esac
49
50 if test -n "$ENABLE_INTL_API"; then
51     USE_ICU=1
52 fi
53
54 if test -n "$EXPOSE_INTL_API"; then
55     AC_DEFINE(EXPOSE_INTL_API)
56 fi
57
58 if test -n "$ENABLE_INTL_API"; then
59     AC_DEFINE(ENABLE_INTL_API)
60 fi
61
62 dnl Settings for the implementation of the ECMAScript Internationalization API
63 if test -n "$USE_ICU"; then
64     icudir="$_topsrcdir/intl/icu/source"
65     if test ! -d "$icudir"; then
66         icudir="$_topsrcdir/../../intl/icu/source"
67         if test ! -d "$icudir"; then
68             AC_MSG_ERROR([Cannot find the ICU directory])
69         fi
70     fi
71
72     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"`
73     if test x"$version" = x; then
74        AC_MSG_ERROR([cannot determine icu version number from uvernum.h header file $lineno])
75     fi
76     MOZ_ICU_VERSION="$version"
77
78     # TODO: the l is actually endian-dependent
79     # We could make this set as 'l' or 'b' for little or big, respectively,
80     # but we'd need to check in a big-endian version of the file.
81     ICU_DATA_FILE="icudt${version}l.dat"
82
83     dnl We won't build ICU data as a separate file when building
84     dnl JS standalone so that embedders don't have to deal with it.
85     dnl We also don't do it on Windows because sometimes the file goes
86     dnl missing -- possibly due to overzealous antivirus software? --
87     dnl which prevents the browser from starting up :(
88     if test -z "$JS_STANDALONE" -a -z "$MOZ_SYSTEM_ICU" -a "$OS_TARGET" != WINNT -a "$MOZ_WIDGET_TOOLKIT" != "android"; then
89         MOZ_ICU_DATA_ARCHIVE=1
90     else
91         MOZ_ICU_DATA_ARCHIVE=
92     fi
93 fi
94
95 AC_SUBST(MOZ_ICU_VERSION)
96 AC_SUBST(ENABLE_INTL_API)
97 AC_SUBST(USE_ICU)
98 AC_SUBST(ICU_DATA_FILE)
99 AC_SUBST(MOZ_ICU_DATA_ARCHIVE)
100
101 if test -n "$USE_ICU" -a -z "$MOZ_SYSTEM_ICU"; then
102     if test -z "$YASM" -a -z "$GNU_AS" -a "$COMPILE_ENVIRONMENT"; then
103       AC_MSG_ERROR([Building ICU requires either yasm or a GNU assembler. If you do not have either of those available for this platform you must use --without-intl-api])
104     fi
105     dnl We build ICU as a static library.
106     AC_DEFINE(U_STATIC_IMPLEMENTATION)
107     dnl Source files that use ICU should have control over which parts of the ICU
108     dnl namespace they want to use.
109     AC_DEFINE(U_USING_ICU_NAMESPACE,0)
110 fi
111 ])