# -*- coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
# $Id: Portfile 76473 2011-02-24 20:58:11Z mnick@macports.org $

PortSystem         1.0
PortGroup          python26 1.0

categories-append  math
name               py26-cvxopt
version            1.1.3
distname           cvxopt-${version}
maintainers        mnick
platforms          darwin
license            GPL

description        Python module for convex optimization 
long_description   CVXOPT is a free software package for convex optimization \
based on the Python programming language. It can be used with the interactive \
Python interpreter, on the command line by executing Python scripts, or \
integrated in other software via Python extension modules. Its main purpose is \
to make the development of software for convex optimization applications \
straightforward by building on Python's extensive standard library and on the \
strengths of Python as a high-level programming language.

homepage            http://abel.ee.ucla.edu/cvxopt/

master_sites        http://abel.ee.ucla.edu/src/

checksums           sha1    fe048bd21bb33eb99adb2759eda6f06d7520aa31 \
                    rmd160  cd0fdf51db957b388803b305f43ff323415b2252

variant atlas description {Use ATLAS as BLAS, LAPACK library} {
    depends_lib-append port:atlas
}

variant gsl description {Allow linking to gsl} {
  depends_lib-append port:gsl
}

variant fftw description {Link to fftw library} {
  depends_lib-append port:fftw-3
}

variant glpk description {Link to glpk library} {
  depends_lib-append port:glpk
}

variant dsdp description {Link to DSDP library} {
  depends_lib-append port:DSDP
}

default_variants +gsl +glpk +fftw +dsdp

configure {
    if {[variant_isset atlas]} {
        reinplace "s|ATLAS_LIB_DIR = .*|ATLAS_LIB_DIR = '${prefix}/lib'|" \
              ${worksrcpath}/src/setup.py
        
        # default to cblas if ${prefix}/lib/libblas.dylib doesnt exist
        if {![file exists ${prefix}/lib/libblas.dylib]} {
            reinplace "s|libraries = \\(.*\\)'blas'\\(.*\\)|libraries = \\1'cblas'\\2|g" \
                ${worksrcpath}/src/setup.py
        }
    }

    if {[variant_isset gsl]} {
        reinplace "s|BUILD_GSL = .*|BUILD_GSL = 1|" \
              ${worksrcpath}/src/setup.py
        reinplace "s|GSL_LIB_DIR = .*|GSL_LIB_DIR = '${prefix}/lib'|" \
              ${worksrcpath}/src/setup.py
        reinplace "s|GSL_INC_DIR = .*|GSL_INC_DIR = '${prefix}/include'|" \
              ${worksrcpath}/src/setup.py
    }
    if {[variant_isset glpk]} {
        reinplace "s|BUILD_GLPK = .*|BUILD_GLPK = 1|" \
              ${worksrcpath}/src/setup.py
        reinplace "s|GLPK_LIB_DIR = .*|GLPK_LIB_DIR = '${prefix}/lib'|" \
              ${worksrcpath}/src/setup.py
        reinplace "s|GLPK_INC_DIR = .*|GLPK_INC_DIR = '${prefix}/include'|" \
              ${worksrcpath}/src/setup.py
    }
    if {[variant_isset fftw]} {
        reinplace "s|BUILD_FFTW = .*|BUILD_FFTW = 1|" \
              ${worksrcpath}/src/setup.py
        reinplace "s|FFTW_LIB_DIR = .*|FFTW_LIB_DIR = '${prefix}/lib'|" \
              ${worksrcpath}/src/setup.py
        reinplace "s|FFTW_INC_DIR = .*|FFTW_INC_DIR = '${prefix}/include'|" \
              ${worksrcpath}/src/setup.py
    }
    if {[variant_isset dsdp]} {
        reinplace "s|BUILD_DSDP = .*|BUILD_DSDP = 1|" \
              ${worksrcpath}/src/setup.py
        reinplace "s|DSDP_LIB_DIR = .*|DSDP_LIB_DIR = '${prefix}/lib'|" \
              ${worksrcpath}/src/setup.py
        reinplace "s|DSDP_INC_DIR = .*|DSDP_INC_DIR = '${prefix}/include'|" \
              ${worksrcpath}/src/setup.py
    }
}

build.dir ${worksrcpath}/src

destroot.dir ${build.dir}

livecheck.type 		regex
livecheck.regex 	<h2> Current release </h2><p>Version (.*) includes:</p>
