# Maintainer: Andreas Radke <andyrtr@archlinux.org>
# Contributor: Hussam Al-Tayeb <ht990332@gmail.com>

pkgname=hunspell
pkgver=1.7.2
pkgrel=2
pkgdesc="Spell checker and morphological analyzer library and program"
arch=('x86_64' 'aarch64')
url="https://github.com/hunspell/hunspell"
license=('LGPL-2.1-or-later OR GPL-2.0-or-later OR MPL-1.1')
depends=('gcc-libs' 'readline' 'ncurses'  'glibc' 'sh')
optdepends=('perl: for ispellaff2myspell')
source=(https://github.com/hunspell/hunspell/releases/download/v${pkgver}/hunspell-${pkgver}.tar.gz)
sha256sums=('11ddfa39afe28c28539fe65fc4f1592d410c1e9b6dd7d8a91ca25d85e9ec65b8')

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

check() {
  cd hunspell-$pkgver
  make check
}

package() {
  cd hunspell-$pkgver
  make DESTDIR="$pkgdir" install
  
  # add generic hunspell.so for development and projects not using pkgconfig flags - FS#30592
  pushd "$pkgdir"/usr/lib
  ln -s libhunspell-?.?.so libhunspell.so
  popd
}
