# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0

github.setup        abella-prover abella 2.0.8.3 v

revision            0
categories          math ocaml
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
license             GPL-3
description         Interactive theorem prover
long_description    Abella is an interactive theorem prover based on lambda-tree syntax. \
                    This means that Abella is well-suited for reasoning about the meta-theory \
                    of programming languages and other logical systems which manipulate objects with binding.
homepage            https://abella-prover.org

checksums           rmd160  f80f8241eb543d515ed45c43a6cd45c40336595c \
                    sha256  b2a67a8c8a275ac46c2f4578b29068386ffa180c5b37ffa539d217193f37c185 \
                    size    258223
github.tarball_from archive

depends_build-append \
                    port:ocaml \
                    port:ocaml-crunch \
                    port:ocaml-dune

depends_lib-append  port:ocaml-base64 \
                    port:ocaml-cmdliner \
                    port:ocaml-menhir \
                    port:ocaml-re \
                    port:ocaml-yojson

depends_test-append port:ocaml-ounit2

build.env-append    DUNE_CONFIG__COPY_FILE=portable

# https://github.com/abella-prover/abella/issues/151
if {${configure.build_arch} in [list ppc ppc64]} {
    build.env-append \
                    BYTECODE=true
    # Manual destroot does not need this, but keep it.
    # destroot.env-append \
                    BYTECODE=true

    set exe_suf     .bc
} else {
    set exe_suf     .exe
}

use_configure       no
use_parallel_build  no

build.target        all-release abella.install

destroot {
    foreach bin { abella abella_dep abella_doc } {
        copy ${worksrcpath}/_build/default/src/${bin}${exe_suf} ${destroot}${prefix}/bin/
    }
    xinstall -d ${destroot}${prefix}/share/${name}
    xinstall -d ${destroot}${prefix}/share/man
    foreach f { abella.1 abella_dep.1 abella_doc.1 } {
        copy ${worksrcpath}/_build/default/src/${f} ${destroot}${prefix}/share/man/
    }
    copy ${worksrcpath}/emacs ${destroot}${prefix}/share/${name}/
    copy ${worksrcpath}/examples ${destroot}${prefix}/share/${name}/
    xinstall -m 0644 -W ${worksrcpath} CHANGES.md LICENSE README.md ${destroot}${prefix}/share/${name}/
}

test.run            yes
test.cmd            ${build.cmd}
