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

github.setup        owl-compositor owl 91abf02613cd2ddb97be58b5b6703240320233a0
version             2026.04.25
revision            0
categories          x11 graphics
license             GPL-3
maintainers         nomaintainer
description         Portable Wayland compositor in Objective-C
long_description    ${description}

checksums           rmd160  552ae809147fce88808a1ca4863433379169f9d0 \
                    sha256  dc553e10ee7c78d13e2ddcb7e1ade77e66b8eefa913361997f18d965ef64129a \
                    size    123999
github.tarball_from archive

depends_lib-append  port:libxkbcommon \
                    port:wayland

# In-source builds are not supported.
post-extract {
    system -W ${worksrcpath} "mkdir ./build && cd ./build"
}

patch.pre_args-replace  -p0 -p1

patchfiles-append   0001-misc-compat-fixes.patch
patchfiles-append   0002-configure-when-building-on-macOS-we-know-we-are-on-m.patch

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) case above for simplicity.
if {${configure.build_arch} ni [list ppc ppc64]} {
    configure.cmd-prepend \
                    CFLAGS=-std=c11
} else {
    # 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}
}
