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

# source: james
TARBALL=ppsspp-2020.08.20.tar.xz
MD5SUM=7eef109f54e76fb1894b00b0baf188e5
SRC_URL=http://distro.ibiblio.org/fatdog/source/800/$TARBALL
BUNDLE=

SLACKREQ='libSDL2 libpng ffmpeg 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() {		
	# preserve git version - we don't have git
	cd /tmp/ppsspp* &&
	sed -i -e 's/PPSSPP_GIT_VERSION_NO_UPDATE 0/PPSSPP_GIT_VERSION_NO_UPDATE 1/' git-version.cpp &&

	# build	the SDL version
	mkdir build && cd build &&
	cmake .. &&
	make $MAKEFLAGS &&
	
	# 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 &&

	# finish
	pkg_build_slackdesc
}
