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

github.setup        facebookresearch fastText 0.9.2 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision            1
name                [string tolower ${github.project}]

categories          textproc
license             MIT
maintainers         nomaintainer

description         Library for fast text representation and classification.
long_description    fastText is a library for efficient learning of \
                    word representations and sentence classification.

checksums           rmd160  f83305b9e95c7e97a0a51c8a82293b235346315b \
                    sha256  e9ce4ab7d2bf6c5e2343faa5920c59370d3e8a08bf6bd07b1f1e7ea48d441fe7 \
                    size    4036928

patchfiles          no-march-native.patch

compiler.cxx_standard   2011

if {${name} eq ${subport}} {
    PortGroup       cmake 1.1
}

post-destroot {
    set docdir ${prefix}/share/doc/${subport}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} LICENSE README.md \
        ${destroot}${docdir}
}

# create Python subports
set python_versions {313}

# Python modules
foreach v ${python_versions} {
    subport py${v}-${name} {
        PortGroup   python 1.0

        description Python bindings for ${name}
        categories-prepend  textproc
        long_description    {*}${description}

        python.default_version  ${v}

        compiler.cxx_standard   2011
    }
}

# common settings for all Python ports
if {[string match "py*" ${subport}]} {
    depends_build-append \
                    port:py${python.version}-pybind11

    depends_run-append \
                    port:py${python.version}-numpy

    test.run        yes
    python.test_framework
    test.cmd        ${python.bin}
    test.target     runtests.py
    test.args       --unit-tests
}
