# Template file for 'wayfire'
pkgname=wayfire
version=0.8.1
revision=2
_utils_commit=15f8e16721585ae3eaf278ba71d7064237eb23f5
_touch_commit=8974eb0f6a65464b63dd03b842795cb441fb6403
build_style=meson
configure_args="-Dprint_trace=false"
hostmakedepends="pkg-config wayland-devel"
makedepends="wf-config-devel wlroots0.17-devel cairo-devel pango-devel json-c++
 $(vopt_if image 'libjpeg-turbo-devel libpng-devel')"
depends="xorg-server-xwayland"
short_desc="3D wayland compositor"
maintainer="Érico Nogueira <ericonr@disroot.org>"
license="MIT"
homepage="https://wayfire.org"
distfiles="https://github.com/WayfireWM/wayfire/archive/refs/tags/v${version}.tar.gz
 https://github.com/WayfireWM/wf-utils/archive/${_utils_commit}.tar.gz
 https://github.com/WayfireWM/wf-touch/archive/${_touch_commit}.tar.gz"
checksum="04f43df21167db15d266f7e01085b111680d57779ebc27a410201f995b33c6df
 5f0a0f523b29bd73e0f11d63079315d3a0a3c3cae6ce9b557e0433e25b5a0d92
 09061c8a4d3d964e8dcfd1a7b97f7dc43d0fc30743b0993585439c6923ce422f"
skip_extraction="${_utils_commit}.tar.gz ${_touch_commit}.tar.gz"

# Optimization for nested STL calls
CXXFLAGS="-O3"
LDFLAGS="-Wl,-O1"

build_options="image"
build_options_default="image"
desc_option_image="Enable JPEG and PNG support"

if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
	makedepends+=" libexecinfo-devel"
fi

post_extract() {
	vsrcextract -C subprojects/wf-utils "${_utils_commit}.tar.gz"
	vsrcextract -C subprojects/wf-touch "${_touch_commit}.tar.gz"
}

post_install() {
	vlicense LICENSE
	vsconf wayfire.ini
	vinstall wayfire.desktop 0644 usr/share/wayland-sessions
}

wayfire-devel_package() {
	depends="${makedepends} ${sourcepkg}>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove "usr/lib/*.a"

		# At least one unverisoned shlib is a plugin helper
		# that should remain in the main package
		local shlib
		for shlib in "${DESTDIR}"/usr/lib/*.so; do
			[ -L "${shlib}" ] || continue
			vmove "${shlib#${DESTDIR}/}"
		done
	}
}
