summaryrefslogtreecommitdiff
path: root/libicuuc/libicu/buildfile
blob: e5c451fc2f48d3ba4b116de8cd9fda5f61d91cd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# file      : libicu/buildfile
# license   : Unicode License; see accompanying LICENSE file

./: lib{icuuc} lib{icudata}

patched = ucasemap unistr uniset

lib{icuuc}: uc/hxx{**} uc/cxx{* -{$patched}} cxx{$patched} lib{icudata}

lib{icudata}: data/{h c}{*} uc/unicode/h{*}

# Our C-files in data/{le,be}/ are included into C-files in ./data/, so treat
# them as files to exclude from the compilation.
#
lib{icudata}: data/le/file{*} data/be/file{*}

tclass = $cc.target.class
tsys   = $cc.target.system

windows = ($tclass == 'windows')

# Build options.
#
cc.poptions  += -DU_ATTRIBUTE_DEPRECATED=
cxx.poptions += -DU_COMMON_IMPLEMENTATION

if! $windows
  cc.poptions += -DU_HAVE_STRTOD_L=1
else
  cc.poptions += -DU_HAVE_STRTOD_L=0 -DHAVE_DLOPEN=0 -DU_HAVE_MMAP=0 -DWIN32

switch $tclass, $tsys
{
  case 'linux'
    cc.poptions += -D_REENTRANT -DU_HAVE_ELF_H -DU_HAVE_XLOCALE_H=0

  case 'bsd'
    cc.poptions += -D_REENTRANT -DU_HAVE_ELF_H -DU_HAVE_XLOCALE_H=1 \
                   -DU_HAVE_TIMEZONE=0 -DU_HAVE_STRING_VIEW=1

  case 'macos'
  {
    cc.poptions += -DU_HAVE_XLOCALE_H=1 -DU_HAVE_STRING_VIEW=1

    # Note that upstream requests the POSIX 2004 compliance (see
    # uc/uposixdefs.h for details). This results with compilation errors for
    # some source files when build on MacOS with gcc (as of 9.2; GCC issues
    # 93151 and 93469 are reported). We workaround the issue disabling this
    # POSIX compliance request for the faulty source files (luckily the
    # request is redundant for them).
    #
    if ($cxx.id == 'gcc')
      uc/obj{putil umapfile}: cxx.poptions += -D_XOPEN_SOURCE=400
  }

  case 'windows', 'mingw32'
    cc.poptions += -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 \
                   -D_MT # Used instead of -mthreads.

  case 'windows'
    cc.poptions += -DU_HAVE_DIRENT_H=0 -DU_HAVE_POPEN=0 -DU_HAVE_TZNAME=0
}

cc.poptions =+ "-I$src_root" "-I$src_base/uc"

obja{*}: cc.poptions += -DU_STATIC_IMPLEMENTATION

switch $c.class, $tsys
{
  case 'gcc'
  {
    cc.coptions  += -fvisibility=hidden

    # Disable warnings that pop up with -Wall -Wextra. Upstream doesn't seem
    # to care about these and it is not easy to disable specific warnings in a
    # way that works across compilers/version (some -Wno-* options are only
    # recognized in newer versions). There are still some warnings left that
    # appear for certain platforms/compilers. We pass them through but disable
    # treating them as errors.
    #
    cc.coptions += -Wno-all -Wno-extra -Wno-error

    # Disable the Clang targeting MSVC warnings.
    #
    if ($c.id == 'clang' && $tsys == 'win32-msvc')
      cc.coptions += -Wno-ignored-pragma-optimize -Wno-ignored-attributes
  }
  case 'msvc'
  {
    cc.coptions  += /utf-8 /GF /Gy
    cxx.coptions += /Zc:wchar_t

    # Disable warnings that pop up with /W3.
    #
    c.coptions   += /wd4229
    cxx.coptions += /wd4244 /wd4996
  }
}

# If install.root is specified, then define the DEFAULT_ICU_PLUGINS macro when
# compiling uc/icuplug.cpp and leave it undefined otherwise.
#
if ($install.root != [null])
{
  plugins_dir = $install.resolve($install.lib)/icu

  # Escape backslashes and quotes in the directory path prior to representing
  # it as C++ string literal.
  #
  pd = $regex.replace($plugins_dir, '(\\|")', '\\\1')

  uc/obj{icuplug}: cxx.poptions += -DDEFAULT_ICU_PLUGINS="\"$pd\""
}

switch $tclass, $tsys
{
  case 'linux'
  {
    cc.loptions += -Wl,-Bsymbolic     \
                   -Wl,--no-undefined # Make sure all symbols are resolvable.

    cxx.libs += -lpthread -ldl -lm
  }
  case 'bsd'
  {
    cc.loptions += -Wl,-Bsymbolic
    cxx.libs    += -lpthread -lm
  }
  case 'macos'
  {
    cxx.libs += -lpthread -lm
  }
  case 'windows', 'mingw32'
  {
    # Note that upstream also passes -mthreads (thread-safe exception
    # handling) that we omit as ICU never throws exceptions (see ICU FAQs for
    # details). We also omit -lpthread -lm that seems to be redundant.
    #
    cc.loptions += -Wl,-Bsymbolic -Wl,--enable-auto-import \
                   -Wl,--no-undefined # Make sure all symbols are resolvable.
  }
  case 'windows'
  {
    cxx.libs += advapi32.lib
  }
}

# Export options.
#
# We don't export libicudata since it is not of much use to anyone except
# libicuuc.
#
lib{icuuc}:  cc.export.poptions  = "-I$src_base/uc"
liba{icuuc}: cc.export.poptions += -DU_STATIC_IMPLEMENTATION

# See bootstrap.build for details.
#
# Note that on Windows and POSIX the data library is named quite differently
# as icudt65.dll and libicudata.so.65.1, respectivelly. We name it
# consistently as icudata-65.dll and libicudata-65.so.
#
if $version.pre_release
  lib{icudata icuuc}: bin.lib.version = @"-$version.project_id"
else
  lib{icudata icuuc}: bin.lib.version = @"-$abi_version_major" \
                                        linux@"$abi_version"

# Install headers from the uc/unicode/ subdirectory only.
#
h{*}:              install = false
hxx{*}:            install = false
uc/unicode/hxx{*}: install = include/unicode/