SUMMARY="A portable ZX-Spectrum emulator"
DESCRIPTION="Portable ZX-Spectrum emulator supports Z80 128K (Pentagon) AY/YM, \
Beeper, Beta Disk, Tape, Kempston Joystick/Mouse, Snapshots, Replays.
Supported formats: sna, z80, szx, rzx, tap, tzx, csw, trd, scl, fdi, td0, udi, zip."
HOMEPAGE="https://bitbucket.org/djdron/unrealspeccyp"
COPYRIGHT="2021 SMT, Dexus, Alone Coder, deathsoft, djdron, scor, 3dEyes"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://github.com/djdron/UnrealSpeccyP/archive/refs/tags/v$portVersion.tar.gz"
CHECKSUM_SHA256="b212e058d011f280cd6fe36a7f35c190d36a74afcd070d721cd80122bd3ffd9a"
SOURCE_DIR="UnrealSpeccyP-$portVersion"
PATCHES="unreal_speccy_portable-$portVersion.patchset"

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

PROVIDES="
	unreal_speccy_portable$secondaryArchSuffix = $portVersion
	app:UnrealSpeccyPortable$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libbz2$secondaryArchSuffix
	lib:libcurl$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libxml2$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libbz2$secondaryArchSuffix
	devel:libcurl$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libxml2$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	mkdir -p build/cmake/build
	cd build/cmake/build
	cmake .. -DCMAKE_BUILD_TYPE=Release -DUSE_HAIKU=ON
	make $jobArgs
}

INSTALL()
{
	mkdir -p $appsDir/UnrealSpeccyPortable

	cp build/cmake/build/unreal_speccy_portable $appsDir/UnrealSpeccyPortable/UnrealSpeccyPortable
	cp -R res $appsDir/UnrealSpeccyPortable

	addAppDeskbarSymlink $appsDir/UnrealSpeccyPortable/UnrealSpeccyPortable "Unreal Speccy Portable"
}
