SUMMARY="An open-source full-featured 2D animation creation software"
DESCRIPTION="OpenToonz is a 2D animation software published by \
DWANGO (http://dwango.co.jp/english/). It is based on Toonz Studio \
Ghibli Version, originally developed in Italy by \
Digital Video, Inc. (http://www.toonz.com/), and customized by \
Studio Ghibli (http://www.ghibli.jp/) over many years of production."
HOMEPAGE="https://github.com/opentoonz/opentoonz/"
COPYRIGHT="2016, DWANGO Co., Ltd."
LICENSE="BSD (3-clause)"
REVISION="3"
SOURCE_URI="$HOMEPAGE/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="e9943abbd49befb5c8963fd7cb744b6c5b93a4faa02c8564610b848d189ea029"
PATCHES="opentoonz-$portVersion.patchset"

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

PROVIDES="
	opentoonz$secondaryArchSuffix = $portVersion
	cmd:opentoonz
	cmd:opentoonz_1.1
	cmd:tcleanup
	cmd:tcomposer
	cmd:tconverter
	cmd:tfarmcontroller
	cmd:tfarmserver
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libGL$secondaryArchSuffix
	lib:libglew$secondaryArchSuffix
	lib:libGLU$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:liblz4$secondaryArchSuffix
	lib:liblzma$secondaryArchSuffix
	lib:libopenblas$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Network$secondaryArchSuffix
	lib:libQt5OpenGL$secondaryArchSuffix
	lib:libQt5PrintSupport$secondaryArchSuffix
	lib:libQt5Script$secondaryArchSuffix
	lib:libQt5Svg$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libQt5Xml$secondaryArchSuffix
	lib:libSDL2_2.0$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libboost_system$secondaryArchSuffix
	devel:libfreetype$secondaryArchSuffix
	devel:libGL$secondaryArchSuffix
	devel:libglew$secondaryArchSuffix
	devel:libGLU$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:liblz4$secondaryArchSuffix
	devel:liblzma$secondaryArchSuffix
	devel:liblzo2$secondaryArchSuffix
	devel:libopenblas$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libQt5Core$secondaryArchSuffix
	devel:libsdl2_2.0$secondaryArchSuffix
	devel:libsuperlu$secondaryArchSuffix
	devel:libusb_1.0$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	cd thirdparty/tiff-4.0.3
	autoreconf -fi
	./configure --with-pic --disable-jbig
	make $jobArgs
	cd ../../toonz
	mkdir -p build && cd build
	cmake ../sources \
		-DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_INSTALL_PREFIX=$prefix \
        -DGLUT_LIB=/system/develop/lib/libglut.so \
        -DCMAKE_CXX_FLAGS=-DBOOST_NO_CXX11_CONSTEXPR
	make $jobArgs
}

INSTALL()
{
	cd toonz/build
	make install
}
