SUMMARY="A Lightweight multi-platform, multi-architecture assembly framework"
DESCRIPTION="* Multi-architecture: Arm, (AArch64/Armv8), Mips, PowerPC, Sparc, \
SystemZ, XCore & X86 (include X86_64) (details).
* Clean/simple/lightweight/intuitive architecture-neutral API.
* Implemented in C/C++ language, with bindings for Powershell Perl, Python, \
Ruby, C#, NodeJS, Java, GO, C++, OCaml, Lua, Rust, Delphi, Free Pascall & Vala available.
* Native support for Windows & *nix (with Mac OSX, iOS, Android, Linux, *BSD & \
Solaris confirmed).
* Thread-safe by design.
* Open source - with a dual license."
HOMEPAGE="https://www.keystone-engine.org"
COPYRIGHT="2013-2015, COSEINC"
LICENSE="GNU GPL v2"
REVISION="2"
SOURCE_URI="https://github.com/keystone-engine/keystone/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="e9d706cd0c19c49a6524b77db8158449b9c434b415fbf94a073968b68cf8a9f0"
PATCHES="keystone-$portVersion.patchset"

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

PROVIDES="
	keystone$secondaryArchSuffix = $portVersion
	cmd:kstool
	lib:libkeystone$secondaryArchSuffix = 0
"
REQUIRES="
	haiku$secondaryArchSuffix
"

PROVIDES_devel="
	keystone${secondaryArchSuffix}_devel = $portVersion
	devel:libkeystone$secondaryArchSuffix = 0
"
REQUIRES_devel="
	keystone$secondaryArchSuffix == $portVersion base
"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	cmd:python
"

BUILD()
{
	mkdir build
	cd build
	cmake -DBUILD_LIBS_ONLY=$BUILD_LIBS_ONLY -DLLVM_BUILD_32_BITS="$LLVM_BUILD_32_BITS" \
		-DLLVM_LIBDIR_SUFFIX="$LLVM_LIBDIR_SUFFIX" -DCMAKE_INSTALL_PREFIX=$prefix \
		-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON \
		-DLLVM_TARGETS_TO_BUILD="all" \
		-G "Unix Makefiles" ..
	make $jobArgs
}

INSTALL()
{
	make install -C build
	mkdir -p $(dirname $includeDir)
	mv $prefix/include $includeDir
	prepareInstalledDevelLib libkeystone
	fixPkgconfig
	packageEntries devel $developDir
}
