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

# Revert to GitHub once updated there.
R.setup             cran r-lib webfakes 1.4.0 v
revision            1
categories-append   devel
maintainers         nomaintainer
license             MIT
description         Fake web-apps for HTTP testing
long_description    {*}${description}
homepage            https://webfakes.r-lib.org
checksums           rmd160  7706b6a82f861e17483c5f6c802584a7191e6c42 \
                    sha256  442c246b89ff3afd202980bb3c91c0e4ec1ee7aca38d8edfbc3cf9f079896284 \
                    size    1882937
# github.tarball_from archive

# https://github.com/r-lib/webfakes/pull/122
patchfiles          0001-Makevars.in-fix-generating-static-lib.patch

# If R will support universal builds, then in a case of ppc+x86, endian define should be dropped.
patchfiles-append   patch-endian.diff
post-patch {
    if {${configure.build_arch} in [list ppc ppc64]} {
        reinplace "s,@ENDIAN_FLAG@,-DARCH_IS_BIG_ENDIAN=1," ${worksrcpath}/src/Makevars.in
    } else {
        reinplace "s,@ENDIAN_FLAG@,-DARCH_IS_BIG_ENDIAN=0," ${worksrcpath}/src/Makevars.in
    }
}

depends_test-append port:R-brotli \
                    port:R-callr \
                    port:R-covr \
                    port:R-curl \
                    port:R-digest \
                    port:R-glue \
                    port:R-httpuv \
                    port:R-httr \
                    port:R-jsonlite \
                    port:R-processx \
                    port:R-testthat \
                    port:R-withr \
                    port:R-xml2 \
                    port:R-zip

test.run            yes
