# -*- 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.6
revision            1
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  f8e1b4d685a12a67f218c0949a3146d3e63d5b81 \
                    sha256  1d9d2e6b7890122f916fd8f86060cb0f101637ead158bbc22ee2f0324b93a066 \
                    size    2376936

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

patch.pre_args      -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.
