# -*- 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
revision            2
categories-append   math
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
license             {GPL-2 GPL-3}
description         Rcpp integration of additional probability distributions
long_description    {*}${description}
checksums           rmd160  36fc06e77bc1c374449e06642e64de46cc7531ec \
                    sha256  3dfcc6f34d781f055ecba64e21bd9bc9e2d504a8304f03b6a4acdde8783fe509 \
                    size    355288

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
