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

# Original upstream is stale for years: https://github.com/owl-compositor/owl
github.setup        barracuda156 owl 681f13e3ea2c8e58b1da82b6317a061fe6cb3f7b
version             2026.11.11
revision            0
categories          sysutils wayland
platforms           {darwin > 8}
license             GPL-3
maintainers         {@barracuda156 macos-powerpc.org:barracuda} openmaintainer
description         Portable Wayland compositor in Objective-C
long_description    {*}${description}

checksums           rmd160  2c320483ff80d1c50cf6c1dbd9b9416bea6fb740 \
                    sha256  c08316d99c8e74325d717ca8b52609cb9495b78daca05ef05b1a008a859d207e \
                    size    278288
github.tarball_from archive

depends_lib-append  port:wayland
depends_run-append  port:libxkbcommon

patch.pre_args-replace  -p0 -p1

platform darwin 9 {
    patchfiles-append   patch-10.5.diff

    post-patch {
        reinplace "s|-weak_framework IOSurface||" ${worksrcpath}/configure
    }
}

configure.cmd       ${worksrcpath}/configure

# Should not use CommandLineTools:
use_xcode           yes

# OwlKnownClientsManager.m: error: ‘for’ loop initial declaration used outside C99 mode
# OwlKnownClientsManager.m: error: 'for' loop initial declarations are only allowed in C99 or C11
# Keep general (non-powerpc, 10.7+) case above for simplicity.
if {${os.major} >= 11} {
    compiler.c_standard 2011
    configure.cmd-prepend \
                    CFLAGS=-std=c11
} else {
    compiler.c_standard 1999
    # Rosetta needs explicit archflags.
    configure.cmd-prepend \
                    CFLAGS='-std=c99 [get_canonical_archflags cc]' \
                    LDFLAGS=' [get_canonical_archflags ld]'
}

destroot {
    move ${worksrcpath}/Owl.app ${destroot}${applications_dir}
}

notes "
Example how to run owl compositor:

mkdir -p -m 700 /tmp/owl-runtime
export XDG_RUNTIME_DIR=/tmp/owl-runtime && open ${applications_dir}/Owl.app

A wayland app then should use the same XDG_RUNTIME_DIR.
"
