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

R.setup             cran koheiw seededlda 1.4.1
revision            0
categories-append   textproc
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
license             GPL-3
description         Seeded sequential LDA for topic modelling
long_description    {*}${description}
homepage            https://koheiw.github.io/seededlda
checksums           rmd160  093b904697b489e2073e5d4375a28972e3b0a48e \
                    sha256  80299411c82ff5e7f1d26256572736faa891d8cd4339ee67d71246ad0ef1acec \
                    size    3849062

depends_build-append \
                    path:bin/pkg-config:pkgconfig

# https://github.com/koheiw/seededlda/issues/93
patchfiles-append   patch-fix-finding-TBB.diff

# https://github.com/koheiw/seededlda/issues/94
patchfiles-append   patch-use-right-prefix.diff

if {[string match *gcc* ${configure.compiler}]} {
    patchfiles-append \
                    patch-atomics.diff
}

post-patch {
    if {${configure.build_arch} in [list arm i386 ppc]} {
        set bitness 32
    } else {
        # Fallback to 64-bit, so that this works on riscv64 etc.
        set bitness 64
    }

    reinplace "s|@PREFIX@|${prefix}|" ${worksrcpath}/configure
    reinplace "s|@BIT@|${bitness}|g" ${worksrcpath}/configure
}

build.env-append    PKG_CONFIG_PATH=${prefix}/libexec/onetbb/lib/pkgconfig \
                    TBBFLAGS=${prefix}/libexec/onetbb/include \
                    TBBLIBS=${prefix}/libexec/onetbb/lib

depends_lib-append  port:onetbb \
                    port:R-proxyC \
                    port:R-quanteda \
                    port:R-Rcpp \
                    port:R-RcppArmadillo \
                    port:R-testthat

compilers.setup     require_fortran

depends_test-append port:R-keyATM \
                    port:R-topicmodels \
                    port:R-spelling

# FIXME: tests freeze due to a broken R BATCH.
# https://trac.macports.org/ticket/67059
test.run            no
