{% set name = "pcre2-split-recipe" %}
{% set version = "10.44" %}

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

source:
  url: https://github.com/PCRE2Project/pcre2/archive/refs/tags/pcre2-{{ version }}.tar.gz
  sha256: 07a002e8216382a96f722bc4a831f3d77457fe3e9e62a6dff250a2dd0e9c5e6d

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

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

outputs:
  - name: pcre2
    script: build-shared.sh  # [unix]
    script: bld-shared.bat  # [win]
    build:
      run_exports:
        # https://abi-laboratory.pro/index.php?view=timeline&l=pcre2
        - {{ pin_subpackage("pcre2", max_pin="x.x") }}
    requirements:
      build:
        - {{ compiler('c') }}
        - {{ stdlib("c") }}
        - cmake
        - ninja
        - posix  # [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.5                   # [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.13.0                      # [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.13.0                     # [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.13.0                     # [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]
        - test -f ${PREFIX}/cmake/pcre2-config.cmake                               # [not win]
        - test -f ${PREFIX}/cmake/pcre2-config-version.cmake                       # [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-16.dll exit 1                          # [win]
        - if not exist %LIBRARY_BIN%\\pcre2-32.dll exit 1                          # [win]
        - if not exist %LIBRARY_BIN%\\pcre2-posix.dll exit 1                       # [win]
        - if not exist %LIBRARY_LIB%\\pcre2-8.lib exit 1                           # [win]
        - if not exist %LIBRARY_LIB%\\pcre2-16.lib exit 1                          # [win]
        - if not exist %LIBRARY_LIB%\\pcre2-32.lib exit 1                          # [win]
        - if not exist %LIBRARY_LIB%\\pcre2-posix.lib exit 1                       # [win]
        - if not exist %LIBRARY_LIB%\\pkgconfig\\libpcre2-posix.pc exit 1          # [win]
        - if not exist %LIBRARY_LIB%\\pkgconfig\\libpcre2-8.pc exit 1              # [win]
        - if not exist %LIBRARY_LIB%\\pkgconfig\\libpcre2-16.pc exit 1             # [win]
        - if not exist %LIBRARY_LIB%\\pkgconfig\\libpcre2-32.pc exit 1             # [win]
        - if not exist %LIBRARY_PREFIX%\\cmake\\pcre2-config.cmake exit 1          # [win]
        - if not exist %LIBRARY_PREFIX%\\cmake\\pcre2-config-version.cmake exit 1  # [win]
  - name: pcre2-static
    script: build-static.sh  # [unix]
    script: bld-static.bat  # [win]
    requirements:
      build:
        - {{ compiler('c') }}
        - {{ stdlib("c") }}
      host:
        - bzip2
        - zlib
        - {{ pin_subpackage('pcre2', exact=True) }}
      run:
        - {{ pin_subpackage('pcre2', exact=True) }}
    test:
      commands:
        - test -f $PREFIX/lib/libpcre2-8.a                             # [unix]
        - test -f $PREFIX/lib/libpcre2-16.a                            # [unix]
        - test -f $PREFIX/lib/libpcre2-32.a                            # [unix]
        - test -f $PREFIX/lib/libpcre2-posix.a                         # [unix]
        - if not exist %LIBRARY_LIB%\pcre2-8-static.lib exit 1         # [win]
        - if not exist %LIBRARY_LIB%\pcre2-16-static.lib exit 1        # [win]
        - if not exist %LIBRARY_LIB%\pcre2-32-static.lib exit 1        # [win]
        - if not exist %LIBRARY_LIB%\pcre2-posix-static.lib 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.
  doc_url: http://www.pcre.org/current/doc/html/

extra:
  feedstock-name: pcre2
  recipe-maintainers:
    - dfornika
    - mariusvniekerk
    - xhochy
