# -*- 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.9.0
revision            1
categories-append   devel
maintainers         {@barracuda156 macos-powerpc.org:barracuda} openmaintainer
license             MIT
description         Interface for the QuickJS light-weight JavaScript engine
long_description    {*}${description}
homepage            https://github.com/andrjohns/QuickJSR
checksums           rmd160  4e99c191b272f77035d8ccd3808f85c9a038ee4f \
                    sha256  b81cba773b1c3b3850c3553ac56382125f41ec21afe225e34580ebf2e3bd0b48 \
                    size    543553

# 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
