# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Arch Haskell Team <arch-haskell@haskell.org>

_hkgname=aeson-pretty
pkgname=haskell-aeson-pretty
pkgver=0.8.11
pkgrel=13
pkgdesc="JSON pretty-printing library and command-line tool."
url="https://github.com/informatikr/aeson-pretty"
license=('BSD-3-Clause')
arch=('x86_64' 'aarch64')
depends=('ghc-libs' "haskell-aeson" "haskell-attoparsec" "haskell-attoparsec-aeson"
         "haskell-base-compat" "haskell-cmdargs" "haskell-scientific"
         "haskell-unordered-containers" "haskell-vector")
makedepends=('ghc')
source=("https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz")
sha512sums=('bb8ac1ae06e3f3f6f5cb99602d69aca82be9f5808e9d75f92f15734701c0ff3b149e9b1a22abbe8938c9e971e71a7a4ed06d0f767ba9d15329ae76137a8ab691')

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 --enable-tests \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid \
            -f-lib-only
    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
}

check() {
    cd $_hkgname-$pkgver
    runhaskell Setup test --show-details=direct
}

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
}
