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

Contents of /eclass/mysql-cmake.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.14 - (show annotations) (download)
Wed Feb 13 00:40:57 2013 UTC (18 months, 2 weeks ago) by robbat2
Branch: MAIN
Changes since 1.13: +10 -1 lines
Bug #455462: Libtool cleanup; Bug #455016: mariadb mytop deps; Bug #448598: USE=pam support.

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

  ViewVC Help
Powered by ViewVC 1.1.20