| 1 |
# Copyright 1999-2012 Gentoo Foundation |
| 2 |
# Distributed under the terms of the GNU General Public License v2 |
| 3 |
# $Header: /var/cvsroot/gentoo-x86/sys-devel/clang/clang-3.1-r4.ebuild,v 1.3 2012/07/27 18:22:45 mgorny Exp $ |
| 4 |
|
| 5 |
EAPI=4 |
| 6 |
|
| 7 |
RESTRICT_PYTHON_ABIS="3.*" |
| 8 |
SUPPORT_PYTHON_ABIS="1" |
| 9 |
|
| 10 |
inherit eutils multilib python |
| 11 |
|
| 12 |
DESCRIPTION="C language family frontend for LLVM" |
| 13 |
HOMEPAGE="http://clang.llvm.org/" |
| 14 |
# Fetching LLVM as well: see http://llvm.org/bugs/show_bug.cgi?id=4840 |
| 15 |
SRC_URI="http://llvm.org/releases/${PV}/llvm-${PV}.src.tar.gz |
| 16 |
http://llvm.org/releases/${PV}/compiler-rt-${PV}.src.tar.gz |
| 17 |
http://llvm.org/releases/${PV}/${P}.src.tar.gz" |
| 18 |
|
| 19 |
LICENSE="UoI-NCSA" |
| 20 |
SLOT="0" |
| 21 |
KEYWORDS="~amd64 ~arm ~x86 ~amd64-fbsd ~x64-freebsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos" |
| 22 |
IUSE="debug kernel_FreeBSD multitarget +static-analyzer test" |
| 23 |
|
| 24 |
DEPEND="static-analyzer? ( dev-lang/perl )" |
| 25 |
RDEPEND="~sys-devel/llvm-${PV}[multitarget=]" |
| 26 |
|
| 27 |
S=${WORKDIR}/llvm-${PV}.src |
| 28 |
|
| 29 |
src_prepare() { |
| 30 |
mv "${WORKDIR}"/clang-${PV}.src "${S}"/tools/clang \ |
| 31 |
|| die "clang source directory move failed" |
| 32 |
mv "${WORKDIR}"/compiler-rt-${PV}.src "${S}"/projects/compiler-rt \ |
| 33 |
|| die "compiler-rt source directory move failed" |
| 34 |
|
| 35 |
# Same as llvm doc patches |
| 36 |
epatch "${FILESDIR}"/${PN}-2.7-fixdoc.patch |
| 37 |
|
| 38 |
# multilib-strict |
| 39 |
sed -e "/PROJ_headers/s#lib/clang#$(get_libdir)/clang#" \ |
| 40 |
-i tools/clang/lib/Headers/Makefile \ |
| 41 |
|| die "clang Makefile failed" |
| 42 |
sed -e "/PROJ_resources/s#lib/clang#$(get_libdir)/clang#" \ |
| 43 |
-i tools/clang/runtime/compiler-rt/Makefile \ |
| 44 |
|| die "compiler-rt Makefile failed" |
| 45 |
# fix the static analyzer for in-tree install |
| 46 |
sed -e 's/import ScanView/from clang \0/' \ |
| 47 |
-i tools/clang/tools/scan-view/scan-view \ |
| 48 |
|| die "scan-view sed failed" |
| 49 |
sed -e "/scanview.css\|sorttable.js/s#\$RealBin#${EPREFIX}/usr/share/${PN}#" \ |
| 50 |
-i tools/clang/tools/scan-build/scan-build \ |
| 51 |
|| die "scan-build sed failed" |
| 52 |
# Set correct path for gold plugin |
| 53 |
sed -e "/LLVMgold.so/s#lib/#$(get_libdir)/llvm/#" \ |
| 54 |
-i tools/clang/lib/Driver/Tools.cpp \ |
| 55 |
|| die "gold plugin path sed failed" |
| 56 |
# Specify python version |
| 57 |
python_convert_shebangs 2 tools/clang/tools/scan-view/scan-view |
| 58 |
python_convert_shebangs -r 2 test/Scripts |
| 59 |
python_convert_shebangs 2 projects/compiler-rt/lib/asan/scripts/asan_symbolize.py |
| 60 |
|
| 61 |
# From llvm src_prepare |
| 62 |
einfo "Fixing install dirs" |
| 63 |
sed -e 's,^PROJ_docsdir.*,PROJ_docsdir := $(PROJ_prefix)/share/doc/'${PF}, \ |
| 64 |
-e 's,^PROJ_etcdir.*,PROJ_etcdir := '"${EPREFIX}"'/etc/llvm,' \ |
| 65 |
-e 's,^PROJ_libdir.*,PROJ_libdir := $(PROJ_prefix)/'$(get_libdir)/llvm, \ |
| 66 |
-i Makefile.config.in || die "Makefile.config sed failed" |
| 67 |
|
| 68 |
einfo "Fixing rpath and CFLAGS" |
| 69 |
sed -e 's,\$(RPATH) -Wl\,\$(\(ToolDir\|LibDir\)),$(RPATH) -Wl\,'"${EPREFIX}"/usr/$(get_libdir)/llvm, \ |
| 70 |
-e '/OmitFramePointer/s/-fomit-frame-pointer//' \ |
| 71 |
-i Makefile.rules || die "rpath sed failed" |
| 72 |
|
| 73 |
# Use system llc (from llvm ebuild) for tests |
| 74 |
sed -e "/^llc_props =/s/os.path.join(llvm_tools_dir, 'llc')/'llc'/" \ |
| 75 |
-i tools/clang/test/lit.cfg || die "test path sed failed" |
| 76 |
|
| 77 |
# Automatically select active system GCC's libraries, bugs #406163 and #417913 |
| 78 |
epatch "${FILESDIR}"/${P}-gentoo-runtime-gcc-detection-v3.patch |
| 79 |
|
| 80 |
# Fix search paths on FreeBSD, bug #409269 |
| 81 |
epatch "${FILESDIR}"/${P}-gentoo-freebsd-fix-lib-path.patch |
| 82 |
|
| 83 |
# Fix regression caused by removal of USE=system-cxx-headers, bug #417541 |
| 84 |
epatch "${FILESDIR}"/${P}-gentoo-freebsd-fix-cxx-paths-v2.patch |
| 85 |
|
| 86 |
# Increase recursion limit, bug #417545, upstream r155737 |
| 87 |
epatch "${FILESDIR}"/${P}-increase-parser-recursion-limit.patch |
| 88 |
|
| 89 |
# User patches |
| 90 |
epatch_user |
| 91 |
} |
| 92 |
|
| 93 |
src_configure() { |
| 94 |
local CONF_FLAGS="--enable-shared |
| 95 |
--with-optimize-option= |
| 96 |
$(use_enable !debug optimized) |
| 97 |
$(use_enable debug assertions) |
| 98 |
$(use_enable debug expensive-checks)" |
| 99 |
|
| 100 |
# Setup the search path to include the Prefix includes |
| 101 |
if use prefix ; then |
| 102 |
CONF_FLAGS="${CONF_FLAGS} \ |
| 103 |
--with-c-include-dirs=${EPREFIX}/usr/include:/usr/include" |
| 104 |
fi |
| 105 |
|
| 106 |
if use multitarget; then |
| 107 |
CONF_FLAGS="${CONF_FLAGS} --enable-targets=all" |
| 108 |
else |
| 109 |
CONF_FLAGS="${CONF_FLAGS} --enable-targets=host-only" |
| 110 |
fi |
| 111 |
|
| 112 |
if use amd64; then |
| 113 |
CONF_FLAGS="${CONF_FLAGS} --enable-pic" |
| 114 |
fi |
| 115 |
|
| 116 |
# clang prefers clang over gcc, so we may need to force that |
| 117 |
tc-export CC CXX |
| 118 |
econf ${CONF_FLAGS} |
| 119 |
} |
| 120 |
|
| 121 |
src_compile() { |
| 122 |
emake VERBOSE=1 KEEP_SYMBOLS=1 REQUIRES_RTTI=1 clang-only |
| 123 |
} |
| 124 |
|
| 125 |
src_test() { |
| 126 |
cd "${S}"/test || die "cd failed" |
| 127 |
emake site.exp |
| 128 |
|
| 129 |
cd "${S}"/tools/clang || die "cd clang failed" |
| 130 |
|
| 131 |
echo ">>> Test phase [test]: ${CATEGORY}/${PF}" |
| 132 |
|
| 133 |
testing() { |
| 134 |
if ! emake -j1 VERBOSE=1 test; then |
| 135 |
has test $FEATURES && die "Make test failed. See above for details." |
| 136 |
has test $FEATURES || eerror "Make test failed. See above for details." |
| 137 |
fi |
| 138 |
} |
| 139 |
python_execute_function testing |
| 140 |
} |
| 141 |
|
| 142 |
src_install() { |
| 143 |
cd "${S}"/tools/clang || die "cd clang failed" |
| 144 |
emake KEEP_SYMBOLS=1 DESTDIR="${D}" install |
| 145 |
|
| 146 |
if use static-analyzer ; then |
| 147 |
dobin tools/scan-build/ccc-analyzer |
| 148 |
dosym ccc-analyzer /usr/bin/c++-analyzer |
| 149 |
dobin tools/scan-build/scan-build |
| 150 |
|
| 151 |
insinto /usr/share/${PN} |
| 152 |
doins tools/scan-build/scanview.css |
| 153 |
doins tools/scan-build/sorttable.js |
| 154 |
|
| 155 |
cd tools/scan-view || die "cd scan-view failed" |
| 156 |
dobin scan-view |
| 157 |
install-scan-view() { |
| 158 |
insinto "$(python_get_sitedir)"/clang |
| 159 |
doins Reporter.py Resources ScanView.py startfile.py |
| 160 |
touch "${ED}"/"$(python_get_sitedir)"/clang/__init__.py |
| 161 |
} |
| 162 |
python_execute_function install-scan-view |
| 163 |
fi |
| 164 |
|
| 165 |
# Fix install_names on Darwin. The build system is too complicated |
| 166 |
# to just fix this, so we correct it post-install |
| 167 |
if [[ ${CHOST} == *-darwin* ]] ; then |
| 168 |
for lib in libclang.dylib ; do |
| 169 |
ebegin "fixing install_name of $lib" |
| 170 |
install_name_tool -id "${EPREFIX}"/usr/lib/llvm/${lib} \ |
| 171 |
"${ED}"/usr/lib/llvm/${lib} |
| 172 |
eend $? |
| 173 |
done |
| 174 |
for f in usr/bin/{c-index-test,clang} usr/lib/llvm/libclang.dylib ; do |
| 175 |
ebegin "fixing references in ${f##*/}" |
| 176 |
install_name_tool \ |
| 177 |
-change "@rpath/libclang.dylib" \ |
| 178 |
"${EPREFIX}"/usr/lib/llvm/libclang.dylib \ |
| 179 |
-change "@executable_path/../lib/libLLVM-${PV}.dylib" \ |
| 180 |
"${EPREFIX}"/usr/lib/llvm/libLLVM-${PV}.dylib \ |
| 181 |
-change "${S}"/Release/lib/libclang.dylib \ |
| 182 |
"${EPREFIX}"/usr/lib/llvm/libclang.dylib \ |
| 183 |
"${ED}"/$f |
| 184 |
eend $? |
| 185 |
done |
| 186 |
fi |
| 187 |
|
| 188 |
# Remove unnecessary headers on FreeBSD, bug #417171 |
| 189 |
use kernel_FreeBSD && rm "${ED}"usr/$(get_libdir)/clang/${PV}/include/{arm_neon,std,float,iso,limits,tgmath,varargs}*.h |
| 190 |
} |
| 191 |
|
| 192 |
pkg_postinst() { |
| 193 |
python_mod_optimize clang |
| 194 |
} |
| 195 |
|
| 196 |
pkg_postrm() { |
| 197 |
python_mod_cleanup clang |
| 198 |
} |