aboutsummaryrefslogtreecommitdiff
path: root/mysql/buildfile
blob: 55138ebf283a973844bdc75a2ea3086e9ed66b0d (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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# file      : mysql/buildfile
# license   : LGPLv2.1; see accompanying COPYING file

import imp_libs = libz%lib{z}

# Windows-specific named pipe and shared memory based communication plugins.
#
pvio_win32 = pvio/pvio_npipe pvio/pvio_shmem

lib{mariadb}: {h}{**                  -version} \
              {h}{                     version} \
      plugins/{c}{**            -{$pvio_win32}} \
   libmariadb/{c}{*  -ma_tls -ma_client_plugin} \
   libmariadb/{c}{            ma_client_plugin} \
              $imp_libs

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

windows = ($tclass == 'windows')

msvc_runtime = ($tsys == 'win32-msvc')

lib{mariadb}: win-iconv/{h c}{*          } \
                plugins/{  c}{$pvio_win32}: include = $windows

# The upstream package, by default, builds without SSL on POSIX systems, and
# with bundled SSL on Windows. However, it fails to build against MinGW API
# that doesn't implement some "bleeding edge" features used, like the
# SecPkgContext_CipherInfo type. So we only enable SSL for VC.
#
# @@ TODO: need to enable SSL by default on POSIX.
#
with_ssl = $msvc_runtime

lib{mariadb}: libmariadb/{  c}{ma_tls} \
       libmariadb/secure/{h c}{*     }: include = $with_ssl

# Symbol exporting on Windows is done via the .def file.
#
lib{mariadb}: libmariadb/def{mariadbclient}: include = $windows

libmariadb/def{mariadbclient}: libmariadb/in{mariadbclient_win32}
{
  mariadb_deinitialize_ssl = ($with_ssl ? 'mariadb_deinitialize_ssl' : '')
}

# 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).
#
# @@ We should probably allow to configure MARIADB_UNIX_ADDR (used as a last
#    resort) via configuration variable config.libmariadb.unix_addr. Note that
#    it is set differently for the upstream package and the major Linux
#    distributions:
#
#    Debian/Ubuntu:  /var/run/mysqld/mysqld.sock
#    Fedora/RHEL:    /var/lib/mysql/mysql.sock
#    Source package: /tmp/mysql.sock
#
h{version}: in{version} $src_root/manifest
{
  dist  = true
  clean = ($src_root != $out_root)

  in.symbol = '@'

  PROTOCOL_VERSION = $protocol_version
  MARIADB_CLIENT_VERSION = $version.project
  MARIADB_BASE_VERSION = "mariadb-$version.major.$version.minor"

  MARIADB_VERSION_ID =                                                   \
    "\(10000 * $version.major + 100 * $version.minor + $version.patch\)"

  MYSQL_VERSION_ID = $MARIADB_VERSION_ID
  MARIADB_PORT = 3306
  MARIADB_UNIX_ADDR = ($windows ? '': /tmp/mysql.sock)
  CPACK_PACKAGE_VERSION = "$client_major.$client_minor.$client_patch"

  MARIADB_PACKAGE_VERSION_ID =                                        \
    "\(10000 * $client_major + 100 * $client_minor + $client_patch\)"

  CMAKE_SYSTEM_NAME = $tsys
  CMAKE_SYSTEM_PROCESSOR = $c.target.cpu

  PLUGINDIR = ($install.root != [null]                                         \
               ? $regex.replace($install.resolve($install.lib)/mariadb/plugin, \
                                '\\',                                          \
                                '/')                                           \
               : '')

  default_charset = ''
  CC_SOURCE_REVISION = ''
}

libmariadb/c{ma_client_plugin}: libmariadb/in{ma_client_plugin}
{
  in.symbol = '@'
  in.substitution = lax

  EXTERNAL_PLUGINS = ''
  BUILTIN_PLUGINS = ''
}

for p: 'pvio_socket' 'native_password_client' 'old_password_client' \
       ($windows ? 'pvio_npipe' 'pvio_shmem' : )
{
  libmariadb/c{ma_client_plugin}:
  {
    EXTERNAL_PLUGINS = "$EXTERNAL_PLUGINS
extern struct st_mysql_client_plugin $(p)_plugin;"

    BUILTIN_PLUGINS = "$BUILTIN_PLUGINS
\(struct st_mysql_client_plugin *\)&$(p)_plugin,"
  }
}

# Build options.
#
# We have dropped the macro definitions that are not used in the package code:
#
#   -DHAVE_AUTH_CLEARTEXT=1 -DHAVE_AUTH_DIALOG=1 -DHAVE_AUTH_NATIVE=1
#   -DHAVE_AUTH_OLDPASSWORD=1 -DHAVE_AURORA=1 -DHAVE_REPLICATION=1
#   -DHAVE_TRACE_EXAMPLE=1
#
# Here are VC-specific macros dropped:
#
#   /D sha256_password_EXPORTS /D HAVE_NPIPE=1 /D HAVE_SHMEM=1
#   /D HAVE_AUTH_SHA256PW=1 /D HAVE_AUTH_GSSAPI=1
#   /D HAVE_AUTH_GSSAPI_DYNAMIC=1 /D HAVE_DIALOG_DYNAMIC=1
#   /D HAVE_SHA256PW_DYNAMIC=1 /D HAVE_CLEARTEXT_DYNAMIC=1 /D _WINDLL
#
# Note that we add "-I$src_root" for the headers auto-generating machinery to
# work properly.
#
# Also note that we add -DLIBICONV_PLUG not to let the GNU's libiconv header to
# rename iconv*() functions to libiconv*(). Not doing so breaks the linkage
# against non-GNU libc, implementing iconv API, if GNU libiconv is installed in
# the system and its header is picked up instead of the system one.
#
mariadb_poptions = "-I$out_root" "-I$src_root" "-I$src_base"              \
                   -DHAVE_SOCKET=1 -DHAVE_COMPRESS -DENABLED_LOCAL_INFILE \
                   -DLIBMARIADB -DTHREAD -DLIBICONV_PLUG -DDBUG_OFF

switch $tclass
{
  case 'linux'
    mariadb_poptions += -D_GNU_SOURCE

  case 'windows'
  {
    # Note that the original package defines the WIN32 macro for VC only,
    # relying on the fact that MinGW GCC defines it by default. However, the
    # macro disappears from the default ones if to compile with -std=c9x (as
    # we do). So we define it for both VC and MinGW GCC.
    #
    c.poptions += -DWIN32 -D_WINDOWS -D_MBCS

    # Using CancelIoEx() in mysql/plugins/pvio/pvio_socket.c requires at least
    # Windows Vista/Server 2008 (_WIN32_WINNT >= 0x0600). Note that Windows
    # Kits (used by VC) default _WIN32_WINNT to the most current version.
    #
    c.poptions += -D_WIN32_WINNT=0x0600

    # Declaration visibility attribute is not supported.
    #
    c.poptions += -DNO_VIZ

    if $with_ssl
      mariadb_poptions += -DHAVE_SCHANNEL -DHAVE_TLS
  }
}

# Note that the bundled win-iconv header is included as a quoted (relative)
# path, so no need for -I option.
#
   plugins/ c.poptions =+ $mariadb_poptions
libmariadb/ c.poptions =+ $mariadb_poptions

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.
    #
    c.coptions += -Wno-all -Wno-extra -Wno-error

    # Disable the Clang targeting MSVC warnings.
    #
    if ($c.id == 'clang' && $msvc_runtime)
      c.coptions += -Wno-deprecated-declarations
  }
  case 'msvc'
  {
    # Disable warnings that pop up with /W3.
    #
    c.coptions += /wd4996 /wd4267
  }
}

