# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ # @ECLASS: mysql-cmake-multilib.eclass # @MAINTAINER: # Maintainers: # - MySQL Team # - Robin H. Johnson # - Jorge Manuel B. S. Vicetto # @BLURB: This eclass provides the support for cmake based mysql releases # @DESCRIPTION: # The mysql-cmake-multilib.eclass provides the support to build the mysql # ebuilds using the cmake build system. This eclass provides # the src_prepare, src_configure, src_compile and src_install # phase hooks. inherit flag-o-matic multilib prefix mysql-cmake cmake-multilib # # HELPER FUNCTIONS: # # @FUNCTION: mysql-cmake-multilib_disable_test # @DESCRIPTION: # Helper function to disable specific tests. mysql-cmake-multilib_disable_test() { debug-print-function ${FUNCTION} "$@" local BUILD_DIR="${BUILD_DIR:-${S}}" mysql-cmake_disable_test "$@" } # @FUNCTION: configure_cmake_minimal # @DESCRIPTION: # Helper function to configure minimal build configure_cmake_minimal() { debug-print-function ${FUNCNAME} "$@" mycmakeargs+=( -DWITHOUT_SERVER=1 -DWITHOUT_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DEXTRA_CHARSETS=none -DINSTALL_SQLBENCHDIR= -DWITH_SSL=system -DWITH_ZLIB=system -DWITHOUT_LIBWRAP=1 -DWITH_READLINE=0 -DWITH_LIBEDIT=0 -DWITHOUT_ARCHIVE_STORAGE_ENGINE=1 -DWITHOUT_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_CSV_STORAGE_ENGINE=1 -DWITHOUT_FEDERATED_STORAGE_ENGINE=1 -DWITHOUT_HEAP_STORAGE_ENGINE=1 -DWITHOUT_INNOBASE_STORAGE_ENGINE=1 -DWITHOUT_MYISAMMRG_STORAGE_ENGINE=1 -DWITHOUT_MYISAM_STORAGE_ENGINE=1 -DWITHOUT_PARTITION_STORAGE_ENGINE=1 -DWITHOUT_INNOBASE_STORAGE_ENGINE=1 -DWITH_UNIT_TESTS=0 ) } # @FUNCTION: configure_cmake_standard # @DESCRIPTION: # Helper function to configure standard build configure_cmake_standard() { debug-print-function ${FUNCNAME} "$@" mycmakeargs+=( -DENABLED_LOCAL_INFILE=1 -DEXTRA_CHARSETS=all -DMYSQL_USER=mysql -DWITH_READLINE=0 -DWITH_LIBEDIT=0 -DWITH_ZLIB=system -DWITHOUT_LIBWRAP=1 ) mycmakeargs+=( $(cmake-utils_use_disable !static SHARED) $(cmake-utils_use_with debug) $(cmake-utils_use_with embedded EMBEDDED_SERVER) $(cmake-utils_use_with profiling) $(cmake-utils_use_enable systemtap DTRACE) $(cmake-utils_use_with test UNIT_TESTS) ) if use static; then mycmakeargs+=( -DWITH_PIC=1 ) fi if use ssl; then mycmakeargs+=( -DWITH_SSL=system ) else mycmakeargs+=( -DWITH_SSL=bundled ) fi if use jemalloc; then mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) fi if use tcmalloc; then mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) fi # Storage engines mycmakeargs+=( -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_CSV_STORAGE_ENGINE=1 -DWITH_HEAP_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MYISAMMRG_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 $(cmake-utils_use_with extraengine FEDERATED_STORAGE_ENGINE) ) if pbxt_available ; then mycmakeargs+=( $(cmake-utils_use_with pbxt PBXT_STORAGE_ENGINE) ) fi if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]]; then mycmakeargs+=( $(mysql-cmake_use_plugin oqgraph OQGRAPH) $(mysql-cmake_use_plugin sphinx SPHINX) $(mysql-cmake_use_plugin extraengine FEDERATEDX) $(mysql-cmake_use_plugin tokudb TOKUDB) $(mysql-cmake_use_plugin pam AUTH_PAM) ) if use jemalloc ; then mycmakeargs+=( -DWITH_JEMALLOC="system" ) else mycmakeargs+=( -DWITH_JEMALLOC=no ) fi if mysql_version_is_at_least 10.0.5 ; then # CassandraSE needs Apache Thrift which is not in portage # TODO: Add use and deps for Connect SE external deps mycmakeargs+=( -DWITHOUT_CASSANDRA=1 -DWITH_CASSANDRA=0 $(mysql-cmake_use_plugin extraengine SEQUENCE) $(mysql-cmake_use_plugin extraengine SPIDER) $(mysql-cmake_use_plugin extraengine CONNECT) -DCONNECT_WITH_MYSQL=1 $(cmake-utils_use xml CONNECT_WITH_LIBXML2) $(cmake-utils_use odbc CONNECT_WITH_ODBC) ) fi fi if [[ ${PN} == "percona-server" ]]; then mycmakeargs+=( $(cmake-utils_use_with pam) ) fi if [[ ${PN} == "mysql-cluster" ]]; then # TODO: This really should include the following options, # but the memcached package doesn't install the files it seeks. # -DWITH_BUNDLED_MEMCACHED=OFF # -DMEMCACHED_HOME=${EPREFIX}/usr mycmakeargs+=( -DWITH_BUNDLED_LIBEVENT=OFF $(cmake-utils_use_with java NDB_JAVA) ) fi } # # EBUILD FUNCTIONS # # @FUNCTION: mysql-cmake-multilib_src_prepare # @DESCRIPTION: # Apply patches to the source code and remove unneeded bundled libs. mysql-cmake-multilib_src_prepare() { debug-print-function ${FUNCNAME} "$@" mysql-cmake_src_prepare "$@" } # @FUNCTION: mysql-cmake-multilib_src_configure # @DESCRIPTION: # Configure mysql to build the code for Gentoo respecting the use flags. mysql-cmake-multilib_src_configure() { debug-print-function ${FUNCNAME} "$@" CMAKE_BUILD_TYPE="RelWithDebInfo" mycmakeargs=( -DCMAKE_INSTALL_PREFIX=${EPREFIX}/usr -DMYSQL_DATADIR=${EPREFIX}/var/lib/mysql -DSYSCONFDIR=${EPREFIX}/etc/mysql -DINSTALL_BINDIR=bin -DINSTALL_DOCDIR=share/doc/${P} -DINSTALL_DOCREADMEDIR=share/doc/${P} -DINSTALL_INCLUDEDIR=include/mysql -DINSTALL_INFODIR=share/info -DINSTALL_LIBDIR=@GET_LIBDIR@/mysql -DINSTALL_MANDIR=share/man -DINSTALL_MYSQLDATADIR=${EPREFIX}/var/lib/mysql -DINSTALL_MYSQLSHAREDIR=share/mysql -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test -DINSTALL_PLUGINDIR=@GET_LIBDIR@/mysql/plugin -DINSTALL_SBINDIR=sbin -DINSTALL_SCRIPTDIR=share/mysql/scripts -DINSTALL_SQLBENCHDIR=share/mysql -DINSTALL_SUPPORTFILESDIR=${EPREFIX}/usr/share/mysql -DMYSQL_UNIX_ADDR=${EPREFIX}/var/run/mysqld/mysqld.sock -DWITH_COMMENT="Gentoo Linux ${PF}" ) # Bug 412851 # MariaDB requires this flag to compile with GPLv3 readline linked # Adds a warning about redistribution to configure if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then mycmakeargs+=( -DNOT_FOR_DISTRIBUTION=1 ) fi configure_cmake_locale # Bug #114895, bug #110149 filter-flags "-O" "-O[01]" CXXFLAGS="${CXXFLAGS} -fno-strict-aliasing" CXXFLAGS="${CXXFLAGS} -felide-constructors -fno-rtti" # Causes linkage failures. Upstream bug #59607 removes it if ! mysql_version_is_at_least "5.6" ; then CXXFLAGS="${CXXFLAGS} -fno-implicit-templates" fi # As of 5.7, exceptions are used! if ! mysql_version_is_at_least "5.7" ; then CXXFLAGS="${CXXFLAGS} -fno-exceptions" fi export CXXFLAGS # bug #283926, with GCC4.4, this is required to get correct behavior. append-flags -fno-strict-aliasing ehook cmake-multilib-pre_src_configure mysql_cmake_abi_pre_configure cmake-multilib_src_configure } mysql_cmake_abi_pre_configure() { debug-print-function ${FUNCNAME} "$@" if multilib_is_best_abi && use '!minimal' ; then configure_cmake_standard else configure_cmake_minimal fi } # @FUNCTION: mysql-cmake-multilib_src_compile # @DESCRIPTION: # Compile the mysql code. mysql-cmake-multilib_src_compile() { debug-print-function ${FUNCNAME} "$@" cmake-multilib_src_compile } # @FUNCTION: mysql-cmake-multilib_src_install # @DESCRIPTION: # Install mysql. mysql-cmake-multilib_src_install() { debug-print-function ${FUNCNAME} "$@" # Make sure the vars are correctly initialized ehook cmake-multilib-pre_src_install mysql_init_vars ehook cmake-multilib-post_src_install _mysql-cmake-post-src_install_perabi cmake-multilib_src_install # Convenience links einfo "Making Convenience links for mysqlcheck multi-call binary" dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlanalyze" dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair" dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize" # Create a mariadb_config symlink [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] && dosym "/usr/bin/mysql_config" "/usr/bin/mariadb_config" # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir rm -Rf "${ED}usr/data" # Various junk (my-*.cnf moved elsewhere) einfo "Removing duplicate /usr/share/mysql files" # Clean up stuff for a minimal build # if use minimal ; then # einfo "Remove all extra content for minimal build" # rm -Rf "${D}${MY_SHAREDSTATEDIR}"/{mysql-test,sql-bench} # rm -f "${ED}"/usr/bin/{mysql{_install_db,manager*,_secure_installation,_fix_privilege_tables,hotcopy,_convert_table_format,d_multi,_fix_extensions,_zap,_explain_log,_tableinfo,d_safe,_install,_waitpid,binlog,test},myisam*,isam*,pack_isam} # rm -f "${ED}/usr/sbin/mysqld" # rm -f "${D}${MY_LIBDIR}"/lib{heap,merge,nisam,my{sys,strings,sqld,isammrg,isam},vio,dbug}.a # fi # Unless they explicitly specific USE=test, then do not install the # testsuite. It DOES have a use to be installed, esp. when you want to do a # validation of your database configuration after tuning it. if ! use test ; then rm -rf "${D}"/${MY_SHAREDSTATEDIR}/mysql-test fi # Configuration stuff case ${MYSQL_PV_MAJOR} in 5.[1-4]*) mysql_mycnf_version="5.1" ;; 5.[5-9]|6*|7*|8*|9*|10*) mysql_mycnf_version="5.5" ;; esac einfo "Building default my.cnf (${mysql_mycnf_version})" insinto "${MY_SYSCONFDIR#${EPREFIX}}" doins scripts/mysqlaccess.conf mycnf_src="my.cnf-${mysql_mycnf_version}" sed -e "s!@DATADIR@!${MY_DATADIR}!g" \ "${FILESDIR}/${mycnf_src}" \ > "${TMPDIR}/my.cnf.ok" if use latin1 ; then sed -i \ -e "/character-set/s|utf8|latin1|g" \ "${TMPDIR}/my.cnf.ok" fi eprefixify "${TMPDIR}/my.cnf.ok" newins "${TMPDIR}/my.cnf.ok" my.cnf #Remove mytop if perl is not selected [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] && ! use perl \ && rm -f "${ED}/usr/bin/mytop" } _mysql-cmake-post-src_install_perabi() { debug-print-function ${FUNCTION} "$@" # Minimal builds don't have the MySQL server if multilib_is_best_abi && use '!minimal' ; then einfo "Creating initial directories" # Empty directories ... diropts "-m0750" if [[ ${PREVIOUS_DATADIR} != "yes" ]] ; then dodir "${MY_DATADIR#${EPREFIX}}" keepdir "${MY_DATADIR#${EPREFIX}}" chown -R mysql:mysql "${D}/${MY_DATADIR}" fi diropts "-m0755" for folder in "${MY_LOGDIR#${EPREFIX}}" ; do dodir "${folder}" keepdir "${folder}" chown -R mysql:mysql "${ED}/${folder}" done einfo "Including support files and sample configurations" docinto "support-files" for script in \ "${S}"/support-files/my-*.cnf.sh \ "${S}"/support-files/magic \ "${S}"/support-files/ndb-config-2-node.ini.sh do [[ -f $script ]] && dodoc "${script}" done docinto "scripts" for script in "${S}"/scripts/mysql* ; do [[ ( -f $script ) && ( ${script%.sh} == ${script} ) ]] && dodoc "${script}" done fi cat <<-EOF > "${T}"/80mysql-libdir$(multilib_is_best_abi || echo "-${ABI}") LDPATH="${EPREFIX}/usr/$(get_libdir)/mysql" EOF doenvd "${T}"/80mysql-libdir$(multilib_is_best_abi || echo "-${ABI}") }