# Contributor: Joe Searle <joe@jsearle.net>
# Maintainer: Noel Kuntze <noel.kuntze@thermi.consulting>
pkgname=mariadb-connector-odbc
pkgver=3.1.20
pkgrel=0
pkgdesc="MariaDB Connector/ODBC database driver"
url="https://github.com/mariadb-corporation/mariadb-connector-odbc"
arch="all"
license="LGPL-2.1-only"
options="!check" # 'test' directory not included in releases
makedepends="cmake samurai openssl-dev>3 unixodbc-dev mariadb-connector-c-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/mariadb-corporation/mariadb-connector-odbc/archive/$pkgver.tar.gz"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	# Link to /usr/include/mysql necessary when using system installed mariadb-connector-c
	CFLAGS="$CFLAGS -I/usr/include/mysql" \
		cmake -G Ninja -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DUSE_SYSTEM_INSTALLED_LIB=True \
		-DWITH_SSL=OPENSSL \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	# Remove license files
	rm -rf "$pkgdir"/usr/docs
}

sha512sums="
f1ebe273855be0ca082ebfcf57c7104a554dece8f718cc8216f4e7f59dde2cec98efd8d3b8f541ba9b92f4e6c1d7f7013d4225621d489a8fd4d6a76e784b178e  mariadb-connector-odbc-3.1.20.tar.gz
"
