SUMMARY="A very powerful but easy to learn dynamic programming language"
DESCRIPTION="
Tcl (Tool Command Language) is a very powerful but easy to learn dynamic \
programming language, suitable for a very wide range of uses, including web \
and desktop applications, networking, administration, testing and many more. \
Open source and business-friendly, Tcl is a mature yet evolving language that \
is truly cross platform, easily deployed and highly extensible."
HOMEPAGE="http://www.tcl.tk"
COPYRIGHT="Regents of the University of California, Sun Microsystems, Inc., Scriptics Corporation, and other parties"
LICENSE="BSD (2-clause)"
REVISION="1"
SOURCE_URI="https://sourceforge.net/projects/tcl/files/Tcl/$portVersion/tcl$portVersion-src.tar.gz"
CHECKSUM_SHA256="8c0486668586672c5693d7d95817cb05a18c5ecca2f40e2836b9578064088258"
SOURCE_DIR="tcl$portVersion"
PATCHES="tcl-$portVersion.patchset"

ARCHITECTURES="all"

PROVIDES="
	tcl = $portVersion compat >= 8.6
	cmd:tclsh = $portVersion compat >= 8.6
	cmd:tclsh8.6 = $portVersion compat >= 8.6
	lib:libtcl8.6 = $portVersion compat >= 8.6
	"
REQUIRES="
	haiku
	lib:libsqlite3
	"

PROVIDES_devel="
	tcl_devel = $portVersion
	devel:libtclstub8.6 = $portVersion
	"
REQUIRES_devel="
	tcl == $portVersion
	"

BUILD_REQUIRES="
	devel:libsqlite3
	"
BUILD_PREREQUIRES="
	haiku_devel
	cmd:autoconf
	cmd:find
	cmd:gcc
	cmd:grep
	cmd:ld
	cmd:make
	cmd:sed
	"

defineDebugInfoPackage tcl \
	"$libDir"/libtcl8.6.so

BUILD()
{
	export CFLAGS="-USQLITE_API -USQLITE_EXTERN"
	cd unix
	autoconf -f
	runConfigure ./configure \
		--enable-man-symlinks \
		--with-system-sqlite
	make
}

INSTALL()
{
	cd unix
	make install install-private-headers

	ln -s tclsh8.6 "${binDir}/tclsh"

	sed -i -e "s#${sourceDir}/unix#${developLibDir}#" \
		-e "s#${sourceDir}#${includeDir}#" \
		${libDir}/tclConfig.sh

	rm $binDir/sqlite3_analyzer

	prepareInstalledDevelLibs libtclstub8.6
	fixPkgconfig
	mv $libDir/tclConfig.sh $developLibDir
	packageEntries devel $developDir
}

TEST()
{
	cd unix
	make test
}
