{% set name = "krb5" %}
{% set version = "1.22.1" %}

# Platform-specific prefixes and suffixes
{% set win_prefix = "Library/" %}
{% set win_suffix = ".exe" %}

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

source:
  url: https://github.com/krb5/{{ name }}/archive/{{ name }}-{{ version }}-final.tar.gz
  sha256: d7dd1ded54c1c2d3381da4a266935feda6ba6398155720df27e2975bd5a39239

build:
  number: 1
  skip: true  # [win and vc<14]
  missing_dso_whitelist:
    - api-ms-win-core-winrt-error-l1-1-0.dll   # [win]
    - api-ms-win-core-winrt-l1-1-0.dll         # [win]
    - api-ms-win-core-winrt-string-l1-1-0.dll  # [win]

requirements:
  build:
    - {{ stdlib('c') }}
    - {{ compiler('c') }}
    - {{ compiler('cxx') }}
    - autoconf     # [not win]
    - bison        # [not win]
    - gettext      # [not win]
    - libtool      # [unix]
    - make         # [unix]
    - msys2-gawk   # [win]
    - msys2-posix  # [win]
    - perl         # [win]
    - pkg-config   # [unix]
    - python *     # [not win]
  host:
    - libedit {{ libedit }}   # [unix]
    - lmdb {{ lmdb }}         # [unix]
    - openssl {{ openssl }}   # [unix]

