# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           python 1.0

name                py-krb5
version             0.9.0
revision            0

categories-append   net security
license             MIT
maintainers         {petr @petrrr} openmaintainer

description         Kerberos API bindings for Python
long_description    \
    This library provides Python functions that wraps the Kerberos 5 C API. \
    Due to the complex nature of this API it is highly recommended to use \
    something like python-gssapi which exposes the Kerberos authentication \
    details through GSSAPI.

homepage            https://github.com/jborean93/pykrb5

checksums           rmd160  030700379186008b29102964659d0a824f6ee7a8 \
                    sha256  4cdd2c85ff4770108edaf48fedf19888cf956ff374e2e97e40f8412b048caee6 \
                    size    236761

python.versions     310 311 312 313 314

if {${subport} ne ${name}} {
    patchfiles      patch-cython-pyproject.toml.diff

    depends_build-append \
                    port:py${python.version}-cython

    # src/krb5/_creds.c:1343: error: ‘for’ loop initial declaration used outside C99 mode
    # src/krb5/_ccache.c:35959: error: #pragma GCC diagnostic not allowed inside functions
    compiler.blacklist-append \
                    *gcc-4.*

    # https://trac.macports.org/ticket/72017
    variant kerberos5 description "Use Kerberos5" {
        depends_lib-append \
                    port:kerberos5
        build.env-append \
                    KRB5_KRB5CONFIG=${prefix}/bin/krb5-config \
                    KRB5_MAIN_LIB=${prefix}/lib/libkrb5.dylib
    }

    # FIXME: +heimdal does not link atm:
    # OSError: dlopen(/opt/local/libexec/heimdal/lib/libkrb5.dylib, 6): Symbol not found: _hc_EVP_cc_sha256
    variant heimdal description "Use Heimdal" {
        depends_lib-append \
                    port:heimdal
        set heimdal_root \
                    ${prefix}/libexec/heimdal
        build.env-append \
                    KRB5_KRB5CONFIG=${heimdal_root}/bin/krb5-config \
                    KRB5_MAIN_LIB=${heimdal_root}/lib/libkrb5.dylib
    }

    default_variants-append \
                    +kerberos5

    post-destroot {
        set dest_doc ${destroot}${prefix}/share/doc/${subport}
        xinstall -d ${dest_doc}
        xinstall -m 0644 -W ${worksrcpath} LICENSE README.md ${dest_doc}
    }
}
