{% set version = "4.1.0" %}

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

source:
  url: https://download.osgeo.org/libtiff/tiff-{{ version }}.tar.gz
  sha256: 5d29f32517dadb6dbcd1255ea5bbc93a2b54b94fbf83653b4d65c7d6775b8634
  patches:
    - patches/0001-CVE-2017-11613_part1.patch
    - patches/0002-CVE-2017-11613_part2.patch
    - patches/fix_TIFFReadRawStrip_man_page_typo.patch

build:
  number: 1
  skip: True  # [win and vc<14]
  # Does a very good job of maintaining compatibility.
  #    https://abi-laboratory.pro/tracker/timeline/libtiff/
  run_exports:
    - {{ 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]
    - ninja   # [win]
    - make    # [not win]
  host:
    - zlib
    - jpeg
    - xz
    - zstd >=1.4
  run:
    - zlib
    - jpeg
    - xz
    - zstd >=1.4

test:
  commands:
    - test -f ${PREFIX}/lib/libtiff.a                            # [unix]
    - test -f ${PREFIX}/lib/libtiffxx.a                          # [unix]
    - test -f ${PREFIX}/lib/libtiff${SHLIB_EXT}                  # [unix]
    - test -f ${PREFIX}/lib/libtiffxx${SHLIB_EXT}                # [unix]
    - if not exist %PREFIX%\\Library\\bin\\tiff.dll exit 1       # [win]
    - if not exist %PREFIX%\\Library\\bin\\tiffxx.dll exit 1     # [win]
    - if not exist %PREFIX%\\Library\\bin\\libtiff.dll exit 1    # [win]
    - if not exist %PREFIX%\\Library\\bin\\libtiffxx.dll exit 1  # [win]

about:
  home: http://www.libtiff.org/
  license: HPND
  license_file: COPYRIGHT
  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.
  doc_url: http://www.libtiff.org/document.html

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