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

Contents of /eclass/mysql-cmake.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Fri Sep 30 02:10:24 2011 UTC (2 years, 6 months ago) by jmbsvicetto
Branch: MAIN
Changes since 1.1: +2 -0 lines
[mysql-cmake.eclass] Add CMAKE_BUILD_TYPE to mysql-cmake eclass so the binaries aren't built with debug. Thanks to Greg M.
[mysql_fx.eclass] Limit the creation of symlinks to the libdir so not to link to plugins.

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 CMAKE_BUILD_TYPE="RelWithDebInfo"
196
197 mycmakeargs=(
198 -DCMAKE_INSTALL_PREFIX=/usr
199 -DMYSQL_DATADIR=/var/lib/mysql
200 -DSYSCONFDIR=/etc/mysql
201 -DINSTALL_BINDIR=bin
202 -DINSTALL_DOCDIR=share/doc/${P}
203 -DINSTALL_DOCREADMEDIR=share/doc/${P}
204 -DINSTALL_INCLUDEDIR=include/mysql
205 -DINSTALL_INFODIR=share/info
206 -DINSTALL_LIBDIR=$(get_libdir)/mysql
207 -DINSTALL_MANDIR=share/man
208 -DINSTALL_MYSQLDATADIR=/var/lib/mysql
209 -DINSTALL_MYSQLSHAREDIR=share/mysql
210 -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test
211 -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
212 -DINSTALL_SBINDIR=sbin
213 -DINSTALL_SCRIPTDIR=share/mysql/scripts
214 -DINSTALL_SQLBENCHDIR=share/mysql
215 -DINSTALL_SUPPORTFILESDIR=/usr/share/mysql
216 -DWITH_COMMENT="Gentoo Linux ${PF}"
217 -DWITHOUT_UNIT_TESTS=1
218 )
219
220 configure_cmake_locale
221
222 if use minimal ; then
223 configure_cmake_minimal
224 else
225 configure_cmake_standard
226 fi
227
228 # Bug #114895, bug #110149
229 filter-flags "-O" "-O[01]"
230
231 CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-strict-aliasing"
232 CXXFLAGS="${CXXFLAGS} -felide-constructors -fno-rtti"
233 CXXFLAGS="${CXXFLAGS} -fno-implicit-templates"
234 export CXXFLAGS
235
236 # bug #283926, with GCC4.4, this is required to get correct behavior.
237 append-flags -fno-strict-aliasing
238
239 cmake-utils_src_configure
240 }
241
242 # @FUNCTION: mysql-cmake_src_compile
243 # @DESCRIPTION:
244 # Compile the mysql code.
245 mysql-cmake_src_compile() {
246
247 debug-print-function ${FUNCNAME} "$@"
248
249 cmake-utils_src_compile
250 }
251
252 # @FUNCTION: mysql-cmake_src_install
253 # @DESCRIPTION:
254 # Install mysql.
255 mysql-cmake_src_install() {
256
257 debug-print-function ${FUNCNAME} "$@"
258
259 # Make sure the vars are correctly initialized
260 mysql_init_vars
261
262 cmake-utils_src_install
263
264 # Convenience links
265 einfo "Making Convenience links for mysqlcheck multi-call binary"
266 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlanalyze"
267 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair"
268 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize"
269
270 # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
271 rm -Rf "${D}/usr/data"
272
273 # Various junk (my-*.cnf moved elsewhere)
274 einfo "Removing duplicate /usr/share/mysql files"
275
276 # Clean up stuff for a minimal build
277 # if use minimal ; then
278 # einfo "Remove all extra content for minimal build"
279 # rm -Rf "${D}${MY_SHAREDSTATEDIR}"/{mysql-test,sql-bench}
280 # 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}
281 # rm -f "${D}/usr/sbin/mysqld"
282 # rm -f "${D}${MY_LIBDIR}"/lib{heap,merge,nisam,my{sys,strings,sqld,isammrg,isam},vio,dbug}.a
283 # fi
284
285 # Unless they explicitly specific USE=test, then do not install the
286 # testsuite. It DOES have a use to be installed, esp. when you want to do a
287 # validation of your database configuration after tuning it.
288 if ! use test ; then
289 rm -rf "${D}"/${MY_SHAREDSTATEDIR}/mysql-test
290 fi
291
292 # Configuration stuff
293 case ${MYSQL_PV_MAJOR} in
294 5.[1-9]|6*|7*) mysql_mycnf_version="5.1" ;;
295 esac
296 einfo "Building default my.cnf (${mysql_mycnf_version})"
297 insinto "${MY_SYSCONFDIR}"
298 doins scripts/mysqlaccess.conf
299 mycnf_src="my.cnf-${mysql_mycnf_version}"
300 sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
301 "${FILESDIR}/${mycnf_src}" \
302 > "${TMPDIR}/my.cnf.ok"
303 if use latin1 ; then
304 sed -i \
305 -e "/character-set/s|utf8|latin1|g" \
306 "${TMPDIR}/my.cnf.ok"
307 fi
308 newins "${TMPDIR}/my.cnf.ok" my.cnf
309
310 # Minimal builds don't have the MySQL server
311 if ! use minimal ; then
312 einfo "Creating initial directories"
313 # Empty directories ...
314 diropts "-m0750"
315 if [[ "${PREVIOUS_DATADIR}" != "yes" ]] ; then
316 dodir "${MY_DATADIR}"
317 keepdir "${MY_DATADIR}"
318 chown -R mysql:mysql "${D}/${MY_DATADIR}"
319 fi
320
321 diropts "-m0755"
322 for folder in "${MY_LOGDIR}" "/var/run/mysqld" ; do
323 dodir "${folder}"
324 keepdir "${folder}"
325 chown -R mysql:mysql "${D}/${folder}"
326 done
327 fi
328
329 # Minimal builds don't have the MySQL server
330 if ! use minimal ; then
331 einfo "Including support files and sample configurations"
332 docinto "support-files"
333 for script in \
334 "${S}"/support-files/my-*.cnf.sh \
335 "${S}"/support-files/magic \
336 "${S}"/support-files/ndb-config-2-node.ini.sh
337 do
338 [[ -f "$script" ]] && dodoc "${script}"
339 done
340
341 docinto "scripts"
342 for script in "${S}"/scripts/mysql* ; do
343 [[ -f "$script" ]] && [[ "${script%.sh}" == "${script}" ]] && dodoc "${script}"
344 done
345
346 fi
347
348 mysql_lib_symlinks "${D}"
349 }

  ViewVC Help
Powered by ViewVC 1.1.20