{% set version = "4.5.1" %}

package:
  name: libtiff
  version: {{ version }}

source:
  - url: https://download.osgeo.org/libtiff/tiff-{{ version }}.tar.gz
    sha256: d7f38b6788e4a8f5da7940c5ac9424f494d8a79eba53d555f4a507167dca5e2b
    folder: .
    patches:                                        # [osx]
      - patches/set_configure_script_version.patch  # [osx]

build:
  number: 0
  run_exports:
    # Does a very good job of maintaining compatibility.
    #    https://abi-laboratory.pro/tracker/timeline/libtiff/
    - {{ pin_subpackage('libtiff', max_pin='x') }}
  missing_dso_whitelist:
    # Only used by libtiff,bin/tiffgt (a viewer), which is ok.
    - /opt/X11/lib/libGL.1.dylib
    - /opt/X11/lib/libglut.3.dylib

requirements:
  build:
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - cmake         # [win]
    - libtool       # [unix]
    - make          # [not win]
    - ninja         # [win]
    - patch         # [osx]
  host:
    - jpeg 9e
    - libwebp-base 1.2.4 # [linux or osx]
    - xz 5.2.*
    - zlib 1.2.13  # should be actually 1.2.11, but pinning hell
    - zstd 1.5.2
    - lerc 3.0
    - libdeflate 1.17
  run:
    - jpeg >=9e,<10a
    - libwebp-base >=1.2.4,<2.0a0 # [linux or osx]
    - xz >=5.2.4,<6.0a0
    - zlib >=1.2.13,<1.3.0a0
    - zstd >=1.5.2,<1.6.0a0
    - lerc >=3.0,<4.0a0
    - libdeflate >=1.17,<1.18.0a0

test:
  downstreams:
    - pillow >=8
    - py-opencv >=4
  commands:
    - test -f ${PREFIX}/lib/libtiff.a  # [not win]
    - test -f ${PREFIX}/lib/libtiffxx.a  # [not win]
    - test -f ${PREFIX}/lib/libtiff{{ SHLIB_EXT }}  # [not win]
    - test -f ${PREFIX}/lib/libtiffxx{{ SHLIB_EXT }}  # [not win]
    - if not exist %PREFIX%\\Library\\bin\\tiff.dll exit 1  # [win]
    - if not exist %PREFIX%\\Library\\lib\\tiffxx.lib exit 1  # [win]
    - if not exist %PREFIX%\\Library\\bin\\libtiff.dll exit 1  # [win]
    # The C++ tiffxx.dll has been removed as of 4.5.0:
    # https://gitlab.com/libtiff/libtiff/-/merge_requests/338

about:
  # HTTPS does not work.
  home: http://www.simplesystems.org/libtiff/
  license: HPND
  license_file: LICENSE.md
  license_family: Other
  summary: Support for the Tag Image File Format (TIFF).
  description: |
    This software provides support for the Tag Image File Format (TIFF), a
    widely used format for storing image data.
  # HTTPS does not work.
  doc_url: http://www.simplesystems.org/libtiff/
  dev_url: https://gitlab.com/libtiff/libtiff

extra:
  recipe-maintainers:
    - jakirkham
    - mingwandroid
    - msarahan
    - ocefpaf
    - stuarteberg
