SUMMARY="Embeddable Javascript engine"
DESCRIPTION="Duktape is a small and portable ECMAScript E5/E5.1 \
implementation.  It isintended to be easily embeddable into C programs, with \
a C API similar in spirit to Lua's."
HOMEPAGE="https://duktape.org/"
COPYRIGHT="2013-present Duktape authors"
LICENSE="MIT"
REVISION="2"
SOURCE_URI="https://duktape.org/duktape-${portVersion}.tar.xz"
CHECKSUM_SHA256="96f4a05a6c84590e53b18c59bb776aaba80a205afbbd92b82be609ba7fe75fa7"
PATCHES="duktape-$portVersion.patchset"

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

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

PROVIDES="
	duktape$secondaryArchSuffix = $portVersion
	lib:libduktape$secondaryArchSuffix = $libVersionCompat
	lib:libduktaped$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	duktape${secondaryArchSuffix}_devel = $portVersion
	devel:libduktape$secondaryArchSuffix = $libVersionCompat
	devel:libduktaped$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	duktape$secondaryArchSuffix == $portVersion base
	"

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

defineDebugInfoPackage duktape$secondaryArchSuffix \
	$libDir/libduktape.so.$libVersion \
	$libDir/libduktaped.so.$libVersion

BUILD()
{
	mv Makefile.sharedlibrary Makefile || die "failed to rename makefile"

	make INSTALL_PREFIX=$prefix \
		INCLUDEDIR=$includeDir \
		LIBDIR=$libDir $jobArgs
}

INSTALL()
{
	make INSTALL_PREFIX=$prefix \
		INCLUDEDIR=$includeDir \
		LIBDIR=$libDir install

	prepareInstalledDevelLibs libduktape libduktaped
	fixPkgconfig

	# devel package
	packageEntries devel \
		$developDir
}
