{% set version = "1.11.1" %}

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

source:
  url: https://www.libssh2.org/download/libssh2-{{ version }}.tar.gz
  sha256: d9ec76cbe34db98eec3539fe2c899d26b0c837cb3eb466a56b0f109cabf658f7

build:
  number: 0

outputs:
  - name: libssh2
    script: build_shared.sh  # [unix]
    script: bld_shared.bat  # [win]
    build:
      run_exports:
        - {{ pin_subpackage('libssh2') }}
    requirements:
      build:
        # This breals a dependency cycle on unix
        # curl->libssh2->cmake->curl
        - cmake-no-system
        - {{ compiler('c') }}   # [not (osx and arm64)]
        - {{ stdlib("c") }}     # [not (osx and arm64)]
        - {{ compiler('clang_bootstrap') }} 11.*  # [osx and arm64]
        - cctools_{{ target_platform }}  # [osx and arm64]
        - ninja  # [win]
        - make   # [unix]
      host:
        - openssl
        - zlib
    test:
      commands:
        - test -f $PREFIX/include/libssh2.h              # [not win]
        - test -f $PREFIX/include/libssh2_publickey.h    # [not win]
        - test -f $PREFIX/include/libssh2_sftp.h         # [not win]

        - test ! -f $PREFIX/lib/libssh2.a          # [not win]
        - test -f $PREFIX/lib/libssh2${SHLIB_EXT}  # [not win]

        - if not exist %LIBRARY_INC%\\libssh2.h           exit 1  # [win]
        - if not exist %LIBRARY_INC%\\libssh2_publickey.h exit 1  # [win]
        - if not exist %LIBRARY_INC%\\libssh2_sftp.h      exit 1  # [win]
        - if not exist %LIBRARY_LIB%\\libssh2.lib         exit 1  # [win]

  - name: libssh2-static
    script: build_static.sh  # [unix]
    script: bld_static.bat  # [win]
    requirements:
      build:
        # This breals a dependency cycle on unix
        # curl->libssh2->cmake->curl
        - cmake-no-system
        - {{ compiler('c') }}
        - {{ stdlib("c") }}
        - ninja  # [win]
        - make   # [unix]
      host:
        - {{ pin_subpackage("libssh2", exact=True) }}
        - openssl
        - zlib
      run:
        - {{ pin_subpackage("libssh2", exact=True) }}
    test:
      commands:
        - test -f $PREFIX/lib/libssh2.a                         # [not win]
        - if not exist %LIBRARY_LIB%\libssh2_static.lib exit 1  # [win]

about:
  home: https://www.libssh2.org/
  license: BSD-3-Clause
  license_family: BSD
  license_file: COPYING
  summary: the SSH library

  description: |
    libssh2 is a library implementing the SSH2 protocol, available under the revised BSD license.
  dev_url: https://github.com/libssh2/libssh2

extra:
  feedstock-name: libssh2
  recipe-maintainers:
    - shadowwalkersb
    - nehaljwani
    - ocefpaf
    - xhochy
