# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
pkgname=mongo-c-driver
pkgver=1.9.2
pkgrel=1
pkgdesc="Client library written in C for MongoDB"
url="https://github.com/mongodb/mongo-c-driver"
arch="all !x86 !armhf" # testsuite fails on x86 and armhf
license="Apache-2.0"
depends=
depends_dev="libressl-dev snappy-dev zlib-dev"
makedepends="$depends_dev autoconf automake libbson-dev libtool py3-sphinx"
install=
subpackages="$pkgname-dev $pkgname-doc"
source="https://github.com/mongodb/$pkgname/releases/download/$pkgver/$pkgname-$pkgver.tar.gz"
builddir="$srcdir/$pkgname-$pkgver"

case "$CARCH" in
	# FIXME: Tests hang on aarch64.
	aarch64) options="!check";;
esac

build() {
	cd "$builddir"
	SPHINX_BUILD=/usr/bin/sphinx-build-3 ./configure \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--enable-man-pages=yes \
		--enable-tests=yes \
		--disable-automatic-init-and-cleanup \
		--with-libbson=system \
		--with-zlib=system
	make
}

check() {
	cd "$builddir"
	MONGOC_TEST_SKIP_LIVE=on make check
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install
}

sha512sums="25fd78e23300c56dd72becd64bd47573e0c2ed9c5d2af1a917c2dbbfeea69054cc9c6eed6965be20aa325fa68a5c37791495cad44a164134868fa2ae823ea2ef  mongo-c-driver-1.9.2.tar.gz"
