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

# Revert to GitHub once updated there.
R.setup             cran helske Rlibeemd 1.4.4 v
revision            1
categories-append   math
maintainers         {@barracuda156 macos-powerpc.org:barracuda} openmaintainer
license             GPL-3
description         Ensemble Empirical Mode Decomposition (EEMD) and its complete variant (CEEMDAN)
long_description    {*}${description}
checksums           rmd160  1a5a3aec8cf7f245c8407e663cc4ac725ae0cbec \
                    sha256  be2a7ec0b7400d7707ff1581d0eb62e9f6b61cd4f4967cd24aae7cebf744e84b \
                    size    72755
# github.tarball_from archive

depends_lib-append  port:gsl \
                    port:R-Rcpp

# https://github.com/helske/Rlibeemd/issues/10
# https://github.com/helske/Rlibeemd/commit/18e267242faa3e8f5a567d6b3240726a5f0bede7
patchfiles          patch-openmp.diff

post-patch {
    if {[string match macports-gcc* ${configure.compiler}]} {
        reinplace "s,@OMP_CFLAGS@,-fopenmp," ${worksrcpath}/src/Makevars.in
        reinplace "s,@OMP_LDFLAGS@,-fopenmp," ${worksrcpath}/src/Makevars.in
    } elseif {[string match macports-clang* ${configure.compiler}]} {
        reinplace "s,@OMP_CFLAGS@,-I${prefix}/include/libomp -fopenmp," ${worksrcpath}/src/Makevars.in
        reinplace "s,@OMP_LDFLAGS@,-L${prefix}/lib/libomp -lomp," ${worksrcpath}/src/Makevars.in
    }
}

compiler.openmp_version 3.0

depends_test-append port:R-testthat

test.run            yes
