# -*- 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 110168 2013-08-27 19:41:46Z jeremyhu@macports.org $

PortSystem          1.0

name                blitz-devel
version             0.10-20120703
categories          math devel
platforms           darwin
license             {LGPL-3+ BSD Artistic-2}
maintainers         nomaintainer

fetch.type      hg
hg.url          http://blitz.hg.sourceforge.net:8000/hgroot/blitz/blitz
hg.tag          ab84372f3dce

description         a C++ class library for scientific computing

long_description    Blitz++ is a (LGPLv3+) licensed meta-template library for \
                    array manipulation in C++ with a speed comparable to \
                    Fortran implementations, while preserving an \
                    object-oriented interface. These results are being \
                    obtained not through better optimizing compilers, \
                    preprocessors, or language extensions, but through the \
                    use of template techniques. By using templates cleverly, \
                    optimizations such as loop fusion, unrolling, tiling, \
                    and algorithm specialization can be performed \
                    automatically at compile time.

homepage            http://blitz.sourceforge.net/

platforms           darwin

use_autoreconf yes

configure.args      --infodir=${prefix}/share/info \
                    --enable-shared \
                    --enable-static \
                    --enable-optimize \
                    --disable-doxygen \
                    --disable-dot \
                    --disable-latex-docs

destroot.args       docdir=${prefix}/share/doc/${name}

variant docs description {Generate API documentation} {
  depends_lib-append     port:doxygen \
                         path:bin/dot:graphviz
  configure.args-delete --disable-doxygen \
                        --disable-dot
  configure.args-append --enable-doxygen \
                        --enable-dot
}

set gcc_versions {4.3 4.4 4.5 4.6 4.7 4.8 4.9}
set default_fortran_variant +gcc48
set g95_conflicts {}

foreach ver ${gcc_versions} {
    set ver_no_dot [join [split ${ver} "."] ""]

    set variant_line {variant gcc${ver_no_dot} description "build with gfortran from gcc${ver_no_dot}" conflicts g95}

    foreach over ${gcc_versions} {
        if {${ver} == ${over}} {
            continue
        }

        set over_no_dot [join [split ${over} "."] ""]
        append variant_line " conflicts gcc${over_no_dot}"
    }
    append variant_line { {}}

    eval $variant_line

    append g95_conflicts " conflicts gcc${ver_no_dot}"

    if {[variant_isset gcc${ver_no_dot}]} {
        if {${default_fortran_variant} != "+gcc${ver_no_dot}"} {
            set default_fortran_variant ""
        }
    }
}

eval [concat {variant g95 description {build with g95}} $g95_conflicts {{}}]

if {[variant_isset g95]} {
    if {${default_fortran_variant} != "+g95"} {
        set default_fortran_variant ""
    }
}

if {${default_fortran_variant} != ""} {
    default_variants "${default_fortran_variant}"
}

foreach ver ${gcc_versions} {
    set ver_no_dot [join [split ${ver} "."] ""]

    if {[variant_isset gcc${ver_no_dot}]} {
        depends_lib-append path:lib/libgcc/libgcc_s.1.dylib:libgcc
        depends_build-append port:gcc${ver_no_dot}

        configure.fc  ${prefix}/bin/gfortran-mp-${ver}
        configure.f77 ${prefix}/bin/gfortran-mp-${ver}
        configure.f90 ${prefix}/bin/gfortran-mp-${ver}
    }
}

if {[variant_isset g95]} {
    depends_lib-append path:lib/libgcc/libgcc_s.1.dylib:libgcc
    depends_build-append port:g95

    configure.fc ${prefix}/bin/g95
    configure.f77 ${prefix}/bin/g95
    configure.f90 ${prefix}/bin/g95
}

# does not do any live check
livecheck.type sourceforge
