SUMMARY="Library for reading and processing of RAW digicam images"
DESCRIPTION="
LibRaw is a library for reading RAW files from digital photo cameras \
(CRW/CR2, NEF, RAF, DNG, MOS, KDC, DCR, etc, virtually all RAW formats are \
supported). 
It pays special attention to correct retrieval of data required for subsequent \
RAW conversion.
The library is intended for embedding in RAW converters, data analyzers, and \
other programs using RAW files as the initial data.
"
HOMEPAGE="http://www.libraw.org"
COPYRIGHT="
	2008-2013 LibRaw LLC
	"
LICENSE="
	GNU LGPL v2.1
	CDDL v1"
SOURCE_URI="http://www.libraw.org/data/LibRaw-$portVersion.tar.gz"
CHECKSUM_SHA256="6344e355f7c23f13e266844b36265d5f624237ba5a62dc901c7b91b510a84187"
REVISION="1"
ARCHITECTURES="x86 x86_64"
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"
fi
SECONDARY_ARCHITECTURES="x86"
SOURCE_DIR="LibRaw-$portVersion"

PATCHES="libraw-$portVersion.patchset"

PROVIDES="
	libraw$secondaryArchSuffix = $portVersion compat >= 0
	lib:libraw$secondaryArchSuffix = 10.0.0 compat >= 10
	lib:libraw_r$secondaryArchSuffix = 10.0.0 compat >= 10
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:liblcms2$secondaryArchSuffix
	lib:libstdc++$secondaryArchSuffix
	"
if [ $effectiveTargetArchitecture != x86_gcc2 ]; then
	REQUIRES+="
		lib:libgcc_s$secondaryArchSuffix
	"
fi

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:liblcms2$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:find
	"

BUILD()
{
	autoreconf -fi
	runConfigure ./configure
	make $jobArgs
}

INSTALL()
{
	make install
	
	prepareInstalledDevelLibs libraw libraw_r
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
		
		# tools package
	packageEntries tools \
		$binDir

}

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

PROVIDES_devel="
	libraw${secondaryArchSuffix}_devel = $portVersion compat >= 0
	devel:libraw$secondaryArchSuffix = 10.0.0 compat >= 10
	devel:libraw_r$secondaryArchSuffix = 10.0.0 compat >= 10
	"
REQUIRES_devel="
	libraw$secondaryArchSuffix == $portVersion base
	"

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

SUMMARY_tools="The libraw tools"
PROVIDES_tools="
	libraw_tools$secondaryArchSuffix = $portVersion
	cmd:4channels$secondaryArchSuffix
	cmd:dcraw_emu$secondaryArchSuffix
	cmd:dcraw_half$secondaryArchSuffix
	cmd:half_mt$secondaryArchSuffix
	cmd:mem_image$secondaryArchSuffix
	cmd:multirender_test$secondaryArchSuffix
	cmd:postprocessing_benchmark$secondaryArchSuffix
	cmd:raw_identify$secondaryArchSuffix
	cmd:simple_dcraw$secondaryArchSuffix
	cmd:unprocessed_raw$secondaryArchSuffix
	"
REQUIRES_tools="
	libraw$secondaryArchSuffix == $portVersion base
	haiku$secondaryArchSuffix
	lib:liblcms2$secondaryArchSuffix
	lib:libstdc++$secondaryArchSuffix
	"
if [ $effectiveTargetArchitecture != x86_gcc2 ]; then
	REQUIRES_tools+="
		lib:libgcc_s$secondaryArchSuffix
		"
fi
