# Maintainer: Felix Yan <felixonmars@gmail.com>
# Contributor: Andrea Scarpino <andrea@archlinux.org>
# Contributor: dorphell <dorphell@archlinux.org>

pkgname=enchant
pkgver=2.8.12
pkgrel=2
pkgdesc="A wrapper library for generic spell checking"
url="https://rrthomas.github.io/enchant/"
arch=('x86_64' 'aarch64')
license=('LGPL-2.1-or-later')
depends=(
  'gcc-libs'
  'glib2'
  'glibc'
)
makedepends=(
  'aspell'
  'git'
  'hspell'
  'hunspell'
  'libvoikko'
  'nuspell'
  'vala'
)
checkdepends=('unittestpp')
optdepends=(
  'aspell: for aspell based spell checking support'
  'hspell: for hspell based spell checking support'
  'hunspell: for hunspell based spell checking support'
  'libvoikko: for libvoikko based spell checking support'
  'nuspell: for nuspell based spell checking support'
)
provides=('libenchant-2.so')
source=(
  "git+https://github.com/rrthomas/enchant#tag=v$pkgver"
  "git+https://https.git.savannah.gnu.org/git/gnulib.git"
  "git+https://github.com/gnulib-modules/bootstrap.git"
)
b2sums=('d6a0fb73bcf9535df38db777f5f5d1dcd8f7e8e239bfff05728dc09202aa2a759c927fac978b604c7792260e415e0ba905e799de467e73c4b0531554216de37f'
        'SKIP'
        'SKIP')

prepare() {
  cd enchant

  git submodule init
  git submodule set-url gnulib "$srcdir/gnulib"
  git submodule set-url gl-mod/bootstrap "$srcdir/bootstrap"
  git -c protocol.file.allow=always -c protocol.allow=never submodule update

  ./bootstrap
}

build() {
  local configure_options=(
    --prefix=/usr
    --sysconfdir=/etc
    --localstatedir=/var
    --disable-static
    --enable-relocatable
  )

  cd enchant
  ./configure "${configure_options[@]}"
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  cd enchant
  make check
}

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