SUMMARY="OpenJPEG is an open-source C-Library for JPEG 2000"
DESCRIPTION="
The OpenJPEG library is an open-source JPEG 2000 codec written in C language. \
It has been developed in order to promote the use of JPEG 2000, the new \
still-image compression standard from the Joint Photographic Experts Group \
(JPEG). In addition to the basic codec, various other features are under \
development, among them the JP2 and MJ2 (Motion JPEG 2000) file formats, an \
indexing tool useful for the JPIP protocol, JPWL-tools for error-resilience, \
a Java-viewer for j2k-images, ...
"
LICENSE="BSD (2-clause)"
COPYRIGHT="2002-2012, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium
	2002-2012 Professor Benoit Macq
 	2003-2012 Antonin Descampe
 	2003-2009 Francois-Olivier Devaux
 	2005 Herve Drolon, FreeImage Team
 	2002-2003 Yannick Verschueren
	2001-2003 David Janssens"
HOMEPAGE="http://www.openjpeg.org/" 
SOURCE_URI="http://sourceforge.net/projects/openjpeg.mirror/files/$portVersion/openjpeg-$portVersion.tar.gz"
CHECKSUM_SHA256="1232bb814fd88d8ed314c94f0bfebb03de8559583a33abbe8c64ef3fc0a8ff03"
REVISION="2"
ARCHITECTURES="x86_gcc2 x86 x86_64"

PROVIDES="
	openjpeg$secondaryArchSuffix = $portVersion
	cmd:opj_decompress = $portVersion
	cmd:opj_compress = $portVersion
	cmd:opj_dump = $portVersion
	lib:libopenjp2$secondaryArchSuffix = 7 compat >= 7
	"

REQUIRES="
	haiku$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	lib:libpng$secondaryArchSuffix
	lib:libtiff$secondaryArchSuffix
"

BUILD_REQUIRES="
	devel:libz$secondaryArchSuffix
	devel:libpng$secondaryArchSuffix
	devel:libtiff$secondaryArchSuffix
	"
#needs devel:libtiff too but that isn't provided by anything

BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	cmd:cmake
	cmd:make
	cmd:gcc$secondaryArchSuffix
	"

PROVIDES_devel="
	openjpeg${secondaryArchSuffix}_devel = $portVersion
	devel:libopenjp2$secondaryArchSuffix = $portVersion compat >= 7
	"

REQUIRES_devel="
	openjpeg$secondaryArchSuffix == $portVersion
	"

PATCHES="openjpeg-2.1.0.patchset"

BUILD()
{
	mkdir -p build
	cd build
	cmake .. -DCMAKE_INSTALL_PREFIX=$prefix -DLIB_SUFFIX=$secondaryArchSubDir \
		-DOPENJPEG_INSTALL_LIB_DIR=$relativeLibDir \
		-DOPENJPEG_INSTALL_INCLUDE_DIR=$relativeIncludeDir \
		-DOPENJPEG_INSTALL_MAN_DIR=$relativeManDir
	make $jobArgs
}

INSTALL()
{
	cd build
	make install

	prepareInstalledDevelLibs libopenjp2

	fixPkgconfig

	packageEntries devel $developDir
}

TEST()
{
	make check
}
