SUMMARY="An outline commandline-only font editor"
DESCRIPTION="An outline font editor that lets you create your own OpenType, \
TrueType, CID-keyed, multi-master fonts and more... or simply edit existing \
ones. This port is only CLI."
HOMEPAGE="https://fontforge.github.io/"
COPYRIGHT="2000-2018 George Williams
	The FontForge Project"
LICENSE="GNU GPL v3
	BSD (3-clause)"
REVISION="4"
srcGitRev="e99cc504beb6b7765d72d9f4698ae1b727031aaa"
SOURCE_URI="https://github.com/fontforge/fontforge/archive/$srcGitRev.tar.gz"
CHECKSUM_SHA256="bf99ec3da1f1467d96a48562367a8c472cd3ec6a2685f537d952da63aa304120"
SOURCE_FILENAME="fontforge-$portVersion.tar.gz"
SOURCE_DIR="fontforge-$srcGitRev"

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

# On x86_gcc2 we don't want to install the commands in bin/<arch>/, but in bin/.
commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

PROVIDES="
	fontforge$secondaryArchSuffix = $portVersion
	cmd:fontforge$commandSuffix
	cmd:fontimage$commandSuffix
	cmd:fontlint$commandSuffix
	cmd:sfddiff$commandSuffix
	lib:libfontforge$secondaryArchSuffix = 3.0.0 compat >= 3
	lib:libfontforgeexe$secondaryArchSuffix = 3.0.0 compat >= 3
	lib:libgunicode$secondaryArchSuffix = 5.0.0 compat >= 5
	lib:libgutils$secondaryArchSuffix = 3.0.1 compat >= 3
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libbz2$secondaryArchSuffix
#	lib:libcairo$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
#	lib:libfribidi$secondaryArchSuffix
	lib:libgif$secondaryArchSuffix
	lib:libglib_2.0$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libintl$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libltdl$secondaryArchSuffix
	lib:libncurses$secondaryArchSuffix
#	lib:libpangocairo_1.0$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libpython3.7m$secondaryArchSuffix
	lib:libreadline$secondaryArchSuffix
	lib:libspiro$secondaryArchSuffix
	lib:libtiff$secondaryArchSuffix
#	lib:libuninameslist$secondaryArchSuffix
	lib:libxml2$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	fontforge${secondaryArchSuffix}_devel = $portVersion
	devel:libfontforge$secondaryArchSuffix = 3.0.0 compat >= 3
	devel:libfontforgeexe$secondaryArchSuffix = 3.0.0 compat >= 3
	devel:libgunicode$secondaryArchSuffix = 5.0.0 compat >= 5
	devel:libgutils$secondaryArchSuffix = 3.0.1 compat >= 3
	"
REQUIRES_devel="
	fontforge$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libbz2$secondaryArchSuffix
#	devel:libcairo$secondaryArchSuffix
	devel:libfreetype$secondaryArchSuffix
#	devel:libfribidi$secondaryArchSuffix
	devel:libgif$secondaryArchSuffix
	devel:libglib_2.0$secondaryArchSuffix
	devel:libiconv$secondaryArchSuffix
	devel:libintl$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
	devel:libltdl$secondaryArchSuffix
	devel:libncurses$secondaryArchSuffix
#	devel:libpangocairo_1.0$secondaryArchSuffix
	devel:libpng16$secondaryArchSuffix
	devel:libpython3.7m$secondaryArchSuffix
	devel:libreadline$secondaryArchSuffix
	devel:libspiro$secondaryArchSuffix
	devel:libtiff$secondaryArchSuffix
#	devel:libuninameslist$secondaryArchSuffix
	devel:libxml2$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:find
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:python3
	"

BUILD()
{
	export LDFLAGS="-lnetwork $LDFLAGS"
	./bootstrap
	runConfigure --omit-dirs binDir ./configure \
		--bindir=$commandBinDir \
		--enable-python-scripting=3
	make $jobArgs
}

INSTALL()
{
	make install

	for l in libfontforge libfontforgeexe libgunicode libgutils; do
		rm -f $libDir/$l.la
		prepareInstalledDevelLib $l
	done
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}

TEST()
{
	make check
}
