# -*- 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 jeroen V8 8.2.0
revision            0
categories-append   devel
maintainers         {@barracuda156 macos-powerpc.org:barracuda} openmaintainer
license             MIT
description         Embedded javascript and webassembly engine for R
long_description    {*}${description}
checksums           rmd160  ed1a10638e2113a4abe3b0ba0e1465cf7cbb81ad \
                    sha256  72974b10eeb5cbfd9208c6b448195685e3e6b6e19bd1f6efb03293309c91a92b \
                    size    657317

set v8_ver          8.3

depends_lib-append  port:R-curl \
                    port:R-jsonlite \
                    port:R-Rcpp \
                    port:v8-${v8_ver}

patchfiles          patch-fix-configure.diff

post-patch {
    reinplace "s|@V8@|v8-${v8_ver}|" ${worksrcpath}/configure
    reinplace "s|@V8_HOME@|${prefix}/libexec/v8-${v8_ver}|g" ${worksrcpath}/configure
    if {[string match *gcc* ${configure.compiler}] && ${configure.build_arch} in [list i386 ppc]} {
        reinplace "s|@V8_LIBS@|-lv8_base_without_compiler -lv8_compiler -lv8_initializers -lv8_inspector -lv8_libbase -lv8_libplatform -lv8_libsampler -lv8_snapshot -latomic|" ${worksrcpath}/configure
    } else {
        reinplace "s|@V8_LIBS@|-lv8_base_without_compiler -lv8_compiler -lv8_initializers -lv8_inspector -lv8_libbase -lv8_libplatform -lv8_libsampler -lv8_snapshot|" ${worksrcpath}/configure
    }
}

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

test.run            yes
