SUMMARY="IM is a toolkit for Digital Imaging."
HOMEPAGE="http://www.tecgraf.puc-rio.br/im/"
SRC_URI="http://freefr.dl.sourceforge.net/project/imtoolkit/3.8.1/Docs%20and%20Sources/im-3.8.1_Sources.tar.gz"
CHECKSUM_SHA256="bf005ec22d240382dacd047ac4ed82110cfb702f8dc4ce3607059ecec60a78c8"
REVISION="1"
ARCHITECTURES="x86_gcc2"
SECONDARY_ARCHITECTURES="x86"
PROVIDES="
	im$secondaryArchSuffix = $portVersion
	lib:libim$secondaryArchSuffix = $portVersion
	lib:libim_fftw$secondaryArchSuffix = $portVersion
	lib:libim_jp2$secondaryArchSuffix = $portVersion
	lib:libim_process$secondaryArchSuffix = $portVersion
	lib:libim_process_omp$secondaryArchSuffix = $portVersion

	lib:libimlua51$secondaryArchSuffix = $portVersion
	lib:libimlua_fftw51$secondaryArchSuffix = $portVersion
	lib:libimlua_jp251$secondaryArchSuffix = $portVersion
	lib:libimlua_process51$secondaryArchSuffix = $portVersion
	lib:libimlua_process_omp51$secondaryArchSuffix = $portVersion

	lib:libimlua52$secondaryArchSuffix = $portVersion
	lib:libimlua_fftw52$secondaryArchSuffix = $portVersion
	lib:libimlua_jp252$secondaryArchSuffix = $portVersion
	lib:libimlua_process52$secondaryArchSuffix = $portVersion
	lib:libimlua_process_omp52$secondaryArchSuffix = $portVersion
"

REQUIRES="
	haiku$secondaryArchSuffix >= $haikuVersion
	lib:libz$secondaryArchSuffix
"

BUILD_REQUIRES="
	devel:liblua$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
"

BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel >= $haikuVersion
	cmd:gcc$secondaryArchSuffix
	cmd:as$secondaryArchSuffix
	cmd:make
	cmd:which
"

SOURCE_DIR="im"
PATCHES="im-3.8.patchset"
BUILD()
{
	cd src
	make
}

INSTALL()
{
	mkdir -p $developLibDir
	mkdir -p $libDir
	mkdir -p $includeDir

	cp lib/Haiku11/* $libDir
	cp include/* $includeDir

	prepareInstalledDevelLibs libim libim_fftw libim_jp2 libim_process \
		libim_process_omp libimlua51 libimlua_fftw51 libimlua_jp251 \
		libimlua_process51 libimlua_process_omp51 libimlua52 libimlua_fftw52 \
		libimlua_jp252 libimlua_process52 libimlua_process_omp52
		
	packageEntries devel $developDir
}

TEST()
{
	ln -s ../../lib/Haiku11 bin/Haiku11/lib
	cd test
	make -f ../tecmake.mak MF=im_info
	! ../bin/Haiku11/im_info `finddir B_SYSTEM_DEVELOP_DIRECTORY`/sample-code/pdflib/data/nesrin.jpg

	make -f ../tecmake.mak MF=im_copy
	! ../bin/Haiku11/im_copy `finddir B_SYSTEM_DEVELOP_DIRECTORY`/sample-code/pdflib/data/nesrin.jpg nesrin.jpg

	# Requires cd and iup.
	# make -f ../tecmake.mak MF=im_view
	# ../bin/Haiku11/im_view
}

PROVIDES_devel="
	im${secondaryArchSuffix}_devel = $portVersion
	devel:libim$secondaryArchSuffix = $portVersion
	devel:libim_fftw$secondaryArchSuffix = $portVersion
	devel:libim_jp2$secondaryArchSuffix = $portVersion
	devel:libim_process$secondaryArchSuffix = $portVersion
	devel:libim_process_omp$secondaryArchSuffix = $portVersion

	devel:libimlua51$secondaryArchSuffix = $portVersion
	devel:libimlua_fftw51$secondaryArchSuffix = $portVersion
	devel:libimlua_jp251$secondaryArchSuffix = $portVersion
	devel:libimlua_process51$secondaryArchSuffix = $portVersion
	devel:libimlua_process_omp51$secondaryArchSuffix = $portVersion

	devel:libimlua52$secondaryArchSuffix = $portVersion
	devel:libimlua_fftw52$secondaryArchSuffix = $portVersion
	devel:libimlua_jp252$secondaryArchSuffix = $portVersion
	devel:libimlua_process52$secondaryArchSuffix = $portVersion
	devel:libimlua_process_omp52$secondaryArchSuffix = $portVersion
"

REQUIRES_devel="
	im$secondaryArchSuffix == $portVersion base
"

LICENSE="MIT"
COPYRIGHT="1994-2012 Tecgraf, PUC-Rio."
DESCRIPTION="
IM is a toolkit for Digital Imaging. IM is based on 4 concepts: Image \
Representation, Storage, Processing and Capture. Image Visualization is a task \
that it is left for a graphics library.
It provides support for image capture, several image file formats and many \
image processing operations. The most popular file formats are supported: \
TIFF, BMP, PNG, JPEG, GIF and AVI.
Image representation includes scientific data types (like IEEE floating point \
data) and attributes (or metadata like GeoTIFF and Exif tags). Animation, \
video and volumes are supported as image sequences, but there is no digital \
audio support.
The main goal of the library is to provide a simple API and abstraction of \
images for scientific applications.
The toolkit API is written in C. The core library source code is implemented \
in C++ and it is very portable, it can be compiled in Windows and UNIX with no \
modifications. New image processing operations can be implemented in C or in \
C++.
IM is free software, can be used for public and commercial applications.
"
