{% set version = "2.4-2" %}

{% 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: 91754cbc68dd1c7093cd550440ea8bb2c6975aaffd74befe6c3638ebc7c54f92

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

requirements:
  build:
    - posix  # [win]
    - {{ compiler('c') }}        # [unix]
    - {{ compiler('m2w64_c') }}  # [win]
  host:
    - r-base
    - libnetcdf
    - udunits2
  run:
    - libnetcdf
    - udunits2
    - r-base

test:
  commands:
    - $R -e "library('RNetCDF')"  # [not win]
    - "\"%R%\" -e \"library('RNetCDF')\""  # [win]
    - conda inspect linkages -p $PREFIX $PKG_NAME  # [not win]
    - conda inspect objects -p $PREFIX $PKG_NAME  # [osx]

about:
  home: https://cran.r-project.org/web/packages/RNetCDF
  license: GPL-2.0-or-later
  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
    - marcelotrevisani
