{% set name = "expat" %}
{% set version = "2.7.5" %}

package:
  name: {{ name }}-split
  version: {{ version }}

source:
  url: https://github.com/lib{{ name }}/lib{{ name }}/releases/download/R_{{ version|replace(".", "_") }}/{{ name }}-{{ version }}.tar.bz2
  sha256: 386a423d40580f1e392e8b512b7635cac5083fe0631961e74e036b0a7a830d77

build:
  number: 0

requirements:
  build:
    - {{ stdlib('c') }}
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - cmake
    - ninja-base

outputs:
  - name: lib{{ name }}
    run_exports:
      # changes soname at major versions, default settings OK
      # https://abi-laboratory.pro/tracker/timeline/expat/
      - {{ pin_subpackage('lib' + name) }}
    ignore_run_exports_from:
      # This package needs the compiler for the tests, but the library
      # does not link to libstdc++.so
      - {{ compiler('cxx') }}
    files:
      - include                  # [unix]
      - lib/libexpat.*           # [unix]
      - lib/cmake                # [unix]
      - lib/pkgconfig            # [unix]
      - share/doc                # [unix]
      - Library/bin/*expat.dll   # [win]
      - Library/include          # [win]
      - Library/lib/*expat.lib   # [win]
      - Library/lib/cmake        # [win]
      - Library/share/doc        # [win]
    requirements:
      build:
        - {{ stdlib('c') }}
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
      host:
      run:
      run_constrained:
        - {{ name }} {{ version }}.*
    test:
      requires:
        - pkg-config
      commands:
        - ls $PREFIX/lib/libexpat*${SHLIB_EXT}* > /dev/null 2>&1  # [unix]
        - pkg-config --libs expat                                 # [unix]
        - if not exist %LIBRARY_BIN%\libexpat.dll exit 1          # [win]

  - name: {{ name }}
    run_exports:
      # changes soname at major versions, default settings OK
      # https://abi-laboratory.pro/tracker/timeline/expat/
      - {{ pin_subpackage('lib' + name) }}
    ignore_run_exports_from:
      # This package needs the compiler for the tests, but the library
      # does not link to libstdc++.so
      - {{ compiler('cxx') }}
    files:
      - bin                   # [unix]
      - share/man             # [unix]
      - Library/bin/*.exe     # [win]
      - Library/share/man     # [win]
    requirements:
      build:
        - {{ stdlib('c') }}
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
      host:
        - {{ pin_subpackage('lib' + name, exact=True) }}
      run:
        - {{ pin_subpackage('lib' + name, exact=True) }}
    test:
      commands:
        - xmlwf -h

about:
  home: https://libexpat.github.io
  license: MIT
  license_family: MIT
  license_file: COPYING
  summary: Expat XML parser library in C
  description: |
    Expat is a stream-oriented XML parser library written in C.
    Expat excels with files too large to fit RAM, and where performance
    and flexibility are crucial.
  dev_url: https://github.com/libexpat/libexpat
  doc_url: https://libexpat.github.io/doc

extra:
  recipe-maintainers:
    - kwilcox
    - ocefpaf
    - pelson
    - mingwandroid
    - msarahan
    - scopatz
