SUMMARY="A rapid prototyping application for image processing"
DESCRIPTION="ImagePlay is a rapid prototyping tool for building and testing \
image processing algorithms. It comes with a variety of over 70 individual \
image processors which can be combined into complex process chains."
HOMEPAGE="http://cpvrlab.github.io/ImagePlay/"
COPYRIGHT="2015-2017 Bern University of Applied Sciences, Engineering and \
	Information Technology, HuCE, cpvrLab "
LICENSE="GNU GPL v3"
REVISION="2"
srcGitRev_1="3cccd1e7dc15f6da848d51c483671092e3904db8"
SOURCE_URI_1="https://github.com/cpvrlab/ImagePlay/archive/$srcGitRev_1.tar.gz"
CHECKSUM_SHA256_1="7242ce7134ee4dfd6da48151a168b68f2ff9053af83dec923a8b8efe233eb817"
SOURCE_FILENAME_1="imageplay-$portVersion.tar.gz"
SOURCE_DIR_1="ImagePlay-$srcGitRev_1"
srcGitRev_2="78194e92d7bc845888377b980fc8393637cbd481"
SOURCE_URI_2="https://github.com/cpvrlab/ImagePlay_lib/archive/$srcGitRev_2.tar.gz"
CHECKSUM_SHA256_2="937397586b1089749d723c0e2639a6e44717001bdb519050930002266f7dd043"
SOURCE_FILENAME_2="imageplay_lib-$portVersion.tar.gz"
SOURCE_DIR_2="ImagePlay_lib-$srcGitRev_2"

ADDITIONAL_FILES="imageplay.rdef.in"
PATCHES_1="imageplay-$portVersion.patchset"

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

