SUMMARY="ZX Second-Emulator And Released for UniX"
DESCRIPTION="It's a ZX Machines Emulator for UNIX based operating systems (and Windows), \
including all the Sinclair computers:
* MK14
* ZX80
* ZX81
* ZX Spectrum
* QL
* Z88

And also:
* Timex TS 2068
* Sam Coupe
* Pentagon
* Chloe 140 SE, 280 SE
* Chrome
* Prism
* ZX-Uno
* ZX-Evolution BaseConf
* ZX-Evolution TS-Conf
* TBBlue/ZX Spectrum Next
* Jupiter Ace
* Amstrad CPC 464, CPC 4128
* MSX1
* Spectravideo 318/328
* Colecovision
* Sega SG1000."
HOMEPAGE="https://github.com/chernandezba/zesarux"
COPYRIGHT="Cesar Hernandez Bano"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://github.com/chernandezba/zesarux/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="75f1e38ab9a462dfcf5bafe84fee3c2a4130416658c438fb1d6272d995e48533"
SOURCE_DIR="zesarux-$portVersion"
PATCHES="zesarux-$portVersion.patchset"

ADDITIONAL_FILES="zesarux.rdef.in"

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

PROVIDES="
	zesarux$secondaryArchSuffix = $portVersion
	app:ZEsarUX
	"
REQUIRES="
	haiku$secondaryArchSuffix
	cmd:gunzip
	cmd:sox$secondaryArchSuffix
	cmd:tar
	cmd:unrar
	lib:libGL$secondaryArchSuffix
	lib:libSDL2_2.0$secondaryArchSuffix
	lib:libsndfile$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libpng16$secondaryArchSuffix
	devel:libSDL2_2.0$secondaryArchSuffix
	devel:libsndfile$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:bison
	cmd:find
	cmd:flex
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:which
	cmd:xargs
	"

BUILD()
{
	cd src
	LDFLAGS="-lnetwork" ./configure --prefix=$appsDir/ZEsarUX --enable-sdl2
	make $jobArgs
}

INSTALL()
{
	cd src
	make install
	mv $appsDir/ZEsarUX/bin/zesarux $appsDir/ZEsarUX/ZEsarUX
	mv $appsDir/ZEsarUX/share/zesarux $appsDir/ZEsarUX/data
	rm -rf $appsDir/ZEsarUX/{bin,share}

	local APP_SIGNATURE="application/x-vnd.zesarux"
	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|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/zesarux.rdef.in > zesarux.rdef

	addResourcesToBinaries zesarux.rdef $appsDir/ZEsarUX/ZEsarUX
	addAppDeskbarSymlink $appsDir/ZEsarUX/ZEsarUX
}
