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

legacysupport.newest_darwin_requires_legacy 15

name                ocaml-core_unix
github.setup        janestreet core_unix 0.16.0 v
revision            1
categories          ocaml devel
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer
license             MIT
description         Unix-specific portions of Core
long_description    ${description}

checksums           rmd160  cffeed09ebed4c3a77f1b5a6d46def3a018b2697 \
                    sha256  9978ae7f56c18cc37b5e3a1adf1c70a7da542a57e17ff73f4e00811eb817d7bd \
                    size    391719
github.tarball_from archive

depends_lib-append  port:ocaml-core \
                    port:ocaml-core_kernel \
                    port:ocaml-expect_test_helpers_core \
                    port:ocaml-jane-street-headers \
                    port:ocaml-jst-config \
                    port:ocaml-ocaml_intrinsics \
                    port:ocaml-ppx_jane \
                    port:ocaml-ppx_optcomp \
                    port:ocaml-sexplib \
                    port:ocaml-spawn \
                    port:ocaml-timezone

patch.pre_args-replace  -p0 -p1
if {${os.platform} eq "darwin" && ${os.major} < 16} {
    patchfiles      0001-time_stamp_counter_stubs.c-add-legacysupport-header-.patch \
                    0002-core_unix_stubs.c-add-legacysupport-header-for-strnl.patch

    post-patch {
        reinplace "s|@PREFIX@|${prefix}|g" \
                    ${worksrcpath}/core_unix/src/dune \
                    ${worksrcpath}/time_stamp_counter/src/dune
    }
}

ocaml.build_type    dune
