aboutsummaryrefslogtreecommitdiff
path: root/build2/buildfile
blob: 0111ed2a86095022bc2c8d4c1c9842d783fc0113 (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
# file      : build2/buildfile
# license   : MIT; see accompanying LICENSE file

# NOTE: imports should go into root.build.
#
libs = $libbutl

# NOTE: don't forget to also update bpkg's buildfile if changing anything
# here.
#
include ../libbuild2/
libs += ../libbuild2/lib{build2}

for m: bash bin c cc cli cxx in version
{
  include ../libbuild2/$m/
  libs += ../libbuild2/$m/lib{build2-$m}
}

exe{b}: {hxx ixx txx cxx}{**} $libs

# Target metadata, see also --build2-metadata in b.cxx.
#
exe{b}:
{
  export.metadata = 1 b
  b.name = [string] b
  b.version  = $version
  b.checksum = $version
  b.static = ($bin.link_member(exe) == liba)
}

# Build options.
#
# Pass our compiler target to be used as build2 host.
#
obj{b}: cxx.poptions += -DBUILD2_HOST_TRIPLET=\"$cxx.target\"

# Pass the copyright notice extracted from the LICENSE file.
#
copyright = $process.run_regex(                      \
  cat $src_root/LICENSE,                             \
  'Copyright \(c\) (.+) \(see the AUTHORS file\)\.', \
  '\1')

obj{b}: cxx.poptions += -DBUILD2_COPYRIGHT=\"$copyright\"

# NOTE: remember to update bpkg buildfile if changing anything here.
#
switch $cxx.target.class
{
  case 'linux'
  {
    # Make sure backtrace includes function names.
    #
    if ($cc.stdlib == 'glibc')
      cxx.loptions += -rdynamic

    # Make sure we use RPATH and not RUNPATH since the latter messes up
    # dlopen().
    #
    cxx.loptions += -Wl,--disable-new-dtags
  }
  case 'windows'
  {
    # Adjust stack size (affects all threads).
    #
    #                                                8M        4M
    stack_size = ($cxx.target.cpu == "x86_64" ? 8388608 : 4194304)

    cxx.loptions += ($cxx.target.system == 'win32-msvc' \
                     ? "/STACK:$stack_size"             \
                     : "-Wl,--stack,$stack_size")
  }
}