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/" 
SRC_URI="http://openjpeg.googlecode.com/files/openjpeg-1.5.0.tar.gz"
CHECKSUM_MD5="e5d66193ddfa59a87da1eb08ea86293b"
REVISION="1"
ARCHITECTURES="x86"
if [ $effectiveTargetArchitecture != x86_gcc2 ]; then
	# x86_gcc2 is fine as primary target architecture as long as we're building
	# for a different secondary architecture.
	ARCHITECTURES="$ARCHITECTURES x86_gcc2"
else
	ARCHITECTURES="$ARCHITECTURES !x86_gcc2"
fi
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	openjpeg$secondaryArchSuffix = $portVersion compat >= 1.5.0
	cmd:JPWL_image_to_j2k$secondaryArchSuffix = $portVersion compat >= 1.5.0
	cmd:JPWL_j2k_to_image$secondaryArchSuffix = $portVersion compat >= 1.5.0
	cmd:extract_j2k_from_mj2$secondaryArchSuffix = $portVersion compat >= 1.5.0
	cmd:frames_to_mj2$secondaryArchSuffix = $portVersion compat >= 1.5.0
	cmd:image_to_j2k$secondaryArchSuffix = $portVersion compat >= 1.5.0
	cmd:j2k_dump$secondaryArchSuffix = $portVersion compat >= 1.5.0
	cmd:j2k_to_image$secondaryArchSuffix = $portVersion compat >= 1.5.0
	cmd:jpip_to_j2k$secondaryArchSuffix = $portVersion compat >= 1.5.0
	cmd:jpip_to_jp2$secondaryArchSuffix = $portVersion compat >= 1.5.0
	cmd:mj2_to_frames$secondaryArchSuffix = $portVersion compat >= 1.5.0
	cmd:opj_dec_server$secondaryArchSuffix = $portVersion compat >= 1.5.0
	cmd:test_index$secondaryArchSuffix = $portVersion compat >= 1.5.0
	cmd:wrap_j2k_in_mj2$secondaryArchSuffix = $portVersion compat >= 1.5.0
	lib:libopenjpeg$secondaryArchSuffix = $portVersion compat >= 1.5.0
	lib:libopenjpeg_JPWL$secondaryArchSuffix = $portVersion compat >= 1.5.0
	lib:libopenjpip_local$secondaryArchSuffix = $portVersion compat >= 1.5.0
	"

REQUIRES="
	haiku$secondaryArchSuffix >= $haikuVersion
	lib:libz$secondaryArchSuffix
	lib:libpng$secondaryArchSuffix
	"
# haiku_x86 doesn't claim to provide lib:libtiff_x86 on gcc2 builds
if [ "$targetArchitecture" != x86_gcc2 ];then
	REQUIRES="$REQUIRES lib:libtiff$secondaryArchSuffix"
fi

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

BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel >= $haikuVersion
	cmd:autoconf
	cmd:aclocal
	cmd:autoreconf
	cmd:libtoolize
	cmd:make
	cmd:gcc$secondaryArchSuffix
	"

PROVIDES_devel="
	openjpeg${secondaryArchSuffix}_devel = $portVersion compat >= 1.5.0
	devel:libopenjpeg$secondaryArchSuffix = $portVersion compat >= 1.5.0
	devel:libopenjpeg_JPWL$secondaryArchSuffix = $portVersion compat >= 1.5.0
	devel:libopenjpip_local$secondaryArchSuffix = $portVersion compat >= 1.5.0
	"

REQUIRES_devel="
	openjpeg$secondaryArchSuffix == $portVersion
	"

SOURCE_DIR="openjpeg-1.5.0"

BUILD()
{
	./bootstrap.sh
	runConfigure ./configure \
		--enable-mj2 \
		--enable-jpwl \
		--enable-jpip
	make
}

INSTALL()
{
	make install

	prepareInstalledDevelLibs libopenjpeg libopenjpip_local \
	libopenjpeg_JPWL

	fixPkgconfig

	packageEntries devel $developDir
}
