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

Contents of /eclass/mysql-cmake.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.19 - (show annotations) (download)
Tue Apr 22 02:00:28 2014 UTC (8 months ago) by jmbsvicetto
Branch: MAIN
Changes since 1.18: +119 -69 lines
Sync mysql-v2 and mysql-cmake eclasses from the mysql overlay.

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

  ViewVC Help
Powered by ViewVC 1.1.20