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

# strnlen
legacysupport.newest_darwin_requires_legacy 10

R.setup             cran astamm nloptr 2.2.1
revision            2
categories-append   math
maintainers         {@barracuda156 macos-powerpc.org:barracuda} openmaintainer
license             LGPL-3+
description         R Interface to NLopt
long_description    {*}${description}
homepage            https://astamm.github.io/nloptr
checksums           rmd160  505d082aea60ad376a7f69bd187765e44adca978 \
                    sha256  76ba40750b475c8b1ad6a86c9e05f0c1746af16d965235ff9293953920aed7f4 \
                    size    2253853

compilers.setup     require_fortran

depends_build-append \
                    path:bin/cmake:cmake

# https://github.com/astamm/nloptr/issues/211
post-patch {
    reinplace "s|CMD config CXX11|CMD config CXX20|g" ${worksrcpath}/src/scripts/r_config.sh
}

if {${os.platform} eq "darwin" && ${os.major} < 11} {
    patchfiles-append \
                    patch-legacy.diff
    post-patch {
        reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/src/Makevars.in
        reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/src/scripts/r_config.sh
    }
}

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

test.run            yes
