# Template file for 'ppsspp'
pkgname=ppsspp
version=1.3
revision=1
build_wrksrc="${pkgname}-${version}"
build_style=cmake
configure_args="-DHEADLESS=1"
hostmakedepends="pkg-config"
makedepends="zlib-devel glew-devel SDL2-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-ffmpeg/archive/0813d5e.tar.gz
 https://github.com/hrydgard/ppsspp-lang/archive/5f474b1.tar.gz
 https://github.com/Kingcom/armips/archive/309a151.tar.gz"
checksum="
 ada81d1bdbb0ec7d1395d3473602087767bb2deb2a8b015ddcfd1f5d08609a52
 c0314b0c755749185f97ebcf8dddf24b9965154b00262238ce1261ad7f84501b
 983e3bad600fa199e2fe668f519d288b59f256a1090ce35914e129df04e833eb
 36fedadf8ca2fd52a5254bb70065f7a9a8c59081ed016168bc8cc34255675cbc"
nocross=yes

pre_configure() {
	# copy submodules to right location
	cp -rup ${wrksrc}/ppsspp-lang-*/* ${wrksrc}/${pkgname}-${version}/lang
	cp -rup ${wrksrc}/ppsspp-ffmpeg-*/linux ${wrksrc}/${pkgname}-${version}/ffmpeg
	cp -rup ${wrksrc}/armips-*/* ${wrksrc}/${pkgname}-${version}/ext/armips
	# 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 assets/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
}