switch $tclass, $tsys
{
  case 'windows', 'mingw32'
    cc.libs += -lws2_32 -lshlwapi -ladvapi32 -lversion # @@ secur32

  case 'windows'
    cc.libs += ws2_32.lib shlwapi.lib advapi32.lib version.lib

  case 'linux'
  {
    # The upstream package also passes the cmake-generated mariadbclient.def
    # version script file. The symbols it contains are hard-coded into
    # libmariadb/libmariadb/CMakeList.txt. We drop the file for now.
    #
    # Make sure all symbols are resolvable.
    #
    c.loptions += -Wl,--no-undefined

    # Drop the redundant linkage of libnsl.
    #
    # The upstream package looks for gethostbyname_r() in libnsl and links it
    # even though it doesn't export the symbol (that actually is not even used
    # in libmariadb).
    #
    # Note that glibc 2.26 deprecates libnsl and doesn't install it by
    # default, so its linkage just fails.
    #
    c.libs += -lpthread -lm -ldl # -lnsl
  }

  case 'bsd'
    c.libs += -lpthread -lm

  case 'macos'
  {
    c.loptions += -compatibility_version "$abi_version.0.0" \
                  -current_version "$abi_version.0.0"

    c.libs += -lpthread -lm -ldl -liconv
  }

  default
    c.libs += -lpthread -lm -ldl
}

# Export options.
#
# The library clients must include the API header as <mysql/mysql.h>.
#
lib{mariadb}: cc.export.poptions = "-I$out_root" "-I$src_root"

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

# Let's install the bare minimum of headers: mysql.h, errmsg.h, mysqld_error.h
# and headers they recursively include.
#
# Note that we don't install dyncol and client plugin API headers. Including
# them wouldn't work out of the box anyway, as they include prerequisite
# headers without mysql/ prefix. These headers don't look important as seems
# to be broken anyway for the upstream package (they reference non-installed
# headers and non-exported functions).
#
h{*}: install = false

# @@ Fix once LHS pair generation is implemented.
#
for h: mysql errmsg mysqld_error mariadb_version mariadb_com ma_list \
       mariadb_ctype mariadb_stmt
  h{$h}@./: install = include/mysql/

# Install into the mysql/ subdirectory of, say, /usr/include.
#
h{version}: install = include/mysql/