# Maintainer: Pierre-Loup A. Griffais <pgriffais@valvesoftware.com>

# This is just for the Gamescope WSI layer.

pkgname=lib32-gamescope
_srctag=3.11.52-beta2
pkgver=${_srctag//-/.}
pkgrel=1
pkgdesc="gaming shell based on Xwayland, powered by Vulkan and DRM (32-bit)"
arch=(x86_64)
url="https://github.com/Plagman/gamescope"
license=('MIT')
depends=('lib32-wayland' 'lib32-libx11' 'lib32-libxcb' 'lib32-vulkan-icd-loader')
makedepends=(git meson cmake ninja vulkan-headers)
source=("lib32-gamescope::git+https://github.com/Plagman/gamescope.git#tag=$_srctag")
sha256sums=('SKIP')

prepare() {
	cd "$pkgname"
}

build() {
	cd "$pkgname"

  	export CC="gcc -m32"
  	export CXX="g++ -m32"
  	export PKG_CONFIG="i686-pc-linux-gnu-pkg-config"

	rm -rf build
	mkdir build
	cd build
	arch-meson --libdir=/usr/lib32 -Denable_gamescope=false -Denable_openvr_support=false -Dpipewire=disabled --buildtype release --prefix /usr ..
	ninja
}

package() {
	cd "$pkgname/build"

	DESTDIR="$pkgdir" meson install --skip-subprojects

	rm -rf "$pkgdir"/usr/include
	rm -rf "$pkgdir"/usr/lib/libwlroots*
	rm -rf "$pkgdir"/usr/lib32/libwlroots*
	rm -rf "$pkgdir"/usr/lib/pkgconfig
	rm -rf "$pkgdir"/usr/lib32/pkgconfig
}
