summaryrefslogtreecommitdiff
path: root/libexpat/libexpat/buildfile
blob: 7e9514c6f7445fff6f38fbf2a80220416bfc1a1f (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
# file      : libexpat/buildfile
# license   : MIT; see accompanying COPYING file

lib{expat}: libul{expat}

# xmltok_{impl,nc}.c files are included into xmltok.c, so exclude them from
# the compilation.
#
{libul libue}{expat}: h{*} c{* -xmltok_impl -xmltok_ns}
{libul libue}{expat}: c{xmltok_impl xmltok_ns}: include = false

tclass = $c.target.class

msvc_runtime = ($c.target.system == 'win32-msvc')

# Symbol exporting for MSVC and Clang targeting MSVC is done via the .def
# file.
#
# Note that for MinGW it's done the same way as for POSIX via the visibility
# function attribute.
#
libs{expat}: def{libexpat}: include = $msvc_runtime

def{libexpat}: in{libexpat}
{
  in.symbol = '@'

  # @@ TMP Use the in.substitutions variable instead when build2 0.16.0 is
  #        released (see README-DEV for details).
  #
  in.substitution = lax

  EXPAT_COMMENT_ATTR_INFO = ';'
  EXPAT_COMMENT_DTD       = ' '
}

# Build options.
#
c.poptions += -DHAVE_EXPAT_CONFIG_H -DXML_BUILDING_EXPAT

if! $msvc_runtime
  c.poptions += -DXML_ENABLE_VISIBILITY=1

c.poptions =+ "-I$src_base"

if ($c.class == 'gcc')
{
  c.coptions += -fexceptions -fno-strict-aliasing

  if! $msvc_runtime
    c.coptions += -fvisibility=hidden

  # Disable warnings that pop up with -Wall -Wextra.
  #
  # Note that -Wno-implicit-fallthrough is only supported starting from GCC 7
  # and Clang 3.9. However, we don't check for the compiler version since the
  # earlier compiler versions do not complain about unknown -Wno-* options,
  # unless some other diagnostics is issued.
  #
  # Also note that these warnings can be build2-specific due to the
  # intermediate translation unit pre-processing phase, which wipes the `fall
  # through` comments from the macro definitions.
  #
  c.coptions += -Wno-implicit-fallthrough
}

switch $tclass
{
  case 'linux' | 'bsd'
  {
    # Make sure all symbols are resolvable.
    #
    c.loptions += -Wl,--no-undefined
  }
}

# Export options.
#
lib{expat}:  cc.export.poptions  = "-I$src_base"
liba{expat}: cc.export.poptions += -DXML_STATIC

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

# Install the bare minimum of headers (note: not recreating subdirectories).
#
h{*}: install = false

for h: expat expat_external expat_config
  h{$h}@./: install = include/