SUMMARY="A portable, high level programming interface"
DESCRIPTION="Libffi is a foreign function interface library which gives its \
user a C programming language interface used to call natively compiled \
functions. Libffi is typically used as a bridging technology between compiled \
and interpreted language implementations. It can also be used to implement \
plugins."
HOMEPAGE="https://sourceware.org/libffi"
COPYRIGHT="1996-2021 Anthony Green, Red Hat, Inc and others."
LICENSE="MIT"
REVISION="1"
SOURCE_URI="https://github.com/libffi/libffi/releases/download/v$portVersion/libffi-$portVersion.tar.gz"
CHECKSUM_SHA256="540fb721619a6aba3bdeef7d940d8e9e0e6d2c193595bc243241b77ff9e93620"
PATCHES="libffi-$portVersion.patchset"

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

PROVIDES="
	libffi$secondaryArchSuffix = $portVersion compat >= 3
	lib:libffi$secondaryArchSuffix = 8.0.1 compat >= 8
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	libffi${secondaryArchSuffix}_devel = $portVersion
	devel:libffi$secondaryArchSuffix = 8.0.1 compat >= 8
	"
REQUIRES_devel="
	libffi$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:make
	"

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

INSTALL()
{
	make install

	rm $libDir/libffi.la
	mkdir -p $includeDir
	rm -rf $libDir/libffi-$portVersion

	prepareInstalledDevelLibs libffi
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir \
		$documentationDir
}
