aboutsummaryrefslogtreecommitdiff
path: root/libbutl-odb/buildfile
blob: 9fff963e89d80d463db54846e67f743b97866953 (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
# file      : libbutl-odb/buildfile
# license   : MIT; see accompanying LICENSE file

sys_sqlite = $config.libbutl.system_libsqlite3

intf_libs =

if $sys_sqlite
  import intf_libs += libsqlite3%lib{sqlite3}

lib{butl-odb}: odb/{h hxx ixx txx cxx}{**}
lib{butl-odb}: sqlite/{h c}{*}: include = (!$sys_sqlite)
lib{butl-odb}: $intf_libs

# Build options.
#
cxx.poptions =+ "-I$src_base"

if! $sys_sqlite
  cxx.poptions =+ "-I($src_base/sqlite)"

# For now we only need single-threaded ODB and SQLite. Note that if we need to
# change that, then we will most likely need to deal with MinGW stdthread mess
# (see libbutl/buildfile for details). Also see SQLITE_THREADSAFE=0 below.
#
cxx.poptions += -DODB_THREADS_NONE

obja{*}: cxx.poptions += -DLIBODB_STATIC_BUILD -DLIBODB_SQLITE_STATIC_BUILD
objs{*}: cxx.poptions += -DLIBODB_SHARED_BUILD -DLIBODB_SQLITE_SHARED_BUILD

if! $sys_sqlite
{
  # Note: copy of libsqlite3/buildfile except for SQLITE_THREADSAFE=0,
  # -DSQLITE_OMIT_SHARED_CACHE, and removed ENABLE_UNLOCK_NOTIFY=1.
  #
  # We also add -Wno-unused-variable and -Wno-unused-but-set-variable.
  #
  tclass = $c.target.class

  bsd     = ($tclass == 'bsd')
  windows = ($tclass == 'windows')

  gcc        = ($c.class == 'gcc')
  clang      = ($c.id.type == 'clang')
  clang_msvc = ($clang && $c.target.system == 'win32-msvc')

  sqlite/
  {
    # @@ TMP: add -DSQLITE_DQS=0, -DSQLITE_OMIT_DEPRECATED=1
    # @@ TODO: maybe use -DSQLITE_OMIT_AUTOINIT?

    c.poptions += \
      -DSQLITE_ALLOW_ROWID_IN_VIEW=1 \
      -DSQLITE_ENABLE_COLUMN_METADATA=1 \
      -DSQLITE_ENABLE_DBPAGE_VTAB=1 \
      -DSQLITE_ENABLE_DBSTAT_VTAB=1 \
      -DSQLITE_ENABLE_EXPLAIN_COMMENTS=1 \
      -DSQLITE_ENABLE_FTS3=1 \
      -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 \
      -DSQLITE_ENABLE_FTS3_TOKENIZER=1 \
      -DSQLITE_ENABLE_FTS4=1 \
      -DSQLITE_ENABLE_FTS5=1 \
      -DSQLITE_ENABLE_GEOPOLY=1 \
      -DSQLITE_ENABLE_JSON1=1 \
      -DSQLITE_ENABLE_LOAD_EXTENSION=1 \
      -DSQLITE_ENABLE_MATH_FUNCTIONS=1 \
      -DSQLITE_ENABLE_PREUPDATE_HOOK=1 \
      -DSQLITE_ENABLE_RTREE=1 \
      -DSQLITE_ENABLE_SESSION=1 \
      -DSQLITE_ENABLE_STMTVTAB=1 \
      -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT=1 \
      -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 \
      -DSQLITE_MAX_SCHEMA_RETRY=25 \
      -DSQLITE_MAX_VARIABLE_NUMBER=250000 \
      -DSQLITE_OMIT_LOOKASIDE=1 \
      -DSQLITE_SECURE_DELETE=1 \
      -DSQLITE_SOUNDEX=1 \
      -DSQLITE_THREADSAFE=0 \
      -DSQLITE_USE_URI=1 \
      -DSQLITE_OMIT_SHARED_CACHE=1

    c.poptions += -DSQLITE_MAX_ATTACHED=125

    if! $windows
      c.poptions += -DHAVE_USLEEP=1

    if $windows
      objs{*}: c.poptions += '-DSQLITE_API=__declspec(dllexport)'

    if $gcc
      c.coptions += -fno-strict-aliasing

    if $clang_msvc
      c.coptions += -Wno-deprecated-declarations

    if ($clang && $c.version.major >= 15)
      c.coptions += -Wno-unused-but-set-variable

    if $gcc
      c.coptions += -Wno-unused-variable -Wno-extra -Wno-error

    if ($c.id == 'gcc' && $c.version.major >= 14)
      c.coptions += -Wno-stringop-overread
  }

  if! $windows
  {
    cxx.libs += -lm

    if! $bsd
      cxx.libs += -ldl
  }
}

# Export options.
#
lib{butl-odb}:
{
  cxx.export.poptions = "-I$src_base" -DODB_THREADS_NONE
  cxx.export.libs = $intf_libs
}

liba{butl-odb}: cxx.export.poptions += -DLIBODB_STATIC -DLIBODB_SQLITE_STATIC
libs{butl-odb}: cxx.export.poptions += -DLIBODB_SHARED -DLIBODB_SQLITE_SHARED

if! $sys_sqlite
{
  lib{butl-odb}: cc.export.poptions = "-I($src_base/sqlite)"

  if $windows
    libs{butl-odb}: cc.export.poptions += '-DSQLITE_API=__declspec(dllimport)'
}

# For pre-releases use the complete version to make sure they cannot be used
# in place of another pre-release or the final version. See the version module
# for details on the version.* variable values.
#
if $version.pre_release
  lib{butl-odb}: bin.lib.version = @"-$version.project_id"
else
  lib{butl-odb}: bin.lib.version = @"-$version.major.$version.minor"

# Install into the libbutl/odb/ subdirectory of, say, /usr/include/. For odb/,
# recreate subdirectories (so we end up with libbutl/odb/odb/...>). For
# sqlite/, install directly into libbutl/odb/. Arrange via pkg-config to be
# able to include ODB headers as <odb/...> and SQLite as just <sqlite3.h>.
#
# The reason we add an extra odb/ subdirectory instead of installing directly
# into libbutl/ is because adding -I for libbutl/ will make all the libbutl
# headers includable without a prefix and thus prone to clashes.
#
odb/{h hxx ixx txx}{*}:
{
  install         = include/libbutl/odb/odb/
  install.subdirs = true
}

sqlite/h{*}: install = include/libbutl/odb/

lib{butl-odb}: cxx.pkgconfig.include = include/libbutl/odb/