# Template file for 'ppsspp'
pkgname=ppsspp
version=1.1.1
revision=1
build_wrksrc="${pkgname}-${version}"
build_style=cmake
configure_args="-DHEADLESS=1"
hostmakedepends="cmake pkg-config"
makedepends="zlib-devel libpng-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/a7cae9c.tar.gz
 https://github.com/hrydgard/ppsspp-lang/archive/a86ff6a.tar.gz
 https://github.com/Kingcom/armips/archive/9b225d9.tar.gz"
checksum="
 4bcd1cc1b3b1f50f5ebbde8dfd47aceffebc07624c03ea651e80c87ce5f68cc8
 b839c78ad1241c51a32f71390352fbe3a923d81292a020440d477cde4da2c595
 0b900d829105e9174b3e43af78ae59529bd206ce6ab1c6b5db91741a78fd3920
 5d412c47de19d72d97abc960aab846e04d4c3c8c181f392e9013529c4c038ee8"
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() {
	cd build
	install -Dm644 ../LICENSE.TXT "$DESTDIR/usr/share/licenses/ppsspp/LICENSE.TXT"
	install -Dm644 ../assets/icon.svg "$DESTDIR/usr/share/icons/ppsspp.svg"
	install -Dm644 ../Qt/PPSSPP.desktop "$DESTDIR/usr/share/applications/PPSSPP.desktop"
	install -Dm755 ${FILESDIR}/ppsspp-sdl.sh "$DESTDIR/usr/bin/ppsspp-sdl"
	install -Dm755 ${FILESDIR}/ppsspp-headless.sh "$DESTDIR/usr/bin/ppsspp-headless"
	install -Dm755 PPSSPPSDL "$DESTDIR/usr/share/ppsspp/PPSSPPSDL"
	install -Dm755 PPSSPPHeadless "$DESTDIR/usr/share/ppsspp/"
	cd assets
	find . -type f -exec install -Dm644 {} "$DESTDIR/usr/share/ppsspp/assets/"{} \;

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