# Template file for 'libpinyin'
pkgname=libpinyin
version=2.6.0
revision=3
build_style=gnu-configure
configure_args="--enable-libzhuyin"
hostmakedepends="intltool libtool pkg-config autoconf-archive autoconf automake"
makedepends="db-devel libglib-devel"
depends="libpinyin-common>=${version}_${revision}"
short_desc="Support library for PinYin"
maintainer="Ben Sung Hsu <pobetiger+github@gmail.com>"
license="GPL-3.0-or-later"
homepage="https://github.com/libpinyin/libpinyin"
changelog="https://raw.githubusercontent.com/libpinyin/libpinyin/${version}/ChangeLog"
distfiles="https://github.com/libpinyin/libpinyin/archive/${version}.tar.gz
 http://downloads.sourceforge.net/libpinyin/models/model19.text.tar.gz"
checksum="2b52f617a99567a8ace478ee82ccc62d1761e3d1db2f1e05ba05b416708c35d2
 56422a4ee5966c2c809dd065692590ee8def934e52edbbe249b8488daaa1f50b"
nocross="Requires data generators compiled against target system"
skip_extraction="model19.text.tar.gz"

post_extract() {
	bsdtar -C data -xf $XBPS_SRCDISTDIR/$pkgname-$version/model19.text.tar.gz
}

pre_configure() {
	NOCONFIGURE=1 ./autogen.sh
}

libpinyin-common_package() {
	short_desc="Common files for libpinyin and libzhuyin"
	pkg_install() {
		vmove usr/lib/libpinyin
	}
}

libzhuyin_package() {
	short_desc="${short_desc/PinYin/ZhuYin}"
	depends="libpinyin-common>=${version}_${revision}"
	pkg_install() {
		vmove "usr/lib/libzhuyin.so.*"
	}
}

libpinyin-utils_package() {
	short_desc="Support utilities for libpinyin and libzhuyin"
	pkg_install() {
		vmove usr/bin
		vmove usr/share/man/man1
	}
}

libpinyin-common-devel_package() {
	short_desc="Common files for libpinyin and libzhuyin"
	pkg_install() {
		vmove "usr/include/libpinyin-2.6.0/novel*"
	}
}

libpinyin-devel_package() {
	depends="libglib-devel libpinyin-${version}_${revision}
	 libpinyin-common-devel-${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove "usr/include/libpinyin-2.6.0/pinyin*"
		vmove usr/lib/pkgconfig/libpinyin.pc
		vmove "usr/lib/libpinyin.so"
		vmove "usr/lib/libpinyin.a"
	}
}

libzhuyin-devel_package() {
	depends="libglib-devel libzhuyin-${version}_${revision}
	 libpinyin-devel-${version}_${revision}"
	short_desc="${short_desc/PinYin/ZhuYin} - development files"
	pkg_install() {
		vmove "usr/include/libpinyin-2.6.0/zhuyin*"
		vmove usr/lib/pkgconfig/libzhuyin.pc
		vmove usr/lib/libzhuyin.a
		vmove usr/lib/libzhuyin.so
	}
}
