# $Id: PKGBUILD 160923 2012-06-07 02:06:49Z pierre $
# Maintainer: AndyRTR <andyrtr@archlinux.org>
# Contributor: Alexander Fehr <pizzapunk gmail com>

pkgname=hunspell-de
pkgver=20120607
pkgrel=1
pkgdesc="German hunspell dictionaries"
arch=('any')
url="http://www.j3e.de/ispell/igerman98/"
license=('GPL' 'custom:OASIS')
makedepends=('hunspell' 'ispell')
optdepends=('hunspell: the spell checking libraries and apps')
source=("http://www.j3e.de/ispell/igerman98/dict/igerman98-$pkgver.tar.bz2")
md5sums=('9433d0ccd7db3c7681037980ece3f710')

build() {
  cd "$srcdir/igerman98-$pkgver"
  make hunspell/de_AT.dic hunspell/de_AT.aff \
       hunspell/de_CH.dic hunspell/de_CH.aff \
       hunspell/de_DE.dic hunspell/de_DE.aff
}

package() {
  cd "$srcdir/igerman98-$pkgver/hunspell"
  install -dm755 ${pkgdir}/usr/share/hunspell
  cp -p de_??.dic de_??.aff $pkgdir/usr/share/hunspell

  pushd $pkgdir/usr/share/hunspell/
  de_DE_aliases="de_BE de_LU"
  for lang in $de_DE_aliases; do
    ln -s de_DE.aff $lang.aff
    ln -s de_DE.dic $lang.dic
  done
  de_CH_aliases="de_LI"
  for lang in $de_CH_aliases; do
    ln -s de_CH.aff $lang.aff
    ln -s de_CH.dic $lang.dic
  done
  popd

  # the symlinks
  install -dm755 ${pkgdir}/usr/share/myspell/dicts
  pushd $pkgdir/usr/share/myspell/dicts
    for file in $pkgdir/usr/share/hunspell/*; do
      ln -sv /usr/share/hunspell/$(basename $file) .
    done
  popd

  # docs
  install -dm755 ${pkgdir}/usr/share/doc/$pkgname
  cp -p README_de_??.txt $pkgdir/usr/share/doc/$pkgname

  # licenses
  install -D -m644 Copyright $pkgdir/usr/share/licenses/$pkgname/Copyright
  install -D -m644 COPYING_OASIS $pkgdir/usr/share/licenses/$pkgname/COPYING_OASIS

}
