summaryrefslogtreecommitdiff
path: root/libxerces-c/xercesc/buildfile
blob: 88cf9b17175eea8f97050c386d067766f34a9dab (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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# file      : xercesc/buildfile
# license   : Apache License 2.0; see accompanying LICENSE file

network = $config.libxerces_c.network
transcoder_icu = $config.libxerces_c.transcoder_icu

intf_libs = # Interface dependencies.
impl_libs = # Implementation dependencies.

# Note that the installed util/NetAccessors/Curl/CurlURLInputStream.hpp
# includes the libcurl headers.
#
if $network
  import intf_libs += libcurl%lib{curl}

if $transcoder_icu
{
  import impl_libs += libicuuc%lib{icuuc}
  import impl_libs += libicui18n%lib{icui18n}
}

lib{xerces-c}: {h          }{config}                    \
               {hxx txx cxx}{*/** -util/FileManagers/** \
                                  -util/NetAccessors/** \
                                  -util/Transcoders/**  \
                                  -util/XercesVersion}  \
               {hxx        }{      util/XercesVersion}

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

macos   = ($tclass == 'macos')
windows = ($tclass == 'windows')

lib{xerces-c}:    {h     c}{stricmp strnicmp}                        \
util/FileManagers/{hxx cxx}{PosixFileMgr    }: include = (!$windows)

lib{xerces-c}: util/FileManagers/{hxx cxx}{WindowsFileMgr}: include = $windows

lib{xerces-c}: util/NetAccessors/Curl/{hxx cxx}{*}: include = $network

lib{xerces-c}: util/Transcoders/ICU/{hxx cxx}{*}: include = $transcoder_icu

lib{xerces-c}: util/Transcoders/MacOSUnicodeConverter/{hxx cxx}{*}: \
include = (!$transcoder_icu && $macos)

lib{xerces-c}: util/Transcoders/Win32/{hxx cxx}{*}: \
include = (!$transcoder_icu && $windows)

lib{xerces-c}: $intf_libs $impl_libs

# Include the generated version header into the distribution (so that we
# don't pick up an installed one) and don't remove it when cleaning in src (so
# that clean results in a state identical to distributed).
#
util/hxx{XercesVersion}: util/in{XercesVersion} $src_root/manifest
{
  dist  = true
  clean = ($src_root != $out_root)

  in.symbol = '@'

  XERCES_VERSION_MAJOR    = "$version.major"
  XERCES_VERSION_MINOR    = "$version.minor"
  XERCES_VERSION_REVISION = "$version.patch"

  XERCES_GRAMMAR_SERIALIZATION_LEVEL = "$grammar_serialization_level"
}

# Build options.
#
if $network
  cc.poptions += -DXERCES_USE_NETACCESSOR_CURL=1

if $transcoder_icu
  cc.poptions += -DXERCES_USE_TRANSCODER_ICU=1
elif $macos
  cc.poptions += -DXERCES_USE_TRANSCODER_MACOSUNICODECONVERTER=1
elif $windows
  cc.poptions += -DXERCES_USE_TRANSCODER_WINDOWS=1

cc.poptions += -DXERCES_BUILDING_LIBRARY -DHAVE_CONFIG_H -D_THREAD_SAFE

if $windows
  cc.poptions += -DWIN32 -D_WINDOWS -D_MBCS

# Note that we need to add "-I$src_root" for the headers auto-generating
# machinery to work properly.
#
cc.poptions =+ "-I$out_root" "-I$src_root" "-I$src_base"

obja{*}: cxx.poptions += -DLIBXERCES_C_STATIC_BUILD
objs{*}: cxx.poptions += -DLIBXERCES_C_SHARED_BUILD

switch $c.class
{
  case 'gcc'
  {
    # 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-deprecated-declarations
  }
  case 'msvc'
  {
    # Disable warnings that pop up with /W3.
    #
    cc.coptions += /wd4244 /wd4267 /wd4996 /wd4305
  }
}

switch $tclass, $tsys
{
  case 'windows', 'mingw32'
  {
    # Make sure all symbols are resolvable.
    #
    cxx.loptions += -Wl,--no-undefined

    if $network
      cxx.libs += -lws2_32
  }
  case 'windows'
  {
    # Suppress the 'object file does not define any public symbols' warning.
    #
    cxx.aoptions += /IGNORE:4221

    if! $transcoder_icu
      cxx.libs += advapi32.lib

    if $network
      cxx.libs += ws2_32.lib
  }
  case 'linux'
  {
    # Make sure all symbols are resolvable.
    #
    cxx.loptions += -Wl,--no-undefined

    cxx.libs += -lm -pthread
  }
  case 'macos'
  {
    if! $transcoder_icu
      cxx.libs += -framework CoreServices

    cxx.libs += -pthread
  }
  default
  {
    cxx.libs += -pthread
  }
}

# Export options.
#
lib{xerces-c}:
{
  cxx.export.poptions = "-I$out_root" "-I$src_root"
  cxx.export.libs     = $intf_libs
}

liba{xerces-c}: cxx.export.poptions += -DLIBXERCES_C_STATIC
libs{xerces-c}: cxx.export.poptions += -DLIBXERCES_C_SHARED

# See bootstrap.build for details.
#
if $version.pre_release
  lib{xerces-c}: bin.lib.version = @"-$version.project_id"
else
  lib{xerces-c}: bin.lib.version = @"-$abi_version"

# Don't install the implementation details C headers (config.h and the
# compatibility function declarations).
#
h{*}: install = false

# Install the C++ headers into the xercesc/ subdirectory of, say, /usr/include/
# recreating subdirectories.
#
{hxx txx}{*}:
{
  install         = include/xercesc/
  install.subdirs = true
}