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

legacysupport.newest_darwin_requires_legacy 15

R.setup             cran andrjohns QuickJSR 1.4.0
revision            0
categories-append   devel
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
license             MIT
description         Interface for the QuickJS light-weight JavaScript engine
long_description    {*}${description}
homepage            https://github.com/andrjohns/QuickJSR
checksums           rmd160  550aad71ba09850946bcfb1c89169bc0f0852f3a \
                    sha256  345dda48e2bd055a67234ebc5ad3270563f5e80300a69069c414ff119a7b54ba \
                    size    801930

# Native ppc build has been fixed in: https://github.com/andrjohns/QuickJSR/commit/07fb3893d29fa17658a8cb8b17ffd2aba4453280
# See: https://github.com/andrjohns/QuickJSR/issues/1
# However the solution used relies on uname, which leaves Rosetta build broken.
# We do not need to guess here and can fix flags directly.
# Notice, this is not a Darwin-specific issue.
if {[string match macports-gcc* ${configure.compiler}]} {
    patchfiles-append \
                    patch-libatomic.diff
}

# https://trac.macports.org/ticket/68152
if {${os.platform} eq "darwin" && ${os.major} < 16} {
    patchfiles-append \
                    patch-legacy.diff
    post-patch {
        reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/src/Makevars
    }
}

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

test.run            yes
