# -*- 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 duckmayr RcppDist 0.1.1.1
revision            1
categories-append   math
maintainers         {@barracuda156 macos-powerpc.org:barracuda} openmaintainer
license             {GPL-2 GPL-3}
description         Rcpp integration of additional probability distributions
long_description    {*}${description}
checksums           rmd160  929a4ebcfe0cb08421a86c5376818a057eb9f9fe \
                    sha256  aefd99dd207b9b545cf6070078bb9dd7f4ba51049063f3324e9849c7131b09ae \
                    size    143179

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

compilers.setup     require_fortran

variant openmp description "Enable OpenMP support" {
    # Configure script is broken for OpenMP detection.
    # https://github.com/duckmayr/RcppDist/issues/8
    patchfiles      patch-openmp.diff

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

depends_test-append port:R-knitr \
                    port:R-rmarkdown \
                    port:R-tinytest

test.run            yes
