# -*- 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           active_variants 1.1
PortGroup           gitlab 1.0
PortGroup           legacysupport 1.1
PortGroup           meson 1.0

name                weston-client
gitlab.instance     https://gitlab.freedesktop.org
gitlab.setup        wayland weston 16.0.0
revision            0
categories          wayland
license             MIT
maintainers         nomaintainer
description         Wayland compositor
long_description    A light-weight and functional {*}${description}.
checksums           rmd160  82afaf180cf92f23053c24bd7f20ac60a4ddeb83 \
                    sha256  67507aa8c20ed5ec2710e4a77717d339cc4f7266cb192efc263b25c59958336a \
                    size    3648454

patch.pre_args-replace  -p0 -p1
patchfiles          weston-macos-clients-only.patch
# simple-egl.c:918:9: error: implicit declaration of function 'gettimeofday' [-Wimplicit-function-declaration]
patchfiles-append   patch-gettimeofday.diff

set py_v            3.14
set py_v_nodot      [string map {. {}} ${py_v}]
post-patch {
    reinplace "s|python3|${prefix}/bin/python${py_v}|" ${worksrcpath}/meson.build
}

depends_build-append \
                    port:gettext \
                    path:bin/pkg-config:pkgconfig \
                    port:python${py_v_nodot} \
                    port:wayland-protocols
depends_lib-append  path:lib/pkgconfig/cairo.pc:cairo \
                    port:epoll-shim \
                    path:lib/pkgconfig/fontconfig.pc:fontconfig \
                    path:lib/pkgconfig/freetype2.pc:freetype \
                    port:fribidi \
                    port:gettext-runtime \
                    path:lib/pkgconfig/glib-2.0.pc:glib2 \
                    path:lib/pkgconfig/harfbuzz.pc:harfbuzz \
                    path:include/turbojpeg.h:libjpeg-turbo \
                    path:lib/pkgconfig/pixman-1.pc:libpixman \
                    port:libpng \
                    port:libxkbcommon \
                    port:mesa \
                    path:lib/pkgconfig/pango.pc:pango \
                    port:wayland \
                    port:webp
depends_run-append  port:owl

require_active_variants mesa wayland

compiler.c_standard 2011

configure.args-append \
                    -Dbackend-default=none \
                    -Dbackend-drm=false \
                    -Dbackend-headless=false \
                    -Dbackend-pipewire=false \
                    -Dbackend-rdp=false \
                    -Dbackend-vnc=false \
                    -Dbackend-wayland=false \
                    -Dbackend-x11=false \
                    -Dcolor-management-lcms=false \
                    -Ddemo-clients=true \
                    -Ddoc=false \
                    -Drenderer-gl=true \
                    -Drenderer-vulkan=false \
                    -Dshell-desktop=false \
                    -Dshell-ivi=false \
                    -Dshell-kiosk=false \
                    -Dshell-lua=false \
                    -Dsimple-clients=damage,egl,shm,touch \
                    -Dsystemd=false \
                    -Dtests=false \
                    -Dtools=terminal \
                    -Dxwayland=false

# Our epoll-shim provides itimerspec now, but earlier we added it here to compat header.
# Instead of throwing it, just add a flexible switch.
# libepoll-shim/sys/timerfd.h:33:8: error: redefinition of 'struct itimerspec'
platform darwin {
    configure.cppflags-append \
                    -DENABLE_EGL \
                    -DEPOLL_SHIM_ITIMERSPEC
}
