net-fs/openafs-kernel: remove vulnerable versions
[gentoo.git] / eclass / mysql-cmake.eclass
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
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 #       - Brian Evans <grknight@gentoo.org>
12 # @BLURB: This eclass provides the support for cmake based mysql releases
13 # @DESCRIPTION:
14 # The mysql-cmake.eclass provides the support to build the mysql
15 # ebuilds using the cmake build system. This eclass provides
16 # the src_prepare, src_configure, src_compile, and src_install
17 # phase hooks.
18
19 inherit cmake-utils flag-o-matic multilib prefix eutils
20
21 #
22 # HELPER FUNCTIONS:
23 #
24
25 # @FUNCTION: mysql_cmake_disable_test
26 # @DESCRIPTION:
27 # Helper function to disable specific tests.
28 mysql-cmake_disable_test() {
29
30         local rawtestname testname testsuite reason mysql_disabled_file mysql_disabled_dir
31         rawtestname="${1}" ; shift
32         reason="${@}"
33         ewarn "test '${rawtestname}' disabled: '${reason}'"
34
35         testsuite="${rawtestname/.*}"
36         testname="${rawtestname/*.}"
37         for mysql_disabled_file in \
38                 ${S}/mysql-test/disabled.def \
39                 ${S}/mysql-test/t/disabled.def ; do
40                 [[ -f ${mysql_disabled_file} ]] && break
41         done
42         #mysql_disabled_file="${S}/mysql-test/t/disabled.def"
43         #einfo "rawtestname=${rawtestname} testname=${testname} testsuite=${testsuite}"
44         echo ${testname} : ${reason} >> "${mysql_disabled_file}"
45
46         if [[ ( -n ${testsuite} ) && ( ${testsuite} != "main" ) ]]; then
47                 for mysql_disabled_file in \
48                         ${S}/mysql-test/suite/${testsuite}/disabled.def \
49                         ${S}/mysql-test/suite/${testsuite}/t/disabled.def \
50                         FAILED ; do
51                         [[ -f ${mysql_disabled_file} ]] && break
52                 done
53                 if [[ ${mysql_disabled_file} != "FAILED" ]]; then
54                         echo "${testname} : ${reason}" >> "${mysql_disabled_file}"
55                 else
56                         for mysql_disabled_dir in \
57                                 ${S}/mysql-test/suite/${testsuite} \
58                                 ${S}/mysql-test/suite/${testsuite}/t \
59                                 FAILED ; do
60                                 [[ -d ${mysql_disabled_dir} ]] && break
61                         done
62                         if [[ ${mysql_disabled_dir} != "FAILED" ]]; then
63                                 echo "${testname} : ${reason}" >> "${mysql_disabled_dir}/disabled.def"
64                         else
65                                 ewarn "Could not find testsuite disabled.def location for ${rawtestname}"
66                         fi
67                 fi
68         fi
69 }
70
71 # @FUNCTION: mysql-cmake_use_plugin
72 # @DESCRIPTION:
73 # Helper function to enable/disable plugins by use flags
74 # cmake-utils_use_with is not enough as some references check WITH_ (0|1)
75 # and some check WITHOUT_. Also, this can easily extend to non-storage plugins.
76 mysql-cmake_use_plugin() {
77         [[ -z $2 ]] && die "mysql-cmake_use_plugin <USE flag> <flag name>"
78         if use_if_iuse $1 ; then
79                 echo "-DWITH_$2=1 -DPLUGIN_$2=YES"
80         else
81                 echo "-DWITHOUT_$2=1 -DWITH_$2=0 -DPLUGIN_$2=NO"
82         fi
83 }
84
85 # @FUNCTION: configure_cmake_locale
86 # @DESCRIPTION:
87 # Helper function to configure locale cmake options
88 configure_cmake_locale() {
89
90         if use_if_iuse minimal ; then
91                 :
92         elif ! in_iuse server || use_if_iuse server ; then
93                 if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then
94                         ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
95                         ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
96                         ewarn "You MUST file bugs without these variables set."
97
98                         mycmakeargs+=(
99                                 -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
100                                 -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
101                         )
102
103                 elif ! use latin1 ; then
104                         mycmakeargs+=(
105                                 -DDEFAULT_CHARSET=utf8
106                                 -DDEFAULT_COLLATION=utf8_general_ci
107                         )
108                 else
109                         mycmakeargs+=(
110                                 -DDEFAULT_CHARSET=latin1
111                                 -DDEFAULT_COLLATION=latin1_swedish_ci
112                         )
113                 fi
114         fi
115 }
116
117 # @FUNCTION: configure_cmake_minimal
118 # @DESCRIPTION:
119 # Helper function to configure minimal build
120 configure_cmake_minimal() {
121
122         mycmakeargs+=(
123                 -DWITHOUT_SERVER=1
124                 -DWITHOUT_EMBEDDED_SERVER=1
125                 -DEXTRA_CHARSETS=none
126                 -DINSTALL_SQLBENCHDIR=
127                 -DWITHOUT_ARCHIVE_STORAGE_ENGINE=1
128                 -DWITHOUT_BLACKHOLE_STORAGE_ENGINE=1
129                 -DWITHOUT_CSV_STORAGE_ENGINE=1
130                 -DWITHOUT_FEDERATED_STORAGE_ENGINE=1
131                 -DWITHOUT_HEAP_STORAGE_ENGINE=1
132                 -DWITHOUT_INNOBASE_STORAGE_ENGINE=1
133                 -DWITHOUT_MYISAMMRG_STORAGE_ENGINE=1
134                 -DWITHOUT_MYISAM_STORAGE_ENGINE=1
135                 -DWITHOUT_PARTITION_STORAGE_ENGINE=1
136                 -DPLUGIN_ARCHIVE=NO
137                 -DPLUGIN_BLACKHOLE=NO
138                 -DPLUGIN_CSV=NO
139                 -DPLUGIN_FEDERATED=NO
140                 -DPLUGIN_HEAP=NO
141                 -DPLUGIN_INNOBASE=NO
142                 -DPLUGIN_MYISAMMRG=NO
143                 -DPLUGIN_MYISAM=NO
144                 -DPLUGIN_PARTITION=NO
145         )
146 }
147
148 # @FUNCTION: configure_cmake_standard
149 # @DESCRIPTION:
150 # Helper function to configure standard build
151 configure_cmake_standard() {
152
153         mycmakeargs+=(
154                 -DEXTRA_CHARSETS=all
155                 -DMYSQL_USER=mysql
156                 -DMYSQL_UNIX_ADDR=${EPREFIX}/var/run/mysqld/mysqld.sock
157                 $(cmake-utils_use_disable !static SHARED)
158                 $(cmake-utils_use_with debug)
159                 $(cmake-utils_use_with embedded EMBEDDED_SERVER)
160                 $(cmake-utils_use_with profiling)
161                 $(cmake-utils_use_enable systemtap DTRACE)
162         )
163
164         if use static; then
165                 mycmakeargs+=( -DWITH_PIC=1 )
166         fi
167
168         if use jemalloc; then
169                 mycmakeargs+=( -DWITH_SAFEMALLOC=OFF )
170         fi
171
172         if use tcmalloc; then
173                 mycmakeargs+=( -DWITH_SAFEMALLOC=OFF )
174         fi
175
176         # Storage engines
177         mycmakeargs+=(
178                 -DWITH_ARCHIVE_STORAGE_ENGINE=1
179                 -DWITH_BLACKHOLE_STORAGE_ENGINE=1
180                 -DWITH_CSV_STORAGE_ENGINE=1
181                 -DWITH_HEAP_STORAGE_ENGINE=1
182                 -DWITH_INNOBASE_STORAGE_ENGINE=1
183                 -DWITH_MYISAMMRG_STORAGE_ENGINE=1
184                 -DWITH_MYISAM_STORAGE_ENGINE=1
185                 -DWITH_PARTITION_STORAGE_ENGINE=1
186         )
187
188         if in_iuse pbxt ; then
189                 mycmakeargs+=( $(cmake-utils_use_with pbxt PBXT_STORAGE_ENGINE) )
190         fi
191
192         if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]]; then
193
194                 # Federated{,X} must be treated special otherwise they will not be built as plugins
195                 if ! use extraengine ; then
196                         mycmakeargs+=(
197                                 -DWITHOUT_FEDERATED_STORAGE_ENGINE=1
198                                 -DPLUGIN_FEDERATED=NO
199                                 -DWITHOUT_FEDERATEDX_STORAGE_ENGINE=1
200                                 -DPLUGIN_FEDERATEDX=NO )
201                 fi
202
203                 mycmakeargs+=(
204                         $(mysql-cmake_use_plugin oqgraph OQGRAPH)
205                         $(mysql-cmake_use_plugin sphinx SPHINX)
206                         $(mysql-cmake_use_plugin tokudb TOKUDB)
207                         $(mysql-cmake_use_plugin pam AUTH_PAM)
208                 )
209
210                 if mysql_version_is_at_least 10.0.5 ; then
211                         # CassandraSE needs Apache Thrift which is not in portage
212                         mycmakeargs+=(
213                                 -DWITHOUT_CASSANDRA=1 -DWITH_CASSANDRA=0
214                                 -DPLUGIN_CASSANDRA=NO
215                                 $(mysql-cmake_use_plugin extraengine SEQUENCE)
216                                 $(mysql-cmake_use_plugin extraengine SPIDER)
217                                 $(mysql-cmake_use_plugin extraengine CONNECT)
218                                 -DCONNECT_WITH_MYSQL=1
219                                 $(cmake-utils_use xml CONNECT_WITH_LIBXML2)
220                                 $(cmake-utils_use odbc CONNECT_WITH_ODBC)
221                         )
222                 fi
223
224                 if in_iuse mroonga ; then
225                         use mroonga || mycmakeargs+=( -DWITHOUT_MROONGA=1 )
226                 else
227                         mycmakeargs+=( -DWITHOUT_MROONGA=1 )
228                 fi
229
230                 if in_iuse galera ; then
231                         mycmakeargs+=( $(cmake-utils_use_with galera WSREP) )
232                 fi
233
234                 if mysql_version_is_at_least "10.1.1" ; then
235                         mycmakeargs+=(  $(cmake-utils_use_with innodb-lz4 INNODB_LZ4)
236                                         $(cmake-utils_use_with innodb-lzo INNODB_LZO) )
237                 fi
238
239                 if in_iuse innodb-snappy ; then
240                         mycmakeargs+=( $(cmake-utils_use_with innodb-snappy INNODB_SNAPPY)  )
241                 fi
242
243                 if mysql_version_is_at_least "10.1.2" ; then
244                         mycmakeargs+=( $(mysql-cmake_use_plugin cracklib CRACKLIB_PASSWORD_CHECK ) )
245                 fi
246         else
247                 mycmakeargs+=( $(cmake-utils_use_with extraengine FEDERATED_STORAGE_ENGINE) )
248         fi
249
250         if [[ ${PN} == "percona-server" ]]; then
251                 mycmakeargs+=(
252                         $(cmake-utils_use_with pam PAM)
253                 )
254                 if in_iuse tokudb ; then
255                         # TokuDB Backup plugin requires valgrind unconditionally
256                         mycmakeargs+=(
257                                 $(mysql-cmake_use_plugin tokudb TOKUDB)
258                                 $(usex tokudb-backup-plugin "" -DTOKUDB_BACKUP_DISABLED=1)
259                         )
260                 fi
261         fi
262
263         if [[ ${PN} == "mysql-cluster" ]]; then
264                 # TODO: This really should include the following options,
265                 # but the memcached package doesn't install the files it seeks.
266                 # -DWITH_BUNDLED_MEMCACHED=OFF
267                 # -DMEMCACHED_HOME=${EPREFIX}/usr
268                 mycmakeargs+=(
269                         -DWITH_BUNDLED_LIBEVENT=OFF
270                         $(cmake-utils_use_with java NDB_JAVA)
271                 )
272         fi
273 }
274
275 #
276 # EBUILD FUNCTIONS
277 #
278
279 # @FUNCTION: mysql-cmake_src_prepare
280 # @DESCRIPTION:
281 # Apply patches to the source code and remove unneeded bundled libs.
282 mysql-cmake_src_prepare() {
283
284         debug-print-function ${FUNCNAME} "$@"
285
286         cd "${S}"
287
288         if [[ ${MY_EXTRAS_VER} != none ]]; then
289
290                 # Apply the patches for this MySQL version
291                 EPATCH_SUFFIX="patch"
292                 mkdir -p "${EPATCH_SOURCE}" || die "Unable to create epatch directory"
293                 # Clean out old items
294                 rm -f "${EPATCH_SOURCE}"/*
295                 # Now link in right patches
296                 mysql_mv_patches
297                 # And apply
298                 epatch
299         fi
300
301         # last -fPIC fixup, per bug #305873
302         i="${S}"/storage/innodb_plugin/plug.in
303         [[ -f ${i} ]] && sed -i -e '/CFLAGS/s,-prefer-non-pic,,g' "${i}"
304
305         rm -f "scripts/mysqlbug"
306         if use jemalloc && ! ( [[ ${PN} == "mariadb" ]] && mysql_version_is_at_least "5.5.33" ); then
307                 echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die
308         fi
309
310         if use tcmalloc; then
311                 echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt"
312         fi
313
314         if in_iuse tokudb ; then
315                 # Don't build bundled xz-utils
316                 if [[ -d "${S}/storage/tokudb/ft-index" ]] ; then
317                         rm -f "${S}/storage/tokudb/ft-index/cmake_modules/TokuThirdParty.cmake" || die
318                         touch "${S}/storage/tokudb/ft-index/cmake_modules/TokuThirdParty.cmake" || die
319                         sed -i 's/ build_lzma//' "${S}/storage/tokudb/ft-index/ft/CMakeLists.txt" || die
320                 elif [[ -d "${S}/storage/tokudb/PerconaFT" ]] ; then
321                         rm "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die
322                         touch "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die
323                         sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die
324                         sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die
325                 fi
326
327                 if [[ -d "${S}/plugin/tokudb-backup-plugin" ]] && ! use tokudb-backup-plugin ; then
328                          rm -r "${S}/plugin/tokudb-backup-plugin/Percona-TokuBackup" || die
329                 fi
330         fi
331
332         # Remove the bundled groonga if it exists
333         # There is no CMake flag, it simply checks for existance
334         if [[ -d "${S}"/storage/mroonga/vendor/groonga ]] ; then
335                 rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga"
336         fi
337
338         epatch_user
339 }
340
341 # @FUNCTION: mysql-cmake_src_configure
342 # @DESCRIPTION:
343 # Configure mysql to build the code for Gentoo respecting the use flags.
344 mysql-cmake_src_configure() {
345
346         debug-print-function ${FUNCNAME} "$@"
347
348         CMAKE_BUILD_TYPE="RelWithDebInfo"
349
350         # debug hack wrt #497532
351         mycmakeargs=(
352                 -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug "" "-DNDEBUG")"
353                 -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug "" "-DNDEBUG")"
354                 -DCMAKE_INSTALL_PREFIX=${EPREFIX}/usr
355                 -DMYSQL_DATADIR=${EPREFIX}/var/lib/mysql
356                 -DSYSCONFDIR=${EPREFIX}/etc/mysql
357                 -DINSTALL_BINDIR=bin
358                 -DINSTALL_DOCDIR=share/doc/${P}
359                 -DINSTALL_DOCREADMEDIR=share/doc/${P}
360                 -DINSTALL_INCLUDEDIR=include/mysql
361                 -DINSTALL_INFODIR=share/info
362                 -DINSTALL_LIBDIR=$(get_libdir)
363                 -DINSTALL_ELIBDIR=$(get_libdir)/mysql
364                 -DINSTALL_MANDIR=share/man
365                 -DINSTALL_MYSQLDATADIR=${EPREFIX}/var/lib/mysql
366                 -DINSTALL_MYSQLSHAREDIR=share/mysql
367                 -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test
368                 -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
369                 -DINSTALL_SBINDIR=sbin
370                 -DINSTALL_SCRIPTDIR=share/mysql/scripts
371                 -DINSTALL_SQLBENCHDIR=share/mysql
372                 -DINSTALL_SUPPORTFILESDIR=${EPREFIX}/usr/share/mysql
373                 -DWITH_COMMENT="Gentoo Linux ${PF}"
374                 $(cmake-utils_use_with test UNIT_TESTS)
375                 -DWITH_LIBEDIT=0
376                 -DWITH_ZLIB=system
377                 -DWITHOUT_LIBWRAP=1
378                 -DENABLED_LOCAL_INFILE=1
379                 $(cmake-utils_use_enable static-libs STATIC_LIBS)
380                 -DWITH_SSL=$(usex ssl system bundled)
381                 -DWITH_DEFAULT_COMPILER_OPTIONS=0
382                 -DWITH_DEFAULT_FEATURE_SET=0
383         )
384
385         if in_iuse bindist ; then
386                 mycmakeargs+=(
387                         -DWITH_READLINE=$(usex bindist 1 0)
388                         -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1)
389                         $(usex bindist -DHAVE_BFD_H=0 '')
390                 )
391         fi
392
393         mycmakeargs+=( -DWITH_EDITLINE=system )
394
395         if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
396                 mycmakeargs+=(
397                         -DWITH_JEMALLOC=$(usex jemalloc system)
398                 )
399                 mysql_version_is_at_least "10.0.9" && mycmakeargs+=( -DWITH_PCRE=system )
400         fi
401
402         configure_cmake_locale
403
404         if use_if_iuse minimal ; then
405                 configure_cmake_minimal
406         else
407                 configure_cmake_standard
408         fi
409
410         # Bug #114895, bug #110149
411         filter-flags "-O" "-O[01]"
412
413         CXXFLAGS="${CXXFLAGS} -fno-strict-aliasing"
414         CXXFLAGS="${CXXFLAGS} -felide-constructors"
415         # Causes linkage failures. Upstream bug #59607 removes it
416         if ! mysql_version_is_at_least "5.6" ; then
417                 CXXFLAGS="${CXXFLAGS} -fno-implicit-templates"
418         fi
419         # As of 5.7, exceptions and rtti are used!
420         if [[ ${PN} -eq 'percona-server' ]] && mysql_version_is_at_least "5.6.26" ; then
421                 CXXFLAGS="${CXXFLAGS} -fno-rtti"
422         elif ! mysql_version_is_at_least "5.7" ; then
423                 CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-rtti"
424         fi
425         export CXXFLAGS
426
427         # bug #283926, with GCC4.4, this is required to get correct behavior.
428         append-flags -fno-strict-aliasing
429
430         cmake-utils_src_configure
431 }
432
433 # @FUNCTION: mysql-cmake_src_compile
434 # @DESCRIPTION:
435 # Compile the mysql code.
436 mysql-cmake_src_compile() {
437
438         debug-print-function ${FUNCNAME} "$@"
439
440         cmake-utils_src_compile
441 }
442
443 # @FUNCTION: mysql-cmake_src_install
444 # @DESCRIPTION:
445 # Install mysql.
446 mysql-cmake_src_install() {
447
448         debug-print-function ${FUNCNAME} "$@"
449
450         # Make sure the vars are correctly initialized
451         mysql_init_vars
452
453         cmake-utils_src_install
454
455         if ! in_iuse tools || use_if_iuse tools ; then
456                 # Convenience links
457                 einfo "Making Convenience links for mysqlcheck multi-call binary"
458                 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlanalyze"
459                 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair"
460                 dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize"
461         fi
462
463         # Create a mariadb_config symlink
464         [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] && dosym "/usr/bin/mysql_config" "/usr/bin/mariadb_config"
465
466         # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
467         rm -Rf "${ED}/usr/data"
468
469         # Various junk (my-*.cnf moved elsewhere)
470         einfo "Removing duplicate /usr/share/mysql files"
471
472         # Unless they explicitly specific USE=test, then do not install the
473         # testsuite. It DOES have a use to be installed, esp. when you want to do a
474         # validation of your database configuration after tuning it.
475         if ! use test ; then
476                 rm -rf "${D}"/${MY_SHAREDSTATEDIR}/mysql-test
477         fi
478
479         # Configuration stuff
480         case ${MYSQL_PV_MAJOR} in
481                 5.[1-4]*) mysql_mycnf_version="5.1" ;;
482                 5.5) mysql_mycnf_version="5.5" ;;
483                 5.[6-9]|6*|7*|8*|9*|10*) mysql_mycnf_version="5.6" ;;
484         esac
485         einfo "Building default my.cnf (${mysql_mycnf_version})"
486         insinto "${MY_SYSCONFDIR#${EPREFIX}}"
487         [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf
488         mycnf_src="my.cnf-${mysql_mycnf_version}"
489         sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
490                 "${FILESDIR}/${mycnf_src}" \
491                 > "${TMPDIR}/my.cnf.ok" || die
492         use prefix && sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' "${TMPDIR}/my.cnf.ok"
493         if use latin1 ; then
494                 sed -i \
495                         -e "/character-set/s|utf8|latin1|g" \
496                         "${TMPDIR}/my.cnf.ok" || die
497         fi
498         eprefixify "${TMPDIR}/my.cnf.ok"
499         newins "${TMPDIR}/my.cnf.ok" my.cnf
500
501         # Minimal builds don't have the MySQL server
502         if use_if_iuse minimal ; then
503                 :
504         elif ! in_iuse server || use_if_iuse server ; then
505                 einfo "Creating initial directories"
506                 # Empty directories ...
507                 diropts "-m0750"
508                 if [[ ${PREVIOUS_DATADIR} != "yes" ]] ; then
509                         dodir "${MY_DATADIR#${EPREFIX}}"
510                         keepdir "${MY_DATADIR#${EPREFIX}}"
511                         chown -R mysql:mysql "${D}/${MY_DATADIR}"
512                 fi
513
514                 diropts "-m0755"
515                 for folder in "${MY_LOGDIR#${EPREFIX}}" ; do
516                         dodir "${folder}"
517                         keepdir "${folder}"
518                         chown -R mysql:mysql "${ED}/${folder}"
519                 done
520         fi
521
522         # Minimal builds don't have the MySQL server
523         if use_if_iuse minimal ; then
524                 :
525         elif ! in_iuse server || use_if_iuse server; then
526                 einfo "Including support files and sample configurations"
527                 docinto "support-files"
528                 for script in \
529                         "${S}"/support-files/my-*.cnf.sh \
530                         "${S}"/support-files/magic \
531                         "${S}"/support-files/ndb-config-2-node.ini.sh
532                 do
533                         [[ -f $script ]] && dodoc "${script}"
534                 done
535
536                 docinto "scripts"
537                 for script in "${S}"/scripts/mysql* ; do
538                         [[ ( -f $script ) && ( ${script%.sh} == ${script} ) ]] && dodoc "${script}"
539                 done
540         fi
541
542         #Remove mytop if perl is not selected
543         [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] && ! use perl \
544         && rm -f "${ED}/usr/bin/mytop"
545
546         in_iuse client-libs && ! use client-libs && return
547
548         # Percona has decided to rename libmysqlclient to libperconaserverclient
549         # Use a symlink to preserve linkages for those who don't use mysql_config
550         if [[ ${PN} == "percona-server" ]] && mysql_version_is_at_least "5.5.36" ; then
551                 dosym libperconaserverclient.so /usr/$(get_libdir)/libmysqlclient.so
552                 dosym libperconaserverclient.so /usr/$(get_libdir)/libmysqlclient_r.so
553                 if use static-libs ; then
554                         dosym libperconaserverclient.a /usr/$(get_libdir)/libmysqlclient.a
555                         dosym libperconaserverclient.a /usr/$(get_libdir)/libmysqlclient_r.a
556                 fi
557         fi
558 }