# Template file for 'libpinyin'
pkgname=libpinyin
version=2.10.3
revision=1
build_style=gnu-configure
build_helper=qemu
configure_args="--enable-libzhuyin"
hostmakedepends="gettext 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/releases/download/${version}/libpinyin-${version}.tar.gz
 http://downloads.sourceforge.net/libpinyin/models/model20.text.tar.gz"
checksum="3fe786ff2c2059bdbdf9d8d752db691a516a941a977521955fe0af3f0b4db299
 59c68e89d43ff85f5a309489499cbcde282d2b04bd91888734884b7defcb1155"
# nocross="Requires data generators compiled against target system"
skip_extraction="model20.text.tar.gz"

post_extract() {
	vsrcextract --no-strip-components -C data model20.text.tar.gz
}

pre_build() {
	if [ "$CROSS_BUILD" ]; then
		export RUN_TARGET="/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}"
	fi
}

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-${version}/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-${version}/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-${version}/zhuyin*"
		vmove usr/lib/pkgconfig/libzhuyin.pc
		vmove usr/lib/libzhuyin.a
		vmove usr/lib/libzhuyin.so
	}
}
