# -*- 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           ocaml 1.1

name                ocaml-mirage-crypto
github.setup        mirage mirage-crypto 2.3.0 v
revision            0
categories          ocaml crypto devel
maintainers         {@barracuda156 macos-powerpc.org:barracuda} openmaintainer
license             ISC
description         Simple symmetric cryptography for the modern age
long_description    {*}${description}
use_bzip2           yes
extract.suffix      .tbz
checksums           rmd160  deb6f542f2c1ee9d38d29ae15cfb3f45a927e1fd \
                    sha256  840fbf4136605b4a1f1dd5c0611932a274fe3bf97464c82a6b3a9731a68e208e \
                    size    2783635
github.tarball_from releases

depends_lib-append  port:ocaml-dune-configurator \
                    port:ocaml-eqaf

ocaml.build_type    dune

subport ${name}-ec {
    description     Elliptic Curve Cryptography with primitives taken from Fiat

    depends_lib-append \
                    port:ocaml-mirage-crypto-rng
}

subport ${name}-pk {
    description     Simple public-key cryptography

    depends_build-append \
                    path:bin/pkg-config:pkgconfig

    depends_lib-append \
                    port:gmp \
                    port:ocaml-mirage-crypto \
                    port:ocaml-mirage-crypto-rng \
                    port:ocaml-zarith
}

subport ${name}-rng {
    PortGroup       legacysupport 1.1

    # getentropy
    legacysupport.newest_darwin_requires_legacy 15

    description     Cryptographically secure PRNG

    if {${os.platform} eq "darwin" && ${os.major} < 16} {
        patchfiles-append \
                    fix-rng.patch
        post-patch {
            reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/rng/unix/dune
        }
    }

    depends_lib-append \
                    port:ocaml-duration \
                    port:ocaml-logs \
                    port:ocaml-mirage-crypto
}

if {${subport} ne ${name}} {
    depends_lib-append \
                    port:ocaml-digestif
}
