aboutsummaryrefslogtreecommitdiff
path: root/mysql/buildfile
blob: acc9883971b6f8ee67fdeab21b666bbf8910eb9d (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
# file      : mysql/buildfile
# copyright : Copyright (c) 2016-2018 Code Synthesis Ltd
# license   : GPLv2 with FOSS License Exception; see accompanying COPYING file

# Windows-specific utilities.
#
mysys_win32 = my_winerr my_winfile

# Windows-specific named pipe and shared memory based communication channels.
#
vio_win32 = viopipe vioshm

lib{mysqlclient}: {h          }{*                       -version} \
                  {h          }{                         version} \
             zlib/{h c        }{*                               } \
          strings/{h c        }{*                               } \
           atomic/{h          }{*                               } \
            mysys/{h c        }{*  -posix_timers -{$mysys_win32}} \
        mysys_ssl/{h       cxx}{*                               } \
      extra/yassl/{h c hxx cxx}{**                              } \
              vio/{h c        }{*                  -{$vio_win32}} \
              sql/{h c hxx cxx}{**                              } \
       sql-common/{h c hxx cxx}{*                               } \
         libmysql/{h c        }{*                               } \
            mysql/{h          }{**                              }

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

linux   = ($tclass == 'linux')
windows = ($tclass == 'windows')

lib{mysqlclient}: mysys/c{posix_timers}: include = $linux

lib{mysqlclient}:       mysys/{  c    }{$mysys_win32} \
                          vio/{  c    }{$vio_win32  } \
  libmysql/authentication_win/{h   cxx}{*           } \
                  libmysql/def{libmysql_exports_win32}: include = $windows

# Makes sense to distribute READMEs and licenses for the bundled libraries.
#
lib{mysqlclient}: zlib/file{README*                        } \
           extra/yassl/file{README COPYING FLOSS-EXCEPTIONS} \
  extra/yassl/taocrypt/file{README COPYING                 }

# See bootstrap.build for details.
#
if $version.pre_release
  lib{mysqlclient}: bin.lib.version = @"-$version.project_id"
else
  lib{mysqlclient}: 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 MYSQL_UNIX_ADDR via configuration
#    variable config.libmysqlclient.unix_addr. Note that it is set differently
#    for the upstream package and major Linux distributions:
#
#    Debian/Ubuntu:  /var/run/mysqld/mysqld.sock
#    Fedora/RHEL:    /var/lib/mysql/mysql.sock
#    Source package: /tmp/mysql.sock
#
# @@ Note that if variable values changes (say install root is reconfigured),
#    then the version files is not regenerated. Should we store instantiated
#    variables name/value hash in the dependency file? This will be fixed
#    as part of the in module.
#
h{version}: in{version} $src_root/manifest

h{version}: dist  = true
h{version}: clean = ($src_root != $out_root)
h{version}: in.symbol = '@'

h{version}: PROTOCOL_VERSION = $protocol_version
h{version}: VERSION = $version.project
h{version}: MYSQL_BASE_VERSION = "$version.major.$version.minor"
h{version}: MYSQL_VERSION_MAJOR = $version.major
h{version}: MYSQL_VERSION_MINOR = $version.minor
h{version}: MYSQL_SERVER_SUFFIX = ''
h{version}: DOT_FRM_VERSION = 6 # File format (server-related).
h{version}: MYSQL_VERSION_ID =                                         \
  "\(10000 * $version.major + 100 * $version.minor + $version.patch\)"
h{version}: MYSQL_TCP_PORT = 3306
h{version}: MYSQL_TCP_PORT_DEFAULT = 0
h{version}: MYSQL_UNIX_ADDR = ($windows ? '' : /tmp/mysql.sock)
h{version}: COMPILATION_COMMENT = 'Source distribution'
h{version}: SYS_SCHEMA_VERSION = '1.5.1' # Server-related.
h{version}: MACHINE_TYPE = $c.target.cpu
h{version}: SYSTEM_TYPE  = $tsys
h{version}: DEFAULT_BASEDIR =                                     \
  ($install.root != [null]                                        \
   ? $regex.replace("$install.resolve($install.root)", '\\', '/') \
   : '')
h{version}: PLUGINDIR =                                                     \
  ($install.root != [null]                                                  \
   ? $regex.replace($install.resolve($install.lib)/mysql/plugin, '\\', '/') \
   : '')
h{version}: SHAREDIR =                                                \
  ($install.root != [null]                                            \
   ? $regex.replace($install.resolve($install.data_root)/share/mysql, \
                    '\\', '/')                                        \
   : '')

# We have dropped the macro definitions that are not used in the package code:
#
#   -DHAVE_LIBEVENT1
#
cc.poptions += -DHAVE_CONFIG_H -DDBUG_OFF

if! $windows
{
  cc.poptions += -D_FILE_OFFSET_BITS=64

  if $linux
    cc.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 (though libmysqlclient
  # doesn't support building with MinGW GCC at the moment).
  #
  cc.poptions += -DWIN32 -D_WINDOWS -D_WIN32_WINNT=0x0601 -DNOGDI -DNOMINMAX \
                 -DWIN32_LEAN_AND_MEAN -D_MBCS
}

# Note that we add "-I$src_root" for the headers auto-generating machinery to
# work properly.
#
cc.poptions =+ "-I$out_root" "-I$src_root" "-I$src_base"

zlib_poptions    = "-I$src_base/zlib"
strings_poptions = "-I$src_base/strings"
mysys_poptions   = "-I$src_base/mysys"

# To keep "-I$out_root" "-I$src_root" first we use '+=', rather than '=+' to
# append poptions for the target wildcards.
#
   zlib/ cc.poptions += $zlib_poptions
  mysys/ cc.poptions += $mysys_poptions $zlib_poptions
strings/ cc.poptions += $strings_poptions -DDISABLE_MYSQL_THREAD_H

yassl_dir    = $src_base/extra/yassl
taocrypt_dir = $yassl_dir/taocrypt

taocrypt_poptions = "-I$taocrypt_dir/include" "-I$taocrypt_dir/mySTL" \
                    -DHAVE_YASSL -DYASSL_PREFIX -DHAVE_OPENSSL        \
                    -DMULTI_THREADED

yassl_poptions = "-I$yassl_dir/include" $taocrypt_poptions

extra/yassl/
{
  taocrypt/ cc.poptions += $taocrypt_poptions

  cc.poptions += -Dget_tty_password=yassl_mysql_get_tty_password         \
                 -Dget_tty_password_ext=yassl_mysql_get_tty_password_ext \
                 $yassl_poptions
}

      vio/ cc.poptions += "-I$src_base" $yassl_poptions
mysys_ssl/ cc.poptions += "-I$src_base" $yassl_poptions $mysys_poptions

# The CLIENT_PROTOCOL_TRACING macro seems to be required for debugging only.
# However, the compilation falls apart if undefined, so we keep it.
#
sql_poptions = "-I$src_base/sql" "-I$src_base/libmysql"         \
               -DCLIENT_PROTOCOL_TRACING                        \
               $yassl_poptions $zlib_poptions $strings_poptions

if $windows
  sql_poptions += -DAUTHENTICATION_WIN

sql/        cc.poptions += $sql_poptions
sql-common/ cc.poptions += $sql_poptions
libmysql/   cc.poptions += $sql_poptions

# The upstream package always adds -DDEBUG_ERRROR_LOG -DWINAUTH_USE_DBUG_LIB.
# Looks like they are required for debugging only, so let's omit them.
#
if $windows
  libmysql/authentication_win/ cc.poptions += -DSECURITY_WIN32

if ($c.class == 'msvc')
{
  # Disable warnings that pop up with /W3.
  #
  cc.coptions += /wd4311 /wd4113 /wd4996 /wd4244 /wd4267 /wd4334 /wd4800 /wd4091
}
elif ($c.class == 'gcc')
{
  # We don't care about C++ ABI specification conformance, especially given
  # that only C functions are exported. So we omit -fabi-version=2.
  #
  cc.coptions += -fno-omit-frame-pointer -fno-strict-aliasing

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

if! $windows
{
  # On Linux the upstream package also passes the cmake-generated
  # libmysql.ver file. The symbols it contains are hard-coded into
  # libmysql/CMakeList.txt. We have dropped the file for now.
  #
  if $linux
    cc.loptions += -Wl,--no-undefined # Make sure all symbols are resolvable.

  cc.libs += ($tclass == 'bsd' ? -lexecinfo : -ldl) -lpthread -lm

  if $linux
    cc.libs += -lrt # Posix timers.
}
else
  cc.libs += advapi32.lib

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

# Let's install the bare minimum of headers: mysql.h, errmsg.h, mysqld_error.h
# and headers they recursively include.
#
h{*}:   install = false
hxx{*}: install = false

# @@ Fix once LHS pair generation is implemented.
#
for h: mysql errmsg mysqld_error mysql_time mysql_version mysql_com \
       my_list my_alloc my_command binary_log_types typelib         \
       mysql/client_plugin mysql/plugin_auth_common                 \
       mysql/psi/psi_base mysql/psi/psi_memory
{
  d = $path.directory($h)

  h{$h}@./$d: install = include/mysql/$d
  h{$h}@./$d: install.subdirs = true
}

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