# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: AndyRTR <andyrtr@archlinux.org>

pkgname=libmythes
pkgver=1.2.5
pkgrel=2
epoch=1
pkgdesc="a simple thesaurus"
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
url="https://github.com/hunspell/mythes"
license=('BSD-3-Clause-Modification' 'MIT')
depends=('glibc' 'gcc-libs' 'perl')
makedepends=('hunspell')
provides=('mythes')
source=(https://github.com/hunspell/mythes/releases/download/v${pkgver}/mythes-${pkgver}.tar.xz)
sha256sums=('19279f70707bbe5ffa619f2dc319f888cec0c4a8d339dc0a21330517bd6f521d')

build() {
  cd "${pkgname/lib/}"-$pkgver
  ./configure --prefix=/usr --disable-static --build=${CHOST}
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  cd "${pkgname/lib/}"-$pkgver
  make check
  # run the example program:
  ./example th_en_US_new.idx th_en_US_new.dat checkme.lst
  # run the example program with stemming and morphological generation:
  # e.g. to check mouse, mice, rodents, eats, eaten, ate, eating etc. words
  ./example morph.idx morph.dat morph.lst morph.aff morph.dic
}

package() {
  cd "${pkgname/lib/}"-$pkgver
  make DESTDIR="$pkgdir" install
  # license
  install -Dm644 "${srcdir}"/${pkgname/lib/}-$pkgver/COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
}
