SUMMARY="Modular and reuseable compiler and toolchain technologies." 
DESCRIPTION="LLVM is a collection of modular and reuseable compiler and and toolchain technologies."
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"
REVISION="2"
ARCHITECTURES="x86 x86_64"
if [ $effectiveTargetArchitecture != x86_gcc2 ]; then
	ARCHITECTURES="$ARCHITECTURES x86_gcc2"
fi
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	llvm$secondaryArchSuffix = $portVersion
	cmd:bugpoint
	cmd:llc
	cmd:lli
	cmd:llvm_ar
	cmd:llvm_as
	cmd:llvm_bcanalyzer
	cmd:llvm_config
	cmd:llvm_cov
	cmd:llvm_diff
	cmd:llvm_dis
	cmd:llvm_dwarfdump
	cmd:llvm_extract
	cmd:llvm_link
	cmd:llvm_mc
	cmd:llvm_mcmarkup
	cmd:llvm_nm
	cmd:llvm_objdump
	cmd:llvm_prof
	cmd:llvm_ranlib
	cmd:llvm_readobj
	cmd:llvm_rtdyld
	cmd:llvm_size
	cmd:llvm_stress
	cmd:llvm_tblgen
	cmd:macho_dump
	cmd:opt
	lib:BugpointPasses
	lib:LLVMHello
	lib:libLTO
	lib:libprofile_rt
	"

REQUIRES="
	haiku$secondaryArchSuffix >= $haikuVersion
	"

BUILD_REQUIRES="
	"

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

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

PATCH()
{
	find . -type f -exec sed -i 's/\/usr\/bin\/env/\/bin\/env/g' "{}" \;
}

BUILD()
{
	# Haiku C++ requires rtti in a lot of central system components
	# such as Mesa
	export REQUIRES_RTTI=1
	runConfigure ./configure --enable-optimized 
	make $jobArgs
}

INSTALL()
{
	make install

	# TODO: $developLibDir doesn't get included in the base package
	# llvm is for -devel only, so having a -devel is odd and would break
	# how llvm works
	#mv $libDir/*.a $developLibdir/
	fixPkgconfig
}
