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

Contents of /eclass/mysql-cmake.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (show annotations) (download)
Thu Jun 7 22:06:04 2012 UTC (2 years, 2 months ago) by zmedico
Branch: MAIN
Changes since 1.8: +2 -2 lines
inherit flag-o-matic for append-flags

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.8 2012/06/02 19:16:31 zmedico 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_disable_file
30 rawtestname="${1}" ; shift
31 reason="${@}"
32 ewarn "test '${rawtestname}' disabled: '${reason}'"
33
34 testsuite="${rawtestname/.*}"
35 testname="${rawtestname/*.}"
36 mysql_disable_file="${S}/mysql-test/t/disabled.def"
37 #einfo "rawtestname=${rawtestname} testname=${testname} testsuite=${testsuite}"
38 echo ${testname} : ${reason} >> "${mysql_disable_file}"
39
40 if [ -n "${testsuite}" ]; then
41 for mysql_disable_file in \
42 ${S}/mysql-test/suite/${testsuite}/disabled.def \
43 ${S}/mysql-test/suite/${testsuite}/t/disabled.def \
44 FAILED ; do
45 [ -f "${mysql_disable_file}" ] && break
46 done
47 if [ "${mysql_disabled_file}" != "FAILED" ]; then
48 echo "${testname} : ${reason}" >> "${mysql_disable_file}"
49 else
50 ewarn "Could not find testsuite disabled.def location for ${rawtestname}"
51 fi
52 fi
53 }
54
55 # @FUNCTION: configure_cmake_locale
56 # @DESCRIPTION:
57 # Helper function to configure locale cmake options
58 configure_cmake_locale() {
59
60 if ! use minimal && [ -n "${MYSQL_DEFAULT_CHARSET}" -a -n "${MYSQL_DEFAULT_COLLATION}" ]; then
61 ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
62 ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
63 ewarn "You MUST file bugs without these variables set."
64
65 mycmakeargs+=(
66 -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
67 -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
68 )
69
70 elif ! use latin1 ; then
71 mycmakeargs+=(
72 -DDEFAULT_CHARSET=utf8
73 -DDEFAULT_COLLATION=utf8_general_ci
74 )
75 else
76 mycmakeargs+=(
77 -DDEFAULT_CHARSET=latin1
78 -DDEFAULT_COLLATION=latin1_swedish_ci
79 )
80 fi
81 }
82
83 # @FUNCTION: configure_cmake_minimal
84 # @DESCRIPTION:
85 # Helper function to configure minimal build
86 configure_cmake_minimal() {
87
88 mycmakeargs+=(
89 -DWITHOUT_SERVER=1
90 -DWITHOUT_EMBEDDED_SERVER=1
91 -DENABLED_LOCAL_INFILE=1
92 -DEXTRA_CHARSETS=none
93 -DINSTALL_SQLBENCHDIR=
94 -DWITH_SSL=system
95 -DWITH_ZLIB=system
96 -DWITHOUT_LIBWRAP=1
97 -DWITHOUT_READLINE=1
98 -DWITHOUT_ARCHIVE_STORAGE_ENGINE=1
99 -DWITHOUT_BLACKHOLE_STORAGE_ENGINE=1
100 -DWITHOUT_CSV_STORAGE_ENGINE=1
101 -DWITHOUT_FEDERATED_STORAGE_ENGINE=1
102 -DWITHOUT_HEAP_STORAGE_ENGINE=1
103 -DWITHOUT_INNOBASE_STORAGE_ENGINE=1
104 -DWITHOUT_MYISAMMRG_STORAGE_ENGINE=1
105 -DWITHOUT_MYISAM_STORAGE_ENGINE=1
106 -DWITHOUT_PARTITION_STORAGE_ENGINE=1
107 -DWITHOUT_INNOBASE_STORAGE_ENGINE=1
108 )
109 }
110
111 # @FUNCTION: configure_cmake_standard
112 # @DESCRIPTION:
113 # Helper function to configure standard build
114 configure_cmake_standard() {
115
116 mycmakeargs+=(
117 -DENABLED_LOCAL_INFILE=1
118 -DEXTRA_CHARSETS=all
119 -DMYSQL_USER=mysql
120 -DMYSQL_UNIX_ADDR=${EPREFIX}/var/run/mysqld/mysqld.sock
121 -DWITHOUT_READLINE=1
122 -DWITH_ZLIB=system
123 -DWITHOUT_LIBWRAP=1
124 )
125
126 mycmakeargs+=(
127 $(cmake-utils_use_disable !static SHARED)
128 $(cmake-utils_use_with debug)
129 $(cmake-utils_use_with embedded EMBEDDED_SERVER)
130 $(cmake-utils_use_with profiling)
131 $(cmake-utils_use_enable systemtap DTRACE)
132 )
133
134 if use ssl; then
135 mycmakeargs+=( -DWITH_SSL=system )
136 else
137 mycmakeargs+=( -DWITH_SSL=0 )
138 fi
139
140 # Storage engines
141 mycmakeargs+=(
142 -DWITH_ARCHIVE_STORAGE_ENGINE=1
143 -DWITH_BLACKHOLE_STORAGE_ENGINE=1
144 -DWITH_CSV_STORAGE_ENGINE=1
145 -DWITH_HEAP_STORAGE_ENGINE=1
146 -DWITH_INNOBASE_STORAGE_ENGINE=1
147 -DWITH_MYISAMMRG_STORAGE_ENGINE=1
148 -DWITH_MYISAM_STORAGE_ENGINE=1
149 -DWITH_PARTITION_STORAGE_ENGINE=1
150 $(cmake-utils_use_with extraengine FEDERATED_STORAGE_ENGINE)
151 )
152 }
153
154 #
155 # EBUILD FUNCTIONS
156 #
157
158 # @FUNCTION: mysql-cmake_src_prepare
159 # @DESCRIPTION:
160 # Apply patches to the source code and remove unneeded bundled libs.
161 mysql-cmake_src_prepare() {
162
163 debug-print-function ${FUNCNAME} "$@"
164
165 cd "${S}"
166
167 # Apply the patches for this MySQL version
168 EPATCH_SUFFIX="patch"
169 mkdir -p "${EPATCH_SOURCE}" || die "Unable to create epatch directory"
170 # Clean out old items
171 rm -f "${EPATCH_SOURCE}"/*
172 # Now link in right patches
173 mysql_mv_patches
174 # And apply
175 epatch
176
177 # last -fPIC fixup, per bug #305873
178 i="${S}"/storage/innodb_plugin/plug.in
179 [ -f "${i}" ] && sed -i -e '/CFLAGS/s,-prefer-non-pic,,g' "${i}"
180
181 rm -f "scripts/mysqlbug"
182 }
183
184 # @FUNCTION: mysql-cmake_src_configure
185 # @DESCRIPTION:
186 # Configure mysql to build the code for Gentoo respecting the use flags.
187 mysql-cmake_src_configure() {
188
189 debug-print-function ${FUNCNAME} "$@"
190
191 CMAKE_BUILD_TYPE="RelWithDebInfo"
192
193 mycmakeargs=(
194 -DCMAKE_INSTALL_PREFIX=${EPREFIX}/usr
195 -DMYSQL_DATADIR=${EPREFIX}/var/lib/mysql
196 -DSYSCONFDIR=${EPREFIX}/etc/mysql
197 -DINSTALL_BINDIR=bin
198 -DINSTALL_DOCDIR=share/doc/${P}
199 -DINSTALL_DOCREADMEDIR=share/doc/${P}
200 -DINSTALL_INCLUDEDIR=include/mysql
201 -DINSTALL_INFODIR=share/info
202 -DINSTALL_LIBDIR=$(get_libdir)/mysql
203 -DINSTALL_MANDIR=share/man
204 -DINSTALL_MYSQLDATADIR=${EPREFIX}/var/lib/mysql
205 -DINSTALL_MYSQLSHAREDIR=share/mysql
206 -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test
207 -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
208 -DINSTALL_SBINDIR=sbin
209 -DINSTALL_SCRIPTDIR=share/mysql/scripts
210 -DINSTALL_SQLBENCHDIR=share/mysql
211 -DINSTALL_SUPPORTFILESDIR=${EPREFIX}/usr/share/mysql
212 -DWITH_COMMENT="Gentoo Linux ${PF}"
213 -DWITHOUT_UNIT_TESTS=1
214 )
215
216 configure_cmake_locale
217
218 if use minimal ; then
219 configure_cmake_minimal
220 else
221 configure_cmake_standard
222 fi
223
224 # Bug #114895, bug #110149
225 filter-flags "-O" "-O[01]"
226
227 CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-strict-aliasing"
228 CXXFLAGS="${CXXFLAGS} -felide-constructors -fno-rtti"
229 CXXFLAGS="${CXXFLAGS} -fno-implicit-templates"
230 export CXXFLAGS
231
232 # bug #283926, with GCC4.4, this is required to get correct behavior.
233 append-flags -fno-strict-aliasing
234
235 cmake-utils_src_configure
236 }
237
238 # @FUNCTION: mysql-cmake_src_compile
239 # @DESCRIPTION:
240 # Compile the mysql code.
241 mysql-cmake_src_compile() {
242
243 debug-print-function ${FUNCNAME} "$@"
244
245 cmake-utils_src_compile
246 }
247
248 # @FUNCTION: mysql-cmake_src_install
249 # @DESCRIPTION:
250 # Install mysql.
251 mysql-cmake_src_install() {
252
253 debug-print-function ${FUNCNAME} "$@"
254
255 # Make sure the vars are correctly initialized
256 mysql_init_vars
257
258 cmake-utils_src_install
259
260 # Convenience links
261 einfo "Making Convenience links for mysqlcheck multi-call binary"
262 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlanalyze"
263 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair"
264 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize"
265
266 # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
267 rm -Rf "${ED}/usr/data"
268
269 # Various junk (my-*.cnf moved elsewhere)
270 einfo "Removing duplicate /usr/share/mysql files"
271
272 # Clean up stuff for a minimal build
273 # if use minimal ; then
274 # einfo "Remove all extra content for minimal build"
275 # rm -Rf "${D}${MY_SHAREDSTATEDIR}"/{mysql-test,sql-bench}
276 # 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}
277 # rm -f "${ED}/usr/sbin/mysqld"
278 # rm -f "${D}${MY_LIBDIR}"/lib{heap,merge,nisam,my{sys,strings,sqld,isammrg,isam},vio,dbug}.a
279 # fi
280
281 # Unless they explicitly specific USE=test, then do not install the
282 # testsuite. It DOES have a use to be installed, esp. when you want to do a
283 # validation of your database configuration after tuning it.
284 if ! use test ; then
285 rm -rf "${D}"/${MY_SHAREDSTATEDIR}/mysql-test
286 fi
287
288 # Configuration stuff
289 case ${MYSQL_PV_MAJOR} in
290 5.[1-9]|6*|7*) mysql_mycnf_version="5.1" ;;
291 esac
292 einfo "Building default my.cnf (${mysql_mycnf_version})"
293 insinto "${MY_SYSCONFDIR}"
294 doins scripts/mysqlaccess.conf
295 mycnf_src="my.cnf-${mysql_mycnf_version}"
296 sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
297 "${FILESDIR}/${mycnf_src}" \
298 > "${TMPDIR}/my.cnf.ok"
299 if use latin1 ; then
300 sed -i \
301 -e "/character-set/s|utf8|latin1|g" \
302 "${TMPDIR}/my.cnf.ok"
303 fi
304 newins "${TMPDIR}/my.cnf.ok" my.cnf
305
306 # Minimal builds don't have the MySQL server
307 if ! use minimal ; then
308 einfo "Creating initial directories"
309 # Empty directories ...
310 diropts "-m0750"
311 if [[ "${PREVIOUS_DATADIR}" != "yes" ]] ; then
312 dodir "${MY_DATADIR#${EPREFIX}}"
313 keepdir "${MY_DATADIR#${EPREFIX}}"
314 chown -R mysql:mysql "${D}/${MY_DATADIR}"
315 fi
316
317 diropts "-m0755"
318 for folder in "${MY_LOGDIR#${EPREFIX}}" "/var/run/mysqld" ; do
319 dodir "${folder}"
320 keepdir "${folder}"
321 chown -R mysql:mysql "${ED}/${folder}"
322 done
323 fi
324
325 # Minimal builds don't have the MySQL server
326 if ! use minimal ; then
327 einfo "Including support files and sample configurations"
328 docinto "support-files"
329 for script in \
330 "${S}"/support-files/my-*.cnf.sh \
331 "${S}"/support-files/magic \
332 "${S}"/support-files/ndb-config-2-node.ini.sh
333 do
334 [[ -f "$script" ]] && dodoc "${script}"
335 done
336
337 docinto "scripts"
338 for script in "${S}"/scripts/mysql* ; do
339 [[ -f "$script" ]] && [[ "${script%.sh}" == "${script}" ]] && dodoc "${script}"
340 done
341
342 fi
343
344 mysql_lib_symlinks "${ED}"
345 }

  ViewVC Help
Powered by ViewVC 1.1.20