SUMMARY="Real Time Electronic Circuit Simulator"
DESCRIPTION="SimulIDE is a simple real time electronic circuit simulator, intended \
for hobbyist or students to learn and experiment with simple electronic circuits an\
d microcontrollers, supporting PIC, AVR and Arduino.

This is not an accurate simulator for circuit analysis, it aims to be fast, simple \
and easy to use, this means simple and not very accurate electronic models and limi\
ted features.

Simplicity and ease of use are the key features of this simulator.
You can create, simulate and interact with your circuits within minutes, just drag \
components from the list, drop into the circuit, connect them and push power button\
 to see how it works.

SimulIDE also features a code Editor and Debugger for GcBasic, Arduino, PIC asm and \
AVR asm. It is still in it's firsts stages of development, with basic functionalitie\
s, but it is possible to write, compile and basic debugging with breakpoints, watch \
registers and global variables."
HOMEPAGE="https://www.simulide.com/"
COPYRIGHT=" 2012-2021 Santiago Gonzalez, Popov Alexey"
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://mailfence.com/pub/docs/santigoro/web/SimulIDE_${portVersion}/SimulIDE_${portVersion}-SR4_Sources.tar.gz"
CHECKSUM_SHA256="39879bf6566b1d4902f6ef8c7e8ceb1f998deeed02c41e1b67b443086acf9ebd"
SOURCE_DIR="simulide_$portVersion-SR4_Sources"
PATCHES="simulide-$portVersion.patchset"
ADDITIONAL_FILES="
	simulide.rdef.in
	icons.zip
	"

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

GLOBAL_WRITABLE_FILES="
	settings/SimulIDE/examples directory auto-merge
	"

PROVIDES="
	simulide$secondaryArchSuffix = $portVersion
	app:SimulIDE$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	cmd:gpasm
	cmd:avra
	lib:libGL$secondaryArchSuffix
	lib:libelf$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libGL$secondaryArchSuffix
	devel:libelf$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:find
	cmd:gcc$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	cmd:qmake$secondaryArchSuffix >= 5
	"

PATCH()
{
	unzip -o $sourceDir/../../additional-files/icons.zip -d $sourceDir/src/icons/mainwindow
}

BUILD()
{
	cd build_XX
	qmake -r prefix=$appsDir/SimulIDE
	make $jobArgs
}

INSTALL()
{
	mkdir -p $appsDir $settingsDir/SimulIDE
	cp -R  $sourceDir/build_XX/executables/SimulIDE_${portVersion}-SR4 $appsDir/SimulIDE
	mv $appsDir/SimulIDE/examples $settingsDir/SimulIDE
	ln -s $settingsDir/SimulIDE/examples $appsDir/SimulIDE/examples

	local APP_SIGNATURE="application/x-vnd.simulide"
	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/simulide.rdef.in > \
			$sourceDir/simulide.rdef

	addResourcesToBinaries $sourceDir/simulide.rdef \
		$appsDir/SimulIDE/SimulIDE

	addAppDeskbarSymlink $appsDir/SimulIDE/SimulIDE
}
