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

github.setup    libuv libuv 1.49.2 v
revision        0
categories      devel
license         {MIT BSD}
maintainers     {michaelld @michaelld} \
                {gmail.com:herby.gillot @herbygillot} \
                openmaintainer

description     Cross-platform asychronous I/O
long_description \
    ${name} is a multi-platform support library with a focus on \
    cross-platform asynchronous I/O.

set domain      libuv.org
homepage        https://${domain}
master_sites    https://dist.${domain}/dist/v${version}
distfiles       ${name}-v${version}-dist${extract.suffix}
github.tarball_from archive

checksums       rmd160  a58e2411aa96de0edcc4cc114b8026525ab3dd0e \
                sha256  2e910e668e5daf1be6a5195a696985d7200adfa5c4d3400ee7b3355affdcf52c \
                size    1678725

# TODO: review suggestions is https://github.com/macports/macports-ports/pull/27671
subport libuv-devel {
    github.setup \
                libuv libuv 1.52.1 v
    revision    0
    checksums   rmd160  a58e2411aa96de0edcc4cc114b8026525ab3dd0e \
                sha256  2e910e668e5daf1be6a5195a696985d7200adfa5c4d3400ee7b3355affdcf52c \
                size    1678725
}

# stdatomic.h
compiler.blacklist-append {clang < 700}
compiler.c_standard 2011

patchfiles-append \
                patch-libuv-unix-core-close-nocancel.diff

if {${subport} eq ${name}} {
    # strnlen, lutimes
    legacysupport.newest_darwin_requires_legacy 10

    patchfiles-append \
                patch-libuv-legacy.diff

    conflicts   libuv-devel
} else {
    # need clock_gettime
    legacysupport.newest_darwin_requires_legacy 15

    # -devel
    patchfiles-append \
                patch-libuv-fix-1.52.0.diff

    conflicts   libuv
}

configure.args  --disable-silent-rules

platform darwin {
    if {${os.major} == 9 || ${os.major} == 10} {
        # needed for the tests to compile correctly on Leopard
        configure.cppflags-append -D__DARWIN_64_BIT_INO_T
    }
}

test.run        yes
test.target     check
