{% set name = "zstd" %}
{% set version = "1.3.7" %}
{% set sha256hash = "3277f236df0ca6edae01ae84e865470000c5a3484588fd5bc3d869877fd3573d" %}

package:
  name: {{ name|lower }}
  version: {{ version }}

source:
  url: https://github.com/facebook/{{ name }}/releases/download/v{{ version }}/{{ name }}-{{ version }}.tar.gz
  sha256: {{ sha256hash }}
  patches:
    - patches/0005-CMake-Fix-windres-.rc-not-including-programs-windres.patch
    # Causes linking errors due to benchmarking not beging built into the shared library on
    # Windows (or it may be there are some missing __declspec(dllexport) in the shared library?)
    # - patches/0006-Link-zstd-exe-dynamically.patch

build:
  number: 0
  run_exports:
    # pretty bad removal of symbols in every other micro release:
    #   https://abi-laboratory.pro/tracker/timeline/zstd/
    - {{ pin_subpackage('zstd', max_pin='x.x.x') }}

requirements:
  build:
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}  # [linux]
    - msinttypes  # [win and vc<14]
    - make   # [unix]
    - cmake
    - m2-patch  # [win]
  host:
    - zlib
    - xz
    - lz4

test:             # [unix]
  requires:       # [unix]
    - pkg-config  # [unix]

  commands:
    - zstd -be -i5
    - test -f ${PREFIX}/include/{{ name }}.h     # [unix]
    - test -f ${PREFIX}/lib/lib{{ name }}.a      # [unix]
    - test -f ${PREFIX}/lib/lib{{ name }}.so     # [linux]
    - test -f ${PREFIX}/lib/lib{{ name }}.dylib  # [osx]
    - if not exist %LIBRARY_INC%\{{ name }}.h exit 1              # [win]
    - if not exist %LIBRARY_BIN%\lib{{ name }}.dll exit 1         # [win]
    - if not exist %LIBRARY_LIB%\lib{{ name }}.lib exit 1         # [win]
    - if not exist %LIBRARY_LIB%\lib{{ name }}_static.lib exit 1  # [win and not py27]

    - pkg-config --cflags lib{{ name }}  # [unix]

about:
  home: http://www.zstd.net
  license: BSD 3-Clause
  license_family: BSD
  license_file: LICENSE
  summary: "Zstandard - Fast real-time compression algorithm"
  description: |
    Zstandard is a real-time compression algorithm, providing high compression
    ratios. It offers a very wide range of compression / speed trade-off, while
    being backed by a very fast decoder. It also offers a special mode for
    small data, called dictionary compression, and can create dictionaries from
    any sample set. Zstandard library is provided as open source software using
    a BSD license.
  doc_url: https://facebook.github.io/zstd/zstd_manual.html
  dev_url: https://github.com/facebook/zstd

extra:
  recipe-maintainers:
    - rmax
    - msarahan

