/[gentoo-x86]/eclass/mysql-cmake.eclass
Gentoo

Contents of /eclass/mysql-cmake.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.27 - (show annotations) (download)
Wed Jan 28 13:48:58 2015 UTC (5 months, 1 week ago) by grknight
Branch: MAIN
CVS Tags: HEAD
Changes since 1.26: +5 -1 lines
Sync changes from mysql overlay

1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/mysql-cmake.eclass,v 1.26 2014/11/26 00:34:41 grknight Exp $
4
5 # @ECLASS: mysql-cmake.eclass
6 # @MAINTAINER:
7 # Maintainers:
8 # - MySQL Team <mysql-bugs@gentoo.org>
9 # - Robin H. Johnson <robbat2@gentoo.org>
10 # - Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
11 # - Brian Evans <grknight@gentoo.org>
12 # @BLURB: This eclass provides the support for cmake based mysql releases
13 # @DESCRIPTION:
14 # The mysql-cmake.eclass provides the support to build the mysql
15 # ebuilds using the cmake build system. This eclass provides
16 # the src_prepare, src_configure, src_compile, and src_install
17 # phase hooks.
18
19 inherit cmake-utils flag-o-matic multilib prefix eutils
20
21 #
22 # HELPER FUNCTIONS:
23 #
24
25 # @FUNCTION: mysql_cmake_disable_test
26 # @DESCRIPTION:
27 # Helper function to disable specific tests.
28 mysql-cmake_disable_test() {
29
30 local rawtestname testname testsuite reason mysql_disabled_file mysql_disabled_dir
31 rawtestname="${1}" ; shift
32 reason="${@}"
33 ewarn "test '${rawtestname}' disabled: '${reason}'"
34
35 testsuite="${rawtestname/.*}"
36 testname="${rawtestname/*.}"
37 for mysql_disabled_file in \
38 ${S}/mysql-test/disabled.def \
39 ${S}/mysql-test/t/disabled.def ; do
40 [[ -f ${mysql_disabled_file} ]] && break
41 done
42 #mysql_disabled_file="${S}/mysql-test/t/disabled.def"
43 #einfo "rawtestname=${rawtestname} testname=${testname} testsuite=${testsuite}"
44 echo ${testname} : ${reason} >> "${mysql_disabled_file}"
45
46 if [[ ( -n ${testsuite} ) && ( ${testsuite} != "main" ) ]]; then
47 for mysql_disabled_file in \
48 ${S}/mysql-test/suite/${testsuite}/disabled.def \
49 ${S}/mysql-test/suite/${testsuite}/t/disabled.def \
50 FAILED ; do
51 [[ -f ${mysql_disabled_file} ]] && break
52 done
53 if [[ ${mysql_disabled_file} != "FAILED" ]]; then
54 echo "${testname} : ${reason}" >> "${mysql_disabled_file}"
55 else
56 for mysql_disabled_dir in \
57 ${S}/mysql-test/suite/${testsuite} \
58 ${S}/mysql-test/suite/${testsuite}/t \
59 FAILED ; do
60 [[ -d ${mysql_disabled_dir} ]] && break
61 done
62 if [[ ${mysql_disabled_dir} != "FAILED" ]]; then
63 echo "${testname} : ${reason}" >> "${mysql_disabled_dir}/disabled.def"
64 else
65 ewarn "Could not find testsuite disabled.def location for ${rawtestname}"
66 fi
67 fi
68 fi
69 }
70
71 # @FUNCTION: mysql-cmake_use_plugin
72 # @DESCRIPTION:
73 # Helper function to enable/disable plugins by use flags
74 # cmake-utils_use_with is not enough as some references check WITH_ (0|1)
75 # and some check WITHOUT_. Also, this can easily extend to non-storage plugins.
76 mysql-cmake_use_plugin() {
77 [[ -z $2 ]] && die "mysql-cmake_use_plugin <USE flag> <flag name>"
78 if use_if_iuse $1 ; then
79 echo "-DWITH_$2=1 -DPLUGIN_$2=YES"
80 else
81 echo "-DWITHOUT_$2=1 -DWITH_$2=0 -DPLUGIN_$2=NO"
82 fi
83 }
84
85 # @FUNCTION: configure_cmake_locale
86 # @DESCRIPTION:
87 # Helper function to configure locale cmake options
88 configure_cmake_locale() {
89
90 if ! use minimal && [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then
91 ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
92 ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
93 ewarn "You MUST file bugs without these variables set."
94
95 mycmakeargs+=(
96 -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
97 -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
98 )
99
100 elif ! use latin1 ; then
101 mycmakeargs+=(
102 -DDEFAULT_CHARSET=utf8
103 -DDEFAULT_COLLATION=utf8_general_ci
104 )
105 else
106 mycmakeargs+=(
107 -DDEFAULT_CHARSET=latin1
108 -DDEFAULT_COLLATION=latin1_swedish_ci
109 )
110 fi
111 }
112
113 # @FUNCTION: configure_cmake_minimal
114 # @DESCRIPTION:
115 # Helper function to configure minimal build
116 configure_cmake_minimal() {
117
118 mycmakeargs+=(
119 -DWITHOUT_SERVER=1
120 -DWITHOUT_EMBEDDED_SERVER=1
121 -DEXTRA_CHARSETS=none
122 -DINSTALL_SQLBENCHDIR=
123 -DWITHOUT_ARCHIVE_STORAGE_ENGINE=1
124 -DWITHOUT_BLACKHOLE_STORAGE_ENGINE=1
125 -DWITHOUT_CSV_STORAGE_ENGINE=1
126 -DWITHOUT_FEDERATED_STORAGE_ENGINE=1
127 -DWITHOUT_HEAP_STORAGE_ENGINE=1
128 -DWITHOUT_INNOBASE_STORAGE_ENGINE=1
129 -DWITHOUT_MYISAMMRG_STORAGE_ENGINE=1
130 -DWITHOUT_MYISAM_STORAGE_ENGINE=1
131 -DWITHOUT_PARTITION_STORAGE_ENGINE=1
132 -DPLUGIN_ARCHIVE=NO
133 -DPLUGIN_BLACKHOLE=NO
134 -DPLUGIN_CSV=NO
135 -DPLUGIN_FEDERATED=NO
136 -DPLUGIN_HEAP=NO
137 -DPLUGIN_INNOBASE=NO
138 -DPLUGIN_MYISAMMRG=NO
139 -DPLUGIN_MYISAM=NO
140 -DPLUGIN_PARTITION=NO
141 )
142 }
143
144 # @FUNCTION: configure_cmake_standard
145 # @DESCRIPTION:
146 # Helper function to configure standard build
147 configure_cmake_standard() {
148
149 mycmakeargs+=(
150 -DEXTRA_CHARSETS=all
151 -DMYSQL_USER=mysql
152 -DMYSQL_UNIX_ADDR=${EPREFIX}/var/run/mysqld/mysqld.sock
153 $(cmake-utils_use_disable !static SHARED)
154 $(cmake-utils_use_with debug)
155 $(cmake-utils_use_with embedded EMBEDDED_SERVER)
156 $(cmake-utils_use_with profiling)
157 $(cmake-utils_use_enable systemtap DTRACE)
158 )
159
160 if use static; then
161 mycmakeargs+=( -DWITH_PIC=1 )
162 fi
163
164 if use jemalloc; then
165 mycmakeargs+=( -DWITH_SAFEMALLOC=OFF )
166 fi
167
168 if use tcmalloc; then
169 mycmakeargs+=( -DWITH_SAFEMALLOC=OFF )
170 fi
171
172 # Storage engines
173 mycmakeargs+=(
174 -DWITH_ARCHIVE_STORAGE_ENGINE=1
175 -DWITH_BLACKHOLE_STORAGE_ENGINE=1
176 -DWITH_CSV_STORAGE_ENGINE=1
177 -DWITH_HEAP_STORAGE_ENGINE=1
178 -DWITH_INNOBASE_STORAGE_ENGINE=1
179 -DWITH_MYISAMMRG_STORAGE_ENGINE=1
180 -DWITH_MYISAM_STORAGE_ENGINE=1
181 -DWITH_PARTITION_STORAGE_ENGINE=1
182 )
183
184 if in_iuse pbxt ; then
185 mycmakeargs+=( $(cmake-utils_use_with pbxt PBXT_STORAGE_ENGINE) )
186 fi
187
188 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]]; then
189
190 # Federated{,X} must be treated special otherwise they will not be built as plugins
191 if ! use extraengine ; then
192 mycmakeargs+=(
193 -DWITHOUT_FEDERATED_STORAGE_ENGINE=1
194 -DPLUGIN_FEDERATED=0
195 -DWITHOUT_FEDERATEDX_STORAGE_ENGINE=1
196 -DPLUGIN_FEDERATEDX=0 )
197 fi
198
199 mycmakeargs+=(
200 $(mysql-cmake_use_plugin oqgraph OQGRAPH)
201 $(mysql-cmake_use_plugin sphinx SPHINX)
202 $(mysql-cmake_use_plugin tokudb TOKUDB)
203 $(mysql-cmake_use_plugin pam AUTH_PAM)
204 )
205
206 if mysql_version_is_at_least 10.0.5 ; then
207 # CassandraSE needs Apache Thrift which is not in portage
208 mycmakeargs+=(
209 -DWITHOUT_CASSANDRA=1 -DWITH_CASSANDRA=0
210 -DPLUGIN_CASSANDRA=NO
211 $(mysql-cmake_use_plugin extraengine SEQUENCE)
212 $(mysql-cmake_use_plugin extraengine SPIDER)
213 $(mysql-cmake_use_plugin extraengine CONNECT)
214 -DCONNECT_WITH_MYSQL=1
215 -DPLUGIN_CONNECT_WITH_MYSQL=YES
216 $(cmake-utils_use xml CONNECT_WITH_LIBXML2)
217 $(cmake-utils_use odbc CONNECT_WITH_ODBC)
218 )
219 fi
220
221 if in_iuse mroonga ; then
222 use mroonga || mycmakeargs+=( -DWITHOUT_MROONGA=1 )
223 else
224 mycmakeargs+=( -DWITHOUT_MROONGA=1 )
225 fi
226
227 if in_iuse galera ; then
228 mycmakeargs+=( $(cmake-utils_use_with galera WSREP) )
229 fi
230
231 if mysql_version_is_at_least "10.1.1" ; then
232 mycmakeargs+=( $(cmake-utils_use_with innodb-lz4 INNODB_LZ4)
233 $(cmake-utils_use_with innodb-lzo INNODB_LZO) )
234 fi
235
236 if mysql_version_is_at_least "10.1.2" ; then
237 mycmakeargs+=( $(mysql-cmake_use_plugin cracklib CRACKLIB_PASSWORD_CHECK ) )
238 fi
239 else
240 mycmakeargs+=( $(cmake-utils_use_with extraengine FEDERATED_STORAGE_ENGINE) )
241 fi
242
243 if [[ ${PN} == "percona-server" ]]; then
244 mycmakeargs+=(
245 $(cmake-utils_use_with pam)
246 )
247 fi
248
249 if [[ ${PN} == "mysql-cluster" ]]; then
250 # TODO: This really should include the following options,
251 # but the memcached package doesn't install the files it seeks.
252 # -DWITH_BUNDLED_MEMCACHED=OFF
253 # -DMEMCACHED_HOME=${EPREFIX}/usr
254 mycmakeargs+=(
255 -DWITH_BUNDLED_LIBEVENT=OFF
256 $(cmake-utils_use_with java NDB_JAVA)
257 )
258 fi
259 }
260
261 #
262 # EBUILD FUNCTIONS
263 #
264
265 # @FUNCTION: mysql-cmake_src_prepare
266 # @DESCRIPTION:
267 # Apply patches to the source code and remove unneeded bundled libs.
268 mysql-cmake_src_prepare() {
269
270 debug-print-function ${FUNCNAME} "$@"
271
272 cd "${S}"
273
274 if [[ ${MY_EXTRAS_VER} != none ]]; then
275
276 # Apply the patches for this MySQL version
277 EPATCH_SUFFIX="patch"
278 mkdir -p "${EPATCH_SOURCE}" || die "Unable to create epatch directory"
279 # Clean out old items
280 rm -f "${EPATCH_SOURCE}"/*
281 # Now link in right patches
282 mysql_mv_patches
283 # And apply
284 epatch
285 fi
286
287 # last -fPIC fixup, per bug #305873
288 i="${S}"/storage/innodb_plugin/plug.in
289 [[ -f ${i} ]] && sed -i -e '/CFLAGS/s,-prefer-non-pic,,g' "${i}"
290
291 rm -f "scripts/mysqlbug"
292 if use jemalloc && ! ( [[ ${PN} == "mariadb" ]] && mysql_version_is_at_least "5.5.33" ); then
293 echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die
294 fi
295
296 if use tcmalloc; then
297 echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt"
298 fi
299
300 if in_iuse tokudb ; then
301 # Don't build bundled xz-utils
302 rm -f "${S}/storage/tokudb/ft-index/cmake_modules/TokuThirdParty.cmake"
303 touch "${S}/storage/tokudb/ft-index/cmake_modules/TokuThirdParty.cmake"
304 sed -i 's/ build_lzma//' "${S}/storage/tokudb/ft-index/ft/CMakeLists.txt" || die
305 fi
306
307 # Remove the bundled groonga if it exists
308 # There is no CMake flag, it simply checks for existance
309 if [[ -d "${S}"/storage/mroonga/vendor/groonga ]] ; then
310 rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga"
311 fi
312
313 epatch_user
314 }
315
316 # @FUNCTION: mysql-cmake_src_configure
317 # @DESCRIPTION:
318 # Configure mysql to build the code for Gentoo respecting the use flags.
319 mysql-cmake_src_configure() {
320
321 debug-print-function ${FUNCNAME} "$@"
322
323 CMAKE_BUILD_TYPE="RelWithDebInfo"
324
325 # debug hack wrt #497532
326 mycmakeargs=(
327 -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug "" "-DNDEBUG")"
328 -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug "" "-DNDEBUG")"
329 -DCMAKE_INSTALL_PREFIX=${EPREFIX}/usr
330 -DMYSQL_DATADIR=${EPREFIX}/var/lib/mysql
331 -DSYSCONFDIR=${EPREFIX}/etc/mysql
332 -DINSTALL_BINDIR=bin
333 -DINSTALL_DOCDIR=share/doc/${P}
334 -DINSTALL_DOCREADMEDIR=share/doc/${P}
335 -DINSTALL_INCLUDEDIR=include/mysql
336 -DINSTALL_INFODIR=share/info
337 -DINSTALL_LIBDIR=$(get_libdir)
338 -DINSTALL_ELIBDIR=$(get_libdir)/mysql
339 -DINSTALL_MANDIR=share/man
340 -DINSTALL_MYSQLDATADIR=${EPREFIX}/var/lib/mysql
341 -DINSTALL_MYSQLSHAREDIR=share/mysql
342 -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test
343 -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
344 -DINSTALL_SBINDIR=sbin
345 -DINSTALL_SCRIPTDIR=share/mysql/scripts
346 -DINSTALL_SQLBENCHDIR=share/mysql
347 -DINSTALL_SUPPORTFILESDIR=${EPREFIX}/usr/share/mysql
348 -DWITH_COMMENT="Gentoo Linux ${PF}"
349 $(cmake-utils_use_with test UNIT_TESTS)
350 -DWITH_LIBEDIT=0
351 -DWITH_ZLIB=system
352 -DWITHOUT_LIBWRAP=1
353 -DENABLED_LOCAL_INFILE=1
354 $(cmake-utils_use_enable static-libs STATIC_LIBS)
355 -DWITH_SSL=$(usex ssl system bundled)
356 -DWITH_DEFAULT_COMPILER_OPTIONS=0
357 -DWITH_DEFAULT_FEATURE_SET=0
358 )
359
360 if in_iuse bindist ; then
361 mycmakeargs+=(
362 -DWITH_READLINE=$(usex bindist 1 0)
363 -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1)
364 $(usex bindist -DHAVE_BFD_H=0 '')
365 )
366 fi
367
368 mycmakeargs+=( -DWITH_EDITLINE=system )
369
370 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
371 mycmakeargs+=(
372 -DWITH_JEMALLOC=$(usex jemalloc system)
373 )
374 mysql_version_is_at_least "10.0.9" && mycmakeargs+=( -DWITH_PCRE=system )
375 fi
376
377 configure_cmake_locale
378
379 if use minimal ; then
380 configure_cmake_minimal
381 else
382 configure_cmake_standard
383 fi
384
385 # Bug #114895, bug #110149
386 filter-flags "-O" "-O[01]"
387
388 CXXFLAGS="${CXXFLAGS} -fno-strict-aliasing"
389 CXXFLAGS="${CXXFLAGS} -felide-constructors"
390 # Causes linkage failures. Upstream bug #59607 removes it
391 if ! mysql_version_is_at_least "5.6" ; then
392 CXXFLAGS="${CXXFLAGS} -fno-implicit-templates"
393 fi
394 # As of 5.7, exceptions and rtti are used!
395 if ! mysql_version_is_at_least "5.7" ; then
396 CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-rtti"
397 fi
398 export CXXFLAGS
399
400 # bug #283926, with GCC4.4, this is required to get correct behavior.
401 append-flags -fno-strict-aliasing
402
403 cmake-utils_src_configure
404 }
405
406 # @FUNCTION: mysql-cmake_src_compile
407 # @DESCRIPTION:
408 # Compile the mysql code.
409 mysql-cmake_src_compile() {
410
411 debug-print-function ${FUNCNAME} "$@"
412
413 cmake-utils_src_compile
414 }
415
416 # @FUNCTION: mysql-cmake_src_install
417 # @DESCRIPTION:
418 # Install mysql.
419 mysql-cmake_src_install() {
420
421 debug-print-function ${FUNCNAME} "$@"
422
423 # Make sure the vars are correctly initialized
424 mysql_init_vars
425
426 cmake-utils_src_install
427
428 # Convenience links
429 einfo "Making Convenience links for mysqlcheck multi-call binary"
430 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlanalyze"
431 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair"
432 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize"
433
434 # Create a mariadb_config symlink
435 [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] && dosym "/usr/bin/mysql_config" "/usr/bin/mariadb_config"
436
437 # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
438 rm -Rf "${ED}/usr/data"
439
440 # Various junk (my-*.cnf moved elsewhere)
441 einfo "Removing duplicate /usr/share/mysql files"
442
443 # Unless they explicitly specific USE=test, then do not install the
444 # testsuite. It DOES have a use to be installed, esp. when you want to do a
445 # validation of your database configuration after tuning it.
446 if ! use test ; then
447 rm -rf "${D}"/${MY_SHAREDSTATEDIR}/mysql-test
448 fi
449
450 # Configuration stuff
451 case ${MYSQL_PV_MAJOR} in
452 5.[1-4]*) mysql_mycnf_version="5.1" ;;
453 5.5) mysql_mycnf_version="5.5" ;;
454 5.[6-9]|6*|7*|8*|9*|10*) mysql_mycnf_version="5.6" ;;
455 esac
456 einfo "Building default my.cnf (${mysql_mycnf_version})"
457 insinto "${MY_SYSCONFDIR#${EPREFIX}}"
458 [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf
459 mycnf_src="my.cnf-${mysql_mycnf_version}"
460 sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
461 "${FILESDIR}/${mycnf_src}" \
462 > "${TMPDIR}/my.cnf.ok" || die
463 use prefix && sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' "${TMPDIR}/my.cnf.ok"
464 if use latin1 ; then
465 sed -i \
466 -e "/character-set/s|utf8|latin1|g" \
467 "${TMPDIR}/my.cnf.ok" || die
468 fi
469 eprefixify "${TMPDIR}/my.cnf.ok"
470 newins "${TMPDIR}/my.cnf.ok" my.cnf
471
472 # Minimal builds don't have the MySQL server
473 if ! use minimal ; then
474 einfo "Creating initial directories"
475 # Empty directories ...
476 diropts "-m0750"
477 if [[ ${PREVIOUS_DATADIR} != "yes" ]] ; then
478 dodir "${MY_DATADIR#${EPREFIX}}"
479 keepdir "${MY_DATADIR#${EPREFIX}}"
480 chown -R mysql:mysql "${D}/${MY_DATADIR}"
481 fi
482
483 diropts "-m0755"
484 for folder in "${MY_LOGDIR#${EPREFIX}}" ; do
485 dodir "${folder}"
486 keepdir "${folder}"
487 chown -R mysql:mysql "${ED}/${folder}"
488 done
489 fi
490
491 # Minimal builds don't have the MySQL server
492 if ! use minimal ; then
493 einfo "Including support files and sample configurations"
494 docinto "support-files"
495 for script in \
496 "${S}"/support-files/my-*.cnf.sh \
497 "${S}"/support-files/magic \
498 "${S}"/support-files/ndb-config-2-node.ini.sh
499 do
500 [[ -f $script ]] && dodoc "${script}"
501 done
502
503 docinto "scripts"
504 for script in "${S}"/scripts/mysql* ; do
505 [[ ( -f $script ) && ( ${script%.sh} == ${script} ) ]] && dodoc "${script}"
506 done
507 fi
508
509 #Remove mytop if perl is not selected
510 [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] && ! use perl \
511 && rm -f "${ED}/usr/bin/mytop"
512
513 # Percona has decided to rename libmysqlclient to libperconaserverclient
514 # Use a symlink to preserve linkages for those who don't use mysql_config
515 if [[ ${PN} == "percona-server" ]] && mysql_version_is_at_least "5.5.36" ; then
516 dosym libperconaserverclient.so /usr/$(get_libdir)/libmysqlclient.so
517 dosym libperconaserverclient.so /usr/$(get_libdir)/libmysqlclient_r.so
518 if use static-libs ; then
519 dosym libperconaserverclient.a /usr/$(get_libdir)/libmysqlclient.a
520 dosym libperconaserverclient.a /usr/$(get_libdir)/libmysqlclient_r.a
521 fi
522 fi
523 }

  ViewVC Help
Powered by ViewVC 1.1.20