{% set version = '1.9-1' %}

{% set posix = 'm2-' if win else '' %}
{% set native = 'm2w64-' if win else '' %}

package:
  name: r-rnetcdf
  version: {{ version|replace("-", "_") }}

source:
  fn: RNetCDF_{{ version }}.tar.gz
  url:
    - https://cran.r-project.org/src/contrib/RNetCDF_{{ version }}.tar.gz
    - https://cran.r-project.org/src/contrib/Archive/RNetCDF/RNetCDF_{{ version }}.tar.gz
  sha256: 7d5a1e47ba3f41050e92ac27fe12c9ffd8dea67e132c43ff071dcdb0fad4ae45

build:
  number: 0
  script: R CMD INSTALL --build .
  skip: True  # [win32]
  rpaths:
    - lib/R/lib/
    - lib/

requirements:
  build:
    - r-base
    - libnetcdf 4.4.*
    - udunits2
    - posix  # [win]
    - {{native}}toolchain  # [win]
    - gcc  # [not win]
  run:
    - libnetcdf 4.4.*
    - udunits2
    - r-base
    - libgcc  # [not win]

test:
  commands:
    - $R -e "library('RNetCDF')"  # [not win]
    - "\"%R%\" -e \"library('RNetCDF')\""  # [win]

about:
  home: https://cran.r-project.org/web/packages/RNetCDF
  license: GPL (>= 2
  license_file: LICENSE
  summary: An interface to the NetCDF file format designed by Unidata for efficient storage of
    array-oriented scientific data and descriptions. The R interface is closely based
    on the C API of the NetCDF library, and it includes calendar conversions from the
    Unidata UDUNITS library. The current implementation supports all operations on NetCDF
    datasets in classic and 64-bit offset file formats, and NetCDF4-classic format is
    supported for reading and modification of existing files.

extra:
  recipe-maintainers:
    - ocefpaf
