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

Contents of /eclass/mysql-cmake.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (show annotations) (download)
Thu Nov 1 23:57:50 2012 UTC (20 months, 1 week ago) by robbat2
Branch: MAIN
Changes since 1.9: +51 -9 lines
Bring in MySQL overlay eclass changes for tcmalloc, jemalloc, systemtap, readline gplv3 and pbxt static build.

1 # Copyright 1999-2012 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.7 2012/01/09 10:42:19 grobian 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 # @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_unpack, src_prepare, src_configure, src_compile, scr_install,
16 # pkg_preinst, pkg_postinst, pkg_config and pkg_postrm phase hooks.
17
18 inherit cmake-utils flag-o-matic multilib
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: configure_cmake_locale
71 # @DESCRIPTION:
72 # Helper function to configure locale cmake options
73 configure_cmake_locale() {
74
75 if ! use minimal && [ -n "${MYSQL_DEFAULT_CHARSET}" -a -n "${MYSQL_DEFAULT_COLLATION}" ]; then
76 ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
77 ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
78 ewarn "You MUST file bugs without these variables set."
79
80 mycmakeargs+=(
81 -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
82 -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
83 )
84
85 elif ! use latin1 ; then
86 mycmakeargs+=(
87 -DDEFAULT_CHARSET=utf8
88 -DDEFAULT_COLLATION=utf8_general_ci
89 )
90 else
91 mycmakeargs+=(
92 -DDEFAULT_CHARSET=latin1
93 -DDEFAULT_COLLATION=latin1_swedish_ci
94 )
95 fi
96 }
97
98 # @FUNCTION: configure_cmake_minimal
99 # @DESCRIPTION:
100 # Helper function to configure minimal build
101 configure_cmake_minimal() {
102
103 mycmakeargs+=(
104 -DWITHOUT_SERVER=1
105 -DWITHOUT_EMBEDDED_SERVER=1
106 -DENABLED_LOCAL_INFILE=1
107 -DEXTRA_CHARSETS=none
108 -DINSTALL_SQLBENCHDIR=
109 -DWITH_SSL=system
110 -DWITH_ZLIB=system
111 -DWITHOUT_LIBWRAP=1
112 -DWITHOUT_READLINE=1
113 -DWITHOUT_ARCHIVE_STORAGE_ENGINE=1
114 -DWITHOUT_BLACKHOLE_STORAGE_ENGINE=1
115 -DWITHOUT_CSV_STORAGE_ENGINE=1
116 -DWITHOUT_FEDERATED_STORAGE_ENGINE=1
117 -DWITHOUT_HEAP_STORAGE_ENGINE=1
118 -DWITHOUT_INNOBASE_STORAGE_ENGINE=1
119 -DWITHOUT_MYISAMMRG_STORAGE_ENGINE=1
120 -DWITHOUT_MYISAM_STORAGE_ENGINE=1
121 -DWITHOUT_PARTITION_STORAGE_ENGINE=1
122 -DWITHOUT_INNOBASE_STORAGE_ENGINE=1
123 )
124 }
125
126 # @FUNCTION: configure_cmake_standard
127 # @DESCRIPTION:
128 # Helper function to configure standard build
129 configure_cmake_standard() {
130
131 mycmakeargs+=(
132 -DENABLED_LOCAL_INFILE=1
133 -DEXTRA_CHARSETS=all
134 -DMYSQL_USER=mysql
135 -DMYSQL_UNIX_ADDR=${EPREFIX}/var/run/mysqld/mysqld.sock
136 -DWITHOUT_READLINE=1
137 -DWITH_ZLIB=system
138 -DWITHOUT_LIBWRAP=1
139 )
140
141 mycmakeargs+=(
142 $(cmake-utils_use_disable !static SHARED)
143 $(cmake-utils_use_with debug)
144 $(cmake-utils_use_with embedded EMBEDDED_SERVER)
145 $(cmake-utils_use_with profiling)
146 $(cmake-utils_use_enable systemtap DTRACE)
147 )
148
149 if use ssl; then
150 mycmakeargs+=( -DWITH_SSL=system )
151 else
152 mycmakeargs+=( -DWITH_SSL=0 )
153 fi
154
155 if mysql_version_is_at_least "5.5" && use jemalloc; then
156 mycmakeargs+=( -DCMAKE_EXE_LINKER_FLAGS='-ljemalloc' -DWITH_SAFEMALLOC=OFF )
157 fi
158
159 if mysql_version_is_at_least "5.5" && use tcmalloc; then
160 mycmakeargs+=( -DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc' -DWITH_SAFEMALLOC=OFF )
161 fi
162
163 # Storage engines
164 mycmakeargs+=(
165 -DWITH_ARCHIVE_STORAGE_ENGINE=1
166 -DWITH_BLACKHOLE_STORAGE_ENGINE=1
167 -DWITH_CSV_STORAGE_ENGINE=1
168 -DWITH_HEAP_STORAGE_ENGINE=1
169 -DWITH_INNOBASE_STORAGE_ENGINE=1
170 -DWITH_MYISAMMRG_STORAGE_ENGINE=1
171 -DWITH_MYISAM_STORAGE_ENGINE=1
172 -DWITH_PARTITION_STORAGE_ENGINE=1
173 $(cmake-utils_use_with extraengine FEDERATED_STORAGE_ENGINE)
174 )
175
176 if pbxt_available ; then
177 mycmakeargs+=( $(cmake-utils_use_with pbxt PBXT_STORAGE_ENGINE) )
178 fi
179
180 if [ "${PN}" == "mariadb" ]; then
181 mycmakeargs+=(
182 $(cmake-utils_use_with oqgraph OQGRAPH_STORAGE_ENGINE)
183 $(cmake-utils_use_with sphinx SPHINX_STORAGE_ENGINE)
184 $(cmake-utils_use_with extraengine FEDERATEDX_STORAGE_ENGINE)
185 )
186 fi
187 }
188
189 #
190 # EBUILD FUNCTIONS
191 #
192
193 # @FUNCTION: mysql-cmake_src_prepare
194 # @DESCRIPTION:
195 # Apply patches to the source code and remove unneeded bundled libs.
196 mysql-cmake_src_prepare() {
197
198 debug-print-function ${FUNCNAME} "$@"
199
200 cd "${S}"
201
202 # Apply the patches for this MySQL version
203 EPATCH_SUFFIX="patch"
204 mkdir -p "${EPATCH_SOURCE}" || die "Unable to create epatch directory"
205 # Clean out old items
206 rm -f "${EPATCH_SOURCE}"/*
207 # Now link in right patches
208 mysql_mv_patches
209 # And apply
210 epatch
211
212 # last -fPIC fixup, per bug #305873
213 i="${S}"/storage/innodb_plugin/plug.in
214 [ -f "${i}" ] && sed -i -e '/CFLAGS/s,-prefer-non-pic,,g' "${i}"
215
216 rm -f "scripts/mysqlbug"
217 }
218
219 # @FUNCTION: mysql-cmake_src_configure
220 # @DESCRIPTION:
221 # Configure mysql to build the code for Gentoo respecting the use flags.
222 mysql-cmake_src_configure() {
223
224 debug-print-function ${FUNCNAME} "$@"
225
226 CMAKE_BUILD_TYPE="RelWithDebInfo"
227
228 mycmakeargs=(
229 -DCMAKE_INSTALL_PREFIX=${EPREFIX}/usr
230 -DMYSQL_DATADIR=${EPREFIX}/var/lib/mysql
231 -DSYSCONFDIR=${EPREFIX}/etc/mysql
232 -DINSTALL_BINDIR=bin
233 -DINSTALL_DOCDIR=share/doc/${P}
234 -DINSTALL_DOCREADMEDIR=share/doc/${P}
235 -DINSTALL_INCLUDEDIR=include/mysql
236 -DINSTALL_INFODIR=share/info
237 -DINSTALL_LIBDIR=$(get_libdir)/mysql
238 -DINSTALL_MANDIR=share/man
239 -DINSTALL_MYSQLDATADIR=${EPREFIX}/var/lib/mysql
240 -DINSTALL_MYSQLSHAREDIR=share/mysql
241 -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test
242 -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
243 -DINSTALL_SBINDIR=sbin
244 -DINSTALL_SCRIPTDIR=share/mysql/scripts
245 -DINSTALL_SQLBENCHDIR=share/mysql
246 -DINSTALL_SUPPORTFILESDIR=${EPREFIX}/usr/share/mysql
247 -DWITH_COMMENT="Gentoo Linux ${PF}"
248 -DWITHOUT_UNIT_TESTS=1
249 )
250
251 # Bug 412851
252 # MariaDB requires this flag to compile with GPLv3 readline linked
253 # Adds a warning about redistribution to configure
254 if [[ "${PN}" == "mariadb" ]] ; then
255 mycmakeargs+=( -DNOT_FOR_DISTRIBUTION=1 )
256 fi
257
258 configure_cmake_locale
259
260 if use minimal ; then
261 configure_cmake_minimal
262 else
263 configure_cmake_standard
264 fi
265
266 # Bug #114895, bug #110149
267 filter-flags "-O" "-O[01]"
268
269 CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-strict-aliasing"
270 CXXFLAGS="${CXXFLAGS} -felide-constructors -fno-rtti"
271 CXXFLAGS="${CXXFLAGS} -fno-implicit-templates"
272 export CXXFLAGS
273
274 # bug #283926, with GCC4.4, this is required to get correct behavior.
275 append-flags -fno-strict-aliasing
276
277 cmake-utils_src_configure
278 }
279
280 # @FUNCTION: mysql-cmake_src_compile
281 # @DESCRIPTION:
282 # Compile the mysql code.
283 mysql-cmake_src_compile() {
284
285 debug-print-function ${FUNCNAME} "$@"
286
287 cmake-utils_src_compile
288 }
289
290 # @FUNCTION: mysql-cmake_src_install
291 # @DESCRIPTION:
292 # Install mysql.
293 mysql-cmake_src_install() {
294
295 debug-print-function ${FUNCNAME} "$@"
296
297 # Make sure the vars are correctly initialized
298 mysql_init_vars
299
300 cmake-utils_src_install
301
302 # Convenience links
303 einfo "Making Convenience links for mysqlcheck multi-call binary"
304 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlanalyze"
305 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair"
306 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize"
307
308 # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
309 rm -Rf "${ED}/usr/data"
310
311 # Various junk (my-*.cnf moved elsewhere)
312 einfo "Removing duplicate /usr/share/mysql files"
313
314 # Clean up stuff for a minimal build
315 # if use minimal ; then
316 # einfo "Remove all extra content for minimal build"
317 # rm -Rf "${D}${MY_SHAREDSTATEDIR}"/{mysql-test,sql-bench}
318 # rm -f "${ED}"/usr/bin/{mysql{_install_db,manager*,_secure_installation,_fix_privilege_tables,hotcopy,_convert_table_format,d_multi,_fix_extensions,_zap,_explain_log,_tableinfo,d_safe,_install,_waitpid,binlog,test},myisam*,isam*,pack_isam}
319 # rm -f "${ED}/usr/sbin/mysqld"
320 # rm -f "${D}${MY_LIBDIR}"/lib{heap,merge,nisam,my{sys,strings,sqld,isammrg,isam},vio,dbug}.a
321 # fi
322
323 # Unless they explicitly specific USE=test, then do not install the
324 # testsuite. It DOES have a use to be installed, esp. when you want to do a
325 # validation of your database configuration after tuning it.
326 if ! use test ; then
327 rm -rf "${D}"/${MY_SHAREDSTATEDIR}/mysql-test
328 fi
329
330 # Configuration stuff
331 case ${MYSQL_PV_MAJOR} in
332 5.[1-9]|6*|7*) mysql_mycnf_version="5.1" ;;
333 esac
334 einfo "Building default my.cnf (${mysql_mycnf_version})"
335 insinto "${MY_SYSCONFDIR}"
336 doins scripts/mysqlaccess.conf
337 mycnf_src="my.cnf-${mysql_mycnf_version}"
338 sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
339 "${FILESDIR}/${mycnf_src}" \
340 > "${TMPDIR}/my.cnf.ok"
341 if use latin1 ; then
342 sed -i \
343 -e "/character-set/s|utf8|latin1|g" \
344 "${TMPDIR}/my.cnf.ok"
345 fi
346 newins "${TMPDIR}/my.cnf.ok" my.cnf
347
348 # Minimal builds don't have the MySQL server
349 if ! use minimal ; then
350 einfo "Creating initial directories"
351 # Empty directories ...
352 diropts "-m0750"
353 if [[ "${PREVIOUS_DATADIR}" != "yes" ]] ; then
354 dodir "${MY_DATADIR#${EPREFIX}}"
355 keepdir "${MY_DATADIR#${EPREFIX}}"
356 chown -R mysql:mysql "${D}/${MY_DATADIR}"
357 fi
358
359 diropts "-m0755"
360 for folder in "${MY_LOGDIR#${EPREFIX}}" "/var/run/mysqld" ; do
361 dodir "${folder}"
362 keepdir "${folder}"
363 chown -R mysql:mysql "${ED}/${folder}"
364 done
365 fi
366
367 # Minimal builds don't have the MySQL server
368 if ! use minimal ; then
369 einfo "Including support files and sample configurations"
370 docinto "support-files"
371 for script in \
372 "${S}"/support-files/my-*.cnf.sh \
373 "${S}"/support-files/magic \
374 "${S}"/support-files/ndb-config-2-node.ini.sh
375 do
376 [[ -f "$script" ]] && dodoc "${script}"
377 done
378
379 docinto "scripts"
380 for script in "${S}"/scripts/mysql* ; do
381 [[ -f "$script" ]] && [[ "${script%.sh}" == "${script}" ]] && dodoc "${script}"
382 done
383
384 fi
385
386 mysql_lib_symlinks "${ED}"
387 }

  ViewVC Help
Powered by ViewVC 1.1.20