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-2014 University of Illinois at Urbana-Champaign"
SOURCE_URI="http://llvm.org/releases/${portVersion}/llvm-${portVersion}.src.tar.xz"
CHECKSUM_SHA256="bf3275d2d7890015c8d8f5e6f4f882f8cf3bf51967297ebe74111d6d8b53be15"
REVISION="1"
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:lli_child_target
	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_profdata
	cmd:llvm_ranlib
	cmd:llvm_readobj
	cmd:llvm_rtdyld
	cmd:llvm_size
	cmd:llvm_stress
	cmd:llvm_symbolizer
	cmd:llvm_tblgen
	cmd:macho_dump
	cmd:opt
	cmd:FileCheck
	cmd:count
	cmd:not
	lib:BugpointPasses$secondaryArchSuffix
	lib:LLVMHello$secondaryArchSuffix
	lib:libLTO$secondaryArchSuffix
	
	devel:libLLVMAArch64AsmParser$secondaryArchSuffix
	devel:libLLVMAArch64AsmPrinter$secondaryArchSuffix
	devel:libLLVMAArch64CodeGen$secondaryArchSuffix
	devel:libLLVMAArch64Desc$secondaryArchSuffix
	devel:libLLVMAArch64Disassembler$secondaryArchSuffix
	devel:libLLVMAArch64Info$secondaryArchSuffix
	devel:libLLVMAArch64Utils$secondaryArchSuffix
	devel:libLLVMARMAsmParser$secondaryArchSuffix
	devel:libLLVMARMAsmPrinter$secondaryArchSuffix
	devel:libLLVMARMCodeGen$secondaryArchSuffix
	devel:libLLVMARMDesc$secondaryArchSuffix
	devel:libLLVMARMDisassembler$secondaryArchSuffix
	devel:libLLVMARMInfo$secondaryArchSuffix
	devel:libLLVMAnalysis$secondaryArchSuffix
	devel:libLLVMAsmParser$secondaryArchSuffix
	devel:libLLVMAsmPrinter$secondaryArchSuffix
	devel:libLLVMBitReader$secondaryArchSuffix
	devel:libLLVMBitWriter$secondaryArchSuffix
	devel:libLLVMCodeGen$secondaryArchSuffix
	devel:libLLVMCore$secondaryArchSuffix
	devel:libLLVMCppBackendCodeGen$secondaryArchSuffix
	devel:libLLVMCppBackendInfo$secondaryArchSuffix
	devel:libLLVMDebugInfo$secondaryArchSuffix
	devel:libLLVMExecutionEngine$secondaryArchSuffix
	devel:libLLVMHexagonAsmPrinter$secondaryArchSuffix
	devel:libLLVMHexagonCodeGen$secondaryArchSuffix
	devel:libLLVMHexagonDesc$secondaryArchSuffix
	devel:libLLVMHexagonInfo$secondaryArchSuffix
	devel:libLLVMIRReader$secondaryArchSuffix
	devel:libLLVMInstCombine$secondaryArchSuffix
	devel:libLLVMInstrumentation$secondaryArchSuffix
	devel:libLLVMInterpreter$secondaryArchSuffix
	devel:libLLVMJIT$secondaryArchSuffix
	devel:libLLVMLineEditor$secondaryArchSuffix
	devel:libLLVMLTO$secondaryArchSuffix
	devel:libLLVMLinker$secondaryArchSuffix
	devel:libLLVMMC$secondaryArchSuffix
	devel:libLLVMMCAnalysis$secondaryArchSuffix
	devel:libLLVMMCDisassembler$secondaryArchSuffix
	devel:libLLVMMCJIT$secondaryArchSuffix
	devel:libLLVMMCParser$secondaryArchSuffix
	devel:libLLVMMSP430AsmPrinter$secondaryArchSuffix
	devel:libLLVMMSP430CodeGen$secondaryArchSuffix
	devel:libLLVMMSP430Desc$secondaryArchSuffix
	devel:libLLVMMSP430Info$secondaryArchSuffix
	devel:libLLVMMipsAsmParser$secondaryArchSuffix
	devel:libLLVMMipsAsmPrinter$secondaryArchSuffix
	devel:libLLVMMipsCodeGen$secondaryArchSuffix
	devel:libLLVMMipsDesc$secondaryArchSuffix
	devel:libLLVMMipsDisassembler$secondaryArchSuffix
	devel:libLLVMMipsInfo$secondaryArchSuffix
	devel:libLLVMNVPTXAsmPrinter$secondaryArchSuffix
	devel:libLLVMNVPTXCodeGen$secondaryArchSuffix
	devel:libLLVMNVPTXDesc$secondaryArchSuffix
	devel:libLLVMNVPTXInfo$secondaryArchSuffix
	devel:libLLVMObjCARCOpts$secondaryArchSuffix
	devel:libLLVMObject$secondaryArchSuffix
	devel:libLLVMOption$secondaryArchSuffix
	devel:libLLVMPowerPCAsmParser$secondaryArchSuffix
	devel:libLLVMPowerPCAsmPrinter$secondaryArchSuffix
	devel:libLLVMPowerPCCodeGen$secondaryArchSuffix
	devel:libLLVMPowerPCDesc$secondaryArchSuffix
	devel:libLLVMPowerPCDisassembler$secondaryArchSuffix
	devel:libLLVMPowerPCInfo$secondaryArchSuffix
	devel:libLLVMProfileData$secondaryArchSuffix
	devel:libLLVMR600AsmPrinter$secondaryArchSuffix
	devel:libLLVMR600CodeGen$secondaryArchSuffix
	devel:libLLVMR600Desc$secondaryArchSuffix
	devel:libLLVMR600Info$secondaryArchSuffix
	devel:libLLVMRuntimeDyld$secondaryArchSuffix
	devel:libLLVMScalarOpts$secondaryArchSuffix
	devel:libLLVMSelectionDAG$secondaryArchSuffix
	devel:libLLVMSparcAsmParser$secondaryArchSuffix
	devel:libLLVMSparcAsmPrinter$secondaryArchSuffix
	devel:libLLVMSparcCodeGen$secondaryArchSuffix
	devel:libLLVMSparcDesc$secondaryArchSuffix
	devel:libLLVMSparcDisassembler$secondaryArchSuffix
	devel:libLLVMSparcInfo$secondaryArchSuffix
	devel:libLLVMSupport$secondaryArchSuffix
	devel:libLLVMSystemZAsmParser$secondaryArchSuffix
	devel:libLLVMSystemZAsmPrinter$secondaryArchSuffix
	devel:libLLVMSystemZCodeGen$secondaryArchSuffix
	devel:libLLVMSystemZDesc$secondaryArchSuffix
	devel:libLLVMSystemZDisassembler$secondaryArchSuffix
	devel:libLLVMSystemZInfo$secondaryArchSuffix
	devel:libLLVMTableGen$secondaryArchSuffix
	devel:libLLVMTarget$secondaryArchSuffix
	devel:libLLVMTransformUtils$secondaryArchSuffix
	devel:libLLVMVectorize$secondaryArchSuffix
	devel:libLLVMX86AsmParser$secondaryArchSuffix
	devel:libLLVMX86AsmPrinter$secondaryArchSuffix
	devel:libLLVMX86CodeGen$secondaryArchSuffix
	devel:libLLVMX86Desc$secondaryArchSuffix
	devel:libLLVMX86Disassembler$secondaryArchSuffix
	devel:libLLVMX86Info$secondaryArchSuffix
	devel:libLLVMX86Utils$secondaryArchSuffix
	devel:libLLVMXCoreAsmPrinter$secondaryArchSuffix
	devel:libLLVMXCoreCodeGen$secondaryArchSuffix
	devel:libLLVMXCoreDesc$secondaryArchSuffix
	devel:libLLVMXCoreDisassembler$secondaryArchSuffix
	devel:libLLVMXCoreInfo$secondaryArchSuffix
	devel:libLLVMipa$secondaryArchSuffix
	devel:libLLVMipo$secondaryArchSuffix
	devel:libLTO$secondaryArchSuffix
	"
