# $Id: Portfile 54089 2009-07-20 20:03:29Z macsforever2000@macports.org $

PortSystem         1.0
PortGroup          python25 1.0

categories-append  math
name               py25-cvxopt
version            1.1.1
distname           cvxopt-${version}
maintainers        cornell.edu:ajb78
platforms          darwin

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

distfiles          cvxopt-${version}.tar.gz
master_sites       http://abel.ee.ucla.edu/cvxopt/download.php

checksums           md5     577e0f2f2288df34310844c67ccd2d77 \
                    sha1    391953aea9ce19a3b5c8055237bb26e79798696e \
                    rmd160  86f729c4f7cd7eac8253efc9fe6f3ac06c940413

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 {
    reinplace "s|ATLAS_LIB_DIR = .*|ATLAS_LIB_DIR = '${prefix}/lib'|" \
              ${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}
