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

Contents of /eclass/mysql-cmake.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.28 - (show annotations) (download)
Tue Jul 28 01:58:13 2015 UTC (14 months ago) by grknight
Branch: MAIN
CVS Tags: HEAD
Changes since 1.27: +40 -29 lines
Add support for the split client/server options to the mysql eclasses

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

  ViewVC Help
Powered by ViewVC 1.1.20