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

Contents of /eclass/mysql-cmake.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations) (download)
Tue Dec 27 07:34:18 2011 UTC (2 years, 7 months ago) by robbat2
Branch: MAIN
Changes since 1.2: +2 -7 lines
Refactor USE=static cmake code.

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

  ViewVC Help
Powered by ViewVC 1.1.20