{% set version = "3.4.8" %}
{% set am_version = "1.15" %} # keep synchronized with build.sh
{% set posix = 'm2-' if win else '' %}
{% set native = 'm2w64-' if win else '' %}

package:
  name: libffi
  version: {{ version }}

source:
  url: https://github.com/libffi/libffi/releases/download/v{{version}}/libffi-{{version}}.tar.gz
  sha256: bc9842a18898bfacb0ed1252c4febcc7e78fa139fd27fdc7a3e30d9d9356119b
  patches:
    - patches/win_cmake.patch                                                  # [win]
    - patches/fix_w3264_masm.patch                                             # [win]
    - patches/0004-LIBFFI_CLOSURE.patch                                        # [linux]
build:
  number: 3
  run_exports:
    # good history: https://abi-laboratory.pro/tracker/timeline/libffi/
    - {{ pin_subpackage('libffi', max_pin='x.x') }}

requirements:
  build:
    - {{ stdlib('c') }}
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - cmake                              # [win]
    - make                               # [unix]
    - autoconf                           # [unix]
    - libtool                            # [unix]
    - automake                           # [unix]

test:
  requires:
    - llvm-tools     # [win]
    - msys2-grep     # [win]
    - make # [unix]
    - cmake # [win]
    # no compile tests here, as used compiler might be not upward-compatible
    # needs to be fixed
    - {{ stdlib('c') }}
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
  source_files:
    - testsuite/libffi.bhaible
    - testsuite

about:
  home: https://sourceware.org/libffi
  license: MIT
  license_file: LICENSE
  license_family: MIT
  summary: A Portable Foreign Function Interface Library
  description: |
    The libffi library provides a portable, high level programming interface
    to various calling conventions. This allows a programmer to call any
    function specified by a call interface description at run-time.
  doc_url: https://sourceware.org/libffi
  dev_url: https://github.com/libffi/libffi

extra:
  recipe-maintainers:
    - stefan-balke
    - scopatz
    - isuruf
