aboutsummaryrefslogtreecommitdiff
path: root/mysql/buildfile
diff options
context:
space:
mode:
Diffstat (limited to 'mysql/buildfile')
-rw-r--r--mysql/buildfile259
1 files changed, 259 insertions, 0 deletions
diff --git a/mysql/buildfile b/mysql/buildfile
new file mode 100644
index 0000000..5759d68
--- /dev/null
+++ b/mysql/buildfile
@@ -0,0 +1,259 @@
+# 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 -DLIBICONV_PLUG
+# -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
+#
+# Also note that we add "-I$src_root" for the headers auto-generating machinery
+# to work properly.
+#
+mariadb_poptions = "-I$out_root" "-I$src_root" "-I$src_base" \
+ -DHAVE_SOCKET=1 -DHAVE_COMPRESS -DENABLED_LOCAL_INFILE \
+ -DLIBMARIADB -DTHREAD -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/obj{*}: c.poptions =+ $zlib_poptions
+ plugins/obj{*}: c.poptions =+ $mariadb_poptions
+libmariadb/obj{*}: c.poptions =+ $mariadb_poptions $zlib_poptions
+
+if ($tsys == 'win32-msvc')
+{
+ # Disable warnings that pop up with /W3.
+ #
+ c.coptions += /wd4996 /wd4267
+}
+else
+{
+ # Disable warnings that pop up with -W -Wall.
+ #
+ c.coptions += -Wno-shift-negative-value -Wno-unused-const-variable \
+ -Wno-unused-variable -Wno-unused-but-set-variable \
+ -Wno-unused-function -Wno-unused-value -Wno-unused-parameter \
+ -Wno-maybe-uninitialized -Wno-varargs -Wno-format-extra-args \
+ -Wno-implicit-fallthrough -Wno-sign-compare -Wno-address \
+ -Wno-pointer-sign -Wno-incompatible-pointer-types \
+ -Wno-format -Wno-unknown-warning-option
+}
+
+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 += ($tclass == 'linux' ? -lnsl : -liconv) -lpthread -lm
+
+ if ($tclass != 'bsd')
+ c.libs += -ldl
+}
+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/