# -*- 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

PortSystem          1.0
PortGroup           cmake 1.0

name                shogun-devel
version             4.0.0
set branch          [join [lrange [split ${version} .] 0 1] .]
revision            23
categories          math science
platforms           darwin
license             GPL-3

conflicts           shogun

maintainers         nomaintainer

description         The machine learning toolbox's focus is on large scale \
                    kernel methods

long_description    ${description} and especially on Support Vector Machines \
                    (SVM). It provides a generic SVM object interfacing to \
                    several different SVM implementations, among them the \
                    state of the art OCAS, LibSVM, SVMLight, SVMLin and GPDT.

homepage            http://shogun-toolbox.org
master_sites        ${homepage}/archives/shogun/releases/${branch}/sources/

use_bzip2           yes

distname            shogun-${version}

checksums           rmd160  b6f63baeee7040ada85feb33374010a525384104 \
                    sha256  ab39d3cc27fc1ddf6128f6e3fc60217e73a843b51c20f5d3ceb69e6565a43695

universal_variant   no

pre-fetch {
    if {${os.major} <= 12} {
        return -code error "Shogun is only supported on Mavericks or above"
    }
}

post-extract {
    file mkdir ${worksrcpath}

    # Fix permissions
    fs-traverse item ${workpath}/${distname} {
        if {[file isdirectory ${item}]} {
            file attributes ${item} -permissions a+rx
        } elseif {[file isfile ${item}]} {
            file attributes ${item} -permissions a+r
        }
    }
}

patchfiles          patch-CMakeLists.txt.diff \
                    patch-src_shogun_CMakeLists.txt.diff \
                    patch-cmake_FindSpinlock.cmake.diff \
                    patch-src_interfaces_python_modular_CMakeLists.txt.diff

cmake.out_of_source yes

configure.args-append \
                    -DENABLE_CCACHE=NO \
                    -DPythonModular=ON \
                    -DPYTHON_EXECUTABLE=${prefix}/bin/python2.7

depends_build-append \
                    port:pkgconfig \
                    port:python27

depends_lib-append  port:hdf5 \
                    port:json-c \
                    port:libxml2 \
                    port:readline \
                    port:atlas \
                    port:arpack \
                    path:share/pkgconfig/eigen3.pc:eigen3 \
                    port:lp_solve \
                    port:glpk \
                    port:lzo2 \
                    port:snappy \
                    port:gzip \
                    port:bzip2 \
                    port:xz \
                    port:protobuf-cpp

variant python27 description {Build the Python 2.7 API}  {
    depends_lib-append  port:swig-python \
                        port:python27 \
                        port:py27-numpy
    configure.args-append \
                        -DPythonModular=ON
}

livecheck.type      regex
livecheck.url       http://www.shogun-toolbox.org
livecheck.regex     {SHOGUN ([0-9.]+)}
