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

# Revert to GitHub once updated there.
R.setup             cran r-spatial s2 1.1.7
revision            0
categories-append   math
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
license             Apache-2
description         Spherical geometry operators using the S2 geometry library
long_description    {*}${description}
homepage            https://r-spatial.github.io/s2
checksums           rmd160  b2ca3bfa17736f3e0c97dce40c79c7a8dd17770a \
                    sha256  30762c7150dd72e2f4a3d50e64b8b73b2d59b73275687ba3eea7a6e07f786878 \
                    size    2381288

depends_lib-append  port:R-Rcpp \
                    port:R-wk

patch.pre_args-replace  -p0 -p1
patchfiles          0001-Misc-PPC-additions.patch \
                    0002-examine_stack.cc-fix-ppc-for-macOS.patch \
                    0003-Some-PPC-fix-ups.patch \
                    0004-patch-fix-bool-error.diff \
                    MAP_ANON.patch

if {[string match *gcc* ${configure.compiler}]} {
    patchfiles-append \
                    0005-patch-libatomic.diff
}

depends_test-append port:R-bit64 \
                    port:R-testthat \
                    port:R-vctrs

test.run            yes

# Some PowerPC-related issues:
# https://github.com/r-spatial/s2/issues/235
# https://github.com/google/s2geometry/issues/315
# https://github.com/google/s2geometry/issues/316
# Notice, that for an unknown reason build on Rosetta fails.
