1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit cmake-multilib eutils flag-o-matic versionator
8 MAJOR="$(get_version_component_range 1-2 $PV)"
9 MY_PN="mysql-connector-odbc"
10 MY_P="${MY_PN}-${PV/_p/r}-src"
12 DESCRIPTION="ODBC driver for MySQL"
13 HOMEPAGE="http://www.mysql.com/products/myodbc/"
14 SRC_URI="mirror://mysql/Downloads/Connector-ODBC/${MAJOR}/${MY_P}.tar.gz"
19 KEYWORDS="~amd64 ~ppc ~x86"
22 # Does not build with mysql-connector-c
24 dev-db/unixODBC[${MULTILIB_USEDEP}]
25 ~virtual/libmysqlclient-18[${MULTILIB_USEDEP}]
27 !app-emulation/emul-linux-x86-db[-abi_x86_32(-)]
29 !dev-db/mysql-connector-c
35 DRIVER_NAME="${PN}-${SLOT}"
39 sed -i -e "s/ADD_SUBDIRECTORY(test)//" \
42 # Fix as-needed on the installer binary
43 echo "TARGET_LINK_LIBRARIES(myodbc-installer odbc)" >> "${S}/installer/CMakeLists.txt"
45 # Patch document path so it doesn't install files to /usr
46 epatch "${FILESDIR}/cmake-doc-path.patch" \
47 "${FILESDIR}/${PV}-r1-cxxlinkage.patch" \
48 "${FILESDIR}/${PV}-mariadb-dynamic-array.patch" \
49 "${FILESDIR}/${PV}-my_malloc.patch"
52 multilib_src_configure() {
53 # The RPM_BUILD flag does nothing except install to /usr/lib64 when "x86_64"
54 # MYSQL_CXX_LINKAGE expects "mysql_config --cxxflags" which doesn't exist on MariaDB
58 -DMYSQLCLIENT_LIB_NAME="libmysqlclient_r.so"
59 -DWITH_DOCUMENTATION_INSTALL_PATH=/usr/share/doc/${PF}
60 -DMYSQL_LIB_DIR="${ROOT}/usr/$(get_libdir)"
61 -DLIB_SUBDIR="$(get_libdir)"
63 cmake-utils_src_configure
66 multilib_src_install_all() {
67 debug-print-function ${FUNCNAME} "$@"
69 dodir /usr/share/${PN}-${SLOT}
70 for i in odbc.ini odbcinst.ini; do
73 -e "s,__PN__,${DRIVER_NAME},g" \
74 -e "s,__PF__,${MAJOR},g" \
75 -e "s,libmyodbc3.so,libmyodbc${SLOT:0:1}a.so,g" \
76 >"${D}"/usr/share/${PN}-${SLOT}/${i} \
77 <"${FILESDIR}"/${i}.m4 \
78 || die "Failed to build $i"
80 mv "${D}/usr/bin/myodbc-installer" \
81 "${D}/usr/bin/myodbc-installer-${MAJOR}" || die "failed to move slotted binary"
86 [ "${ROOT}" != "/" ] && \
87 die 'Sorry, non-standard ROOT setting is not supported :-('
89 local msg='MySQL ODBC driver'
90 local drivers=$(/usr/bin/odbcinst -q -d)
92 if echo $drivers | grep -vq "^\[${DRIVER_NAME}\]$" ; then
93 ebegin "Installing ${msg}"
94 /usr/bin/odbcinst -i -d -f /usr/share/${PN}-${SLOT}/odbcinst.ini
99 einfo "Skipping already installed ${msg}"
102 local sources=$(/usr/bin/odbcinst -q -s)
103 msg='sample MySQL ODBC DSN'
104 if echo $sources | grep -vq "^\[${DRIVER_NAME}-test\]$"; then
105 ebegin "Installing ${msg}"
106 /usr/bin/odbcinst -i -s -l -f /usr/share/${PN}-${SLOT}/odbc.ini
111 einfo "Skipping already installed ${msg}"
117 elog "If this is a new install, please run the following command"
118 elog "to configure the MySQL ODBC drivers and sources:"
119 elog "emerge --config =${CATEGORY}/${PF}"
120 elog "Please note that the driver name used to form the DSN now includes the SLOT."
121 elog "The myodbc-install utility is installed as myodbc-install-${MAJOR}"