{% set name = "libsolv" %}
{% set version = "0.7.30" %}

package:
  name: {{ name|lower }}-suite
  version: {{ version }}

source:
  url: https://github.com/openSUSE/{{ name }}/archive/{{ version }}.tar.gz
  sha256: ce4aa2f0e3c5c9ab99dced6a1810af3f670f1b98892394edc68ccabe7b272133
  patches:
    - patches/win_export_and_static_build.patch  # [win]
    - patches/conda_variant_priorization.patch
    - patches/no_error_subdir_mismatch.patch
    - patches/pcre2-compat.patch

build:
  number: 1
  run_exports:
    - {{ pin_subpackage('libsolv', max_pin='x.x') }}
  ignore_run_exports:  # [win]
    - zlib             # [win]

requirements:
  build:
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - m2-patch  # [win]
    - patch     # [not win]
    - ninja
    - cmake
  host:
    # pkg-config is placed in host because in build it is not available for win64
    - pkg-config
    - zlib
    - pcre2

outputs:
  - name: libsolv
    script: install.sh           # [unix]
    script: install_dynamic.bat  # [win]
    requirements:
      build:
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
        - ninja
        - cmake
      host:
        # pkg-config is placed in host because in build it is not available for win64
        - pkg-config
        - zlib
        - pcre2
    test:
      commands:
        - test -f ${PREFIX}/lib/libsolv${SHLIB_EXT}     # [unix]
        - test -f ${PREFIX}/lib/libsolvext${SHLIB_EXT}  # [unix]
        - test -f ${PREFIX}/lib/libsolv.so.1            # [linux]
        - test -f ${PREFIX}/include/solv/repo.h         # [unix]
        - if not exist %LIBRARY_INC%\solv\repo.h (exit 1)     # [win]
        - if not exist %LIBRARY_BIN%\solv.dll (exit 1)        # [win]
        - if not exist %LIBRARY_LIB%\solv.lib (exit 1)        # [win]
        - if not exist %LIBRARY_BIN%\solvext.dll (exit 1)     # [win]
        - if not exist %LIBRARY_LIB%\solvext.lib (exit 1)     # [win]
        - if exist %LIBRARY_LIB%\solv_static.lib (exit 1)     # [win]
        - if exist %LIBRARY_LIB%\solvext_static.lib (exit 1)  # [win]
        # Running the executables
        - dumpsolv.exe -h  # [win]
        - dumpsolv -h      # [unix]

  - name: libsolv-static
    script: install.sh          # [unix]
    script: install_static.bat  # [win]
    requirements:
      build:
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
        - ninja
        - cmake
      host:
        - pkg-config
        - zlib
        - pcre2
        - {{ pin_subpackage("libsolv", exact=True) }}
      run:
        - {{ pin_subpackage("libsolv", exact=True) }}
    test:
      commands:
        - test -f "${PREFIX}/lib/libsolv.a"     # [unix]
        - test -f "${PREFIX}/lib/libsolvext.a"  # [unix]
        - if not exist %LIBRARY_LIB%\solv_static.lib (exit 1)     # [win]
        - if not exist %LIBRARY_LIB%\solvext_static.lib (exit 1)  # [win]

about:
  home: https://github.com/openSUSE/libsolv
  license: BSD-3-Clause
  license_family: BSD
  license_file: LICENSE.BSD
  summary: Library for solving packages and reading repositories
  description: |
    libsolv, a free package dependency solver using a satisfiability algorithm.
  dev_url: https://github.com/openSUSE/libsolv
  doc_url: https://github.com/openSUSE/libsolv/tree/master/doc

extra:
  recipe-maintainers:
    - SylvainCorlay
    - JohanMabille
    - wolfv
    - davidbrochart
    - adriendelsalle
