# Copyright 1999-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: Exp $ # @ECLASS: mysql.cmake.eclass # @BLURB: This eclass provides the cmake configure functions for mysql ebuilds # @DESCRIPTION: # The mysql.cmake.eclass provides the code to configure the mysql ebuilds # including the src_prepare, src_configure, src_compile phase hooks. inherit cmake-utils mysql case "${EAPI:-0}" in 2) EXPORT_FUNCTIONS src_prepare src_compile src_configure IUSE_DEFAULT_ON='+' ;; 0 | 1) EXPORT_FUNCTIONS src_prepare src_compile ;; *) die "Unsupported EAPI: ${EAPI}" ;; esac if use debug ; then CMAKE_BUILD_TYPE="Debug" else CMAKE_BUILD_TYPE="RelWithDebInfo" fi # # HELPER FUNCTIONS: # configure_minimal_cmake() { # These are things we exclude from a minimal build, please # note that the server actually does get built and installed, # but we then delete it before packaging. mycmakeargs+=( -DWITH_EMBEDDED_SERVER=0 -DWITHOUT_INNOBASE_STORAGE_ENGINE=1 -DINSTALL_SQLBENCHDIR= -DWITH_READLINE=0 -DENABLED_LOCAL_INFILE=1 -DEXTRA_CHARSETS=none -DMYSQL_USER=mysql -DMYSQL_UNIX_ADDR=/var/run/mysqld/mysqld.sock -DWITH_LIBWRAP=0 -DWITHOUT_SERVER=1) if use static ; then mycmakeargs+=( -DDISABLE_SHARED=1 -DWITH_PIC=1) else mycmakeargs+=( -DDISABLED_SHARED=0) fi if mysql_version_is_at_least "4.1" && ! use latin1 ; then mycmakeargs+=( -DDEFAULT-CHARSET=utf8 -DDEFAULT-COLLATION=utf8_general_ci) else mycmakeargs+=( -DDEFAULT-CHARSET=latin1 -DDEFAULT-COLLATION=latin1_swedish_ci) fi } configure_common_cmake() { mycmakeargs+=( -DENABLED_LOCAL_INFILE=1 -DEXTRA_CHARSETS=all -DMYSQL_USER=mysql -DMYSQL_UNIX_ADDR=/var/run/mysqld/mysqld.sock -DWITH_LIBWRAP=0 -DWITHOUT_SERVER=0) if use static ; then mycmakeargs+=( -DDISABLE_SHARED=1 -DWITH_PIC=1) else mycmakeargs+=( -DDISABLED_SHARED=0) fi mycmakeargs+=( $(cmake-utils_use_with debug DEBUG) ) if mysql_version_is_at_least "4.1.3" \ && ( use cluster || [[ "${PN}" == "mysql-cluster" ]] ) \ ; then mycmakeargs+=( $(cmake-utils_use_with debug NDB-DEBUG)) fi if [ -n "${MYSQL_DEFAULT_CHARSET}" -a -n "${MYSQL_DEFAULT_COLLATION}" ]; then ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}" ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}." ewarn "You MUST file bugs without these variables set." mycmakeargs+=( -DDEFAULT-CHARSET="${MYSQL_DEFAULT_CHARSET}" -DDEFAULT-COLLATION="${MYSQL_DEFAULT_COLLATION}") elif mysql_version_is_at_least "4.1" && ! use latin1 ; then mycmakeargs+=( -DDEFAULT-CHARSET=utf8 -DDEFAULT-COLLATION=utf8_general_ci) else mycmakeargs+=( -DDEFAULT-CHARSET=latin1 -DDEFAULT-COLLATION=latin1_swedish_ci) fi mycmakeargs+=( $(cmake-utils_use_with embedded EMBEDDED_SERVER) $(cmake-utils_use_has embedded EMBEDDED_PRIVILEGE_CONTROL)) } configure_55() { # TODO: !!!! readd --without-readline # the failure depend upon config/ac-macros/readline.m4 checking into # readline.h instead of history.h if use ssl ; then mycmakeargs+=( -DWITH_SSL=system) else mycmakeargs+=( -DWITH_SSL=no) fi mycmakeargs+=( -DWITH-ZLIB=system -DWITH-READLINE=1 -DINSTALL_PLUGINDIR="${MY_LIBDIR}/plugin") # This is an explict die here, because if we just forcibly disable it, then the # user's data is not accessible. use max-idx-128 && die "MySQL 5.5 has removed support for increasing the size of MyISAM indexes." if [ "${MYSQL_COMMUNITY_FEATURES}" == "1" ]; then mycmakeargs+=( $(cmake-utils_use_enable profiling PROFILING)) fi # Scan for all available plugins local plugins_avail="$( LANG=C \ find "${S}" \ \( \ -name 'plug.in' \ -o -iname 'configure.in' \ -o -iname 'configure.ac' \ \) \ -print0 \ | xargs -0 sed -r -n \ -e '/^MYSQL_STORAGE_ENGINE/{ s~MYSQL_STORAGE_ENGINE\([[:space:]]*\[?([-_a-z0-9]+)\]?.*,~\1 ~g ; s~^([^ ]+).*~\1~gp; }' \ | tr -s '\n' ' ' )" # 5.1 introduces a new way to manage storage engines (plugins) # like configuration=none # This base set are required, and will always be statically built. local plugins_sta="" local plugins_dyn="" local plugins_dis="example daemon_example ftexample" # These aren't actually required by the base set, but are really useful: plugins_sta="${plugins_sta} archive blackhole" # default in 5.5.4 if mysql_version_is_at_least "5.5.4" ; then plugins_sta="${plugins_sta} partition" fi # Now the extras if use extraengine ; then # like configuration=max-no-ndb, archive and example removed in 5.1.11 # not added yet: ibmdb2i # Not supporting as examples: example,daemon_example,ftexample plugins_sta="${plugins_sta} partition" if [[ "${PN}" != "mariadb" ]] ; then elog "Before using the Federated storage engine, please be sure to read" elog "http://dev.mysql.com/doc/refman/5.5/en/federated-limitations.html" plugins_dyn="${plugins_sta} federated" else elog "MariaDB includes the FederatedX engine. Be sure to read" elog "http://askmonty.org/wiki/index.php/Manual:FederatedX_storage_engine" plugins_dyn="${plugins_sta} federatedx" fi else plugins_dis="${plugins_dis} partition federated" fi # Upstream specifically requests that InnoDB always be built: # - innobase, innodb_plugin # Build falcon if available for 6.x series. for i in innobase falcon ; do [ -e "${S}"/storage/${i} ] && plugins_sta="${plugins_sta} ${i}" done for i in innodb_plugin ; do [ -e "${S}"/storage/${i} ] && plugins_dyn="${plugins_dyn} ${i}" done # like configuration=max-no-ndb if ( use cluster || [[ "${PN}" == "mysql-cluster" ]] ) ; then plugins_sta="${plugins_sta} ndbcluster partition" plugins_dis="${plugins_dis//partition}" myconf="${myconf} --with-ndb-binlog" else plugins_dis="${plugins_dis} ndbcluster" fi if [[ "${PN}" == "mariadb" ]] ; then # In MariaDB, InnoDB is packaged in the xtradb directory, so it's not # caught above. # This is not optional, without it several upstream testcases fail. # Also strongly recommended by upstream. if [[ "${PV}" < "5.2.0" ]] ; then mycmakeargs+=( -DWITH_MARIA_TMP_TABLES) plugins_sta="${plugins_sta} maria" else mycmakeargs+=( -DWITH_ARIA_TMP_TABLES) plugins_sta="${plugins_sta} aria" fi [ -e "${S}"/storage/innobase ] || [ -e "${S}"/storage/xtradb ] || die "The ${P} package doesn't provide innobase nor xtradb" for i in innobase xtradb ; do [ -e "${S}"/storage/${i} ] && plugins_sta="${plugins_sta} ${i}" done mycmakeargs+=( $(cmake-utils_use_with libevent)) if mysql_version_is_at_least "5.2" ; then #This should include sphinx, but the 5.2.4 archive forgot the plug.in file #for i in oqgraph sphinx ; do for i in oqgraph ; do use ${i} \ && plugins_dyn="${plugins_dyn} ${i}" \ || plugins_dis="${plugins_dis} ${i}" done fi fi if pbxt_available && [[ "${PBXT_NEWSTYLE}" == "1" ]]; then use pbxt \ && plugins_dyn="${plugins_dyn} pbxt" \ || plugins_dis="${plugins_dis} pbxt" fi use static && \ plugins_sta="${plugins_sta} ${plugins_dyn}" && \ plugins_dyn="" einfo "Available plugins: ${plugins_avail}" einfo "Dynamic plugins: ${plugins_dyn}" einfo "Static plugins: ${plugins_sta}" einfo "Disabled plugins: ${plugins_dis}" local uper # These are the static plugins for i in ${plugins_sta} ; do uper=$(echo ${i} | tr '[:lower:]' '[:upper:]') mycmakeargs+=( -DWITH_${uper}=1) done # And the disabled ones for i in ${plugins_dis} ; do uper=$(echo ${i} | tr '[:lower:]' '[:upper:]') mycmakeargs+=( -DWITHOUT_${uper}=1) done } # @FUNCTION: mysql_src_configure # @DESCRIPTION: # Configure mysql to build the code for Gentoo respecting the use flags. mysql.cmake_src_configure() { # Make sure the vars are correctly initialized mysql_init_vars # $myconf is modified by the configure_* functions local mycmakeargs=( -DCMAKE_INSTALL_PREFIX=/usr -DINSTALL_SBINDIR=sbin -DSYSCONFDIR="${MY_SYSCONFDIR}" -DMYSQL_DATADIR="${MY_DATADIR}" -DINSTALL_MYSQLSHAREDIR="${MY_SHAREDSTATEDIR}" -DINSTALL_MYSQLDATADIR="${MY_LOCALSTATEDIR}" -DINSTALL_LIBDIR="${MY_LIBDIR}" -DINSTALL_MANDIR=share/man -DINSTALL_INFODIR=share/info -DINSTALL_DOCREADMEDIR="share/doc/${PF}" -DINSTALL_DOCDIR="share/doc/${PF}" -DINSTALL_SCRIPTDIR="share/doc/${PF}/scripts" -DINSTALL_SQLBENCHDIR="${MY_SHAREDSTATEDIR}" -DINSTALL_MYSQLTESTDIR="${MY_SHAREDSTATEDIR}"/mysql-test -DINSTALL_SUPPORTFILESDIR="${MY_SHAREDSTATEDIR}" -DWITH_COMMENT="Gentoo Linux ${PF}") if use minimal ; then configure_minimal_cmake else configure_common_cmake if mysql_version_is_at_least "5.5.0" ; then configure_55 fi fi # Bug #114895, bug #110149 filter-flags "-O" "-O[01]" # glib-2.3.2_pre fix, bug #16496 append-flags "-DHAVE_ERRNO_AS_DEFINE=1" # As discovered by bug #246652, doing a double-level of SSP causes NDB to # fail badly during cluster startup. if [[ $(gcc-major-version) -lt 4 ]]; then filter-flags "-fstack-protector-all" fi CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-strict-aliasing" CXXFLAGS="${CXXFLAGS} -felide-constructors -fno-rtti" mysql_version_is_at_least "5.0" \ && CXXFLAGS="${CXXFLAGS} -fno-implicit-templates" export CXXFLAGS # bug #283926, with GCC4.4, this is required to get correct behavior. append-flags -fno-strict-aliasing # bug #335185, #335995, with >= GCC4.3.3 on x86 only, omit-frame-pointer # causes a mis-compile. # Upstream bugs: # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38562 # http://bugs.mysql.com/bug.php?id=45205 use x86 && version_is_at_least "4.3.3" "$(gcc-fullversion)" && \ append-flags -fno-omit-frame-pointer && \ filter-flags -fomit-frame-pointer export CFLAGS cmake-utils_src_configure if [[ $EAPI == 2 ]] && [[ "${PBXT_NEWSTYLE}" != "1" ]]; then pbxt_patch_available && use pbxt && pbxt_src_configure fi } # @FUNCTION: mysql_src_compile # @DESCRIPTION: # Compile the mysql code. mysql.cmake_src_compile() { # Be backwards compatible for now case ${EAPI:-0} in 2) : ;; 0 | 1) mysql.cmake_src_configure ;; esac cmake-utils_src_compile if [[ "${PBXT_NEWSTYLE}" != "1" ]]; then pbxt_patch_available && use pbxt && pbxt_src_compile fi } # @FUNCTION: mysql_src_prepare # @DESCRIPTION: # Apply patches to the source code and remove unneeded bundled libs. mysql.cmake_src_prepare() { cd "${S}" # Apply the patches for this MySQL version EPATCH_SUFFIX="patch" mkdir -p "${EPATCH_SOURCE}" || die "Unable to create epatch directory" # Clean out old items rm -f "${EPATCH_SOURCE}"/* # Now link in right patches mysql_mv_patches # And apply epatch # last -fPIC fixup, per bug #305873 i="${S}"/storage/innodb_plugin/plug.in [ -f "${i}" ] && sed -i -e '/CFLAGS/s,-prefer-non-pic,,g' "${i}" # Additional checks, remove bundled zlib (Cluster needs this, for static # memory management in zlib, leave available for Cluster) if [[ "${PN}" != "mysql-cluster" ]] ; then rm -f "${S}/zlib/"*.[ch] sed -i -e "s/zlib\/Makefile dnl/dnl zlib\/Makefile/" "${S}/configure.in" fi rm -f "scripts/mysqlbug" if xtradb_patch_available && use xtradb ; then einfo "Adding storage engine: Percona XtraDB (replacing InnoDB)" pushd "${S}"/storage >/dev/null i="innobase" o="${WORKDIR}/storage-${i}.mysql-upstream" # Have we been here already? [ -d "${o}" ] && rm -f "${i}" # Or maybe we haven't [ -d "${i}" -a ! -d "${o}" ] && mv "${i}" "${o}" cp -ral "${WORKDIR}/${XTRADB_P}" "${i}" popd >/dev/null fi if pbxt_patch_available && [[ "${PBXT_NEWSTYLE}" == "1" ]] && use pbxt ; then einfo "Adding storage engine: PBXT" pushd "${S}"/storage >/dev/null i='pbxt' [ -d "${i}" ] && rm -rf "${i}" cp -ral "${WORKDIR}/${PBXT_P}" "${i}" popd >/dev/null sed --in-place -e 's!MYSQL_STORAGE_ENGINE(PBXT)!IF(MYSQL_VERSION_MINOR LESS 5) \ MYSQL_STORAGE_ENGINE(PBXT) \ ELSE() \ MYSQL_ADD_PLUGIN(pbxt \${PBXT_SOURCES} STORAGE_ENGINE DEFAULT MODULE_OUTPUT_NAME ha_pbxt) \ ENDIF()!' \ "${S}/storage/pbxt/CMakeLists.txt" fi # This should probably be a gentoo patch instead of a sed sed --in-place -e 's!DESTINATION data!DESTINATION ${MYSQL_DATADIR}!g' "${S}/sql/CMakeLists.txt" }