SUMMARY="Modular and reuseable compiler and toolchain technologies" 
DESCRIPTION="LLVM is a collection of modular and reuseable compiler and \
toolchain technologies."
HOMEPAGE="http://www.llvm.org/"
LICENSE="UIUC"
REVISION="1"

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

COPYRIGHT="2003-2013 University of Illinois at Urbana-Champaign"
SOURCE_URI="http://llvm.org/releases/${portVersion}/llvm-${portVersion}.src.tar.gz"
CHECKSUM_SHA256="7d28bb6eca243a2bb6d65a05743ab915b57958a7770277364e93534b63eef93a"
SOURCE_DIR="llvm-$portVersion.src"
PATCHES="llvm-3.4.1.patchset"

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_ranlib
	cmd:llvm_readobj
	cmd:llvm_rtdyld
	cmd:llvm_size
	cmd:llvm_stress
	cmd:llvm_symbolizer
	cmd:llvm_tblgen
	cmd:macho_dump
	cmd:opt
	lib:BugpointPasses
	lib:LLVMHello
	lib:libLTO
	
	devel:libLLVMAArch64AsmParser
	devel:libLLVMAArch64AsmPrinter
	devel:libLLVMAArch64CodeGen
	devel:libLLVMAArch64Desc
	devel:libLLVMAArch64Disassembler
	devel:libLLVMAArch64Info
	devel:libLLVMAArch64Utils
	devel:libLLVMARMAsmParser
	devel:libLLVMARMAsmPrinter
	devel:libLLVMARMCodeGen
	devel:libLLVMARMDesc
	devel:libLLVMARMDisassembler
	devel:libLLVMARMInfo
	devel:libLLVMAnalysis
	devel:libLLVMAsmParser
	devel:libLLVMAsmPrinter
	devel:libLLVMBitReader
	devel:libLLVMBitWriter
	devel:libLLVMCodeGen
	devel:libLLVMCore
	devel:libLLVMCppBackendCodeGen
	devel:libLLVMCppBackendInfo
	devel:libLLVMDebugInfo
	devel:libLLVMExecutionEngine
	devel:libLLVMHexagonAsmPrinter
	devel:libLLVMHexagonCodeGen
	devel:libLLVMHexagonDesc
	devel:libLLVMHexagonInfo
	devel:libLLVMIRReader
	devel:libLLVMInstCombine
	devel:libLLVMInstrumentation
	devel:libLLVMInterpreter
	devel:libLLVMJIT
	devel:libLLVMLTO
	devel:libLLVMLinker
	devel:libLLVMMC
	devel:libLLVMMCDisassembler
	devel:libLLVMMCJIT
	devel:libLLVMMCParser
	devel:libLLVMMSP430AsmPrinter
	devel:libLLVMMSP430CodeGen
	devel:libLLVMMSP430Desc
	devel:libLLVMMSP430Info
	devel:libLLVMMipsAsmParser
	devel:libLLVMMipsAsmPrinter
	devel:libLLVMMipsCodeGen
	devel:libLLVMMipsDesc
	devel:libLLVMMipsDisassembler
	devel:libLLVMMipsInfo
	devel:libLLVMNVPTXAsmPrinter
	devel:libLLVMNVPTXCodeGen
	devel:libLLVMNVPTXDesc
	devel:libLLVMNVPTXInfo
	devel:libLLVMObjCARCOpts
	devel:libLLVMObject
	devel:libLLVMOption
	devel:libLLVMPowerPCAsmParser
	devel:libLLVMPowerPCAsmPrinter
	devel:libLLVMPowerPCCodeGen
	devel:libLLVMPowerPCDesc
	devel:libLLVMPowerPCInfo
	devel:libLLVMR600AsmPrinter
	devel:libLLVMR600CodeGen
	devel:libLLVMR600Desc
	devel:libLLVMR600Info
	devel:libLLVMRuntimeDyld
	devel:libLLVMScalarOpts
	devel:libLLVMSelectionDAG
	devel:libLLVMSparcCodeGen
	devel:libLLVMSparcDesc
	devel:libLLVMSparcInfo
	devel:libLLVMSupport
	devel:libLLVMSystemZAsmParser
	devel:libLLVMSystemZAsmPrinter
	devel:libLLVMSystemZCodeGen
	devel:libLLVMSystemZDesc
	devel:libLLVMSystemZDisassembler
	devel:libLLVMSystemZInfo
	devel:libLLVMTableGen
	devel:libLLVMTarget
	devel:libLLVMTransformUtils
	devel:libLLVMVectorize
	devel:libLLVMX86AsmParser
	devel:libLLVMX86AsmPrinter
	devel:libLLVMX86CodeGen
	devel:libLLVMX86Desc
	devel:libLLVMX86Disassembler
	devel:libLLVMX86Info
	devel:libLLVMX86Utils
	devel:libLLVMXCoreAsmPrinter
	devel:libLLVMXCoreCodeGen
	devel:libLLVMXCoreDesc
	devel:libLLVMXCoreDisassembler
	devel:libLLVMXCoreInfo
	devel:libLLVMipa
	devel:libLLVMipo
	devel:libLTO
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libstdc++$secondaryArchSuffix
	"
BUILD_REQUIRES="
	"
BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	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
	"

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
	prepareInstalledDevelLibs libLLVMSystemZAsmParser libLLVMSystemZDisassembler
	prepareInstalledDevelLibs libLLVMX86AsmParser libLLVMX86Disassembler libLLVMX86Utils
	prepareInstalledDevelLibs libLLVMXCoreDisassembler
	
	prepareInstalledDevelLibs libLLVMSparcCodeGen libLLVMSparcDesc libLLVMSparcInfo

	for arch in AArch64 ARM Hexagon Mips MSP430 NVPTX PowerPC R600 SystemZ 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 libLLVMMC libLLVMMCDisassembler libLLVMMCJIT \
		libLLVMMCParser libLLVMObjCARCOpts libLLVMObject libLLVMOption \
		libLLVMRuntimeDyld libLLVMScalarOpts libLLVMSelectionDAG libLLVMSupport \
		libLLVMTableGen libLLVMTarget libLLVMTransformUtils libLLVMVectorize \
		libLLVMipa libLLVMipo libLTO
}

TEST()
{
	make check
}
