{% set name = "pcre2" %}
{% set version = "10.37" %}

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

source:
  url: https://github.com/PhilipHazel/{{ name }}/releases/download/{{ name }}-{{ version }}/{{ name }}-{{ version }}.tar.bz2
  sha256: 4d95a96e8b80529893b4562be12648d798b957b1ba1aae39606bbc2ab956d270

build:
  number: 1
  run_exports:
    # https://abi-laboratory.pro/index.php?view=timeline&l=pcre2
    - {{ pin_subpackage("pcre2", max_pin="x.x") }}

requirements:
  build:
    - {{ compiler('c') }}
    - cmake
    - ninja
    - posix  # [win]
    - m2-sed  # [win]
  host:
    - bzip2
    - zlib

test:
  commands:
    - pcre2test --version
    - pcre2grep --version

    - pcre2-config --version                                  # [not win]
    - test -f ${PREFIX}/include/pcre2.h                       # [not win]
    - test -f ${PREFIX}/include/pcre2posix.h                  # [not win]
    - test -f ${PREFIX}/lib/libpcre2-posix${SHLIB_EXT}        # [not win]
    - test -f ${PREFIX}/lib/libpcre2-posix.3${SHLIB_EXT}      # [osx]
    - test -f ${PREFIX}/lib/libpcre2-posix${SHLIB_EXT}.3      # [linux]
    - test -f ${PREFIX}/lib/libpcre2-posix${SHLIB_EXT}.3.0.0  # [linux]
    - test -f ${PREFIX}/lib/libpcre2-8${SHLIB_EXT}            # [not win]
    - test -f ${PREFIX}/lib/libpcre2-8.0${SHLIB_EXT}          # [osx]
    - test -f ${PREFIX}/lib/libpcre2-8${SHLIB_EXT}.0          # [linux]
    - test -f ${PREFIX}/lib/libpcre2-8${SHLIB_EXT}.0.10.2      # [linux]
    - test -f ${PREFIX}/lib/libpcre2-16${SHLIB_EXT}            # [not win]
    - test -f ${PREFIX}/lib/libpcre2-16.0${SHLIB_EXT}          # [osx]
    - test -f ${PREFIX}/lib/libpcre2-16${SHLIB_EXT}.0          # [linux]
    - test -f ${PREFIX}/lib/libpcre2-16${SHLIB_EXT}.0.10.2      # [linux]
    - test -f ${PREFIX}/lib/libpcre2-32${SHLIB_EXT}            # [not win]
    - test -f ${PREFIX}/lib/libpcre2-32.0${SHLIB_EXT}          # [osx]
    - test -f ${PREFIX}/lib/libpcre2-32${SHLIB_EXT}.0          # [linux]
    - test -f ${PREFIX}/lib/libpcre2-32${SHLIB_EXT}.0.10.2      # [linux]
    - test -f ${PREFIX}/lib/pkgconfig/libpcre2-8.pc           # [not win]
    - test -f ${PREFIX}/lib/pkgconfig/libpcre2-16.pc           # [not win]
    - test -f ${PREFIX}/lib/pkgconfig/libpcre2-32.pc           # [not win]
    - test -f ${PREFIX}/lib/pkgconfig/libpcre2-posix.pc       # [not win]

    - if not exist %LIBRARY_INC%\\pcre2.h exit 1                              # [win]
    - if not exist %LIBRARY_INC%\\pcre2posix.h exit 1                         # [win]
    - if not exist %LIBRARY_BIN%\\pcre2-8.dll exit 1                          # [win]
    - if not exist %LIBRARY_BIN%\\pcre2-posix.dll exit 1                      # [win]
    - if not exist %LIBRARY_PREFIX%\\lib\\pkgconfig\\libpcre2-posix.pc exit 1  # [win]
    - if not exist %LIBRARY_PREFIX%\\lib\\pkgconfig\\libpcre2-8.pc exit 1      # [win]

about:
  home: http://www.pcre.org/
  license: BSD-3-Clause
  license_family: BSD
  license_file: LICENCE
  summary: Regular expression pattern matching using Perl 5 syntax and semantics.
  description: |
    The PCRE library is a set of functions that implement regular expression pattern matching
    using the same syntax and semantics as Perl 5. PCRE has its own native API, as well as a set of
    wrapper functions that correspond to the POSIX regular expression API. The PCRE library is
    free, even for building proprietary software.
  dev_url: https://github.com/PhilipHazel/pcre2
  doc_url: http://www.pcre.org/current/doc/html/

extra:
  recipe-maintainers:
    - dfornika
    - mariusvniekerk
    - xhochy
