# Packager = Tuxcore <dev@tuxcore.org> 
pkgname=(libmaxminddb mmdblookup)

pkgver=1.11.0
pkgrel=1
pkgdesc="MaxMind GeoIP2 database - split package with library and utilities"
license=('Apache-2.0')
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=('b2eea79a96fed77ad4d6c39ec34fed83d45fcb75a31c58956813d58dcf30b19f')

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}
}
