maintainer="Bart Ribbers <bribbers@disroot.org>"
pkgname=libpinyin
pkgver=2.10.2
pkgrel=0
pkgdesc="Library to deal with pinyin"
url="https://github.com/libpinyin/libpinyin"
arch="all"
license="GPL-3.0-or-later"
depends_dev="kyotocabinet-dev"
makedepends="$depends_dev
	autoconf
	automake
	glib-dev
	libtool
	"
subpackages="$pkgname-static $pkgname-dev $pkgname-doc"
source="https://github.com/libpinyin/libpinyin/releases/download/$pkgver/libpinyin-$pkgver.tar.gz
	disable-test_ngram_patch
	"

prepare() {
	default_prepare

	case $CARCH in
	a*|loongarch64|s390x|x86|ppc*)
		# this test is failing on the package builders for these architectures
		# but not in CI
		patch -p1 < "$srcdir"/disable-test_ngram_patch
		;;
	esac
}

build() {
	./configure \
		--prefix=/usr \
		--enable-libzhuyin \
		--with-dbm=KyotoCabinet
	make
}

check() {
	make check
}

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

sha512sums="
120ca46df86accc9e223bc4736de955dd34009853cb19be98514ad30c283eb04df77af6e76572ff41f0ac2d853be302cf71cafff97a9fa5962316be14164d196  libpinyin-2.10.2.tar.gz
b8e43152caa30b0eeb69dd0498416792988ccb6434b10a06b258320a3c6b3789e1a1cdf07c694f0d6f42ed3466bc20bf45f065c584dbc81e5edc410d3d112c5f  disable-test_ngram_patch
"
