SUMMARY="JPEG image compression library and tools"
DESCRIPTION="
This package contains C software to implement JPEG image encoding, decoding, \
and transcoding. JPEG is a standardized compression method for full-color and \
gray-scale images.
The distributed programs provide conversion between JPEG "JFIF" format and \
image files in PBMPLUS PPM/PGM, GIF, BMP, and Targa file formats. The core \
compression and decompression library can easily be reused in other programs, \
such as image viewers. The package is highly portable C code; we have tested \
it on many machines ranging from PCs to Crays.
"
HOMEPAGE="http://www.ijg.org"
LICENSE="JPEG"
COPYRIGHT="1991-2013, Thomas G. Lane, Guido Vollbeding.  All Rights Reserved"
SRC_URI="http://www.ijg.org/files/jpegsrc.v8d.tar.gz"
CHECKSUM_MD5="52654eb3b2e60c35731ea8fc87f1bd29"
REVISION="2"
ARCHITECTURES="x86_gcc2 ?x86 ?x86_64"
SECONDARY_ARCHITECTURES="x86_gcc2 ?x86"

PATCHES="jpeg-8d.patch"

PROVIDES="
	jpeg$secondaryArchSuffix = $portVersion compat >= 8
	lib:libjpeg$secondaryArchSuffix = $portVersion compat >= 8
	"
REQUIRES="
	haiku$secondaryArchSuffix >= $haikuVersion
	"
BUILD_REQUIRES="
	"
BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel >= $haikuVersion
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:grep
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize
	cmd:make
	"

BUILD()
{
	#sed -i 's/^AM_C_PROTOTYPES//' configure.ac
	#sed -i 's/^AM_INIT_AUTOMAKE//' configure.ac
	#aclocal
	#libtoolize --force --copy --install
	#automake --add-missing
	autoconf
	runConfigure ./configure \
		--enable-shared
	make $jobArgs
}

INSTALL()
{
	make install

	prepareInstalledDevelLibs libjpeg

	# devel package
	packageEntries devel \
		$developDir

	# tools package
	if [ -z "$secondaryArchSuffix" ]; then
		packageEntries tools \
			$binDir \
			$documentationDir
	fi

	# Remove stuff we don't need in the secondary architecture base package.
	if [ -n "$secondaryArchSuffix" ]; then
		rm -rf $binDir
		rm -rf $documentationDir
	fi
}

# ----- devel package -------------------------------------------------------

PROVIDES_devel="
	jpeg${secondaryArchSuffix}_devel = $portVersion compat >= 8
	devel:libjpeg$secondaryArchSuffix = $portVersion compat >= 8
	"
REQUIRES_devel="
	jpeg$secondaryArchSuffix == $portVersion base
	"

# ----- tools package -------------------------------------------------------

if [ -z "$secondaryArchSuffix" ]; then
	SUMMARY_tools="The JPEG tools"
	PROVIDES_tools="
		jpeg_tools = $portVersion compat >= 8
		cmd:cjpeg = $portVersion compat >= 8
		cmd:djpeg = $portVersion compat >= 8
		cmd:jpegtran = $portVersion compat >= 8
		cmd:rdjpgcom = $portVersion compat >= 8
		cmd:wrjpgcom = $portVersion compat >= 8
		"
	REQUIRES_tools="
		haiku >= $haikuVersion
		jpeg == $portVersion base
		"
fi
