# Maintainer: Felix Yan <felixonmars@archlinux.org>

_hkgname=hspec-expectations
pkgname=haskell-hspec-expectations
pkgver=0.8.3
pkgrel=71
pkgdesc="Catchy combinators for HUnit"
url="https://github.com/sol/hspec-expectations"
license=('MIT')
arch=('x86_64' 'aarch64')
depends=('ghc-libs' 'haskell-call-stack' 'haskell-hunit')
makedepends=('ghc')
source=(https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz)
sha512sums=('d2e0c8b37560d7c1e1aba673dd9125bfdd97d435550b4d9dbadc2ffb8ec2b1abaa520b3a1ffc01fa0398118f59190db8c32d10129b5626c0eb838205bf04af60')

build() {
    cd $_hkgname-$pkgver
    
    runhaskell Setup configure -O --enable-shared --enable-debug-info --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
    cd $_hkgname-$pkgver
    
    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
