SUMMARY="A llvm front end compiler for C and C++" 
DESCRIPTION="
Clang is an 'LLVM native' C/C++/Objective-C compiler, which aims to deliver \
amazingly fast compiles (e.g. about 3x faster than GCC when compiling \
Objective-C code in a debug configuration), extremely useful error and warning \
messages and to provide a platform for building great source level tools.
"

HOMEPAGE="http://www.llvm.org/"
LICENSE="UIUC"
COPYRIGHT="2003-2012 University of Illinois at Urbana-Champaign"

SRC_URI="http://llvm.org/releases/${portVersion}/llvm-${portVersion}.src.tar.gz"
CHECKSUM_SHA256="125090c4d26740f1d5e9838477c931ed7d9ad70d599ba265f46f3a42cb066343"
SRC_URI_2="http://llvm.org/releases/${portVersion}/clang-${portVersion}.src.tar.gz"
CHECKSUM_SHA256_2="2aaaf03f7c0f6b16fe97ecc81247dc2bf2d4bec7620a77cc74670b7e07ff5658"
REVISION="1"

ARCHITECTURES="?x86 ?x86_64"
if [ $effectiveTargetArchitecture != x86_gcc2 ]; then
	ARCHITECTURES="$ARCHITECTURES x86_gcc2"
fi
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	clang$secondaryArchSuffix = $portVersion
	cmd:clang = $portVersion
	cmd:clang++ = $portVersion
	cmd:c_index_test = $portVersion
	lib:libLTO = $portVersion
	lib:libclang = $portVersion
	lib:libprofile_rt = $portVersion
	"

REQUIRES="
	haiku$secondaryArchSuffix >= $haikuVersion
	"

BUILD_REQUIRES="
	"

BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel >= $haikuVersion
	cmd:aclocal
	cmd:autoconf
	cmd:automake
	cmd:gcc$secondaryArchSuffix
	cmd:groff
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize
	cmd:make
	cmd:python
	cmd:sed
	"

SOURCE_DIR="llvm-${portVersion}.src"

BUILD()
{
	mkdir -p tools/clang
	cp -rd $sourceDir2/clang-${portVersion}.src/* tools/clang/
	#cp -r /boot/system/data/libtool/config/. autoconf/
	#cp -r /boot/system/data/libtool/config/. projects/sample/autoconf/
	
	# Haiku C++ requires rtti in a lot of central system components
	# such as Mesa
	export REQUIRES_RTTI=1

	# TODO: clang's build system seems to ignore doc / man / shared dirs?
	runConfigure ./configure --enable-optimized
	make $jobArgs
}

INSTALL()
{
	mkdir -p $developDir
	mkdir -p $docDir

	make install-clang

	# devel package
	packageEntries devel \
		$developDir
}

TEST()
{
	make check
}


# ----- devel package -------------------------------------------------------

PROVIDES_devel="
	clang${secondaryArchSuffix}_devel = $portVersion
	"

REQUIRES_devel="
	clang$secondaryArchSuffix == $portVersion base
	"