outputs:
  - name: lib{{ name }}
    script: build-krb5-split.sh   # [unix]
    script: build-krb5-split.bat  # [win]
    build:
      run_exports:
        - {{ pin_subpackage('libkrb5', max_pin='x.x') }}
      ignore_run_exports:
        - libcxx          # [osx]
        - libedit         # [unix]
        - libstdcxx-ng    # [linux]
        - lmdb            # [unix]
        - ncurses         # [unix]
    files:
      # Libraries - Unix (only krb5 libraries, not executables)
      - lib/libcom_err*       # [unix]
      - lib/libgssapi*        # [unix]
      - lib/libgssrpc*        # [unix]
      - lib/libk5crypto*      # [unix]
      - lib/libkadm5*         # [unix]
      - lib/libkdb5*          # [unix]
      - lib/libkrad*          # [unix]
      - lib/libkrb5*          # [unix]
      - lib/libkrb5support*   # [unix]
      - lib/libverto*         # [unix]
      # Libraries - Windows
      - {{ win_prefix }}bin/comerr*.dll    # [win]
      - {{ win_prefix }}bin/gssapi*.dll    # [win]
      - {{ win_prefix }}bin/gssrpc*.dll    # [win]
      - {{ win_prefix }}bin/k5crypto*.dll  # [win]
      - {{ win_prefix }}bin/k5sprt*.dll    # [win]
      - {{ win_prefix }}bin/kadm5*.dll     # [win]
      - {{ win_prefix }}bin/kdb5*.dll      # [win]
      - {{ win_prefix }}bin/kfwlogon*.dll  # [win]
      - {{ win_prefix }}bin/krad*.dll      # [win]
      - {{ win_prefix }}bin/krb5*.dll      # [win]
      - {{ win_prefix }}bin/krbcc*.dll     # [win]
      - {{ win_prefix }}bin/leashw*.dll    # [win]
      - {{ win_prefix }}bin/plugins/preauth/spake*.dll # [win]
      - {{ win_prefix }}bin/verto*.dll      # [win]
      - {{ win_prefix }}bin/xpprof*.dll     # [win]
      - {{ win_prefix }}bin/krb5_64.dll     # [win]
      - {{ win_prefix }}lib/comerr*.lib      # [win]
      - {{ win_prefix }}lib/gssapi*.lib      # [win]
      - {{ win_prefix }}lib/k5sprt*.lib      # [win]
      - {{ win_prefix }}lib/kfwlogon*.lib    # [win]
      - {{ win_prefix }}lib/krb5*.lib        # [win]
      - {{ win_prefix }}lib/krbcc*.lib       # [win]
      - {{ win_prefix }}lib/leashw*.lib      # [win]
      - {{ win_prefix }}lib/xpprof*.lib      # [win]
      
      # Headers - Unix
      - include/com_err.h                   # [unix]
      - include/gssapi.h                    # [unix]
      - include/gssapi/                     # [unix]
      - include/gssrpc/                     # [unix]
      - include/kadm5/                      # [unix]
      - include/kdb.h                       # [unix]
      - include/krad.h                      # [unix]
      - include/krb5.h                      # [unix]
      - include/krb5/                       # [unix]
      - include/profile.h                   # [unix]
      - include/verto-module.h              # [unix]
      - include/verto.h                     # [unix]
      
      # Headers - Windows
      - {{ win_prefix }}include/com_err.h   # [win]
      - {{ win_prefix }}include/gssapi/     # [win]
      - {{ win_prefix }}include/krb5.h      # [win]
      - {{ win_prefix }}include/krb5/       # [win]
      - {{ win_prefix }}include/profile.h   # [win]
      - {{ win_prefix }}include/win-mac.h   # [win]
      
      # Development tools (krb5-config needed for build-time dependencies)
      - bin/compile_et                      # [unix]
      - bin/krb5-config                     # [unix]
      - {{ win_prefix }}bin/compile_et.exe  # [win]
      # Note: krb5-config.exe doesn't exist on Windows (Unix-specific utility)

      
    requirements:
      build:
        - {{ stdlib('c') }}
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
        - libtool      # [unix]
        - bison        # [not win]
        - autoconf     # [not win]
        - msys2-posix  # [win]
        - perl         # [win]
        - pkg-config   # [unix]
        - make         # [unix]
        - python *     # [not win]
        - gettext      # [not win]
        - msys2-gawk   # [win]
      host:
        - libedit {{ libedit }}  # [unix]
        - lmdb {{ lmdb }}        # [unix]
        - openssl {{ openssl }}  # [unix]
      run:
        - lmdb         # [unix]
        - openssl      # [unix]
      run_constrained:
        - krb5 {{ version }}
    test:
      commands:
        - set -x                                  # [unix]
        - test -f $PREFIX/lib/libkrb5${SHLIB_EXT} # [unix]
        - test -f $PREFIX/include/krb5.h          # [unix]
        - test -f $PREFIX/include/gssapi.h        # [unix]
        - test -f $PREFIX/include/gssapi/gssapi.h # [unix]
        - test -f $PREFIX/include/krb5/krb5.h     # [unix]
        - test -f $PREFIX/bin/krb5-config         # [unix]
        - echo on                                 # [win]
        - if exist "%PREFIX%\\Library\\bin\\krb5_64.dll" (exit 0) else (exit 1) # [win]
        - if exist "%PREFIX%\\Library\\include\\krb5.h" (exit 0) else (exit 1)  # [win]

  - name: {{ name }}
    script: build-krb5-split.sh   # [unix]
    script: build-krb5-split.bat  # [win]
    build:
      ignore_run_exports:
        - libcxx          # [osx]
        - libstdcxx-ng    # [linux]
        - lmdb            # [unix]
        - openssl         # [unix]
    files:
      # Executables - Unix (only executables, not libraries)
      - bin/gss-client
      - bin/k5srvutil
      - bin/kadmin
      - bin/kdestroy
      - bin/kinit
      - bin/klist
      - bin/kpasswd
      - bin/kswitch
      - bin/ktutil
      - bin/kvno
      - bin/sclient
      - bin/sim_client
      - bin/uuclient
      - sbin/gss-server
      - sbin/kadmin.local
      - sbin/kadmind
      - sbin/kdb5_util
      - sbin/kprop
      - sbin/kpropd
      - sbin/kproplog
      - sbin/krb5-send-pr
      - sbin/krb5kdc
      - sbin/sim_server
      - sbin/sserver
      - sbin/uuserver

      # Windows executables
      - {{ win_prefix }}bin/ccapiserver{{ win_suffix }}
      - {{ win_prefix }}bin/gss-client{{ win_suffix }}
      - {{ win_prefix }}bin/gss-server{{ win_suffix }}
      - {{ win_prefix }}bin/k5srvutil{{ win_suffix }}
      - {{ win_prefix }}bin/kadmin.local{{ win_suffix }}
      - {{ win_prefix }}bin/kadmin{{ win_suffix }}
      - {{ win_prefix }}bin/kadmind{{ win_suffix }}
      - {{ win_prefix }}bin/kcpytkt{{ win_suffix }}
      - {{ win_prefix }}bin/kdb5_util{{ win_suffix }}
      - {{ win_prefix }}bin/kdeltkt{{ win_suffix }}
      - {{ win_prefix }}bin/kdestroy{{ win_suffix }}
      - {{ win_prefix }}bin/kfwcpcc{{ win_suffix }}
      - {{ win_prefix }}bin/kinit{{ win_suffix }}
      - {{ win_prefix }}bin/klist{{ win_suffix }}
      - {{ win_prefix }}bin/kpasswd{{ win_suffix }}
      - {{ win_prefix }}bin/kprop{{ win_suffix }}
      - {{ win_prefix }}bin/kpropd{{ win_suffix }}
      - {{ win_prefix }}bin/kproplog{{ win_suffix }}
      - {{ win_prefix }}bin/krb5-send-pr{{ win_suffix }}
      - {{ win_prefix }}bin/krb5kdc{{ win_suffix }}
      - {{ win_prefix }}bin/kswitch{{ win_suffix }}
      - {{ win_prefix }}bin/ktutil{{ win_suffix }}
      - {{ win_prefix }}bin/kvno{{ win_suffix }}
      - {{ win_prefix }}bin/mit2ms{{ win_suffix }}
      - {{ win_prefix }}bin/ms2mit{{ win_suffix }}
      - {{ win_prefix }}bin/sclient{{ win_suffix }}
      - {{ win_prefix }}bin/sim_client{{ win_suffix }}
      - {{ win_prefix }}bin/sim_server{{ win_suffix }}
      - {{ win_prefix }}bin/sserver{{ win_suffix }}
      - {{ win_prefix }}bin/uuclient{{ win_suffix }}
      - {{ win_prefix }}bin/uuserver{{ win_suffix }}
    requirements:
      build:
        - {{ stdlib('c') }}
        - {{ compiler('c') }}
        - {{ compiler('cxx') }}
        - autoconf     # [not win]
        - bison        # [not win]
        - gettext      # [not win]
        - libtool      # [unix]
        - make         # [unix]
        - msys2-gawk   # [win]
        - msys2-posix  # [win]
        - perl         # [win]
        - pkg-config   # [unix]
        - python *     # [not win]
      host:
        - libedit {{ libedit }}  # [unix]
        - lmdb {{ lmdb }}        # [unix]
        - openssl {{ openssl }}  # [unix]
        - {{ pin_subpackage('libkrb5', exact=True) }}
      run:
        - {{ pin_subpackage('libkrb5', exact=True) }}
        - libedit  # [unix]
    test:
      commands:
        - set -x                           # [unix]
        # Test for key executables
        - test -f $PREFIX/bin/kdestroy     # [unix]
        - test -f $PREFIX/bin/kinit        # [unix]
        - test -f $PREFIX/bin/klist        # [unix]
        - test -f $PREFIX/sbin/krb5kdc     # [unix]
        - echo on                          # [win]
        # Test for Windows executables
        - if exist "%PREFIX%\\Library\\bin\\kinit.exe" (exit 0) else (exit 1)  # [win]
        - if exist "%PREFIX%\\Library\\bin\\klist.exe" (exit 0) else (exit 1)  # [win]

about:
  home: https://web.mit.edu/kerberos
  license: MIT
  license_family: MIT
  license_file: doc/notice.rst
  summary: A network authentication protocol.
  description: |
    Kerberos is a network authentication protocol. It is designed to provide strong authentication for client/server applications by using secret-key cryptography. 
  doc_url: https://web.mit.edu/kerberos/krb5-1.21/doc/index.html
  dev_url: https://github.com/krb5/krb5

extra:
  recipe-maintainers:
    - pelson
    - ocefpaf
    - mingwandroid
    - mariusvniekerk
    - chenghlee
