{% set version = "8.44" %}

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

source:
  url: https://ftp.pcre.org/pub/pcre/pcre-{{ version }}.tar.gz
  sha256: aecafd4af3bd0f3935721af77b889d9024b2e01d96b58471bd91a3063fb47728
  patches:
    - 0001-Define-snprintf-for-old-VS.patch
    - 0002-Workaround-CMake-FIND_PACKAGE-looking-on-PATH-misfeature.patch

build:
  number: 0
  run_exports:
    # mostly OK, but some scary symbol removal.  Let's try for trusting them.
    #    https://abi-laboratory.pro/tracker/timeline/pcre/
    - {{ pin_subpackage('pcre', max_pin='x') }}

requirements:
  build:
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - cmake        # [win]
    - m2-patch     # [win]
    - pkg-config   # [unix]
    - libtool      # [unix]
    - make         # [unix]

test:
  commands:
    # CLI tests.
    - pcre-config --version                             # [unix]
    - pcregrep --help
    - pcretest --help

    # Verify headers.
    - test -f "${PREFIX}/include/pcre.h"                # [unix]
    - test -f "${PREFIX}/include/pcre_scanner.h"        # [unix]
    - test -f "${PREFIX}/include/pcre_stringpiece.h"    # [unix]
    - test -f "${PREFIX}/include/pcrecpp.h"             # [unix]
    - test -f "${PREFIX}/include/pcrecpparg.h"          # [unix]
    - test -f "${PREFIX}/include/pcreposix.h"           # [unix]
    - if not exist %LIBRARY_INC%\pcre.h exit 1          # [win]
    - if not exist %LIBRARY_INC%\pcre_scanner.h exit 1  # [win]
    - if not exist %LIBRARY_INC%\pcre_stringpiece.h exit 1  # [win]
    - if not exist %LIBRARY_INC%\pcrecpp.h exit 1       # [win]
    - if not exist %LIBRARY_INC%\pcrecpparg.h exit 1    # [win]
    - if not exist %LIBRARY_INC%\pcreposix.h exit 1     # [win]

    # Verify libraries.
    - test -f "${PREFIX}/lib/libpcre.a"                 # [unix]
    - test -f "${PREFIX}/lib/libpcre${SHLIB_EXT}"       # [unix]
    - test -f "${PREFIX}/lib/libpcrecpp.a"              # [unix]
    - test -f "${PREFIX}/lib/libpcrecpp${SHLIB_EXT}"    # [unix]
    - test -f "${PREFIX}/lib/libpcreposix.a"            # [unix]
    - test -f "${PREFIX}/lib/libpcreposix${SHLIB_EXT}"  # [unix]
    - if not exist %LIBRARY_LIB%\pcre.lib exit 1        # [win]
    - if not exist %LIBRARY_BIN%\pcre.dll exit 1        # [win]
    - if not exist %LIBRARY_LIB%\pcreposix.lib exit 1   # [win]
    - if not exist %LIBRARY_BIN%\pcreposix.dll exit 1   # [win]
    - if not exist %LIBRARY_LIB%\pcrecpp.lib exit 1     # [win]
    - if not exist %LIBRARY_BIN%\pcrecpp.dll 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 the same syntax and semantics as Perl 5.
  description: |
    PCRE 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.
  doc_url: http://www.pcre.org/original/doc/html/
  doc_source_url: https://vcs.pcre.org/pcre2/code/trunk/doc/?sortdir=down
  dev_url: http://vcs.pcre.org/pcre2/

extra:
  recipe-maintainers:
    - jakirkham
    - scopatz
    - sebastian-luna-valero
    - saraedum
    - ocefpaf
    - chenghlee
