{% set name = "zstd" %}
{% set version = "1.5.0" %}

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

source:
  url: https://github.com/facebook/{{ name }}/archive/v{{ version }}.tar.gz
  sha256: 0d9ade222c64e912d6957b11c923e214e2e010a18f39bec102f572e693ba2867

build:
  number: 0

outputs:
  - name: zstd
    script: install.sh  # [unix]
    script: install.bat  # [win]
    build:
      run_exports:
        # pretty bad removal of symbols in every other micro release:
        #   https://abi-laboratory.pro/tracker/timeline/zstd/
        #  Working smoothly since 1.4.x
        - {{ pin_subpackage('zstd', max_pin='x.x') }}
    requirements:
      build:
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
        - msinttypes  # [win]
        - ninja
        - make  # [unix]
        - cmake-no-system  # [unix]
        - cmake  # [win]
      host:
        - zlib
        - xz
        - lz4-c
    test:
      requires:
        - 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 exist %LIBRARY_LIB%\lib{{ name }}_static.lib exit 1  # [win]

        - export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig  # [unix]
        - test -f ${PREFIX}/lib/pkgconfig/lib{{ name }}.pc  # [unix]
        - pkg-config --cflags lib{{ name }}  # [unix]

  - name: zstd-static
    script: install.sh  # [unix]
    build:
      skip: true  # [win]
    requirements:
      build:
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
        - msinttypes  # [win]
        - ninja
        - make  # [unix]
        - cmake-no-system
      host:
        - {{ pin_subpackage('zstd', exact=True) }}
      run:
        - {{ pin_subpackage('zstd', exact=True) }}
    test:
      commands:
        - test -f ${PREFIX}/lib/lib{{ name }}.a    # [unix]

about:
  home: http://www.zstd.net
  license: BSD-3-Clause
  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:
  feedstock-name: zstd
  recipe-maintainers:
    - rmax
    - msarahan
    - xhochy
    - hmaarrfk
