# Template file for 'libretro-mupen64plus'
pkgname=libretro-mupen64plus
version=20150204
revision=1
wrksrc="mupen64plus-libretro-master"
build_options="opengl rpi"
hostmakedepends="pkg-config unzip"
makedepends="$(vopt_if opengl MesaLib-devel) $(vopt_if rpi rpi-firmware)"
short_desc="Libretro port of Mupen64 Plus"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
license="GPL-3"
homepage="http://www.libretro.com/"
distfiles="http://ftp.netbsd.org/pub/NetBSD/misc/jmcneill/retroarch/mupen64plus-libretro-${version}.zip"
checksum=643379eaa840d632cd8fa046fc4858cc8ccd5a57ce5991771ab16f1ef675cee2

case "$XBPS_TARGET_MACHINE" in
	i686*|x86_64*)  build_options_default="opengl";;
	armv[67]*) build_options_default="rpi";;
esac

do_build() {
	local _args

	case "$XBPS_TARGET_MACHINE" in
		i686*) _args="DYNAREC=x86";;
		x86_64*) _args="DYNAREC=x86_64";;
		arm*) _args="DYNAREC=arm";;
	esac
	if [ "$build_option_rpi" ]; then
		install -d /opt/vc/lib
		_args+=" platform=rpi"
		sed -i "s|-L/opt/vc/lib|-L${XBPS_CROSS_BASE}/opt/vc/lib -Wl,-R /opt/vc/lib|g" Makefile
		sed -i 's|/opt/vc/include|${XBPS_CROSS_BASE}/opt/vc/include|g' Makefile
	fi
	make CC=$CC ${_args} ${makejobs}
}
do_install() {
	vinstall mupen64plus_libretro.so 755 usr/lib/libretro
}
