# Template file for 'higan'
pkgname=higan
version=106
revision=1
wrksrc="higan_v${version}-source"
build_style=gnu-makefile
build_wrksrc=higan
make_build_args='compiler=${CXX}'
make_install_args="prefix=${DESTDIR}/usr"
hostmakedepends="p7zip pkg-config SDL-devel"
makedepends="gtk+-devel gtksourceview2-devel libgomp-devel
 $(vopt_if sdl SDL-devel)
 $(vopt_if opengl MesaLib-devel) $(vopt_if xv libXv-devel)
 $(vopt_if ao libao-devel) $(vopt_if alsa alsa-lib-devel)
 $(vopt_if openal libopenal-devel) $(vopt_if pulseaudio pulseaudio-devel)"
short_desc="Multi-system emulator (SNES/Game Boy/Mega Drive/PC Engine/WonderSwan)"
maintainer="John <johnz@posteo.net>"
license="GPL-3"
homepage="https://byuu.org/emulation/higan/"
distfiles="https://download.byuu.org/higan_v${version}-source.7z"
checksum=6564f91f232040c46c052de763dc139e94005e0f2376959fdacbb6ccd3fd6d18

build_options="icarus pulseaudio alsa oss openal ao sdl xv opengl udev"
build_options_default="icarus pulseaudio alsa oss openal ao sdl xv opengl udev"
desc_option_ao="Enable support for cross-platform audio"
desc_option_icarus="Enable the icarus binary"
desc_option_openal="Enable support for 3D audio"
desc_option_oss="Enable support for OSS"
desc_option_udev="Enable support for udev"
desc_option_xv="Enable support for Xv"

disable_module() {
	echo Disabling: "$1"
	sed -i \
		-e "s|$1\b||" \
		"${wrksrc}"/higan/target-tomoko/GNUmakefile
}

do_configure() {
	$(vopt_if pulseaudio '' 'disable_module audio.pulseaudio')
	$(vopt_if pulseaudio '' 'disable_module audio.pulseaudiosimple')
	$(vopt_if alsa '' 'disable_module audio.alsa')
	$(vopt_if oss '' 'disable_module audio.oss')
	$(vopt_if openal '' 'disable_module audio.openal')
	$(vopt_if ao '' 'disable_module audio.ao')

	$(vopt_if sdl '' 'disable_module video.sdl')
	$(vopt_if xv '' 'disable_module video.xvideo')
	$(vopt_if opengl '' 'disable_module video.glx')

	$(vopt_if sdl '' 'disable_module input.sdl')
	$(vopt_if udev '' 'disable_module input.udev')
}

if [ "$build_option_icarus" ];then
	post_build() {
		cd $wrksrc/icarus
		make ${makejobs} ${make_build_args}
	}

	post_install() {
		cd $wrksrc/icarus
		make STRIP=true ${make_install_args} install
	}
fi
