#!/bin/mkpkg
# description: Wayland compositor inspired by Window Maker
# url: https://github.com/phkaeser/wlmaker

name=wlmaker
version=0.7.1
release=1
depends=(wlroots cairo libxkbcommon libxdg-basedir ncurses)
makedeps=(cmake bison flex wayland-protocols)
source=(https://github.com/phkaeser/$name/releases/download/v$version/$name-$version.tar.gz
        no-x11-backend.patch)

patch() {
    cd $name-$version

    # Guard X11 backend code for pure Wayland builds
    patch -p1 -i $SRC/no-x11-backend.patch

    # Fix ELSE/ELSEIF build logic (from AUR)
    for i in CMakeLists.txt submodules/libbase/CMakeLists.txt; do
        sed -i 's/^\s*ELSE\s*(config_OPTIM)$/  ELSEIF (config_DEBUG)/' "$i"
    done
}

sha256sums=(
    "2dc025300d9e51599c35bf6f4133a14275dce2f7081c7bd04b5eb89ac442e791"
    "dcc530ef531a6de0eef1e04aced332f5e6e51db08493612ae9c7b947fe6e77eb"
)

build() {
    cd $name-$version

    cmake -B build \
        -DCMAKE_INSTALL_PREFIX=/ \
        -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_C_COMPILER=clang \
        -Dconfig_DEBUG=OFF \
        -Dconfig_OPTIM=OFF

    cmake --build build
    DESTDIR=$PKG cmake --install build

    # Remove Debian wrapper
    rm -f $PKG/usr/bin/wrap-wlmaker.sh

    # Remove Debian theme and menu
    rm -f $PKG/etc/xdg/$name/Themes/Debian.plist
    rm -f $PKG/etc/xdg/$name/RootMenuDebian.plist
}

signify() {
    untrusted comment: public key
    RWTZ9IduCSQ/mL8337TEUinPwT92xFEUpD92hkS7IxcOnzTt9QdpohT3
}

# vim: filetype=sh
