# -*- 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

name                DoCon
set shortname       docon
version             2.11
revision            5
categories          math devel
maintainers         nomaintainer

description         DoCon is the Algebraic Domain Constructor
long_description    \
        DoCon joins the categorial approach to mathematical \
        computation expressed via the Haskell type classes, \
        and explicit processing of the domain description \
        terms.  It implements recently a good piece of \
        commutative algebra: linear algebra, polynomial gcd, \
        factorization, Groebner bases, and other functions.

homepage            http://www.botik.ru/pub/local/Mechveliani/docon/
master_sites        ${homepage}${version}
distname            ${shortname}-${version}
use_zip             yes

checksums           md5 229b4af2005bc6fcac0e386d88bf69e4

patchfiles          patch-docon.cabal.diff

depends_lib         port:ghc

worksrcdir          ${shortname}/source

variant printable_doc description {Build printable documentation} {
    depends_build bin:latex:texlive port:ghostscript

    post-destroot {
        # Run latex twice to resolve references
        system -W ${workpath}/${shortname} "latex manual.lat"
        system -W ${workpath}/${shortname} "latex manual.lat"
        system -W ${workpath}/${shortname} "dvipdf manual"
        file mkdir ${destroot}${prefix}/share/doc/${shortname}-${version}
        file copy ${workpath}/${shortname}/manual.pdf ${destroot}${prefix}/share/doc/${shortname}-${version}/
    }
}

configure {
    system -W ${worksrcpath} "runhaskell Setup configure --ghc --prefix=${prefix} --enable-library-profiling"
}

build {
    system -W ${worksrcpath} "runhaskell Setup build -v"
}

destroot {
    system -W ${worksrcpath} "runhaskell Setup copy --copy-prefix=${destroot}${prefix}"
    system -W ${worksrcpath} "runhaskell Setup register   --gen-script"
    system -W ${worksrcpath} "runhaskell Setup unregister --gen-script"

    file mkdir ${destroot}${prefix}/libexec/${shortname}-${version}
    file copy ${worksrcpath}/register.sh \
        ${destroot}${prefix}/libexec/${shortname}-${version}
    file copy ${worksrcpath}/unregister.sh \
        ${destroot}${prefix}/libexec/${shortname}-${version}
}

post-activate {
    system "${prefix}/libexec/${shortname}-${version}/register.sh"
}

#pre-deactivate { system "${prefix}/libexec/${shortname}-${version}/unregister.sh" }

livecheck.type      regex
livecheck.url       ${homepage}
livecheck.regex     {>([0-9.]+)/<}
