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

# CRAN version lacks OpenMP support, stay with the GitHub one.
R.setup             github helske Rlibeemd 1.4.3 v
revision            2
categories-append   math
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
license             GPL-3
description         Ensemble Empirical Mode Decomposition (EEMD) and its complete variant (CEEMDAN)
long_description    {*}${description}
checksums           rmd160  752f7ce96115220ee009d1f016ae7d447794a15f \
                    sha256  bc16c030a27ff761011b961561c98b02e49275a6bc9af6cc131a72f936e16eba \
                    size    101734

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

# https://github.com/helske/Rlibeemd/issues/10
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
