# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=libpinyin
pkgver=2.9.92
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)
		# 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="
0ce0c950bb77511c73a5f4e587aa72dce7a5541a748d4e5cc6e9df1660146ef03d259da8c9fee42768a468f91facff489bf604ebdeafe01c5719b13e68a8b7fb  libpinyin-2.9.92.tar.gz
b8e43152caa30b0eeb69dd0498416792988ccb6434b10a06b258320a3c6b3789e1a1cdf07c694f0d6f42ed3466bc20bf45f065c584dbc81e5edc410d3d112c5f  disable-test_ngram_patch
"
