# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
# $Id: Portfile 92837 2012-05-09 00:51:48Z ryandesign@macports.org $

PortSystem 1.0

name                octave
version             3.2.4
revision            8
conflicts           octave-devel
categories          math science
license             GPL-3+
maintainers         nomaintainer
platforms           darwin
description         a Matlab-like environment for numerical analysis
long_description    Octave provides a convenient command line interface \
                    for solving linear and nonlinear problems numerically, \
                    using a language that is mostly compatible with Matlab. \
                    It is easily extensible and customizable via \
                    user-defined functions or using dynamically loaded \
                    modules written in e.g. C++, C or Fortran.

homepage            http://www.gnu.org/software/octave/
master_sites        gnu

checksums           md5     90c39fa9e241ad2e978bcee4682a2ba9 \
                    sha1    93b81fc300bc5e27e88b6668ef0622f29898dfd2 \
                    rmd160  13b2198db1b8684229d2ba787ebbedd8e50a518c

depends_build       port:gawk \
                    path:bin/perl:perl5 \
                    port:texinfo

depends_lib         port:arpack \
                    port:curl \
                    port:fftw-3 \
                    port:fftw-3-single \
                    port:ftgl \
                    port:ghostscript \
                    port:glpk \
                    port:GraphicsMagick \
                    port:gnuplot \
                    port:hdf5-18 \
                    port:metis \
                    port:ncurses \
                    port:pcre \
                    port:readline \
                    port:qhull \
                    port:qrupdate \
                    port:SuiteSparse \
                    port:gsed

configure.args      --enable-shared \
                    --enable-dl \
                    --with-hdf5 \
                    --with-fftw \
                    --enable-static \
                    --enable-readline \
                    --with-zlib \
                    --with-glpk \
                    --with-curl \
                    --with-lapack \
                    --with-umfpack \
                    --with-colamd \
                    --with-ccolamd \
                    --with-cholmod \
                    --with-cxsparse \
                    --without-framework-carbon

configure.perl      ${prefix}/bin/perl
configure.python    ' '
configure.awk       ${prefix}/bin/gawk

configure.env-append SED="${prefix}/bin/gsed" \
                    MAKEINFO="${prefix}/bin/makeinfo" \
                    TEXI2DVI="${prefix}/bin/texi2dvi" \
                    TEXI2PDF="${prefix}/bin/texi2pdf"

use_parallel_build  no
universal_variant   no

test.run            yes
test.target         check

variant atlas conflicts accelerate description {use BLAS from ATLAS} {
    depends_lib-append port:atlas
}
variant accelerate conflicts atlas description {use BLAS from Accelerate.framework} {
    if {![variant_isset g95]} {
        configure.fflags-append -ff2c
    }
    if {[variant_isset g95] || ([string match *64* $build_arch] && ${os.major} >= 10)} {
        depends_lib-append      port:dotwrp
        configure.args-append   --with-blas="-ldotwrp -framework Accelerate"
    }
    configure.args-append   --with-lapack="-framework Accelerate"
}
if {[variant_isset g95]} {
    default_variants +accelerate
} elseif {![variant_isset accelerate]} {
    default_variants +atlas
}
if {![variant_isset atlas] && ![variant_isset accelerate]} {
    pre-fetch {
        return -code error "You must use either the atlas or accelerate variant."
    }
}

variant gcc43 description {build with the macports gcc43 toolchain} conflicts gcc44 gcc45 g95 {
    depends_build-append    port:gcc43
    configure.compiler      macports-gcc-4.3
}

variant gcc44 description {build with the macports gcc44 toolchain} conflicts gcc43 gcc45 g95 {
    depends_build-append    port:gcc44
    configure.compiler      macports-gcc-4.4
}

variant gcc45 description {build with the macports gcc45 toolchain} conflicts gcc43 gcc44 g95 {
    depends_build-append    port:gcc45
    configure.compiler      macports-gcc-4.5
}

variant g95 description {build with g95} requires accelerate conflicts atlas gcc43 gcc44 gcc45 {
    depends_build-append    port:g95
    configure.f77       "${prefix}/bin/g95"
}

if { ![variant_isset gcc43] && ![variant_isset gcc44] && ![variant_isset g95] } {
    default_variants +gcc45
}
if {![variant_isset gcc43] && ![variant_isset gcc44] && ![variant_isset gcc45] && ![variant_isset g95]} {
    pre-fetch {
        return -code error "You must use one of the compiler variants."
    }
}

patchfiles patch-lo-specfun.cc.diff patch-configure-no_x11.diff

post-patch {
    reinplace "s|-lcholmod|-lcholmod -lmetis|g" ${worksrcpath}/configure
}

livecheck.type      regex
livecheck.url       http://www.gnu.org/software/octave/news.html
livecheck.regex     Version (\\d+(\\.\\d+)*)
