{% set version = "2.12" %}

package:
  name: pandoc
  version: {{ version }}  # [not (ppc64le or win32 or s390x)]
  version: "1.16.0"       # [s390x]
  version: "2.2.1"        # [ppc64le]
  version: "2.9.2.1"      # [win32]

source:
  url: https://github.com/jgm/pandoc/releases/download/{{ version }}/pandoc-{{ version }}-linux-amd64.tar.gz  # [linux64]
  sha256: 6d89c16f31ef4cd826133b35bbe978dd2ca7328d7b8d51fbaf2c02ca5b5553e0  # [linux64]

  url: https://github.com/jgm/pandoc/releases/download/{{ version }}/pandoc-{{ version }}-linux-arm64.tar.gz  # [aarch64]
  sha256: ec41752bcea7416d00e7f845d58351dc831246b910004cfe62d52079085a640a  # [aarch64]

  url: https://github.com/jgm/pandoc/releases/download/{{ version }}/pandoc-{{ version }}-macOS.zip  # [osx]
  sha256: 7a23d5ed5e4eab251c8c208a25330a53787eec8216e4b768f194f850a64dc664  # [osx]

  url: https://github.com/jgm/pandoc/releases/download/{{ version }}/pandoc-{{ version }}-windows-x86_64.zip  # [win64]
  sha256: 3ed3283438a1a3d45b8c1fb3cddb87cf93c86064b84de4f8521436292ed94e50  # [win64]

  # upstream no longer provides win-32 binaries
  url: https://github.com/jgm/pandoc/releases/download/2.9.2.1/pandoc-2.9.2.1-windows-i386.zip    # [win32]
  sha256: db5a8533b7e2ef38114e9788e56530bb6be330c326731692f236218682017d4d  # [win32]

  # repackage the RPM built for EPEL
  url: https://copr-be.cloud.fedoraproject.org/results/petersen/pandoc/epel-7-ppc64le/00770404-pandoc/pandoc-2.2.1-1.el7.ppc64le.rpm  # [ppc64le]
  sha256: 5a9818493f8b14821c5fb44234c898f776faf011089dc77e1dcf6ba3e51e0a81  # [ppc64le]

  # s390x ...
  - url: http://download.sinenomine.net/clefos/epel7/s390x/pandoc-static-1.16.0.2-1.el7.s390x.rpm   # [s390x]
  - folder: common  # [s390x]
    url: http://download.sinenomine.net/clefos/epel7/s390x/pandoc-common-1.16.0.2-1.el7.s390x.rpm   # [s390x]
  - folder: cmark   # [s390x]
    url: http://download.sinenomine.net/clefos/epel7/s390x/cmark-lib-0.23.0-4.el7.s390x.rpm         # [s390x]

build:
  number: 3
  binary_relocation: False  # [osx]
  missing_dso_whitelist:  # [osx or s390x]
    - /usr/lib/libiconv.2.dylib  # [osx]
    - /usr/lib/libz.1.dylib  # [osx]
    - /usr/lib/libcharset.1.dylib  # [osx]
    - $RPATH/liblua-5.1.so  # [s390x]
    - $RPATH/libpcre.so.1   # [s390x]
    - $RPATH/libffi.so.6    # [s390x]

# The pandoc binary from the RPM depends on libgmp, libz and libffi and system libraries.
# Add these as host requirements to pick up the correct run_exports
{% if ARCH == "ppc64le" or ARCH == "s390x" %}
requirements:
  build:
    - patchelf
    # we do not actually need a compiler but want the
    # sysroot for link checking and the run_exports
    # avoid {{ compiler('c') }} which adds unneeded hashes on all platforms
    - gcc_linux-ppc64le  # [ppc64le]
    - gcc_linux-s390x    # [s390x]
  host:
    - gmp 6.1.2
    - zlib 1.2.11
    - libffi 3.4
    - yaml  # [s390x]
  run:
    - libffi >=3.4,<3.5
{% endif %}

test:
  commands:
    - type pandoc  # [osx]
    - pandoc --version
    - pandoc --help

about:
  home: https://pandoc.org/
  license: GPL-2.0
  license_family: GPL
  license_file: LICENSE
  summary: Universal markup converter (repackaged binaries)
  description: |
    Pandoc is a Haskell library for converting from one markup format to
    another, and a command-line tool that uses this library.
  doc_url: https://pandoc.org/MANUAL.html
  dev_url: https://github.com/jgm/pandoc
  doc_source_url: https://github.com/jgm/pandoc/tree/master/doc

extra:
  recipe-maintainers:
    - jankatins
    - ocefpaf
    - dhimmel
    - kiwi0fruit
    - katietz
