SUMMARY="An OpenType text shaping engine"
DESCRIPTION="HarfBuzz is an OpenType text shaping engine. It is used to \
layout complex text such as the Indic and Arabic alphabets."
HOMEPAGE="https://www.freedesktop.org/wiki/Software/HarfBuzz/"
COPYRIGHT="2004-2018 Behdad Esfahbod
	2000-2005 Owen Taylor
	2013, 2015-2017 Khaled Hosny
	2010,2011,2012 Google, Inc.
	2012 Mozilla Foundation
	2011 Codethink Limited
	2008,2010 Nokia Corporation and/or its subsidiary(-ies)
	2009 Keith Stribley
	2009 Martin Hosken and SIL International
	2007 Chris Wilson
	2005 David Turner
	2004,2007,2008,2009,2010 Red Hat, Inc.
	1998-2004 David Turner and Werner Lemberg"
LICENSE="MIT"
REVISION="1"
SOURCE_URI="https://github.com/harfbuzz/harfbuzz/releases/download/$portVersion/harfbuzz-$portVersion.tar.xz"
CHECKSUM_SHA256="7158a87c4db82521fc506711f0c8864115f0292d95f7136c8812c11811cdf952"
PATCHES="harfbuzz-$portVersion.patchset"

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

commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

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

PROVIDES="
	harfbuzz$secondaryArchSuffix = $portVersion compat >= 0.9
	lib:libharfbuzz$secondaryArchSuffix = $libVersionCompat
	lib:libharfbuzz_icu$secondaryArchSuffix = $libVersionCompat
	lib:libharfbuzz_subset$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libbz2$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libgraphite2$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libicuuc$secondaryArchSuffix >= 66
	lib:libintl$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	harfbuzz${secondaryArchSuffix}_devel = $portVersion compat >= 0.9
	devel:libharfbuzz$secondaryArchSuffix = $libVersionCompat
	devel:libharfbuzz_icu$secondaryArchSuffix = $libVersionCompat
	devel:libharfbuzz_subset$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	harfbuzz$secondaryArchSuffix == $portVersion base
	devel:libfreetype$secondaryArchSuffix
	devel:libgraphite2$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libbz2$secondaryArchSuffix
	devel:libfreetype$secondaryArchSuffix >= 6.18.1
	devel:libgraphite2$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libicuuc$secondaryArchSuffix >= 66
	devel:libintl$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:grep
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:python3
	cmd:ragel$secondaryArchSuffix
	cmd:sed
	cmd:which
	"

defineDebugInfoPackage harfbuzz$secondaryArchSuffix \
	"$libDir"/libharfbuzz.so.$libVersion \
	"$libDir"/libharfbuzz-icu.so.$libVersion \
	"$libDir"/libharfbuzz-subset.so.$libVersion

BUILD()
{
	autoreconf -fi
	runConfigure --omit-dirs binDir ./configure --bindir="$commandBinDir" \
		--with-graphite2=yes --with-icu --without-glib
	make $jobArgs
}

INSTALL()
{
	make install

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

	prepareInstalledDevelLibs \
		libharfbuzz \
		libharfbuzz-icu \
		libharfbuzz-subset \

	fixPkgconfig

	# devel package
	packageEntries devel \
		"$dataDir" \
		"$developDir" \
		"$libDir"/cmake
}

TEST()
{
	make check
}
