# Contributor: Bhushan Shah <bshah@kde.org>
# Contributor: Bart Ribbers <bribbers@disroot.org>
maintainer="fossdd <fossdd@pwned.life>"
pkgname=libphonenumber
pkgver=9.0.5
pkgrel=0
pkgdesc="Library for parsing, formatting, and validating international phone numbers."
url="https://github.com/google/libphonenumber"
arch="all"
license="Apache-2.0"
depends_dev="
	abseil-cpp-dev
	icu-dev
	protobuf-dev
	"
makedepends="$depends_dev
	cmake
	gtest-dev
	ninja
	"
checkdepends="icu-data-full"
subpackages="$pkgname-static libgeocoding $pkgname-dev"
source="https://github.com/google/libphonenumber/archive/v$pkgver/libphonenumber-v$pkgver.tar.gz
	system-abseil.patch
	"

build() {
	cd cpp
	LDFLAGS="$LDFLAGS -Wl,--copy-dt-needed-entries" \
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DREGENERATE_METADATA=OFF \
		-DUSE_BOOST=OFF \
		-DUSE_STDMUTEX=ON
	cmake --build build
}

check() {
	cd cpp
	./build/libphonenumber_test
}

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

libgeocoding() {
	amove usr/lib/libgeocoding.so.*
}

sha512sums="
965d4385027a07ed55cf01168530453e793ad5c8954ad5b94959396a4b7902e22f72d9f73c88a2e45f7502922783a0bae568040822e7bf4899bd26e6b0f86b2d  libphonenumber-v9.0.5.tar.gz
03c1eb32208a868bcacf92eb42b1f3f009bcc898fa6446594a3e79baadbef5fb53bbe829adfb7d0c8ebebdd37898c6686ff837320d258cd47ef5de7a6bf341bc  system-abseil.patch
"
