# -*- 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.17.1 v
revision            2
categories          ocaml devel
maintainers         nomaintainer
license             MIT
description         Unix-specific portions of Core
long_description    ${description}

checksums           rmd160  2d7296692b7f0ca82f5cdbb473ba0ef9ad8d2d5b \
                    sha256  b1ed25aa3a7d809dec048fc0e2241e2a2bdcf88f31141f5b158b6879c958d177 \
                    size    403373
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