REQUIRES="
	haiku$secondaryArchSuffix >= $haikuVersion
	lib:libstdc++$secondaryArchSuffix
	lib:libgcc_s$secondaryArchSuffix
	"
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
	cmd:find
	cmd:grep
	"

PATCHES="llvm-${portVersion}.patchset"

SOURCE_DIR="llvm-$portVersion.src"

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 PROJ_datadir=$dataDir PROJ_docsdir=$docDir \
    	PROJ_mandir=$manDir PROJ_includedir=$includeDir PROJ_libdir=$libDir
}

INSTALL()
{
	make install PROJ_datadir=$dataDir PROJ_docsdir=$docDir \
    	PROJ_mandir=$manDir PROJ_includedir=$includeDir PROJ_libdir=$libDir

	prepareInstalledDevelLibs libLLVMAArch64AsmParser libLLVMAArch64Disassembler \
		libLLVMAArch64Utils
	prepareInstalledDevelLibs libLLVMARMAsmParser libLLVMARMDisassembler
	prepareInstalledDevelLibs libLLVMMipsAsmParser libLLVMMipsDisassembler
	prepareInstalledDevelLibs libLLVMPowerPCAsmParser libLLVMPowerPCDisassembler
	prepareInstalledDevelLibs libLLVMSystemZAsmParser libLLVMSystemZDisassembler
	prepareInstalledDevelLibs libLLVMX86AsmParser libLLVMX86Disassembler libLLVMX86Utils
	prepareInstalledDevelLibs libLLVMXCoreDisassembler
	prepareInstalledDevelLibs libLLVMSparcAsmParser libLLVMSparcDisassembler
	
	for arch in AArch64 ARM Hexagon Mips MSP430 NVPTX PowerPC R600 SystemZ Sparc X86 XCore
	do
		prepareInstalledDevelLibs libLLVM${arch}AsmPrinter \
			libLLVM${arch}CodeGen libLLVM${arch}Desc libLLVM${arch}Info
	done
	
	prepareInstalledDevelLibs libLLVMAnalysis libLLVMAsmParser \
		libLLVMAsmPrinter libLLVMBitReader libLLVMBitWriter libLLVMCodeGen \
		libLLVMCore libLLVMCppBackendCodeGen libLLVMCppBackendInfo \
		libLLVMDebugInfo libLLVMExecutionEngine libLLVMIRReader \
		libLLVMInstCombine libLLVMInstrumentation libLLVMInterpreter libLLVMJIT \
		libLLVMLTO libLLVMLinker libLLVMLineEditor libLLVMMC libLLVMMCAnalysis \
		libLLVMMCDisassembler libLLVMMCJIT libLLVMMCParser libLLVMObjCARCOpts \
		libLLVMObject libLLVMOption libLLVMProfileData libLLVMRuntimeDyld \
		libLLVMScalarOpts libLLVMSelectionDAG libLLVMSupport libLLVMTableGen \
		libLLVMTarget libLLVMTransformUtils libLLVMVectorize libLLVMipa \
		libLLVMipo libLTO
}

TEST()
{
	make check
}
