# Template file for 'ppsspp'
pkgname=ppsspp
version=1.6.3
revision=3
build_wrksrc="ppsspp-${version}"
build_style=cmake
configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1 -DUNITTEST=ON"
hostmakedepends="pkg-config"
makedepends="zlib-devel glew-devel SDL2-devel ffmpeg-devel libzip-devel
 snappy-devel"
depends="desktop-file-utils"
short_desc="A fast and portable PSP emulator"
maintainer="John <jojhnz@posteo.net>"
license="GPL-2.0-or-later"
homepage="https://www.ppsspp.org/"
distfiles="
 https://github.com/hrydgard/ppsspp/archive/v${version}.tar.gz
 https://github.com/hrydgard/ppsspp-lang/archive/c2c4ad9c38c5f5e97ff022a703c470fcd53da249.tar.gz
 https://github.com/hrydgard/glslang/archive/2edde6665d.tar.gz
 https://github.com/KhronosGroup/SPIRV-Cross/archive/90966d50f5.tar.gz
 https://github.com/Kingcom/armips/archive/8b4cadaf62.tar.gz"
checksum="366f8b3c545071d919e1f51a5c4e0da48ba55cf1c15ff8d78a90985b3d5e8eb3
 5a97d1a2949482082bb4e7dff7704cb0fe8263a828cc66773e1d70c7bce472dc
 5e20a5758c13cc3967a2c31e7017fe4d8135c005733662be4585d9d19b5d8f34
 282d1f17bd3003162dd945b8ba5c5a10cb5738a7750949a8200ff6555f10ff28
 c4a2bdc231d8e30fb9a19467b7cc9854e844fb3aafc83449e31152b97ace2157"
nocross=yes
create_wrksrc=yes

pre_configure() {
	# copy submodules to right location
	cp -rup ${wrksrc}/ppsspp-lang-*/* ${wrksrc}/${pkgname}-${version}/assets/lang
	cp -rup ${wrksrc}/armips-*/* ${wrksrc}/${pkgname}-${version}/ext/armips
	cp -rup ${wrksrc}/glslang-*/* ${wrksrc}/${pkgname}-${version}/ext/glslang
	cp -rup ${wrksrc}/SPIRV-Cross-*/* ${wrksrc}/${pkgname}-${version}/ext/SPIRV-Cross

	# disable git versioning
	sed 's|find_package(Git)|# &|' -i ${wrksrc}/${pkgname}-${version}/git-version.cmake
	rm -rf ${pkgname}-${version}/build
}

do_install() {
	vlicense LICENSE.TXT
	vinstall icons/icon.svg 644 usr/share/pixmaps ppsspp.svg
	vinstall Qt/PPSSPP.desktop 644 usr/share/applications
	vbin build/PPSSPPSDL ppsspp-sdl
	vbin build/PPSSPPHeadless ppsspp-headless
	vmkdir usr/share/ppsspp
	vcopy build/assets usr/share/ppsspp/

	sed -e 's,^Exec=.*,Exec=/usr/bin/ppsspp-sdl,' -i $DESTDIR/usr/share/applications/PPSSPP.desktop
	sed -e 's,^Icon=.*,Icon=/usr/share/pixmaps/ppsspp.svg,' -i $DESTDIR/usr/share/applications/PPSSPP.desktop
}
