# -*- 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           github 1.0
PortGroup           cmake 1.1
PortGroup           legacysupport 1.1

# strnlen
legacysupport.newest_darwin_requires_legacy 10

# see lib/internal.h
if {(${os.platform} eq "darwin" && ${os.major} < 13) || ${os.platform} eq "linux"} {
    PortGroup       openssl 1.0

}

github.setup        Yubico yubico-piv-tool 2.3.1 yubico-piv-tool-
revision            0
categories          security
license             BSD
maintainers         nomaintainer

description         Command line tool for the YubiKey PIV application
long_description    \
    The Yubico PIV tool is used for interacting with the Privilege and \
    Identification Card (PIV) application on a YubiKey.\
    With it you may generate keys on the device, importing keys and \
    certificates, and create certificate requests, and other operations. \
    A shared library and a command-line tool is included.
homepage            https://developers.yubico.com/yubico-piv-tool
github.tarball_from archive

checksums           rmd160  cdf8273fe002a3bd5b1890f060bb2e60e5ec3920 \
                    sha256  11de1b708c6b917bec3da7d584f534a4314c51ccd461840fd16f15478ac2668f \
                    size    1316046

depends_build-append \
                    port:check \
                    port:gengetopt \
                    port:help2man \
                    port:pkgconfig

patchfiles-append   patch-older-systems.diff

compiler.c_standard 2011

configure.pre_args-replace \
                    -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF

post-destroot {
    # symlink PKCS#11 module in the standard pkcs11 module directory
    set p11kit_module_path ${prefix}/lib/pkcs11
    xinstall -d ${destroot}${p11kit_module_path}
    ln -s ${prefix}/lib/libykcs11.dylib \
          ${destroot}${p11kit_module_path}/libykcs11.so

    # register PKCS#11 module so it will be auto-discovered by p11-kit
    set p11kit_module_configs ${prefix}/share/p11-kit/modules
    xinstall -d ${destroot}${p11kit_module_configs}
    xinstall ${filespath}/p11-kit.module \
             ${destroot}${p11kit_module_configs}/${name}.module
}

github.livecheck.regex \
                    ((?:\\d+\\.?)+)