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

_hkgname=tamarin-prover-utils
pkgname=haskell-tamarin-prover-utils
pkgver=1.10.0
pkgrel=123
pkgdesc="Utility library for the tamarin prover"
url="http://www.infsec.ethz.ch/research/software/tamarin"
license=("GPL")
arch=('x86_64')
depends=('ghc-libs' 'haskell-sha' 'haskell-base64-bytestring' 'haskell-blaze-builder'
         'haskell-dlist' 'haskell-fclabels' 'haskell-graphviz' 'haskell-list-t' 'haskell-safe'
         'haskell-split' 'haskell-syb')
makedepends=('ghc')
source=("tamarin-prover-$pkgver.tar.gz::https://github.com/tamarin-prover/tamarin-prover/archive/$pkgver.tar.gz")
sha512sums=('52ea3e77051208ab2f2b9425988640a2a699adfaaac90d5946d3ce43663ad535f5efb1bf845e0d540eb719e0f26c4d8beec4e231f54f0f393f42c2a392cfd486')

build() {
    cd "${srcdir}/tamarin-prover-${pkgver}/lib/utils"
    
    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
    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 "${srcdir}/tamarin-prover-${pkgver}/lib/utils"
    runhaskell Setup test --show-details=direct
}

package() {
    cd "${srcdir}/tamarin-prover-${pkgver}/lib/utils"
    
    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
}
