# -*- 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 118072 2014-03-20 21:22:51Z mmoll@macports.org $

PortSystem          1.0

name                liblinear
version             1.94
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  56cc112d3e4397804d67eea4e266b363c822307b \
                    sha256  11367ebdbd492fb8daa2ad13c749db5b301b01a11a8c0e6e1b9529caf9bb3114

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}

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

    # Copy additional documents.
    set dest_doc ${destroot}${prefix}/share/doc/${name}
    xinstall -m 755 -d ${dest_doc}
    xinstall -m 644 -W ${worksrcpath} COPYRIGHT README ${dest_doc}

    # Copy sample data.
    set dest_ex ${destroot}${prefix}/share/examples/${name}
    xinstall -m 755 -d ${dest_ex}
    xinstall -m 644 -W ${worksrcpath} heart_scale ${dest_ex}

    # Copy python scripts.
    set dest_py ${dest_ex}/python
    xinstall -m 755 -d ${dest_py}
    xinstall -m 644 -W ${worksrcpath}/python \
        README liblinear.py liblinearutil.py \
        ${dest_py}
}

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 }
}

variant python33 description {Install Python 3.3 interface} {
    depends_lib-append  port:python33
    post-destroot { install_py 3.3 }
}

variant python34 description {Install Python 3.4 interface} {
    depends_lib-append  port:python34
    post-destroot { install_py 3.4 }
}

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.]+) *}
