# libkscreen 6.7.2 — Plasma (ADR 0011). Gestión de pantallas/salidas (KScreen). La usa plasma-workspace
# (KScreen daemon, config de monitores). CMakeLists: Qt6 Core+DBus+Gui+Test+WaylandClient (WaylandClient
# → qtwayland) + Wayland Client + PlasmaWaylandProtocols + find_package(XCB COMPONENTS XCB RANDR DPMS)
# + KF6 Config CoreAddons + KWayland. XCB RANDR/DPMS los provee libxcb (xcb-randr.pc/xcb-dpms.pc, sin
# --disable en la receta) → NO hace falta libXrandr. rm -rf po.
name    = "libkscreen"
version = "6.7.2"

[source]
tarball = "https://download.kde.org/stable/plasma/6.7.2/libkscreen-6.7.2.tar.xz"
sha256  = "408dc2753001a689cadfc77bdcc4a968baa385cae8dd8abce6c3ce422284d078"

[build]
compiler = "zig-cc"
target   = "x86_64-linux-musl"
link     = "dynamic"
flags    = []

[build.phases]
configure = '''
rm -rf po
# Wrapper que PRESERVA args con espacios: el moc_predefs de libkscreen (target libdpms) genera un
# `-I"/src/src/libdpms /src/build/src/libdpms"` (dos dirs, espacio en un solo -I); el wrapper clásico
# (`a="$a $x"; exec ... $a` sin comillas) lo splitea → "unrecognized file extension". Acá reconstruimos
# los args en los positional params ("$@") filtrando -Wl,--fatal-warnings, y pasamos "$@" con comillas.
ZW="$PWD/.zwrap"; mkdir -p "$ZW"
cat > "$ZW/cc"  <<'W'
#!/bin/sh
f=1; for x in "$@"; do [ "$x" = "-Wl,--fatal-warnings" ] && continue; if [ "$f" = 1 ]; then set -- "$x"; f=0; else set -- "$@" "$x"; fi; done; [ "$f" = 1 ] && set --
exec /opt/zig/zig cc -mcpu=baseline "$@"
W
cat > "$ZW/cxx" <<'W'
#!/bin/sh
f=1; for x in "$@"; do [ "$x" = "-Wl,--fatal-warnings" ] && continue; if [ "$f" = 1 ]; then set -- "$x"; f=0; else set -- "$@" "$x"; fi; done; [ "$f" = 1 ] && set --
exec /opt/zig/zig c++ -mcpu=baseline "$@"
W
chmod +x "$ZW/cc" "$ZW/cxx"
cmake -B build -G Ninja -Wno-dev \
  -DCMAKE_C_COMPILER="$ZW/cc" -DCMAKE_CXX_COMPILER="$ZW/cxx" -DCMAKE_ASM_COMPILER="$ZW/cc" \
  -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_PREFIX_PATH=/usr \
  -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF \
  -DBUILD_TESTING=OFF -DBUILD_PYTHON_BINDINGS=OFF
'''
compile = "cmake --build build"
install = "DESTDIR=/out cmake --install build"

[deps]
build = ["cmake", "samurai", "python3", "pkgconf", "qtbase", "dbus", "extra-cmake-modules", "qttools", "mesa", "libdrm", "libxkbcommon", "wayland", "wayland-protocols", "plasma-wayland-protocols", "qtwayland", "kwayland", "kconfig", "kcoreaddons", "libxcb", "libX11", "xorgproto", "libXau", "libXdmcp", "libXext", "libXrender", "libXfixes", "libXi"]
