#### this file is sourced not run
PKGVER=1.15.4
PKGBUILD=1
PKGARCH=x86_64

# source: james
TARBALL=ppsspp-$PKGVER.tar.xz
MD5SUM=4b30f39f0ecf8ec8c2af349e88c97c06
SRC_URL=https://github.com/hrydgard/ppsspp/releases/download/v$PKGVER/$TARBALL
BUNDLE=

SLACKREQ='libSDL2 libpng libglew' # and OpenGL (mesa), python3 build-time 
SLACKDESC="ppsspp: ppsspp $PKGVER (PSP Emulator)
ppsspp: 
ppsspp: A fast and portable PSP emulator, written in C++.
ppsspp: 
ppsspp: https://www.ppsspp.org/
ppsspp: https://github.com/hrydgard/ppsspp/
ppsspp: 
ppsspp: 
ppsspp: 
ppsspp: 
ppsspp: 
"

### default pkg_download
### default pkg_prepare
### default pkg_package
### build
pkg_build() {		
	cd /tmp/ppsspp* &&

	# preserve git version - we don't have git. For git-master only
	#sed -i -e 's/PPSSPP_GIT_VERSION_NO_UPDATE 0/PPSSPP_GIT_VERSION_NO_UPDATE 1/' git-version.cpp &&

	mkdir build && cd build &&
	cmake .. \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DUSE_SYSTEM_SNAPPY=OFF \
		-DUSE_SYSTEM_FFMPEG=OFF \
		-DUSING_X11_VULKAN=OFF  \
		-DUSE_FFMPEG=OFF \
	&&
	# using ffmpeg causes build failure (cannot find ffmpeg)

	make $MAKEFLAGS &&
	make install &&

<< "MANUAL_INSTALL_NOT_USED_ANYMORE"
	# manual install
	mkdir -p /opt/PPSSPP-$PKGVER &&
	install -m755 PPSSPPSDL /opt/PPSSPP-$PKGVER &&
	cp -a assets /opt/PPSSPP-$PKGVER &&
	
	# wrapper script
	cat > /usr/bin/PPSSPP << EOF &&
#!/bin/dash
cd /opt/PPSSPP-$PKGVER
exec ./PPSSPPSDL "\$@"
EOF
	chmod +x /usr/bin/PPSSPP &&

	# desktop
	mkdir -p /usr/share/icons /usr/share/applications &&
	install -m644 /tmp/pkg/PPSSPP.desktop /usr/share/applications &&
	ln -s /opt/PPSSPP-$PKGVER/assets/icon_regular_72.png /usr/share/icons/PPSSPP.png &&
MANUAL_INSTALL_NOT_USED_ANYMORE

	# finish
	pkg_build_slackdesc
}
