# $Id: PKGBUILD 137802 2015-08-03 10:15:10Z fyan $
# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Yangtse <yangtsesu@gmail.com> 
# Contributor: WU Jun <quark at lihdd dot net>

pkgname=libpinyin
pkgver=1.2.0
_modelver=10
pkgrel=1
pkgdesc="Library to deal with pinyin"
arch=('i686' 'x86_64')
url="https://github.com/libpinyin/libpinyin"
license=('GPL')
# Switching to kyotocabinet will break all existing installation. Requesting a migration tool to prevent data loss:
# https://github.com/libpinyin/libpinyin/issues/44
depends=('db' 'glib2') # 'kyotocabinet'
makedepends=('git')
source=("git+https://github.com/$pkgname/${pkgname}.git#tag=$pkgver"
        "http://downloads.sourceforge.net/libpinyin/model${_modelver}.text.tar.gz")
noextract=("model${_modelver}.text.tar.gz")
sha512sums=('SKIP'
            '75006472fc522026605a6f93a0328fa7d0a9b01da7c1d804a168f390b39cf7fac3985852b6efcb0f3ef01bec0b48a73652042af44191d11ca7e54097414c140a')

prepare() {
  cd ${pkgname}

  cp ../model${_modelver}.text.tar.gz data/
  sed -i "/wget.*model${_modelver}\.text\.tar\.gz/ d" data/Makefile.am
}

build() {
  cd ${pkgname}
  aclocal && libtoolize --force && autoheader && automake -a && autoconf

  ./configure --prefix=/usr # --with-dbm=KyotoCabinet
  make
}

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