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

pkgname=tamarin-prover
pkgver=1.10.0
pkgrel=222
pkgdesc="The Tamarin prover for security protocol analysis"
url="https://tamarin-prover.github.io"
license=("GPL")
arch=('x86_64')
depends=('ghc-libs' 'graphviz' 'maude' 'haskell-hunit' 'haskell-binary-orphans'
         'haskell-binary-instances' 'haskell-blaze-builder' 'haskell-blaze-html' 'haskell-cmdargs'
         'haskell-conduit' 'haskell-fclabels' 'haskell-file-embed' 'haskell-gitrev'
         'haskell-http-types' 'haskell-lifted-base' 'haskell-resourcet' 'haskell-safe'
         'haskell-shakespeare' 'haskell-threads' 'haskell-wai' 'haskell-warp' 'haskell-yesod-core'
         'haskell-yesod-static' 'haskell-tamarin-prover-utils' 'haskell-tamarin-prover-term'
         'haskell-tamarin-prover-theory' 'haskell-tamarin-prover-sapic'
         'haskell-tamarin-prover-export' 'haskell-tamarin-prover-accountability')
makedepends=('ghc')
source=("https://github.com/tamarin-prover/tamarin-prover/archive/$pkgver/tamarin-prover-$pkgver.tar.gz")
sha512sums=('52ea3e77051208ab2f2b9425988640a2a699adfaaac90d5946d3ce43663ad535f5efb1bf845e0d540eb719e0f26c4d8beec4e231f54f0f393f42c2a392cfd486')

build() {
    cd $pkgname-$pkgver

    runhaskell Setup configure -O --enable-executable-dynamic --prefix=/usr \
        --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname \
            -fthreaded -ftest-coverage -f-build-tests --ghc-option='-pie'
    runhaskell Setup build $MAKEFLAGS
}

check() {
    cd $pkgname-$pkgver
    LD_LIBRARY_PATH="$PWD"/dist/build dist/build/tamarin-prover/tamarin-prover test
}

package() {
    cd $pkgname-$pkgver
    runhaskell Setup copy --destdir="${pkgdir}"

    install -Dm644 etc/filetype.vim "$pkgdir"/usr/share/vim/vimfiles/ftdetect/tamarin.vim
    install -Dm644 etc/syntax/spthy.vim "$pkgdir"/usr/share/vim/vimfiles/syntax/spthy.vim
    ln -s spthy.vim "$pkgdir"/usr/share/vim/vimfiles/syntax/sapic.vim
}
