# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Daniel Nagy <danielnagy at gmx de>
# Contributor: Daniel Micay <danielmicay@gmail.com>

pkgname=haskell-aeson
_hkgname=aeson
pkgver=1.4.4.0
pkgrel=13
pkgdesc="A JSON parsing and encoding library optimized for ease of use and high performance."
url="https://github.com/bos/aeson"
license=("GPL")
arch=('x86_64')
depends=('ghc-libs' 'haskell-attoparsec' 'haskell-base-compat' 'haskell-dlist' 'haskell-hashable'
         'haskell-primitive' 'haskell-scientific' 'haskell-tagged' 'haskell-th-abstraction'
         'haskell-time-compat' 'haskell-unordered-containers' 'haskell-uuid-types'
         'haskell-vector')
makedepends=('ghc' 'haskell-quickcheck' 'haskell-integer-logarithms'
             'haskell-base-orphans' 'haskell-base16-bytestring' 'haskell-diff'
             'haskell-generic-deriving' 'haskell-hashable-time' 'haskell-tasty'
             'haskell-tasty-golden' 'haskell-tasty-hunit' 'haskell-tasty-quickcheck'
             'haskell-quickcheck-instances')
source=("https://hackage.haskell.org/packages/archive/$_hkgname/$pkgver/$_hkgname-${pkgver}.tar.gz")
sha512sums=('0ff462f93f28135ad255e77aaf0523a6d306c0a5fde7439ed4f652fec7811c6b446a3571098fd2af04bafbb2874b4e3052eb1792b61996cde23eabfa9abce944')

build() {
  cd $_hkgname-$pkgver
  runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname --enable-tests \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid \
            -f-developer -f-fast -f-bytestring-builder -f-cffi
  runhaskell Setup build
  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
}

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"
  rm -f "$pkgdir/usr/share/doc/$pkgname/LICENSE"
}
