SUMMARY="Free UNIX Spectrum emulator"
DESCRIPTION="ZX Spectrum and derivative machines emulator with the following \
features:
* Accurate 16K, 48K (including the NTSC variant), 128K, +2, +2A and +3 \
emulation.
* Working +3e, SE, TC2048, TC2068, TS2068, Pentagon 128, Pentagon \"512\" \
(Pentagon 128 modified for extra memory), Pentagon 1024 and Scorpion ZS 256 \
emulation.
* Runs at true Speccy speed on any computer you're likely to try it on.
* Support for loading from .tzx files, including accelerated loading.
* Sound (using SDL).
* Kempston joystick emulation.
* Emulation of the various printers you could attach to the Spectrum.
* Support for the RZX input recording file format, including 'competition mode'.
* Emulation of the DivIDE, Interface 1, +D, DISCiPLE, Beta 128, Opus \
Discovery, Kempston mouse, Fuller audio box, SpecDrum, Spectrum +3e, ZXATASP \
and ZXCF interfaces.
* Emulation of the Spectranet and SpeccyBoot interfaces."
HOMEPAGE="http://fuse-emulator.sourceforge.net/fuse.php"
COPYRIGHT="2003-2018 Philip Kendall and FUSE contributors"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://sourceforge.net/projects/fuse-emulator/files/fuse/$portVersion/fuse-$portVersion.tar.gz"
CHECKSUM_SHA256="cb0e1f8e7c15a57710bcd7a844bd954134d28f169870c3633f59fa32bfc38037"
SOURCE_DIR="fuse-$portVersion"
SOURCE_URI_2="https://sourceforge.net/projects/fuse-emulator/files/fuse/1.0.0/fuse-1.0.0.tar.gz"
CHECKSUM_SHA256_2="a00add3abc0148247f7990e6feebcc32d82ebe857897d9426e5230222425aeb9"
SOURCE_DIR_2="fuse-1.0.0"
PATCHES="fuse-$portVersion.patchset"
ADDITIONAL_FILES="fuse.rdef.in"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	fuse$secondaryArchSuffix = $portVersion
	app:Fuse$secondaryArchSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libbz2$secondaryArchSuffix
	lib:libgcrypt$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libglib_2.0$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libSDL_1.2$secondaryArchSuffix
	lib:libspectrum$secondaryArchSuffix
	lib:libxml2$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libbz2$secondaryArchSuffix
	devel:libgcrypt$secondaryArchSuffix
	devel:libglib_2.0$secondaryArchSuffix
	devel:libpng$secondaryArchSuffix
	devel:libsdl$secondaryArchSuffix
	devel:libspectrum$secondaryArchSuffix
	devel:libxml2$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:bison
	cmd:flex
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:perl
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	LIBS=-lnetwork ./configure \
		--bindir=$appsDir/Fuse/bin \
		--datarootdir=$appsDir/Fuse \
		--with-sdl
	make $jobArgs
}

INSTALL()
{
	make install
	cp -rf $sourceDir2/roms/*.rom $appsDir/Fuse/fuse
	mv $appsDir/Fuse/bin/fuse $appsDir/Fuse/Fuse
	rm -rf $appsDir/Fuse/{bin,man}

	local APP_SIGNATURE="application/x-vnd.fuse-emulator"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3`"
	local LONG_INFO="$SUMMARY"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@MINOR@|$MINOR|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/fuse.rdef.in > fuse.rdef

	addResourcesToBinaries fuse.rdef $appsDir/Fuse/Fuse
	mimeset -f $appsDir/Fuse/Fuse
	addAppDeskbarSymlink $appsDir/Fuse/Fuse
}
