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

# GitHub version lags behind.
R.setup             cran USDAForestService gdalraster 1.8.0
revision            0
categories-append   gis
maintainers         nomaintainer
license             MIT
description         Bindings to the Geospatial Data Abstraction Library Raster API
long_description    {*}${description}
homepage            https://usdaforestservice.github.io/gdalraster
checksums           rmd160  da283ebdb278c2c3bb3f13dbec875d8bdf5387f4 \
                    sha256  bbc000ed465fe89d88b852372e633a7065c4cc494e0167ea6ca18a7c83bdd8af \
                    size    1777981

set proj_v          proj9

depends_build-append \
                    port:pkgconfig
depends_lib-append  path:lib/${proj_v}/lib/pkgconfig/proj.pc:${proj_v} \
                    port:gdal \
                    port:libxml2 \
                    port:R-Rcpp \
                    port:R-xml2 \
                    port:sqlite3

# configure fails to do its job: https://github.com/r-spatial/sf/issues/2292
destroot.env-append CPPFLAGS=-I${prefix}/lib/${proj_v}/include

destroot.pre_args-append \
                    --configure-args=' \
                        --with-proj-include=${prefix}/lib/${proj_v}/include \
                        --with-proj-lib=${prefix}/lib/${proj_v}/lib \
                        --with-proj-share=${prefix}/lib/${proj_v}/share/proj \
                        '

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

# Rather install it first and run tests from within R session.
test.run            no
