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
|
# file : mysql/buildfile
# copyright : Copyright (c) 2016-2017 Code Synthesis Ltd
# license : LGPLv2.1; see accompanying COPYING file
define def: file
def{*}: extension = def
# Windows-specific named pipe and shared memory based communication plugins.
#
pvio_win32 = pvio/pvio_npipe pvio/pvio_shmem
lib{mariadb}: zlib/{c}{* } \
plugins/{c}{** -{$pvio_win32}} \
libmariadb/{c}{* -ma_tls -ma_client_plugin} \
libmariadb/{c}{ ma_client_plugin} \
{h}{** -version} \
{h}{ version}
# Makes sense to distribute README for the bundled library.
#
lib{mariadb}: zlib/file{README}
tclass = $c.target.class
tsys = $c.target.system
if ($tclass == 'windows')
lib{mariadb}: win-iconv/{h c }{* } \
plugins/{ c }{$pvio_win32 } \
libmariadb/{ def}{mariadbclient} # Exports.
else
lib{mariadb}: win-iconv/file{*.h *.c } \
plugins/file{$regex.apply($pvio_win32, '(.+)', '\1.c')} \
libmariadb/file{mariadbclient_win32.def.in}
# 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 = ($tsys == 'win32-msvc')
if $with_ssl
lib{mariadb}: libmariadb/{ c}{ma_tls} \
libmariadb/secure/{h c}{* }
else
lib{mariadb}: libmariadb/file{ma_tls.c} \
libmariadb/secure/file{*.h *.c }
# 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"
# 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/file{manifest}
h{version}: dist = true
h{version}: clean = ($src_root != $out_root)
h{version}: in.symbol = '@'
h{version}: PROTOCOL_VERSION = $protocol_version
h{version}: MARIADB_CLIENT_VERSION = $version.project
h{version}: MARIADB_BASE_VERSION = "mariadb-$version.major.$version.minor"
h{version}: MARIADB_VERSION_ID = \
"\(10000 * $version.major + 100 * $version.minor + $version.patch\)"
h{version}: MYSQL_VERSION_ID = $MARIADB_VERSION_ID
h{version}: MARIADB_PORT = 3306
h{version}: MARIADB_UNIX_ADDR = ($tclass != 'windows' ? /tmp/mysql.sock : '')
h{version}: CPACK_PACKAGE_VERSION = "$client_major.$client_minor.$client_patch"
h{version}: MARIADB_PACKAGE_VERSION_ID = \
"\(10000 * $client_major + 100 * $client_minor + $client_patch\)"
h{version}: CMAKE_SYSTEM_NAME = $tsys
h{version}: CMAKE_SYSTEM_PROCESSOR = $c.target.cpu
h{version}: PLUGINDIR = \
($install.root != [null] \
? $regex.replace($install.resolve($install.lib)/mariadb/plugin, '\\', '/') \
: '')
h{version}: default_charset = ''
h{version}: CC_SOURCE_REVISION = ''
# @@ Here we generate files from the templates using the version file
# generating machinery (this is why the redundant $src_root/file{manifest}
# prerequisite).
#
libmariadb/c{ma_client_plugin}: libmariadb/in{ma_client_plugin} \
$src_root/file{manifest} # @@ TMP
libmariadb/c{ma_client_plugin}: in.symbol = '@'
libmariadb/c{ma_client_plugin}: in.substitution = lax
libmariadb/c{ma_client_plugin}: EXTERNAL_PLUGINS = ''
libmariadb/c{ma_client_plugin}: BUILTIN_PLUGINS = ''
for p: 'pvio_socket' 'native_password_client' 'old_password_client' \
($tclass == 'windows' ? 'pvio_npipe' 'pvio_shmem' : )
{
libmariadb/c{ma_client_plugin}: EXTERNAL_PLUGINS = "$EXTERNAL_PLUGINS
extern struct st_mysql_client_plugin $(p)_plugin;"
libmariadb/c{ma_client_plugin}: BUILTIN_PLUGINS = "$BUILTIN_PLUGINS
\(struct st_mysql_client_plugin *\)&$(p)_plugin,"
}
if ($tclass == 'windows')
{
libmariadb/def{mariadbclient}: libmariadb/in{mariadbclient_win32} \
$src_root/file{manifest} # @@ TMP
libmariadb/def{mariadbclient}: mariadb_deinitialize_ssl = \
($with_ssl ? 'mariadb_deinitialize_ssl' : '')
}
# 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
if ($tclass != 'windows')
{
if ($tclass == 'linux')
mariadb_poptions += -D_GNU_SOURCE
}
else
{
# 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
}
zlib_poptions = "-I$src_base/zlib"
# Note that the bundled win-iconv header is included as a quoted (relative)
# path, so no need for -I option.
#
zlib/: c.poptions =+ $zlib_poptions
plugins/: c.poptions =+ $mariadb_poptions
libmariadb/: c.poptions =+ $mariadb_poptions $zlib_poptions
if ($c.class == 'msvc')
{
# Disable warnings that pop up with /W3.
#
c.coptions += /wd4996 /wd4267
}
elif ($c.class == 'gcc')
{
# Disable all warnings. 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). Note that we tried -Wno-all -Wno-extra but that wasn't
# sufficient.
#
c.coptions += -w
}
if ($tclass != 'windows')
{
# On 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.
#
if ($tclass == 'linux')
c.loptions += -Wl,--no-undefined # Make sure all symbols are resolvable.
elif ($tclass == 'macos')
c.loptions += -compatibility_version "$abi_version.0.0" \
-current_version "$abi_version.0.0"
c.libs += -lpthread -lm
if ($tclass == 'linux')
c.libs += -lnsl
if ($tclass != 'bsd')
c.libs += -ldl
if ($tclass == 'macos')
c.libs += -liconv
}
else
{
libs = ws2_32 shlwapi advapi32 version # secur32
def = $out_base/libmariadb/mariadbclient.def
if ($tsys == 'mingw32')
{
c.loptions += $def
c.libs += $regex.apply($libs, '(.+)', '-l\1')
}
else
{
c.loptions += "/DEF:$def"
c.libs += $regex.apply($libs, '(.+)', '\1.lib')
}
}
# The library clients must include the API header as <mysql/mysql.h>.
#
lib{mariadb}: c.export.poptions = "-I$out_root" "-I$src_root"
# Let's install the bare minimum of headers: mysql/mysql.h and headers it
# recursively includes.
#
# 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 mariadb_com ma_list mariadb_ctype mariadb_stmt mariadb_version
h{$h}@./: install = include/mysql/
# Install into the mysql/ subdirectory of, say, /usr/include.
#
h{version}: install = include/mysql/
|