# $Id: Portfile 57375 2009-09-10 08:16:41Z ryandesign@macports.org $

PortSystem          1.0

name                DSDP
version             5.8
maintainers         mnick

categories          math science
description         DSDP is a open source implementation of an interior-point method for semidefinite programming
long_description    DSDP provides primal and dual solutions, exploits low-rank structure \
                    and sparsity in the data, and has relatively low memory requirements for an \
                    interior-point method. The dual-scaling algorithm implemented in this package has \
                    a convergence proof and worst-case polynomial complexity under mild assumptions on the data
platforms           darwin

homepage            http://www.mcs.anl.gov/hs/software/DSDP/
master_sites        ${homepage}

distname            ${name}${version}

use_zip             yes
use_configure       no
checksums           md5     f61d3759cc8c6de688ab5c30877ca83c \
                    sha1    8327a6fe2de902d97c3b4cf63668f2731c84b80d \
                    rmd160  75cf8629445522a4f9bbfffdcec25e832c8ffc4e

patchfiles          make.include.diff

build.target        dsdpapi
build.env-append    DSDPROOT=${worksrcpath} 

variant octave description {Build DSDP with octave interface} {
    build.target            all
    depends_lib-append      port:octave
}

destroot {
    xinstall ${worksrcpath}/lib/libdsdp.a ${destroot}/${prefix}/lib
    eval xinstall [glob ${worksrcpath}/include/*] ${destroot}/${prefix}/include
    xinstall ${worksrcpath}/bin/dsdp5 ${destroot}/${prefix}/bin
    xinstall ${worksrcpath}/bin/maxcut ${destroot}/${prefix}/bin
    xinstall ${worksrcpath}/bin/theta ${destroot}/${prefix}/bin
    
    if {[variant_isset octave]} {
        if {[catch {set msite [exec ${prefix}/bin/octave-config --m-site-dir]}]} {
            set msite ${prefix}/share/dsdp/matlab
        }
        set msite ${msite}/dsdp
        xinstall -d ${destroot}${msite}
        eval file copy [glob ${worksrcpath}/matlab/*] ${destroot}${msite}
    }
}

livecheck.type      regex
livecheck.url       ${master_sites}
livecheck.regex     <a href=\"${name}(.*).tar.gz\">.tar.gz</a>
