SUMMARY="A toolkit for digital imaging"
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."
HOMEPAGE="https://www.tecgraf.puc-rio.br/im/"
COPYRIGHT="1994-2019 Tecgraf, PUC-Rio."
LICENSE="MIT"
REVISION="2"
SOURCE_URI="http://freefr.dl.sourceforge.net/project/imtoolkit/$portVersion/Docs%20and%20Sources/im-${portVersion}_Sources.tar.gz"
CHECKSUM_SHA256="d303de96ea104f8d1bfc82e1bb4b061a6617a6f0082e37fe69950b7d2dcea3cd"
SOURCE_DIR="im"
PATCHES="im-$portVersion.patchset"

ARCHITECTURES="all ?x86"
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:libim_lzo$secondaryArchSuffix = $portVersion
	lib:libimlua51$secondaryArchSuffix = $portVersion
	lib:libimlua52$secondaryArchSuffix = $portVersion
	lib:libimlua_fftw51$secondaryArchSuffix = $portVersion
	lib:libimlua_fftw52$secondaryArchSuffix = $portVersion
	lib:libimlua_jp251$secondaryArchSuffix = $portVersion
	lib:libimlua_jp252$secondaryArchSuffix = $portVersion
	lib:libimlua_process51$secondaryArchSuffix = $portVersion
	lib:libimlua_process52$secondaryArchSuffix = $portVersion
	lib:libimlua_process_omp51$secondaryArchSuffix = $portVersion
	lib:libimlua_process_omp52$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

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:libim_lzo$secondaryArchSuffix = $portVersion
	devel:libimlua51$secondaryArchSuffix = $portVersion
	devel:libimlua52$secondaryArchSuffix = $portVersion
	devel:libimlua_fftw51$secondaryArchSuffix = $portVersion
	devel:libimlua_fftw52$secondaryArchSuffix = $portVersion
	devel:libimlua_jp251$secondaryArchSuffix = $portVersion
	devel:libimlua_jp252$secondaryArchSuffix = $portVersion
	devel:libimlua_process51$secondaryArchSuffix = $portVersion
	devel:libimlua_process52$secondaryArchSuffix = $portVersion
	devel:libimlua_process_omp51$secondaryArchSuffix = $portVersion
	devel:libimlua_process_omp52$secondaryArchSuffix = $portVersion
	"
REQUIRES_devel="
	im$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:liblua5.1$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:as$secondaryArchSuffix
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:which
	"

BUILD()
{
	cd src
	make
}

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

	cp lib/Haiku11/Lua51/* $libDir
	rm -rf lib/Haiku11/Lua51
	cp -r lib/Haiku11/* $libDir

	cp include/* $includeDir

	prepareInstalledDevelLibs libim libim_fftw libim_jp2 libim_process \
		libim_process_omp libim_lzo libimlua51 libimlua_fftw51 libimlua_jp251 \
		libimlua_process51 libimlua_process_omp51

	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
}
