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

_hkgname=tamarin-prover-theory
pkgname=haskell-tamarin-prover-theory
pkgver=1.10.0
pkgrel=117
pkgdesc="Security protocol types and constraint solver library for the tamarin prover"
url="http://www.infsec.ethz.ch/research/software/tamarin"
license=("GPL")
arch=('x86_64')
depends=('ghc-libs' 'haskell-aeson' 'haskell-aeson-pretty' 'haskell-attoparsec' 'haskell-dlist'
         'haskell-fclabels' 'haskell-parallel' 'haskell-regex-pcre' 'haskell-regex-posix'
         'haskell-safe' 'haskell-split' 'haskell-uniplate' 'haskell-tamarin-prover-utils'
         'haskell-tamarin-prover-term')
makedepends=('ghc' 'uusi')
source=("https://github.com/tamarin-prover/tamarin-prover/archive/$pkgver/tamarin-prover-$pkgver.tar.gz")
sha512sums=('52ea3e77051208ab2f2b9425988640a2a699adfaaac90d5946d3ce43663ad535f5efb1bf845e0d540eb719e0f26c4d8beec4e231f54f0f393f42c2a392cfd486')

prepare() {
    cd tamarin-prover-$pkgver/lib/theory
    uusi -r regex-pcre-builtin:regex-pcre $_hkgname.cabal
}

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

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