# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/sys-devel/clang/clang-3.2.ebuild,v 1.5 2013/02/04 08:50:49 mgorny Exp $ EAPI=5 PYTHON_COMPAT=( python{2_6,2_7} pypy{1_9,2_0} ) inherit cmake-utils eutils flag-o-matic multilib python-r1 DESCRIPTION="C language family frontend for LLVM" HOMEPAGE="http://clang.llvm.org/" SRC_URI="http://llvm.org/releases/${PV}/${P}.src.tar.gz" LICENSE="UoI-NCSA" SLOT="0" KEYWORDS="~amd64 ~arm ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos" IUSE="debug kernel_FreeBSD multitarget python +static-analyzer test" DEPEND="static-analyzer? ( dev-lang/perl ) ${PYTHON_DEPS}" RDEPEND="~sys-devel/llvm-${PV}[compiler-rt,debug=,multitarget=] ${PYTHON_DEPS}" S=${WORKDIR}/${P}.src src_prepare() { # Same as llvm doc patches epatch "${FILESDIR}"/${PN}-2.7-fixdoc.patch # fix the static analyzer for in-tree install sed -e 's/import ScanView/from clang \0/' \ -i tools/scan-view/scan-view \ || die "scan-view sed failed" sed -e "/scanview.css\|sorttable.js/s#\$RealBin#${EPREFIX}/usr/share/${PN}#" \ -i tools/scan-build/scan-build \ || die "scan-build sed failed" # Set correct path for gold plugin sed -e "/LLVMgold.so/s#lib/#$(get_libdir)/llvm-${PV}/#" \ -i lib/Driver/Tools.cpp \ || die "gold plugin path sed failed" # Use system llc (from llvm ebuild) for tests sed -e "/^llc_props =/s/os.path.join(llvm_tools_dir, 'llc')/'llc'/" \ -i test/lit.cfg || die "test path sed failed" # Automatically select active system GCC's libraries, bugs #406163 and #417913 epatch "${FILESDIR}"/${PN}-3.1-gentoo-runtime-gcc-detection-v3.patch # Fix search paths on FreeBSD, bug #409269 epatch "${FILESDIR}"/${PN}-3.1-gentoo-freebsd-fix-lib-path.patch # Fix regression caused by removal of USE=system-cxx-headers, bug #417541 # Needs to be updated for 3.2 #epatch "${FILESDIR}"/${PN}-3.1-gentoo-freebsd-fix-cxx-paths-v2.patch # User patches epatch_user } src_configure() { # build with a suitable Python version python_export_best local libdir=$(get_libdir) local llvm_libdir=${EPREFIX}/usr/${libdir}/llvm-${PV} local mycmakeargs=( -DBUILD_SHARED_LIBS=ON # using versioned libdir avoids lack of SONAME issues -DLLVM_LIBDIR_SUFFIX=${libdir#lib}/llvm-${PV} -DCMAKE_INSTALL_RPATH="${llvm_libdir}" # Setup the search path to include the Prefix includes $(use prefix && echo -DC_INCLUDE_DIRS="${EPREFIX}/usr/include:/usr/include") # Targets are read from LLVM config. -DCLANG_PATH_TO_LLVM_BUILD="${EPREFIX}"/usr # Respect Python the easy way. -DPYTHON_EXECUTABLE="${PYTHON}" ) # Seems not to respect llvm-config. append-ldflags -L"${llvm_libdir}" -Wl,-rpath,"${llvm_libdir}" cmake-utils_src_configure } src_test() { cmake-utils_src_make check } src_install() { cmake-utils_src_install return 0 if use static-analyzer ; then dobin tools/scan-build/ccc-analyzer dosym ccc-analyzer /usr/bin/c++-analyzer dobin tools/scan-build/scan-build insinto /usr/share/${PN} doins tools/scan-build/scanview.css doins tools/scan-build/sorttable.js fi python_inst() { if use static-analyzer ; then pushd tools/scan-view >/dev/null || die python_doscript scan-view touch __init__.py || die python_moduleinto clang python_domodule __init__.py Reporter.py Resources ScanView.py startfile.py popd >/dev/null || die fi if use python ; then pushd bindings/python/clang >/dev/null || die python_moduleinto clang python_domodule __init__.py cindex.py enumerations.py popd >/dev/null || die fi # AddressSanitizer symbolizer (currently separate) python_doscript "${S}"/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py } python_foreach_impl python_inst # Fix install_names on Darwin. The build system is too complicated # to just fix this, so we correct it post-install if [[ ${CHOST} == *-darwin* ]] ; then for lib in libclang.dylib ; do ebegin "fixing install_name of $lib" install_name_tool -id "${EPREFIX}"/usr/lib/llvm/${lib} \ "${ED}"/usr/lib/llvm/${lib} eend $? done for f in usr/bin/{c-index-test,clang} usr/lib/llvm/libclang.dylib ; do ebegin "fixing references in ${f##*/}" install_name_tool \ -change "@rpath/libclang.dylib" \ "${EPREFIX}"/usr/lib/llvm/libclang.dylib \ -change "@executable_path/../lib/libLLVM-${PV}.dylib" \ "${EPREFIX}"/usr/lib/llvm/libLLVM-${PV}.dylib \ -change "${S}"/Release/lib/libclang.dylib \ "${EPREFIX}"/usr/lib/llvm/libclang.dylib \ "${ED}"/$f eend $? done fi # Remove unnecessary headers on FreeBSD, bug #417171 use kernel_FreeBSD && rm "${ED}"usr/$(get_libdir)/clang/${PV}/include/{arm_neon,std,float,iso,limits,tgmath,varargs}*.h }