# Template file for 'ppsspp'
pkgname=ppsspp
version=1.4.2
revision=1
build_wrksrc="${pkgname}-${version}"
build_style=cmake
configure_args="-DHEADLESS=1 -DUSE_SYSTEM_FFMPEG=1"
hostmakedepends="pkg-config"
makedepends="zlib-devel glew-devel SDL2-devel ffmpeg-devel"
depends="desktop-file-utils"
short_desc="A fast and portable PSP emulator"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
license="GPL-2"
homepage="http://www.ppsspp.org/"
create_wrksrc=yes
distfiles="
 https://github.com/hrydgard/ppsspp/archive/v${version}.tar.gz
 https://github.com/hrydgard/ppsspp-lang/archive/7b31a30fd0.tar.gz
 https://github.com/hrydgard/glslang/archive/136b1e2d5d.tar.gz
 https://github.com/Kingcom/tinyformat/archive/b7f5a22753.tar.gz
 https://github.com/KhronosGroup/SPIRV-Cross/archive/90966d50f5.tar.gz
 https://github.com/Kingcom/armips/archive/07853e5.tar.gz"
checksum="5877b68a1333315ed7c7521dacd045aa6f92337f7063e58fb7124dbb1ae50b54
 c27ed60ef2e0c185cb82f40b30c2837c31913209344bfc28a0b1fb2e47c8bdcd
 66beae370a64a5eb6f45cf8ce4b21565930dbfecc44c794be282c9dcb161a624
 9db9bc16e9fafede493b5890b935a57ee6e5e284a9d6e8fa6d9329790a96b8c6
 282d1f17bd3003162dd945b8ba5c5a10cb5738a7750949a8200ff6555f10ff28
 d0d7a9d9e4995ec8b7b4323b3bc737b6d7a28f9d0cb6967eb201ed454b17d1a2"
nocross=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
	cp -rup ${wrksrc}/tinyformat-*/* ${wrksrc}/${pkgname}-${version}/ext/armips/ext/tinyformat
	# 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
}
