# -*- 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
# $Id: Portfile 108140 2013-07-13 22:47:34Z larryv@macports.org $

PortSystem 1.0

name                cadabra
version             1.33
revision            1
categories          math
platforms           darwin
license             GPL-3+
maintainers         gwright

description         A field theory approach to symbolic computer algebra
long_description    Cadabra is a computer algebra system for the \
                    manipulation of what could loosely be called \
                    tensorial expressions. It is aimed at, though not \
                    necessarily restricted to, theoretical high energy \
                    physicists. Because of its target audience, the \
                    program's interface, storage system and underlying \
                    philosophy differ substantially from other computer \
                    algebra systems.

homepage            http://cadabra.phi-sci.com/
master_sites        ${homepage}

checksums           rmd160  52686bdd7a635a6db30a91add951720f14c1ddc6 \
                    sha256  075dad3a1a9fd8774473f6d28f036f65629a286304c02f0ac1e10be3cb2ebd12

depends_build       port:pkgconfig \
                    port:pcrexx

depends_lib         port:modglue \
                    port:pcre \
                    port:gmp \
                    port:LiE

# Invalid C++, ticket #33045
#
# Cannot use clang because xperm uses nested functions and variable
# sized arrays, both of which clang will never support. Silly llvm makes
# cadabra crash all over the place for no good reason, so that's out
# too. Furthermore, we cannot use anything except 4.2 because that will
# lead to cadabra being linked to two different libstdc++ libraries,
# with malloc failures as a result.
configure.compiler  apple-gcc-4.2

# TODO: Remove when MacPorts 2.2 is released.
if {[info exists portconfigure::compiler_name_map(${configure.compiler})]} {
    set compiler $portconfigure::compiler_name_map(${configure.compiler})
    if {[string first macports-gcc- ${configure.compiler}] == 0} {
        depends_lib-append      port:${compiler}
    } else {
        depends_build-append    port:${compiler}
    }
    if {[portconfigure::arch_flag_supported ${configure.compiler}]} {
        depends_skip_archcheck-append   ${compiler}
    }
}

configure.args      --disable-gui \
                    --disable-runtime-dependency-check

build.env           CC=${configure.cc} \
                    CXX=${configure.cxx}

test.run            yes
test.env            CDB_LOG=1
test.target         test advtest

post-activate {
    system "${prefix}/bin/texhash"
}

variant texmacs description {install TeXmacs front end} {
    depends_run-append      port:TeXmacs
}

# Legacy no_gui variant to be removed after July 2014
variant no_gui conflicts gui description {Legacy compatibility variant} {}
variant gui description {build with GUI} {
    depends_lib-append      port:gtkmm
    depends_run-append      port:dvipng \
                            port:texlive-basic \
                            port:texlive-latex \
                            port:texlive-latex-recommended
    configure.args-delete   --disable-gui
}
if {[variant_isset no_gui]} {
    default_variants        -gui
} else {
    default_variants        +gui
}
