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

Contents of /eclass/mysql-cmake.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.17 - (hide annotations) (download)
Thu Jun 27 17:23:33 2013 UTC (17 months, 3 weeks ago) by jmbsvicetto
Branch: MAIN
Changes since 1.16: +5 -0 lines
[eclass] Add env file to add /usr/lib/mysql to LDPATH. Fixes bug 474952.

1 robbat2 1.15 # Copyright 1999-2013 Gentoo Foundation
2 robbat2 1.1 # Distributed under the terms of the GNU General Public License v2
3 jmbsvicetto 1.16 # $Header: /var/cvsroot/gentoo-x86/eclass/mysql-cmake.eclass,v 1.15 2013/03/04 19:10:31 robbat2 Exp $
4 robbat2 1.1
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 robbat2 1.13 inherit cmake-utils flag-o-matic multilib prefix
19 robbat2 1.1
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 robbat2 1.10 local rawtestname testname testsuite reason mysql_disabled_file mysql_disabled_dir
30 robbat2 1.1 rawtestname="${1}" ; shift
31     reason="${@}"
32     ewarn "test '${rawtestname}' disabled: '${reason}'"
33    
34     testsuite="${rawtestname/.*}"
35     testname="${rawtestname/*.}"
36 robbat2 1.10 for mysql_disabled_file in \
37     ${S}/mysql-test/disabled.def \
38     ${S}/mysql-test/t/disabled.def ; do
39 jmbsvicetto 1.16 [[ -f ${mysql_disabled_file} ]] && break
40 robbat2 1.10 done
41     #mysql_disabled_file="${S}/mysql-test/t/disabled.def"
42 robbat2 1.1 #einfo "rawtestname=${rawtestname} testname=${testname} testsuite=${testsuite}"
43 robbat2 1.10 echo ${testname} : ${reason} >> "${mysql_disabled_file}"
44 robbat2 1.1
45 jmbsvicetto 1.16 if [[ ( -n ${testsuite} ) && ( ${testsuite} != "main" ) ]]; then
46 robbat2 1.10 for mysql_disabled_file in \
47 robbat2 1.1 ${S}/mysql-test/suite/${testsuite}/disabled.def \
48     ${S}/mysql-test/suite/${testsuite}/t/disabled.def \
49     FAILED ; do
50 jmbsvicetto 1.16 [[ -f ${mysql_disabled_file} ]] && break
51 robbat2 1.1 done
52 jmbsvicetto 1.16 if [[ ${mysql_disabled_file} != "FAILED" ]]; then
53 robbat2 1.10 echo "${testname} : ${reason}" >> "${mysql_disabled_file}"
54 robbat2 1.1 else
55 robbat2 1.10 for mysql_disabled_dir in \
56     ${S}/mysql-test/suite/${testsuite} \
57     ${S}/mysql-test/suite/${testsuite}/t \
58     FAILED ; do
59 jmbsvicetto 1.16 [[ -d ${mysql_disabled_dir} ]] && break
60 robbat2 1.10 done
61 jmbsvicetto 1.16 if [[ ${mysql_disabled_dir} != "FAILED" ]]; then
62 robbat2 1.10 echo "${testname} : ${reason}" >> "${mysql_disabled_dir}/disabled.def"
63     else
64     ewarn "Could not find testsuite disabled.def location for ${rawtestname}"
65     fi
66 robbat2 1.1 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 jmbsvicetto 1.16 if ! use minimal && [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then
76 robbat2 1.1 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 robbat2 1.11 -DWITH_READLINE=0
113     -DWITH_LIBEDIT=0
114 robbat2 1.1 -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 jmbsvicetto 1.5 -DMYSQL_UNIX_ADDR=${EPREFIX}/var/run/mysqld/mysqld.sock
137 robbat2 1.11 -DWITH_READLINE=0
138     -DWITH_LIBEDIT=0
139 robbat2 1.1 -DWITH_ZLIB=system
140     -DWITHOUT_LIBWRAP=1
141     )
142    
143     mycmakeargs+=(
144 robbat2 1.3 $(cmake-utils_use_disable !static SHARED)
145 robbat2 1.1 $(cmake-utils_use_with debug)
146     $(cmake-utils_use_with embedded EMBEDDED_SERVER)
147     $(cmake-utils_use_with profiling)
148 robbat2 1.4 $(cmake-utils_use_enable systemtap DTRACE)
149 robbat2 1.1 )
150    
151     if use ssl; then
152     mycmakeargs+=( -DWITH_SSL=system )
153     else
154 jmbsvicetto 1.16 mycmakeargs+=( -DWITH_SSL=bundled )
155 robbat2 1.1 fi
156    
157 robbat2 1.10 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 robbat2 1.1 # 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 robbat2 1.10
178     if pbxt_available ; then
179     mycmakeargs+=( $(cmake-utils_use_with pbxt PBXT_STORAGE_ENGINE) )
180     fi
181    
182 jmbsvicetto 1.16 if [[ ${PN} == "mariadb" ]]; then
183 robbat2 1.10 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 robbat2 1.14
189     if ! use pam ; then
190     mycmakeargs+=( -DAUTH_PAM_DISABLED=1 )
191     fi
192 jmbsvicetto 1.16 fi
193    
194     if [[ ${PN} == "percona-server" ]]; then
195     mycmakeargs+=(
196     $(cmake-utils_use_with pam)
197     )
198 robbat2 1.10 fi
199 robbat2 1.1 }
200    
201     #
202     # EBUILD FUNCTIONS
203     #
204    
205     # @FUNCTION: mysql-cmake_src_prepare
206     # @DESCRIPTION:
207     # Apply patches to the source code and remove unneeded bundled libs.
208     mysql-cmake_src_prepare() {
209    
210     debug-print-function ${FUNCNAME} "$@"
211    
212     cd "${S}"
213    
214     # Apply the patches for this MySQL version
215     EPATCH_SUFFIX="patch"
216     mkdir -p "${EPATCH_SOURCE}" || die "Unable to create epatch directory"
217     # Clean out old items
218     rm -f "${EPATCH_SOURCE}"/*
219     # Now link in right patches
220     mysql_mv_patches
221     # And apply
222     epatch
223    
224     # last -fPIC fixup, per bug #305873
225     i="${S}"/storage/innodb_plugin/plug.in
226 jmbsvicetto 1.16 [[ -f ${i} ]] && sed -i -e '/CFLAGS/s,-prefer-non-pic,,g' "${i}"
227 robbat2 1.1
228     rm -f "scripts/mysqlbug"
229 robbat2 1.15 epatch_user
230 robbat2 1.1 }
231    
232     # @FUNCTION: mysql-cmake_src_configure
233     # @DESCRIPTION:
234     # Configure mysql to build the code for Gentoo respecting the use flags.
235     mysql-cmake_src_configure() {
236    
237     debug-print-function ${FUNCNAME} "$@"
238    
239 jmbsvicetto 1.2 CMAKE_BUILD_TYPE="RelWithDebInfo"
240    
241 robbat2 1.1 mycmakeargs=(
242 jmbsvicetto 1.5 -DCMAKE_INSTALL_PREFIX=${EPREFIX}/usr
243     -DMYSQL_DATADIR=${EPREFIX}/var/lib/mysql
244     -DSYSCONFDIR=${EPREFIX}/etc/mysql
245 robbat2 1.1 -DINSTALL_BINDIR=bin
246     -DINSTALL_DOCDIR=share/doc/${P}
247     -DINSTALL_DOCREADMEDIR=share/doc/${P}
248     -DINSTALL_INCLUDEDIR=include/mysql
249     -DINSTALL_INFODIR=share/info
250     -DINSTALL_LIBDIR=$(get_libdir)/mysql
251     -DINSTALL_MANDIR=share/man
252 jmbsvicetto 1.5 -DINSTALL_MYSQLDATADIR=${EPREFIX}/var/lib/mysql
253 robbat2 1.1 -DINSTALL_MYSQLSHAREDIR=share/mysql
254     -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test
255     -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
256     -DINSTALL_SBINDIR=sbin
257     -DINSTALL_SCRIPTDIR=share/mysql/scripts
258     -DINSTALL_SQLBENCHDIR=share/mysql
259 jmbsvicetto 1.5 -DINSTALL_SUPPORTFILESDIR=${EPREFIX}/usr/share/mysql
260 robbat2 1.1 -DWITH_COMMENT="Gentoo Linux ${PF}"
261 jmbsvicetto 1.16 $(cmake-utils_use_with test UNIT_TESTS)
262 robbat2 1.1 )
263    
264 robbat2 1.10 # Bug 412851
265     # MariaDB requires this flag to compile with GPLv3 readline linked
266     # Adds a warning about redistribution to configure
267 jmbsvicetto 1.16 if [[ ${PN} == "mariadb" ]] ; then
268 robbat2 1.10 mycmakeargs+=( -DNOT_FOR_DISTRIBUTION=1 )
269     fi
270    
271 robbat2 1.1 configure_cmake_locale
272    
273     if use minimal ; then
274     configure_cmake_minimal
275     else
276     configure_cmake_standard
277     fi
278    
279     # Bug #114895, bug #110149
280     filter-flags "-O" "-O[01]"
281    
282 jmbsvicetto 1.16 CXXFLAGS="${CXXFLAGS} -fno-strict-aliasing"
283 robbat2 1.1 CXXFLAGS="${CXXFLAGS} -felide-constructors -fno-rtti"
284 robbat2 1.15 # Causes linkage failures. Upstream bug #59607 removes it
285     if ! mysql_version_is_at_least "5.6" ; then
286     CXXFLAGS="${CXXFLAGS} -fno-implicit-templates"
287     fi
288 jmbsvicetto 1.16 # As of 5.7, exceptions are used!
289     if ! mysql_version_is_at_least "5.7" ; then
290     CXXFLAGS="${CXXFLAGS} -fno-exceptions"
291     fi
292 robbat2 1.1 export CXXFLAGS
293    
294     # bug #283926, with GCC4.4, this is required to get correct behavior.
295     append-flags -fno-strict-aliasing
296    
297     cmake-utils_src_configure
298     }
299    
300     # @FUNCTION: mysql-cmake_src_compile
301     # @DESCRIPTION:
302     # Compile the mysql code.
303     mysql-cmake_src_compile() {
304    
305     debug-print-function ${FUNCNAME} "$@"
306    
307     cmake-utils_src_compile
308     }
309    
310     # @FUNCTION: mysql-cmake_src_install
311     # @DESCRIPTION:
312     # Install mysql.
313     mysql-cmake_src_install() {
314    
315     debug-print-function ${FUNCNAME} "$@"
316    
317     # Make sure the vars are correctly initialized
318     mysql_init_vars
319    
320     cmake-utils_src_install
321    
322     # Convenience links
323     einfo "Making Convenience links for mysqlcheck multi-call binary"
324     dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlanalyze"
325     dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair"
326     dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize"
327    
328 jmbsvicetto 1.16 # Create a mariadb_config symlink
329     [[ ${PN} == "mariadb" ]] && dosym "/usr/bin/mysql_config" "/usr/bin/mariadb_config"
330    
331 robbat2 1.1 # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
332 jmbsvicetto 1.5 rm -Rf "${ED}/usr/data"
333 robbat2 1.1
334     # Various junk (my-*.cnf moved elsewhere)
335     einfo "Removing duplicate /usr/share/mysql files"
336    
337     # Clean up stuff for a minimal build
338     # if use minimal ; then
339     # einfo "Remove all extra content for minimal build"
340     # rm -Rf "${D}${MY_SHAREDSTATEDIR}"/{mysql-test,sql-bench}
341 jmbsvicetto 1.5 # 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}
342     # rm -f "${ED}/usr/sbin/mysqld"
343 robbat2 1.1 # rm -f "${D}${MY_LIBDIR}"/lib{heap,merge,nisam,my{sys,strings,sqld,isammrg,isam},vio,dbug}.a
344     # fi
345    
346     # Unless they explicitly specific USE=test, then do not install the
347     # testsuite. It DOES have a use to be installed, esp. when you want to do a
348     # validation of your database configuration after tuning it.
349     if ! use test ; then
350     rm -rf "${D}"/${MY_SHAREDSTATEDIR}/mysql-test
351     fi
352    
353     # Configuration stuff
354     case ${MYSQL_PV_MAJOR} in
355 robbat2 1.11 5.[1-4]*) mysql_mycnf_version="5.1" ;;
356 jmbsvicetto 1.16 5.[5-9]|6*|7*|8*|9*|10*) mysql_mycnf_version="5.5" ;;
357 robbat2 1.1 esac
358     einfo "Building default my.cnf (${mysql_mycnf_version})"
359 robbat2 1.12 insinto "${MY_SYSCONFDIR#${EPREFIX}}"
360 robbat2 1.1 doins scripts/mysqlaccess.conf
361     mycnf_src="my.cnf-${mysql_mycnf_version}"
362     sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
363     "${FILESDIR}/${mycnf_src}" \
364     > "${TMPDIR}/my.cnf.ok"
365     if use latin1 ; then
366     sed -i \
367     -e "/character-set/s|utf8|latin1|g" \
368     "${TMPDIR}/my.cnf.ok"
369     fi
370 robbat2 1.13 eprefixify "${TMPDIR}/my.cnf.ok"
371 robbat2 1.1 newins "${TMPDIR}/my.cnf.ok" my.cnf
372    
373     # Minimal builds don't have the MySQL server
374     if ! use minimal ; then
375     einfo "Creating initial directories"
376     # Empty directories ...
377     diropts "-m0750"
378 jmbsvicetto 1.16 if [[ ${PREVIOUS_DATADIR} != "yes" ]] ; then
379 jmbsvicetto 1.5 dodir "${MY_DATADIR#${EPREFIX}}"
380     keepdir "${MY_DATADIR#${EPREFIX}}"
381 robbat2 1.1 chown -R mysql:mysql "${D}/${MY_DATADIR}"
382     fi
383    
384     diropts "-m0755"
385 jmbsvicetto 1.5 for folder in "${MY_LOGDIR#${EPREFIX}}" "/var/run/mysqld" ; do
386 robbat2 1.1 dodir "${folder}"
387     keepdir "${folder}"
388 jmbsvicetto 1.5 chown -R mysql:mysql "${ED}/${folder}"
389 robbat2 1.1 done
390     fi
391    
392     # Minimal builds don't have the MySQL server
393     if ! use minimal ; then
394     einfo "Including support files and sample configurations"
395     docinto "support-files"
396     for script in \
397     "${S}"/support-files/my-*.cnf.sh \
398     "${S}"/support-files/magic \
399     "${S}"/support-files/ndb-config-2-node.ini.sh
400     do
401 jmbsvicetto 1.16 [[ -f $script ]] && dodoc "${script}"
402 robbat2 1.1 done
403    
404     docinto "scripts"
405     for script in "${S}"/scripts/mysql* ; do
406 jmbsvicetto 1.16 [[ ( -f $script ) && ( ${script%.sh} == ${script} ) ]] && dodoc "${script}"
407 robbat2 1.1 done
408     fi
409    
410 jmbsvicetto 1.17 cat <<-EOF > "${T}"/80mysql-libdir
411     LDPATH="${EPREFIX}/usr/$(get_libdir)/mysql"
412     EOF
413     doenvd "${T}"/80mysql-libdir
414    
415 robbat2 1.14 #Remove mytop if perl is not selected
416 jmbsvicetto 1.16 [[ ${PN} == "mariadb" ]] && ! use perl \
417 robbat2 1.14 && rm -f "${ED}/usr/bin/mytop"
418 robbat2 1.1 }

  ViewVC Help
Powered by ViewVC 1.1.20