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

Contents of /eclass/mysql-cmake.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.21 - (show annotations) (download)
Fri Jun 20 00:03:33 2014 UTC (3 weeks, 2 days ago) by grknight
Branch: MAIN
CVS Tags: HEAD
Changes since 1.20: +21 -9 lines
Sync eclasses with 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.20 2014/05/15 03:18:47 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"
80 else
81 echo "-DWITHOUT_$2=1 -DWITH_$2=0"
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 -DWITHOUT_INNOBASE_STORAGE_ENGINE=1
133 )
134 }
135
136 # @FUNCTION: configure_cmake_standard
137 # @DESCRIPTION:
138 # Helper function to configure standard build
139 configure_cmake_standard() {
140
141 mycmakeargs+=(
142 -DEXTRA_CHARSETS=all
143 -DMYSQL_USER=mysql
144 -DMYSQL_UNIX_ADDR=${EPREFIX}/var/run/mysqld/mysqld.sock
145 $(cmake-utils_use_disable !static SHARED)
146 $(cmake-utils_use_with debug)
147 $(cmake-utils_use_with embedded EMBEDDED_SERVER)
148 $(cmake-utils_use_with profiling)
149 $(cmake-utils_use_enable systemtap DTRACE)
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 mycmakeargs+=(
193 -DWITHOUT_CASSANDRA=1 -DWITH_CASSANDRA=0
194 $(mysql-cmake_use_plugin extraengine SEQUENCE)
195 $(mysql-cmake_use_plugin extraengine SPIDER)
196 $(mysql-cmake_use_plugin extraengine CONNECT)
197 -DCONNECT_WITH_MYSQL=1
198 $(cmake-utils_use xml CONNECT_WITH_LIBXML2)
199 $(cmake-utils_use odbc CONNECT_WITH_ODBC)
200 )
201 fi
202 fi
203
204 if [[ ${PN} == "percona-server" ]]; then
205 mycmakeargs+=(
206 $(cmake-utils_use_with pam)
207 )
208 fi
209
210 if [[ ${PN} == "mysql-cluster" ]]; then
211 # TODO: This really should include the following options,
212 # but the memcached package doesn't install the files it seeks.
213 # -DWITH_BUNDLED_MEMCACHED=OFF
214 # -DMEMCACHED_HOME=${EPREFIX}/usr
215 mycmakeargs+=(
216 -DWITH_BUNDLED_LIBEVENT=OFF
217 $(cmake-utils_use_with java NDB_JAVA)
218 )
219 fi
220 }
221
222 #
223 # EBUILD FUNCTIONS
224 #
225
226 # @FUNCTION: mysql-cmake_src_prepare
227 # @DESCRIPTION:
228 # Apply patches to the source code and remove unneeded bundled libs.
229 mysql-cmake_src_prepare() {
230
231 debug-print-function ${FUNCNAME} "$@"
232
233 cd "${S}"
234
235 if [[ ${MY_EXTRAS_VER} != none ]]; then
236
237 # Apply the patches for this MySQL version
238 EPATCH_SUFFIX="patch"
239 mkdir -p "${EPATCH_SOURCE}" || die "Unable to create epatch directory"
240 # Clean out old items
241 rm -f "${EPATCH_SOURCE}"/*
242 # Now link in right patches
243 mysql_mv_patches
244 # And apply
245 epatch
246 fi
247
248 # last -fPIC fixup, per bug #305873
249 i="${S}"/storage/innodb_plugin/plug.in
250 [[ -f ${i} ]] && sed -i -e '/CFLAGS/s,-prefer-non-pic,,g' "${i}"
251
252 rm -f "scripts/mysqlbug"
253 if use jemalloc && ! ( [[ ${PN} == "mariadb" ]] && mysql_version_is_at_least "5.5.33" ); then
254 echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die
255 fi
256
257 if use tcmalloc; then
258 echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt"
259 fi
260
261 if in_iuse tokudb ; then
262 # Don't build bundled xz-utils
263 rm -f "${S}/storage/tokudb/ft-index/cmake_modules/TokuThirdParty.cmake"
264 touch "${S}/storage/tokudb/ft-index/cmake_modules/TokuThirdParty.cmake"
265 fi
266
267 epatch_user
268 }
269
270 # @FUNCTION: mysql-cmake_src_configure
271 # @DESCRIPTION:
272 # Configure mysql to build the code for Gentoo respecting the use flags.
273 mysql-cmake_src_configure() {
274
275 debug-print-function ${FUNCNAME} "$@"
276
277 CMAKE_BUILD_TYPE="RelWithDebInfo"
278
279 # debug hack wrt #497532
280 mycmakeargs=(
281 -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug "" "-DNDEBUG")"
282 -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug "" "-DNDEBUG")"
283 -DCMAKE_INSTALL_PREFIX=${EPREFIX}/usr
284 -DMYSQL_DATADIR=${EPREFIX}/var/lib/mysql
285 -DSYSCONFDIR=${EPREFIX}/etc/mysql
286 -DINSTALL_BINDIR=bin
287 -DINSTALL_DOCDIR=share/doc/${P}
288 -DINSTALL_DOCREADMEDIR=share/doc/${P}
289 -DINSTALL_INCLUDEDIR=include/mysql
290 -DINSTALL_INFODIR=share/info
291 -DINSTALL_LIBDIR=$(get_libdir)
292 -DINSTALL_ELIBDIR=$(get_libdir)/mysql
293 -DINSTALL_MANDIR=share/man
294 -DINSTALL_MYSQLDATADIR=${EPREFIX}/var/lib/mysql
295 -DINSTALL_MYSQLSHAREDIR=share/mysql
296 -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test
297 -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
298 -DINSTALL_SBINDIR=sbin
299 -DINSTALL_SCRIPTDIR=share/mysql/scripts
300 -DINSTALL_SQLBENCHDIR=share/mysql
301 -DINSTALL_SUPPORTFILESDIR=${EPREFIX}/usr/share/mysql
302 -DWITH_COMMENT="Gentoo Linux ${PF}"
303 $(cmake-utils_use_with test UNIT_TESTS)
304 -DWITH_LIBEDIT=0
305 -DWITH_ZLIB=system
306 -DWITHOUT_LIBWRAP=1
307 -DENABLED_LOCAL_INFILE=1
308 $(cmake-utils_use_enable static-libs STATIC_LIBS)
309 -DWITH_SSL=$(usex ssl system bundled)
310 )
311
312 if [[ ${PN} == "mysql" || ${PN} == "percona-server" ]] && mysql_version_is_at_least "5.6.12" ; then
313 mycmakeargs+=( -DWITH_EDITLINE=system )
314 else
315 mycmakeargs+=(
316 -DWITH_READLINE=$(usex bindist 1 0)
317 -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1)
318 $(usex bindist -DHAVE_BFD_H=0 '')
319 )
320 fi
321
322 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
323 mycmakeargs+=(
324 -DWITH_JEMALLOC=$(usex jemalloc system)
325 )
326 mysql_version_is_at_least "10.0.9" && mycmakeargs+=( -DWITH_PCRE=system )
327 fi
328
329 configure_cmake_locale
330
331 if use minimal ; then
332 configure_cmake_minimal
333 else
334 configure_cmake_standard
335 fi
336
337 # Bug #114895, bug #110149
338 filter-flags "-O" "-O[01]"
339
340 CXXFLAGS="${CXXFLAGS} -fno-strict-aliasing"
341 CXXFLAGS="${CXXFLAGS} -felide-constructors"
342 # Causes linkage failures. Upstream bug #59607 removes it
343 if ! mysql_version_is_at_least "5.6" ; then
344 CXXFLAGS="${CXXFLAGS} -fno-implicit-templates"
345 fi
346 # As of 5.7, exceptions and rtti are used!
347 if ! mysql_version_is_at_least "5.7" ; then
348 CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-rtti"
349 fi
350 export CXXFLAGS
351
352 # bug #283926, with GCC4.4, this is required to get correct behavior.
353 append-flags -fno-strict-aliasing
354
355 cmake-utils_src_configure
356 }
357
358 # @FUNCTION: mysql-cmake_src_compile
359 # @DESCRIPTION:
360 # Compile the mysql code.
361 mysql-cmake_src_compile() {
362
363 debug-print-function ${FUNCNAME} "$@"
364
365 cmake-utils_src_compile
366 }
367
368 # @FUNCTION: mysql-cmake_src_install
369 # @DESCRIPTION:
370 # Install mysql.
371 mysql-cmake_src_install() {
372
373 debug-print-function ${FUNCNAME} "$@"
374
375 # Make sure the vars are correctly initialized
376 mysql_init_vars
377
378 cmake-utils_src_install
379
380 # Convenience links
381 einfo "Making Convenience links for mysqlcheck multi-call binary"
382 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlanalyze"
383 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair"
384 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize"
385
386 # Create a mariadb_config symlink
387 [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] && dosym "/usr/bin/mysql_config" "/usr/bin/mariadb_config"
388
389 # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
390 rm -Rf "${ED}/usr/data"
391
392 # Various junk (my-*.cnf moved elsewhere)
393 einfo "Removing duplicate /usr/share/mysql files"
394
395 # Unless they explicitly specific USE=test, then do not install the
396 # testsuite. It DOES have a use to be installed, esp. when you want to do a
397 # validation of your database configuration after tuning it.
398 if ! use test ; then
399 rm -rf "${D}"/${MY_SHAREDSTATEDIR}/mysql-test
400 fi
401
402 # Configuration stuff
403 case ${MYSQL_PV_MAJOR} in
404 5.[1-4]*) mysql_mycnf_version="5.1" ;;
405 5.[5-9]|6*|7*|8*|9*|10*) mysql_mycnf_version="5.5" ;;
406 esac
407 einfo "Building default my.cnf (${mysql_mycnf_version})"
408 insinto "${MY_SYSCONFDIR#${EPREFIX}}"
409 doins "${S}"/scripts/mysqlaccess.conf
410 mycnf_src="my.cnf-${mysql_mycnf_version}"
411 sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
412 "${FILESDIR}/${mycnf_src}" \
413 > "${TMPDIR}/my.cnf.ok" || die
414 if use latin1 ; then
415 sed -i \
416 -e "/character-set/s|utf8|latin1|g" \
417 "${TMPDIR}/my.cnf.ok" || die
418 fi
419 eprefixify "${TMPDIR}/my.cnf.ok"
420 newins "${TMPDIR}/my.cnf.ok" my.cnf
421
422 # Minimal builds don't have the MySQL server
423 if ! use minimal ; then
424 einfo "Creating initial directories"
425 # Empty directories ...
426 diropts "-m0750"
427 if [[ ${PREVIOUS_DATADIR} != "yes" ]] ; then
428 dodir "${MY_DATADIR#${EPREFIX}}"
429 keepdir "${MY_DATADIR#${EPREFIX}}"
430 chown -R mysql:mysql "${D}/${MY_DATADIR}"
431 fi
432
433 diropts "-m0755"
434 for folder in "${MY_LOGDIR#${EPREFIX}}" ; do
435 dodir "${folder}"
436 keepdir "${folder}"
437 chown -R mysql:mysql "${ED}/${folder}"
438 done
439 fi
440
441 # Minimal builds don't have the MySQL server
442 if ! use minimal ; then
443 einfo "Including support files and sample configurations"
444 docinto "support-files"
445 for script in \
446 "${S}"/support-files/my-*.cnf.sh \
447 "${S}"/support-files/magic \
448 "${S}"/support-files/ndb-config-2-node.ini.sh
449 do
450 [[ -f $script ]] && dodoc "${script}"
451 done
452
453 docinto "scripts"
454 for script in "${S}"/scripts/mysql* ; do
455 [[ ( -f $script ) && ( ${script%.sh} == ${script} ) ]] && dodoc "${script}"
456 done
457 fi
458
459 #Remove mytop if perl is not selected
460 [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] && ! use perl \
461 && rm -f "${ED}/usr/bin/mytop"
462
463 # Percona has decided to rename libmysqlclient to libperconaserverclient
464 # Use a symlink to preserve linkages for those who don't use mysql_config
465 if [[ ${PN} == "percona-server" ]] && mysql_version_is_at_least "5.5.36" ; then
466 dosym libperconaserverclient.so /usr/$(get_libdir)/libmysqlclient.so
467 dosym libperconaserverclient.so /usr/$(get_libdir)/libmysqlclient_r.so
468 if use static-libs ; then
469 dosym libperconaserverclient.a /usr/$(get_libdir)/libmysqlclient.a
470 dosym libperconaserverclient.a /usr/$(get_libdir)/libmysqlclient_r.a
471 fi
472 fi
473 }

  ViewVC Help
Powered by ViewVC 1.1.20