SUMMARY="Electronic Design Tool"
DESCRIPTION="Fritzing is an open-source electronic design tool focusing on makers, hobbyists, and everyone else \
interested in getting creative with interactive electronics. Document your electronic sketches, learn \
from example projects, produce your own PCBs, and share with the community.

Fritzing differs from other tools through:
 * a real-world breadboard view that is hands-on and easy to understand
 * a visual component library including the Arduino, Raspberry Pi, SparkFun parts and many more
 * an intuitive user interface, with seamless switching between breadboard, schematic and pcb design

The lively community on fritzing.org exchanges projects and tips, and there is also a PCB service 'Fritzing Fab' that produces user designs."
HOMEPAGE="http://www.fritzing.org"
COPYRIGHT="Interaction Design Lab Potsdam"
LICENSE="GNU GPL v2
	GNU GPL v3"
REVISION="1"
SOURCE_URI="https://github.com/fritzing/fritzing-app/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="2475a95aad2c1536eef3fdb72665c5c16590644b45bd110a0cde223c916625b8"
SOURCE_DIR="fritzing-app-$portVersion"
SOURCE_URI_2="https://github.com/fritzing/fritzing-parts/archive/$portVersion.zip"
CHECKSUM_SHA256_2="bda500e993f8990fa5fa50bb7d189dc7206d4cc64fa57ce6b99cee45f4480e14"
SOURCE_DIR_2="fritzing-parts-$portVersion"
PATCHES="fritzing-$portVersion.patchset"
ADDITIONAL_FILES="fritzing.rdef.in"

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

PROVIDES="
	fritzing$secondaryArchSuffix = $portVersion
	app:Fritzing$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libgit2$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libminizip$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5PrintSupport$secondaryArchSuffix
	lib:libQt5Svg$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libboost_system$secondaryArchSuffix
	devel:libgit2$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libminizip$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5PrintSupport$secondaryArchSuffix
	devel:libQt5Svg$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:find
	cmd:g++$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:qmake$secondaryArchSuffix >= 5
	cmd:which
	"

BUILD()
{
	qmake \
		PREFIX=$appsDir/Fritzing \
		DATADIR=$dataDir \
		PKGDATADIR=$dataDir/fritzing \
		DEFINES=QUAZIP_INSTALLED \
		DEFINES=LIBGIT2_INSTALLED
	make $jobArgs
}

INSTALL()
{
	mkdir -p $appsDir/Fritzing
	make install

	cp -r $sourceDir2/* $appsDir/Fritzing

	local APP_SIGNATURE="application/x-vnd.fritzing"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3 | tr -d '[:alpha:]'`"
	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/fritzing.rdef.in > $sourceDir/fritzing.rdef

	addResourcesToBinaries $sourceDir/fritzing.rdef $appsDir/Fritzing/Fritzing
	addAppDeskbarSymlink $appsDir/Fritzing/Fritzing Fritzing
}
