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