SUMMARY="Collection of image processing tools"
DESCRIPTION="GraphicsMagick provides a set of command-line applications to manipulate \
image files. It is a fork of the ImageMagick project and therefore offers \
a similar set of features, but puts a larger emphasis on stability.

The tools support a large variety of image formats from the widely used \
jpeg, tiff, bmp or xpm to special-purpose formats such as fits or image \
formats found on some photo CDs. They can convert between formats, \
concatenate several images into one, annotate and distort them, create \
thumbnails or manipulate the colormap."
HOMEPAGE="http://www.graphicsmagick.org"
COPYRIGHT="2002-2020 GraphicsMagick Group"
LICENSE="MIT"
REVISION="2"
SOURCE_URI="http://downloads.sourceforge.net/project/graphicsmagick/graphicsmagick/$portVersion/GraphicsMagick-$portVersion.tar.gz"
CHECKSUM_SHA256="1e6723c48c4abbb31197fadf8396b2d579d97e197123edc70a4f057f0533d563"
SOURCE_DIR="GraphicsMagick-$portVersion"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

liblibGraphicsMagickVersion="3.22.0"
liblibGraphicsMagickVersionCompat="$liblibGraphicsMagickVersion compat >= ${liblibGraphicsMagickVersion%%.*}"
liblibGraphicsMagickppVersion="12.5.0"
liblibGraphicsMagickppVersionCompat="$liblibGraphicsMagickppVersion compat >= ${liblibGraphicsMagickppVersion%%.*}"
liblibGraphicsMagickWandVersion="2.9.5"
liblibGraphicsMagickWandVersionCompat="$liblibGraphicsMagickWandVersion compat >= ${liblibGraphicsMagickWandVersion%%.*}"

PROVIDES="
	graphicsmagick$secondaryArchSuffix = $portVersion
	cmd:gm$secondaryArchSuffix
	lib:libGraphicsMagick$secondaryArchSuffix = $liblibGraphicsMagickVersionCompat
	lib:libGraphicsMagick++$secondaryArchSuffix = $liblibGraphicsMagickppVersionCompat
	lib:libGraphicsMagickWand$secondaryArchSuffix = $liblibGraphicsMagickWandVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libbz2$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libgomp$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:liblcms2$secondaryArchSuffix
	lib:libltdl$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libtiff$secondaryArchSuffix
	lib:libwebp$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	graphicsmagick${secondaryArchSuffix}_devel
	cmd:GraphicsMagick++_config$secondaryArchSuffix
	cmd:GraphicsMagick_config$secondaryArchSuffix
	cmd:GraphicsMagickWand_config$secondaryArchSuffix
	devel:libGraphicsMagick$secondaryArchSuffix = $liblibGraphicsMagickVersionCompat
	devel:libGraphicsMagick++$secondaryArchSuffix = $liblibGraphicsMagickppVersionCompat
	devel:libGraphicsMagickWand$secondaryArchSuffix = $liblibGraphicsMagickWandVersionCompat
	"
REQUIRES_devel="
	graphicsmagick$secondaryArchSuffix == $portVersion
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libjpeg$secondaryArchSuffix
	devel:liblcms2$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libtiff$secondaryArchSuffix
	devel:libwebp$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	"

defineDebugInfoPackage graphicsmagick$secondaryArchSuffix \
	$libDir/libGraphicsMagick.so.$liblibGraphicsMagickVersion \
	$libDir/libGraphicsMagick++.so.$liblibGraphicsMagickppVersion \
	$libDir/libGraphicsMagickWand.so.$liblibGraphicsMagickWandVersion

BUILD()
{
	runConfigure ./configure --enable-shared --with-modules \
		--with-quantum-depth=16
	make $jobArgs
}

INSTALL()
{
	make install
	rm $libDir/libGraphicsMagick*.la $libDir/libGraphicsMagick*.a
	prepareInstalledDevelLibs libGraphicsMagick++ \
		libGraphicsMagickWand \
		libGraphicsMagick
	fixPkgconfig

	sed -i 's|Cflags:.*|Cflags: -I${includedir} -I${includedir}/GraphicsMagick|' \
		$developLibDir/pkgconfig/*.pc

	packageEntries devel \
		$developDir \
		$binDir/*-config
}

TEST()
{
	make check
}
