# Maintainer: Developer <dev@opalos.org>
# Maintainer: Developer <dev@opalos.org>

pkgname=(libmaxminddb mmdblookup)

pkgver=%version%
pkgrel=%release%
pkgdesc="MaxMind GeoIP2 database - split package with library and utilities"
license=('Apache')
arch=('x86_64')
url="https://dev.maxmind.com/geoip/geoip2/downloadable/"
optdepends=('geoip2-database: IP geolocation databases')
source=("https://github.com/maxmind/libmaxminddb/releases/download/$pkgver/libmaxminddb-$pkgver.tar.gz")
sha256sums=('a80682a89d915fdf60b35d316232fb04ebf36fff27fda9bd39fe8a38d3cd3f12')

build() {
	cd "$srcdir"/libmaxminddb-$pkgver
	./configure --prefix=/usr
	make
}

check() {
	cd "$srcdir"/libmaxminddb-$pkgver
	make check
}

package_libmaxminddb() {
	pkgdesc="MaxMindDB GeoIP2 database library"
	depends=('glibc')

	cd "$srcdir"/libmaxminddb-$pkgver
	make PREFIX=/usr DESTDIR="$pkgdir" install
	rm -rf "$pkgdir"/usr/{bin,share/man/man1}
}

package_mmdblookup() {
	pkgdesc="MaxMindDB GeoIP2 lookup utility"
	depends=('libmaxminddb')

	cd "$srcdir"/libmaxminddb-$pkgver
	make PREFIX=/usr DESTDIR="$pkgdir" install
	rm -rf "$pkgdir"/usr/{lib,include,share/man/man3}
}
