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

# O_CLOEXEC, clock_gettime
legacysupport.newest_darwin_requires_legacy 15

github.setup        jiixyj epoll-shim 0.0.20240608 v
categories          devel
license             MIT
maintainers         nomaintainer
description         Small epoll implementation using kqueue
long_description    ${description}. Includes all features \
                    needed for libinput/libevdev.

checksums           rmd160  3cead7960ad43d9e03355753527024da0ceab0b5 \
                    sha256  8f5125217e4a0eeb96ab01f9dfd56c38f85ac3e8f26ef2578e538e72e87862cb \
                    size    104137
github.tarball_from archive

patch.pre_args-replace  -p0 -p1

# https://github.com/jiixyj/epoll-shim/pull/57
patchfiles-append   0001-Use-EV_TRIGGER-as-a-fallback-for-NOTE_TRIGGER.patch \
                    0002-Define-MSG_NOSIGNAL-when-undefined.patch \
                    0003-timerfd-root-test-skip-on-macOS-10.12.patch

compiler.c_standard 2011

# error: use of unknown builtin '__builtin_mul_overflow' on macOS < 10.11
# this feature was implemented after the release of LLVM 3.8
compiler.blacklist-append \
                    {clang < 800}

# Build tries to run test binaries during the build, which fails otherwise.
configure.pre_args-replace \
                    -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON \
                    -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF

platform darwin powerpc {
    depends_lib-append \
                    port:libdispatch-legacy
    configure.cppflags-append \
                    -I${prefix}/libexec/dispatch/usr/include
    configure.ldflags-append \
                    ${prefix}/libexec/dispatch/usr/lib/libdispatch.a
}

test.run            yes
