{% set version = "1.17.1" %}

package:
  name: c-ares
  version: {{ version }}

source:
  url: https://c-ares.haxx.se/download/c-ares-{{ version }}.tar.gz
  sha256: d73dd0f6de824afd407ce10750ea081af47eba52b8a6cb307d220131ad93fc40

build:
  number: 1

outputs:
  - name: c-ares
    script: build_output.sh  # [unix]
    script: bld_output.bat  # [win]
    build:
      run_exports:
        - {{ pin_subpackage("c-ares", max_pin="x") }}
    requirements:
      build:
        - {{ compiler("c") }}
        - cmake  # [win]
        # cmake on unix depends on c-ares. This breaks the cycle.
        - cmake-no-system  # [unix]
        - ninja  # [unix]
      run_constraint:
        - c-ares-static <0a0
    test:
      commands:
        - test -f ${PREFIX}/include/ares.h            # [not win]
        - test -f ${PREFIX}/lib/libcares${SHLIB_EXT}  # [not win]
        - test ! -f ${PREFIX}/lib/libcares.a          # [not win]
        - test ! -f ${PREFIX}/lib/libcares_static.a   # [not win]
        - if not exist %PREFIX%\\Library\\include\\ares.h exit 1  # [win]
        - if not exist %PREFIX%\\Library\\bin\\cares.dll exit 1  # [win]
        - if not exist %PREFIX%\\Library\\lib\\cares.lib exit 1  # [win]
        - if exist %PREFIX%\\Library\\lib\\cares_static.lib exit 1  # [win]
  - name: c-ares-static
    script: build_output.sh  # [unix]
    script: bld_output.bat  # [win]
    requirements:
      build:
        - {{ compiler("c") }}
        - cmake  # [win]
        # cmake on unix depends on c-ares. This breaks the cycle.
        - cmake-no-system  # [unix]
        - ninja  # [unix]
      run_constraint:
        - c-ares <0a0
    test:
      commands:
        - test -f ${PREFIX}/lib/libcares.a  # [not win]
        - test ! -f ${PREFIX}/lib/libcares${SHLIB_EXT}  # [not win]
        - test -f ${PREFIX}/include/ares.h            # [not win]
        - if not exist %PREFIX%\\Library\\include\\ares.h exit 1  # [win]
        - if exist %PREFIX%\\Library\\bin\\cares.dll exit 1  # [win]
        - if not exist %PREFIX%\\Library\\lib\\cares.lib exit 1  # [win]

about:
  home: https://c-ares.haxx.se/
  license: MIT
  license_family: MIT
  license_file: LICENSE.md
  summary: This is c-ares, an asynchronous resolver library

extra:
  recipe-maintainers:
    - ocefpaf
    - wesm
    - xhochy
