# Template file for 'wayfire'
pkgname=wayfire
version=0.7.5
revision=2
_utils_commit=889fdafa7b09fc6ce70313fd3f067cfc8c21a2ac
_touch_commit=8974eb0f6a65464b63dd03b842795cb441fb6403
create_wrksrc=yes
build_wrksrc="${pkgname}-${version}"
build_style=meson
configure_args="-Dprint_trace=false"
hostmakedepends="pkg-config wayland-devel"
makedepends="wf-config-devel wlroots0.16-devel cairo-devel pango-devel
 $(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="ae9a44d3ddcdf97b2dbe2baeeaf880f24f95bfb18e11e1dd5ad7443c26c5e19e
 bbde37e1a8b5ecb322096b32891593c14264800291be8773f7f0708fc110ed2f
 09061c8a4d3d964e8dcfd1a7b97f7dc43d0fc30743b0993585439c6923ce422f"

# 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() {
	rmdir ${build_wrksrc}/subprojects/wf-utils
	rmdir ${build_wrksrc}/subprojects/wf-touch
	mv wf-utils-${_utils_commit} ${build_wrksrc}/subprojects/wf-utils
	mv wf-touch-${_touch_commit} ${build_wrksrc}/subprojects/wf-touch
}

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"
		vmove "usr/lib/*.so"
	}
}
