SUMMARY="Logic analyzer, oscilloscope and MSO GUI for sigrok"
DESCRIPTION="A graphical frontend for the libsigrok and libsigrokdecode \
libraries, permitting access to a wide range of devices and protocol decoders \
to let you record, analyze, process and export analog and logic data.

The sigrok suite needs some kind of hardware to interface to the signals you \
want to examine.
A variety of compatible low cost chinese made logic analyzer products are \
available for as little as $5. Sigrok also supports FX2-based oscilloscopes \
such as the Hantek 6022BE, non-FX2 devices like the Openbench Logic Sniffer \
or devices that make use of the SCPI protocol, as all reasonably modern \
oscilloscopes do (Rigol DS1054z, LeCroy WaveRunner, Yokogawa DLM and similar)."
HOMEPAGE="https://sigrok.org/wiki/PulseView"
COPYRIGHT="2012-2019 PulseView contributors"
LICENSE="GNU GPL v3"
REVISION="3"
SOURCE_URI="http://sigrok.org/download/source/pulseview/pulseview-$portVersion.tar.gz"
CHECKSUM_SHA256="f042f77a3e1b35bf30666330e36ec38fab8d248c3693c37b7e35d401c3bfabcb"
PATCHES="pulseview-$portVersion.patchset
	pulseview-0.4.2-qt-5.15.patch"
ADDITIONAL_FILES="pulseview.rdef.in"

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

boostMinumumVersion="1.70.0"

PROVIDES="
	pulseview$secondaryArchSuffix = $portVersion
	app:PulseView
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libboost_filesystem$secondaryArchSuffix
	lib:libboost_serialization$secondaryArchSuffix
	lib:libboost_system$secondaryArchSuffix
	lib:libftdi1$secondaryArchSuffix
	lib:libglib_2.0$secondaryArchSuffix
	lib:libglibmm_2.4$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Svg$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libsigrok$secondaryArchSuffix
	lib:libsigrokdecode$secondaryArchSuffix
	lib:libsigc_2.0$secondaryArchSuffix
	lib:libusb_1.0$secondaryArchSuffix
	lib:libzip$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libboost_filesystem$secondaryArchSuffix >= $boostMinumumVersion
	devel:libboost_serialization$secondaryArchSuffix >= $boostMinumumVersion
	devel:libboost_system$secondaryArchSuffix >= $boostMinumumVersion
	devel:libftdi1$secondaryArchSuffix
	devel:libglib_2.0$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Svg$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libsigrok$secondaryArchSuffix
	devel:libsigrokdecode$secondaryArchSuffix
	devel:libusb_1.0$secondaryArchSuffix
	devel:libzip$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:pkg_config$secondaryArchSuffix
	cmd:linguist$secondaryArchSuffix >= 5
	cmd:make
	"

BUILD()
{
	mkdir -p build && cd build
	cmake $cmakeDirArgs \
		-DCMAKE_BUILD_TYPE=Release \
		-DENABLE_TEST=OFF \
		-DDISABLE_WERROR=ON ..
	make $jobArgs
}

INSTALL()
{
	make -C build install
	# rename the app
	mv $appsDir/pulseview $appsDir/PulseView
	# cleanup
	rm -rf $prefix/share

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

	addResourcesToBinaries $sourceDir/pulseview.rdef $appsDir/PulseView
	addAppDeskbarSymlink $appsDir/PulseView
}
