{% set version = "58.2" %}
{% set version_under = version.replace(".", "_") %}

package:
  name: icu
  version: {{ version }}

source:
  fn:  icu4c-{{ version_under }}-src.tgz
  url:
    # Sources for this version are no longer available from the ICU site, so
    # use the official SourceForge prior releases mirror.
    - https://sourceforge.net/projects/icu/files/ICU4C/{{ version }}/icu4c-{{ version_under }}-src.tgz/download
    - http://download.icu-project.org/files/icu4c/{{ version }}/icu4c-{{ version_under }}-src.tgz
  sha256: 2b0a4410153a9b20de0e20c7d8b66049a72aef244b53683d0d7521371683da0c
  patches:
    # Include an extra header when using mingw.
    - icu4c-4_9_1-mingw-w64-mkdir-compatibility.patch  # [win]
    # Omit lib prefix on libraries.
    - icu-config.patch  # [win]
    # Fixes a high severity integer/buffer overflow vulnerability
    - CVE-2020-10531.patch
    # Fix high severity out-bound-write/buffer overflow vulnerabilities
    - CVE-2017-7867_CVE-2017-7868.patch
    # Fixes critical severity double free/arbitrary code execution vulnerability
    - CVE-2017-14952.patch
    # Fixes medium severity stack buffer overflow/heap corruption vulnerability
    - CVE-2017-15396.patch
    # Fixes medium severity integer overflow vulnerability
    - CVE-2017-15422.patch

build:
  number: 3
  run_exports:
    # icu changes their file extension with each major rev.  Default pin OK.
    - {{ pin_subpackage('icu') }}

requirements:
  build:
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - make     # [unix]
    - m2-base  # [win]
    - m2-make  # [win]

test:
  files:
    # From http://source.icu-project.org/repos/icu/data/trunk/charset/data/ucm/gb-18030-2000.ucm
    - gb-18030-2000.ucm
    # From ICU's data folder.
    - de.txt
  commands:
    # Libraries
    {% set libs = [
       "libicudata",
       "libicui18n",
       "libicuio",
       "libicutest",
       "libicutu",
       "libicuuc"
     ] %}
    {% for each_lib in libs %}
    - test -f $PREFIX/lib/{{ each_lib }}.a  # [not win]
    - test -f $PREFIX/lib/{{ each_lib }}.{{ version }}.dylib   # [osx]
    - test -f $PREFIX/lib/{{ each_lib }}.so.{{ version }}  # [linux]
    {% endfor %}

    # CLI tests
    - genbrk --help
    - gencfu --help
    - gencnval --help
    - gendict --help
    - icuinfo --help
    - icu-config --help  # [not win]
    - makeconv gb-18030-2000.ucm

    - conda inspect linkages -p $PREFIX icu  # [not win]
    - conda inspect objects -p $PREFIX icu  # [osx]

about:
  home: http://site.icu-project.org/
  license: MIT
  summary: 'International Components for Unicode.'
  description: |
    ICU is a mature, widely used set of C/C++ and Java libraries providing
    Unicode and Globalization support for software applications. ICU is
    widely portable and gives applications the same results on all platforms
    and between C/C++ and Java software.
  doc_url: http://site.icu-project.org/design
  dev_url: http://source.icu-project.org/repos/icu/

extra:
  recipe-maintainers:
    - ccordoba12
    - jakirkham
    - msarahan
    - ocefpaf
    - chenghlee
