# Maintainer: Will Sinatra <wpsinatra@gmail.com>
pkgname=anthy
pkgver=9100h
_filecode=37536
pkgrel=4
pkgdesc="Hiragana text to Kana Kanji mixed text Japanese input method"
url="https://sourceforge.jp/projects/anthy/"
arch="all"
license="LGPL-2.1-or-later"
subpackages="$pkgname-dev $pkgname-emacs::noarch"
# curl: (60) SSL certificate problem: certificate has expired
#source="https://osdn.dl.osdn.net/anthy/37536/anthy-$pkgver.tar.gz"
source="https://dev.alpinelinux.org/archive/anthy/anthy-$pkgver.tar.gz"

prepare() {
	default_prepare

	update_config_sub
}

build() {
	./configure \
		--host=$CHOST \
		--build=$CBUILD \
		--target=$CTARGET \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var
	make
}

check() {
	./src-util/anthy-agent --version
}

package() {
	make EMACS=emacs DESTDIR="$pkgdir" install
	rm -rf "$pkgdir"/usr/share/emacs
}

emacs() {
	depends="$pkgname"
	pkgdesc="emacs support for Anthy"

	cd "$builddir"
	make EMACS=emacs DESTDIR="${subpkgdir:?}" install
	rm -rf \
		"${subpkgdir:?}"/etc \
		"${subpkgdir:?}"/usr/bin \
		"${subpkgdir:?}"/usr/include \
		"${subpkgdir:?}"/usr/lib \
		"${subpkgdir:?}"/usr/share/anthy
}

sha512sums="
315ebd9e1af208f3ecaeaa13620213b35f004e47edb54e60c3e02c2997444cd2326cc58b725dd2d0bd6a723130884d946ea193ea3d92418082256b59ecc8d88b  anthy-9100h.tar.gz
"
