# -*- 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 102070 2013-01-27 09:36:42Z hum@macports.org $

PortSystem          1.0

name                liblinear
version             1.93
categories          math
maintainers         hum openmaintainer

description         A simple package for solving large-scale regularized linear classification.

long_description    LIBLINEAR is a simple package for solving large-scale regularized \
                    linear classification. It currently supports L2-regularized logistic \
                    regression/L2-loss support vector classification/L1-loss support vector \
                    classification, and L1-regularized L2-loss support vector classification/ \
                    logistic regression.

homepage            http://www.csie.ntu.edu.tw/~cjlin/liblinear/
platforms           darwin
license             BSD

master_sites        ${homepage}
checksums           rmd160  bff86e790e237791961ac1598df51a1c7dec151e \
                    sha256  76c542aa056bd4514fa15de7a80219f60bb8bee5c5dd84e303e523fa1c5d9b46

patchfiles          patch-Makefile.diff

use_configure       no

variant universal {}

build.target        all
build.args          CC="${configure.cc}   ${configure.cflags}   [get_canonical_archflags]" \
                    CXX="${configure.cxx} ${configure.cxxflags} [get_canonical_archflags cxx]" \
                    PREFIX=${prefix}

set liblinear_dir   ${prefix}/share/${name}

destroot {
    xinstall -m 755 -W ${worksrcpath} train predict ${destroot}${prefix}/bin
    xinstall -m 644 -W ${worksrcpath} liblinear.dylib ${destroot}${prefix}/lib
    xinstall -m 644 -W ${worksrcpath} linear.h tron.h ${destroot}${prefix}/include

    xinstall -m 755 -d ${destroot}${liblinear_dir}
    xinstall -m 644 -W ${worksrcpath} COPYRIGHT README heart_scale \
        ${destroot}${liblinear_dir}

    # install python interface.
    xinstall -m 755 -d ${destroot}${liblinear_dir}/python
    xinstall -m 644 -W ${worksrcpath}/python README liblinear.py liblinearutil.py \
        ${destroot}${liblinear_dir}/python
}

variant python24 description {Install Python 2.4 interface} {
    depends_lib-append  port:python24
    post-destroot { install_py 2.4 }
}

variant python25 description {Install Python 2.5 interface} {
    depends_lib-append  port:python25
    post-destroot { install_py 2.5 }
}

variant python26 description {Install Python 2.6 interface} {
    depends_lib-append  port:python26
    post-destroot { install_py 2.6 }
}

variant python27 description {Install Python 2.7 interface} {
    depends_lib-append  port:python27
    post-destroot { install_py 2.7 }
}

variant python31 description {Install Python 3.1 interface} {
    depends_lib-append  port:python31
    post-destroot { install_py 3.1 }
}

variant python32 description {Install Python 3.2 interface} {
    depends_lib-append  port:python32
    post-destroot { install_py 3.2 }
}

proc install_py {branch} {
    global frameworks_dir destroot worksrcpath
    set py_prefix  ${frameworks_dir}/Python.framework/Versions/${branch}
    set dir        ${destroot}${py_prefix}/lib/python${branch}/site-packages
    xinstall -m 755 -d ${dir}
    xinstall -m 644 -W ${worksrcpath}/python liblinear.py liblinearutil.py ${dir}
}            

livecheck.type          regex
livecheck.regex         {Version *([0-9.]+) *}
