# Maintainer: Alexander F Rødseth <xyproto@archlinux.org>
# Contributor: Vesa Kaihlavirta <vesa@archlinux.org>
# Contributor: Arch Haskell Team <arch-haskell@haskell.org>

_hkgname=QuickCheck
pkgname=haskell-quickcheck
pkgver=2.14.3
pkgrel=109
pkgdesc='Automatic testing of Haskell programs'
url='https://hackage.haskell.org/package/QuickCheck'
license=('BSD')
arch=('x86_64' 'aarch64')
depends=('ghc-libs' 'haskell-erf' 'haskell-random' 'haskell-splitmix')
makedepends=('ghc')
source=("https://hackage.haskell.org/packages/archive/$_hkgname/$pkgver/$_hkgname-$pkgver.tar.gz")
sha512sums=('d00499fcdbe66d384a40c66a0d01dfe80f0622599f2f19ab569b45ef13c8d726c855b4687c7a1be022ea22df4bc66c48cf12fc156fadc558714fccc5a3deef7e')

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

  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
}

# vim: ts=2 sw=2 et:
