# MariaDB - a database server that offers drop-in replacement functionality for MySQL.
# http://mariadb.org/

[buildout]
extends =
  ../cmake/buildout.cfg
  ../groonga/buildout.cfg
  ../jemalloc/buildout.cfg
  ../libaio/buildout.cfg
  ../libxml2/buildout.cfg
  ../ncurses/buildout.cfg
  ../openssl/buildout.cfg
  ../patch/buildout.cfg
  ../pcre/buildout.cfg
  ../pkgconfig/buildout.cfg
  ../readline/buildout.cfg
  ../xz-utils/buildout.cfg
  ../zlib/buildout.cfg

parts =
  mariadb

[mariadb]
recipe = slapos.recipe.cmmi
version = 10.1.17
url = https://downloads.mariadb.org/f/mariadb-${:version}/source/mariadb-${:version}.tar.gz/from/http:/ftp.osuosl.org/pub/mariadb/?serve
md5sum = 036aca95257cb2948dd100605ec6d5a1
location = ${buildout:parts-directory}/${:_buildout_section_name_}
patch-options = -p0
patches =
  ${:_profile_base_location_}/mariadb_10.1.8_create_system_tables__no_test.patch#d2f337e76b290071daf8985a79bda82a
configure-command = ${cmake:location}/bin/cmake
configure-options =
  -DCMAKE_INSTALL_PREFIX=${:location}
  -DBUILD_CONFIG=mysql_release
  -DDEFAULT_CHARSET=utf8
  -DDEFAULT_COLLATION=utf8_unicode_ci
  -DWITH_SSL=system
  -DWITH_ZLIB=system
  -DWITH_READLINE=0
  -DWITH_PIC=1
  -DWITH_PCRE=system
  -DENABLE_DTRACE=0
  -DWITH_EXTRA_CHARSETS=complex
  -DWITH_EMBEDDED_SERVER=0
  -DWITH_JEMALLOC=yes
  -DWITH_INNODB_BZIP2=OFF
  -DWITH_INNODB_LZ4=OFF
  -DWITH_INNODB_LZMA=ON
  -DWITH_INNODB_LZO=OFF
  -DWITH_INNODB_SNAPPY=OFF
  -DWITH_SAFEMALLOC=OFF
  -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1
  -DWITHOUT_MROONGA_STORAGE_ENGINE=1
  -DWITHOUT_DAEMON_EXAMPLE=1
  -DCMAKE_C_FLAGS="-I${jemalloc:location}/include -I${libaio:location}/include -I${libxml2:location}/include -I${ncurses:location}/include -I${openssl:location}/include -I${pcre:location}/include -I${readline5:location}/include -I${xz-utils:location}/include -I${zlib:location}/include"
  -DCMAKE_CXX_FLAGS="-I${jemalloc:location}/include -I${libaio:location}/include -I${libxml2:location}/include -I${ncurses:location}/include -I${openssl:location}/include -I${pcre:location}/include -I${readline5:location}/include -I${xz-utils:location}/include -I${zlib:location}/include"
  -DCMAKE_INSTALL_RPATH=${jemalloc:location}/lib:${libaio:location}/lib:${libxml2:location}/lib:${ncurses:location}/lib:${openssl:location}/lib:${pcre:location}/lib:${readline5:location}/lib:${xz-utils:location}/lib:${zlib:location}/lib
environment =
  CMAKE_PROGRAM_PATH=${cmake:location}/bin
  CMAKE_INCLUDE_PATH=${libaio:location}/include:${libaio:location}/include:${libxml2:location}/include:${ncurses:location}/include:${openssl:location}/include:${pcre:location}/include:${readline5:location}/include:${xz-utils:location}/include:${zlib:location}/include
  CMAKE_LIBRARY_PATH=${libaio:location}/lib:{libaio:location}/lib:${libxml2:location}/lib:${ncurses:location}/lib:${openssl:location}/lib:${pcre:location}/lib:${readline5:location}/lib:${xz-utils:location}/lib:${zlib:location}/lib
  LDFLAGS=-L${jemalloc:location}/lib -Wl,-rpath=${jemalloc:location}/lib -L${libaio:location}/lib -Wl,-rpath=${libaio:location}/lib -L${pcre:location}/lib -L${xz-utils:location}/lib -L${zlib:location}/lib
  PATH=${patch:location}/bin:%(PATH)s
post-install =
  mkdir -p ${:location}/include/wsrep &&
  cp -p wsrep/wsrep_api.h ${:location}/include/wsrep

[mroonga-mariadb]
# mroonga - a storage engine for MySQL. It provides fast fulltext search feature to all MySQL users.
# http://mroonga.github.com/
recipe = slapos.recipe.cmmi
url = http://packages.groonga.org/source/mroonga/mroonga-6.08.tar.gz
md5sum = 10c13aa9f7e520d93799be893aa44d3c
pre-configure =
  mkdir fake_mariadb_source &&
  ln -s ${mariadb:location}/include/mysql/private fake_mariadb_source/sql
configure-options =
  --with-mysql-source=fake_mariadb_source
  --with-mysql-config=${mariadb:location}/bin/mysql_config
  --disable-static
  --disable-document
patch-options = -p1
patches =
  ${:_profile_base_location_}/mroonga_boolean.patch#29f85fc98e85d39b31e53b1e1683d288
environment =
  PATH=${groonga:location}/bin:${patch:location}/bin:${pkgconfig:location}/bin:%(PATH)s
  CPPFLAGS=-I${groonga:location}/include/groonga -I${pcre:location}/include
  LDFLAGS=-L${groonga:location}/lib
  PKG_CONFIG_PATH=${groonga:location}/lib/pkgconfig:${groonga-normalizer-mysql:location}/lib/pkgconfig
