SUMMARY="Anti-Grain Geometry (AGG)"
DESCRIPTION="Anti-Grain Geometry (AGG) is an Open Source, free of charge \
graphic library, written in industrially standard C++."
HOMEPAGE="https://en.wikipedia.org/wiki/Anti-Grain_Geometry"
COPYRIGHT="2002-2006 Maxim Shemanarev"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://sourceforge.net/projects/cross-stuff/files/OldFiles/agg-2.5.tar.gz"
CHECKSUM_SHA256="ab1edc54cc32ba51a62ff120d501eecd55fceeedf869b9354e7e13812289911f"
PATCHES="agg-2.5.patchset"

ARCHITECTURES="x86_gcc2 x86_64"
SECONDARY_ARCHITECTURES="x86"

libVersion="2.0.4"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

PROVIDES="
	agg$secondaryArchSuffix = $portVersion
	lib:libagg$secondaryArchSuffix = $libVersionCompat
	lib:libaggfontfreetype$secondaryArchSuffix = $libVersionCompat
	lib:libagggpc$secondaryArchSuffix = $libVersionCompat
	lib:libaggplatformHaiku$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libbz2$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	agg${secondaryArchSuffix}_devel = $portVersion
	devel:libagg$secondaryArchSuffix = $libVersionCompat
	devel:libaggfontfreetype$secondaryArchSuffix = $libVersionCompat
	devel:libagggpc$secondaryArchSuffix = $libVersionCompat
	devel:libaggplatformHaiku$secondaryArchSuffix = $libVersionCompat
	devel:libaggplatformsdl$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	agg$secondaryArchSuffix == $portVersion base
	"

PROVIDES_sdl="
	agg${secondaryArchSuffix}_sdl = $portVersion
	lib:libaggplatformsdl$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_sdl="
	agg$secondaryArchSuffix == $portVersion base
	haiku$secondaryArchSuffix
	lib:libSDL_1.2$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libbz2$secondaryArchSuffix
	devel:libfreetype$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libSDL_1.2$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:autoreconf
	cmd:autoheader
	cmd:automake
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:sed
	"

defineDebugInfoPackage agg$secondaryArchSuffix \
	$libDir/libagg.so.$libVersion \
	$libDir/libaggfontfreetype.so.$libVersion \
	$libDir/libagggpc.so.$libVersion \
	$libDir/libaggplatformHaiku.so.$libVersion

BUILD()
{
	if [ -d src/platform/BeOS ]; then
		mv src/platform/BeOS src/platform/Haiku
	fi
	touch AUTHORS README NEWS
	autoreconf -vfi
	runConfigure ./configure \
		--enable-ctrl \
		--enable-gpc \
		--enable-platform \
		--disable-examples
	make $jobArgs
}

INSTALL()
{
	make install

	# remove libtool files
	rm -f $libDir/*.la

	prepareInstalledDevelLibs libagg libagggpc libaggfontfreetype \
		libaggplatformHaiku libaggplatformsdl
	fixPkgconfig
	# fix include path in pkgconfig
	sed -i -e 's#^includedir=\(.*\)#includedir=\1/agg2#g' \
		$developLibDir/pkgconfig/libagg.pc

	packageEntries devel \
		$developDir \
		$dataRootDir/aclocal
	packageEntries sdl \
		$libDir/libaggplatformsdl*
}