PROVIDES="
	imageplay$secondaryArchSuffix = $portVersion
	app:imageplay$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libfreeimage$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libgomp$secondaryArchSuffix
	lib:libopencv_alphamat$secondaryArchSuffix
	lib:libopencv_aruco$secondaryArchSuffix
	lib:libopencv_bgsegm$secondaryArchSuffix
	lib:libopencv_bioinspired$secondaryArchSuffix
	lib:libopencv_calib3d$secondaryArchSuffix
	lib:libopencv_ccalib$secondaryArchSuffix
	lib:libopencv_core$secondaryArchSuffix
	lib:libopencv_cvv$secondaryArchSuffix
	lib:libopencv_datasets$secondaryArchSuffix
	lib:libopencv_dnn_objdetect$secondaryArchSuffix
	lib:libopencv_dnn_superres$secondaryArchSuffix
	lib:libopencv_dnn$secondaryArchSuffix
	lib:libopencv_dpm$secondaryArchSuffix
	lib:libopencv_face$secondaryArchSuffix
	lib:libopencv_features2d$secondaryArchSuffix
	lib:libopencv_flann$secondaryArchSuffix
	lib:libopencv_freetype$secondaryArchSuffix
	lib:libopencv_fuzzy$secondaryArchSuffix
	lib:libopencv_gapi$secondaryArchSuffix
	lib:libopencv_hdf$secondaryArchSuffix
	lib:libopencv_hfs$secondaryArchSuffix
	lib:libopencv_highgui$secondaryArchSuffix
	lib:libopencv_img_hash$secondaryArchSuffix
	lib:libopencv_imgcodecs$secondaryArchSuffix
	lib:libopencv_imgproc$secondaryArchSuffix
	lib:libopencv_intensity_transform$secondaryArchSuffix
	lib:libopencv_line_descriptor$secondaryArchSuffix
	lib:libopencv_mcc$secondaryArchSuffix
	lib:libopencv_ml$secondaryArchSuffix
	lib:libopencv_objdetect$secondaryArchSuffix
	lib:libopencv_optflow$secondaryArchSuffix
	lib:libopencv_phase_unwrapping$secondaryArchSuffix
	lib:libopencv_photo$secondaryArchSuffix
	lib:libopencv_plot$secondaryArchSuffix
	lib:libopencv_quality$secondaryArchSuffix
	lib:libopencv_rapid$secondaryArchSuffix
	lib:libopencv_reg$secondaryArchSuffix
	lib:libopencv_rgbd$secondaryArchSuffix
	lib:libopencv_saliency$secondaryArchSuffix
	lib:libopencv_shape$secondaryArchSuffix
	lib:libopencv_stereo$secondaryArchSuffix
	lib:libopencv_stitching$secondaryArchSuffix
	lib:libopencv_structured_light$secondaryArchSuffix
	lib:libopencv_superres$secondaryArchSuffix
	lib:libopencv_surface_matching$secondaryArchSuffix
	lib:libopencv_text$secondaryArchSuffix
	lib:libopencv_tracking$secondaryArchSuffix
	lib:libopencv_video$secondaryArchSuffix
	lib:libopencv_videoio$secondaryArchSuffix
	lib:libopencv_videostab$secondaryArchSuffix
	lib:libopencv_xfeatures2d$secondaryArchSuffix
	lib:libopencv_ximgproc$secondaryArchSuffix
	lib:libopencv_xobjdetect$secondaryArchSuffix
	lib:libopencv_xphoto$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libfreeimage$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:libopencv_alphamat$secondaryArchSuffix
	devel:libopencv_aruco$secondaryArchSuffix
	devel:libopencv_bgsegm$secondaryArchSuffix
	devel:libopencv_bioinspired$secondaryArchSuffix
	devel:libopencv_calib3d$secondaryArchSuffix
	devel:libopencv_ccalib$secondaryArchSuffix
	devel:libopencv_core$secondaryArchSuffix
	devel:libopencv_cvv$secondaryArchSuffix
	devel:libopencv_datasets$secondaryArchSuffix
	devel:libopencv_dnn_objdetect$secondaryArchSuffix
	devel:libopencv_dnn_superres$secondaryArchSuffix
	devel:libopencv_dnn$secondaryArchSuffix
	devel:libopencv_dpm$secondaryArchSuffix
	devel:libopencv_face$secondaryArchSuffix
	devel:libopencv_features2d$secondaryArchSuffix
	devel:libopencv_flann$secondaryArchSuffix
	devel:libopencv_freetype$secondaryArchSuffix
	devel:libopencv_fuzzy$secondaryArchSuffix
	devel:libopencv_gapi$secondaryArchSuffix
	devel:libopencv_hdf$secondaryArchSuffix
	devel:libopencv_hfs$secondaryArchSuffix
	devel:libopencv_highgui$secondaryArchSuffix
	devel:libopencv_img_hash$secondaryArchSuffix
	devel:libopencv_imgcodecs$secondaryArchSuffix
	devel:libopencv_imgproc$secondaryArchSuffix
	devel:libopencv_intensity_transform$secondaryArchSuffix
	devel:libopencv_line_descriptor$secondaryArchSuffix
	devel:libopencv_mcc$secondaryArchSuffix
	devel:libopencv_ml$secondaryArchSuffix
	devel:libopencv_objdetect$secondaryArchSuffix
	devel:libopencv_optflow$secondaryArchSuffix
	devel:libopencv_phase_unwrapping$secondaryArchSuffix
	devel:libopencv_photo$secondaryArchSuffix
	devel:libopencv_plot$secondaryArchSuffix
	devel:libopencv_quality$secondaryArchSuffix
	devel:libopencv_rapid$secondaryArchSuffix
	devel:libopencv_reg$secondaryArchSuffix
	devel:libopencv_rgbd$secondaryArchSuffix
	devel:libopencv_saliency$secondaryArchSuffix
	devel:libopencv_shape$secondaryArchSuffix
	devel:libopencv_stereo$secondaryArchSuffix
	devel:libopencv_stitching$secondaryArchSuffix
	devel:libopencv_structured_light$secondaryArchSuffix
	devel:libopencv_superres$secondaryArchSuffix
	devel:libopencv_surface_matching$secondaryArchSuffix
	devel:libopencv_text$secondaryArchSuffix
	devel:libopencv_tracking$secondaryArchSuffix
	devel:libopencv_video$secondaryArchSuffix
	devel:libopencv_videoio$secondaryArchSuffix
	devel:libopencv_videostab$secondaryArchSuffix
	devel:libopencv_xfeatures2d$secondaryArchSuffix
	devel:libopencv_ximgproc$secondaryArchSuffix
	devel:libopencv_xobjdetect$secondaryArchSuffix
	devel:libopencv_xphoto$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:g++$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:qmake$secondaryArchSuffix >= 5
	"

BUILD()
{
	#Preparation
	rm -rf "$sourceDir/_lib"
	ln -sfn "$sourceDir2" "$sourceDir/_lib"

	qmake PREFIX="$appsDir/ImagePlay"
	make $jobArgs
}

INSTALL()
{
#	make install #broken
	mkdir -p $appsDir/ImagePlay
	cp -R $sourceDir/_bin/Release/haiku/* $appsDir/ImagePlay
	mv $appsDir/ImagePlay/imageplay $appsDir/ImagePlay/ImagePlay
	rm -rf $appsDir/ImagePlay/libIPL.a

	local APP_SIGNATURE="application/x-vnd.imageplay"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local MINOR="`echo "$portVersion" | cut -d. -f3 | cut -d~ -f1`"
	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/imageplay.rdef.in > imageplay.rdef

	addResourcesToBinaries imageplay.rdef $appsDir/ImagePlay/ImagePlay

	addAppDeskbarSymlink $appsDir/ImagePlay/ImagePlay
}
