SUMMARY="FreeType-based font drawing library for X"
DESCRIPTION="Xft provides a client-side font API for X applications, making \
the FreeType font rasterizer available to X clients. Fontconfig is used for \
font specification resolution. Where available, the RENDER extension handles \
glyph drawing; otherwise, the core X protocol is used."
HOMEPAGE="https://www.x.org/"
COPYRIGHT="2000-2003 Keith Packard"
LICENSE="libXft"
REVISION="2"
SOURCE_URI="https://www.x.org/releases/individual/lib/libXft-$portVersion.tar.bz2"
CHECKSUM_SHA256="225c68e616dd29dbb27809e45e9eadf18e4d74c50be43020ef20015274529216"
SOURCE_DIR="libXft-$portVersion"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="?x86_gcc2 x86"

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

# server-interfacing: needs libX11_xcb.

PROVIDES="
	libxft$secondaryArchSuffix = $portVersion
	lib:libXft$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libfontconfig$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libX11_xcb$secondaryArchSuffix
	lib:libXrender$secondaryArchSuffix
	"

PROVIDES_devel="
	libxft${secondaryArchSuffix}_devel = $portVersion
	devel:libXft$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	libxft$secondaryArchSuffix == $portVersion base
	devel:libfontconfig$secondaryArchSuffix
	devel:libfreetype$secondaryArchSuffix
	devel:libXrender$secondaryArchSuffix
	devel:xproto
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libfontconfig$secondaryArchSuffix
	devel:libfreetype$secondaryArchSuffix
	devel:libX11_xcb$secondaryArchSuffix
	devel:libXrender$secondaryArchSuffix
	devel:util_macros
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage libxft$secondaryArchSuffix \
	"$libDir"/libXft.so.$libVersion

BUILD()
{
	runConfigure ./configure
	make $jobArgs
}

INSTALL()
{
	make install

	if [ -z "$secondaryArchSuffix" ]; then
		install -m 0755 -d "$developDocDir"
		install -m 0644 -t "$developDocDir" README.md
		maybe_manDir="$manDir"
	else
		rm -rf "$manDir"
		rm -rf "$developDir/documentation"
		maybe_manDir=
	fi

	# remove libtool library file
	rm -f "$libDir"/libXft.la

	prepareInstalledDevelLib libXft
	fixPkgconfig

	packageEntries devel \
		"$developDir" \
		${maybe_manDir:+"$maybe_manDir"}
}
