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

Contents of /eclass/mysql-cmake.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Wed Jul 13 07:07:15 2011 UTC (3 years, 2 months ago) by robbat2
Branch: MAIN
Part 2 of MySQL eclass revamp: the split cmake/autotools support.

1 # Copyright 1999-2011 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
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
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=/var/run/mysqld/mysqld.sock
121 -DWITHOUT_READLINE=1
122 -DWITH_ZLIB=system
123 -DWITHOUT_LIBWRAP=1
124 )
125
126 if use static ; then
127 mycmakeargs+=( -DDISABLE_SHARED=1 )
128 else
129 mycmakeargs+=( -DDISABLED_SHARED=0 )
130 fi
131
132 mycmakeargs+=(
133 $(cmake-utils_use_with debug)
134 $(cmake-utils_use_with embedded EMBEDDED_SERVER)
135 $(cmake-utils_use_with profiling)
136 )
137
138 if use ssl; then
139 mycmakeargs+=( -DWITH_SSL=system )
140 else
141 mycmakeargs+=( -DWITH_SSL=0 )
142 fi
143
144 # Storage engines
145 mycmakeargs+=(
146 -DWITH_ARCHIVE_STORAGE_ENGINE=1
147 -DWITH_BLACKHOLE_STORAGE_ENGINE=1
148 -DWITH_CSV_STORAGE_ENGINE=1
149 -DWITH_HEAP_STORAGE_ENGINE=1
150 -DWITH_INNOBASE_STORAGE_ENGINE=1
151 -DWITH_MYISAMMRG_STORAGE_ENGINE=1
152 -DWITH_MYISAM_STORAGE_ENGINE=1
153 -DWITH_PARTITION_STORAGE_ENGINE=1
154 $(cmake-utils_use_with extraengine FEDERATED_STORAGE_ENGINE)
155 )
156 }
157
158 #
159 # EBUILD FUNCTIONS
160 #
161
162 # @FUNCTION: mysql-cmake_src_prepare
163 # @DESCRIPTION:
164 # Apply patches to the source code and remove unneeded bundled libs.
165 mysql-cmake_src_prepare() {
166
167 debug-print-function ${FUNCNAME} "$@"
168
169 cd "${S}"
170
171 # Apply the patches for this MySQL version
172 EPATCH_SUFFIX="patch"
173 mkdir -p "${EPATCH_SOURCE}" || die "Unable to create epatch directory"
174 # Clean out old items
175 rm -f "${EPATCH_SOURCE}"/*
176 # Now link in right patches
177 mysql_mv_patches
178 # And apply
179 epatch
180
181 # last -fPIC fixup, per bug #305873
182 i="${S}"/storage/innodb_plugin/plug.in
183 [ -f "${i}" ] && sed -i -e '/CFLAGS/s,-prefer-non-pic,,g' "${i}"
184
185 rm -f "scripts/mysqlbug"
186 }
187
188 # @FUNCTION: mysql-cmake_src_configure
189 # @DESCRIPTION:
190 # Configure mysql to build the code for Gentoo respecting the use flags.
191 mysql-cmake_src_configure() {
192
193 debug-print-function ${FUNCNAME} "$@"
194
195 mycmakeargs=(
196 -DCMAKE_INSTALL_PREFIX=/usr
197 -DMYSQL_DATADIR=/var/lib/mysql
198 -DSYSCONFDIR=/etc/mysql
199 -DINSTALL_BINDIR=bin
200 -DINSTALL_DOCDIR=share/doc/${P}
201 -DINSTALL_DOCREADMEDIR=share/doc/${P}
202 -DINSTALL_INCLUDEDIR=include/mysql
203 -DINSTALL_INFODIR=share/info
204 -DINSTALL_LIBDIR=$(get_libdir)/mysql
205 -DINSTALL_MANDIR=share/man
206 -DINSTALL_MYSQLDATADIR=/var/lib/mysql
207 -DINSTALL_MYSQLSHAREDIR=share/mysql
208 -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test
209 -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
210 -DINSTALL_SBINDIR=sbin
211 -DINSTALL_SCRIPTDIR=share/mysql/scripts
212 -DINSTALL_SQLBENCHDIR=share/mysql
213 -DINSTALL_SUPPORTFILESDIR=/usr/share/mysql
214 -DWITH_COMMENT="Gentoo Linux ${PF}"
215 -DWITHOUT_UNIT_TESTS=1
216 )
217
218 configure_cmake_locale
219
220 if use minimal ; then
221 configure_cmake_minimal
222 else
223 configure_cmake_standard
224 fi
225
226 # Bug #114895, bug #110149
227 filter-flags "-O" "-O[01]"
228
229 CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-strict-aliasing"
230 CXXFLAGS="${CXXFLAGS} -felide-constructors -fno-rtti"
231 CXXFLAGS="${CXXFLAGS} -fno-implicit-templates"
232 export CXXFLAGS
233
234 # bug #283926, with GCC4.4, this is required to get correct behavior.
235 append-flags -fno-strict-aliasing
236
237 cmake-utils_src_configure
238 }
239
240 # @FUNCTION: mysql-cmake_src_compile
241 # @DESCRIPTION:
242 # Compile the mysql code.
243 mysql-cmake_src_compile() {
244
245 debug-print-function ${FUNCNAME} "$@"
246
247 cmake-utils_src_compile
248 }
249
250 # @FUNCTION: mysql-cmake_src_install
251 # @DESCRIPTION:
252 # Install mysql.
253 mysql-cmake_src_install() {
254
255 debug-print-function ${FUNCNAME} "$@"
256
257 # Make sure the vars are correctly initialized
258 mysql_init_vars
259
260 cmake-utils_src_install
261
262 # Convenience links
263 einfo "Making Convenience links for mysqlcheck multi-call binary"
264 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlanalyze"
265 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair"
266 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize"
267
268 # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
269 rm -Rf "${D}/usr/data"
270
271 # Various junk (my-*.cnf moved elsewhere)
272 einfo "Removing duplicate /usr/share/mysql files"
273
274 # Clean up stuff for a minimal build
275 # if use minimal ; then
276 # einfo "Remove all extra content for minimal build"
277 # rm -Rf "${D}${MY_SHAREDSTATEDIR}"/{mysql-test,sql-bench}
278 # rm -f "${D}"/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}
279 # rm -f "${D}/usr/sbin/mysqld"
280 # rm -f "${D}${MY_LIBDIR}"/lib{heap,merge,nisam,my{sys,strings,sqld,isammrg,isam},vio,dbug}.a
281 # fi
282
283 # Unless they explicitly specific USE=test, then do not install the
284 # testsuite. It DOES have a use to be installed, esp. when you want to do a
285 # validation of your database configuration after tuning it.
286 if ! use test ; then
287 rm -rf "${D}"/${MY_SHAREDSTATEDIR}/mysql-test
288 fi
289
290 # Configuration stuff
291 case ${MYSQL_PV_MAJOR} in
292 5.[1-9]|6*|7*) mysql_mycnf_version="5.1" ;;
293 esac
294 einfo "Building default my.cnf (${mysql_mycnf_version})"
295 insinto "${MY_SYSCONFDIR}"
296 doins scripts/mysqlaccess.conf
297 mycnf_src="my.cnf-${mysql_mycnf_version}"
298 sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
299 "${FILESDIR}/${mycnf_src}" \
300 > "${TMPDIR}/my.cnf.ok"
301 if use latin1 ; then
302 sed -i \
303 -e "/character-set/s|utf8|latin1|g" \
304 "${TMPDIR}/my.cnf.ok"
305 fi
306 newins "${TMPDIR}/my.cnf.ok" my.cnf
307
308 # Minimal builds don't have the MySQL server
309 if ! use minimal ; then
310 einfo "Creating initial directories"
311 # Empty directories ...
312 diropts "-m0750"
313 if [[ "${PREVIOUS_DATADIR}" != "yes" ]] ; then
314 dodir "${MY_DATADIR}"
315 keepdir "${MY_DATADIR}"
316 chown -R mysql:mysql "${D}/${MY_DATADIR}"
317 fi
318
319 diropts "-m0755"
320 for folder in "${MY_LOGDIR}" "/var/run/mysqld" ; do
321 dodir "${folder}"
322 keepdir "${folder}"
323 chown -R mysql:mysql "${D}/${folder}"
324 done
325 fi
326
327 # Minimal builds don't have the MySQL server
328 if ! use minimal ; then
329 einfo "Including support files and sample configurations"
330 docinto "support-files"
331 for script in \
332 "${S}"/support-files/my-*.cnf.sh \
333 "${S}"/support-files/magic \
334 "${S}"/support-files/ndb-config-2-node.ini.sh
335 do
336 [[ -f "$script" ]] && dodoc "${script}"
337 done
338
339 docinto "scripts"
340 for script in "${S}"/scripts/mysql* ; do
341 [[ -f "$script" ]] && [[ "${script%.sh}" == "${script}" ]] && dodoc "${script}"
342 done
343
344 fi
345
346 mysql_lib_symlinks "${D}"
347 }

  ViewVC Help
Powered by ViewVC 1.1.20