/[gentoo-x86]/sys-devel/clang/clang-2.9.ebuild
Gentoo

Contents of /sys-devel/clang/clang-2.9.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations) (download)
Mon Oct 3 13:36:31 2011 UTC (2 years, 11 months ago) by voyageur
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +1 -1 lines
FILE REMOVED
Rename alltargets USE flag to multitarget, bug #382307. Drop some versions

(Portage version: 2.2.0_alpha60/cvs/Linux x86_64)

1 # Copyright 1999-2011 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/sys-devel/clang/clang-2.9.ebuild,v 1.3 2011/07/08 10:10:59 ssuominen Exp $
4
5 EAPI=3
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}.tgz
16 http://llvm.org/releases/${PV}/${P}.tgz"
17
18 LICENSE="UoI-NCSA"
19 SLOT="0"
20 KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux ~ppc-macos"
21 IUSE="alltargets debug +static-analyzer +system-cxx-headers test"
22
23 # Note: for LTO support, clang will depend on binutils with gold plugins, and LLVM built after that - http://llvm.org/docs/GoldPlugin.html
24 DEPEND="static-analyzer? ( dev-lang/perl )"
25 RDEPEND="~sys-devel/llvm-${PV}[alltargets=]"
26
27 S="${WORKDIR}/llvm-${PV}"
28
29 src_prepare() {
30 mv "${WORKDIR}"/clang-${PV} "${S}"/tools/clang || die "clang source directory not found"
31
32 # Same as llvm doc patches
33 epatch "${FILESDIR}"/${PN}-2.7-fixdoc.patch
34
35 # Fix toolchain lookup for Darwin/Prefix.
36 epatch "${FILESDIR}"/${PN}-2.9-darwin-prefix.patch
37 sed -e "s|@GENTOO_PORTAGE_CHOST_ARCH@|${CHOST%%-darwin*}-darwin|g" \
38 -e "s|@GENTOO_PORTAGE_CHOST@|${CHOST}|g" \
39 -e "s|@GENTOO_PORTAGE_EPREFIX@|${EPREFIX}|g" \
40 -i tools/clang/lib/Driver/ToolChains.cpp \
41 || die "fixing toolchain lookup"
42
43 # multilib-strict
44 sed -e "/PROJ_headers/s#lib/clang#$(get_libdir)/clang#" \
45 -i tools/clang/lib/Headers/Makefile \
46 || die "clang Makefile failed"
47 # fix the static analyzer for in-tree install
48 sed -e 's/import ScanView/from clang \0/' \
49 -i tools/clang/tools/scan-view/scan-view \
50 || die "scan-view sed failed"
51 sed -e "/scanview.css\|sorttable.js/s#\$RealBin#${EPREFIX}/usr/share/${PN}#" \
52 -i tools/clang/tools/scan-build/scan-build \
53 || die "scan-build sed failed"
54 # Specify python version
55 python_convert_shebangs 2 tools/clang/tools/scan-view/scan-view
56
57 # From llvm src_prepare
58 einfo "Fixing install dirs"
59 sed -e 's,^PROJ_docsdir.*,PROJ_docsdir := $(PROJ_prefix)/share/doc/'${PF}, \
60 -e 's,^PROJ_etcdir.*,PROJ_etcdir := '"${EPREFIX}"'/etc/llvm,' \
61 -e 's,^PROJ_libdir.*,PROJ_libdir := $(PROJ_prefix)/'$(get_libdir)/llvm, \
62 -i Makefile.config.in || die "Makefile.config sed failed"
63
64 einfo "Fixing rpath"
65 sed -e 's,\$(RPATH) -Wl\,\$(\(ToolDir\|LibDir\)),$(RPATH) -Wl\,'"${EPREFIX}"/usr/$(get_libdir)/llvm, \
66 -i Makefile.rules || die "rpath sed failed"
67 }
68
69 src_configure() {
70 local CONF_FLAGS="--enable-shared"
71
72 if use debug; then
73 CONF_FLAGS="${CONF_FLAGS} --disable-optimized"
74 einfo "Note: Compiling LLVM in debug mode will create huge and slow binaries"
75 # ...and you probably shouldn't use tmpfs, unless it can hold 900MB
76 else
77 CONF_FLAGS="${CONF_FLAGS} \
78 --enable-optimized \
79 --disable-assertions \
80 --disable-expensive-checks"
81 fi
82
83 # Setup the search path to include the Prefix includes
84 if use prefix ; then
85 CONF_FLAGS="${CONF_FLAGS} \
86 --with-c-include-dirs=${EPREFIX}/usr/include:/usr/include"
87 fi
88
89 if use alltargets; then
90 CONF_FLAGS="${CONF_FLAGS} --enable-targets=all"
91 else
92 CONF_FLAGS="${CONF_FLAGS} --enable-targets=host-only"
93 fi
94
95 if use amd64; then
96 CONF_FLAGS="${CONF_FLAGS} --enable-pic"
97 fi
98
99 # Skip llvm-gcc parts even if installed
100 CONF_FLAGS="${CONF_FLAGS} --with-llvmgccdir=/dev/null"
101
102 if use system-cxx-headers; then
103 # Try to get current gcc headers path
104 local CXX_PATH=$(gcc-config -X| cut -d: -f1 | sed 's,/include/g++-v4$,,')
105 CONF_FLAGS="${CONF_FLAGS} --with-c-include-dirs=/usr/include:${CXX_PATH}/include"
106 CONF_FLAGS="${CONF_FLAGS} --with-cxx-include-root=${CXX_PATH}/include/g++-v4"
107 CONF_FLAGS="${CONF_FLAGS} --with-cxx-include-arch=$CHOST"
108 if has_multilib_profile; then
109 CONF_FLAGS="${CONF_FLAGS} --with-cxx-include-32bit-dir=32"
110 fi
111 fi
112
113 econf ${CONF_FLAGS} || die "econf failed"
114 }
115
116 src_compile() {
117 emake VERBOSE=1 KEEP_SYMBOLS=1 REQUIRES_RTTI=1 clang-only || die "emake failed"
118 }
119
120 src_test() {
121 cd "${S}"/test || die "cd failed"
122 emake site.exp || die "updating llvm site.exp failed"
123
124 cd "${S}"/tools/clang || die "cd clang failed"
125
126 echo ">>> Test phase [test]: ${CATEGORY}/${PF}"
127 if ! emake -j1 VERBOSE=1 test; then
128 has test $FEATURES && die "Make test failed. See above for details."
129 has test $FEATURES || eerror "Make test failed. See above for details."
130 fi
131 }
132
133 src_install() {
134 cd "${S}"/tools/clang || die "cd clang failed"
135 emake KEEP_SYMBOLS=1 DESTDIR="${D}" install || die "install failed"
136
137 if use static-analyzer ; then
138 dobin tools/scan-build/ccc-analyzer
139 dosym ccc-analyzer /usr/bin/c++-analyzer
140 dobin tools/scan-build/scan-build
141
142 insinto /usr/share/${PN}
143 doins tools/scan-build/scanview.css
144 doins tools/scan-build/sorttable.js
145
146 cd tools/scan-view || die "cd scan-view failed"
147 dobin scan-view
148 install-scan-view() {
149 insinto "$(python_get_sitedir)"/clang
150 doins Reporter.py Resources ScanView.py startfile.py
151 touch "${ED}"/"$(python_get_sitedir)"/clang/__init__.py
152 }
153 python_execute_function install-scan-view
154 fi
155
156 # Fix install_names on Darwin. The build system is too complicated
157 # to just fix this, so we correct it post-install
158 if [[ ${CHOST} == *-darwin* ]] ; then
159 for lib in libclang.dylib ; do
160 ebegin "fixing install_name of $lib"
161 install_name_tool -id "${EPREFIX}"/usr/lib/llvm/${lib} \
162 "${ED}"/usr/lib/llvm/${lib}
163 eend $?
164 done
165 for f in usr/bin/{c-index-test,clang} usr/lib/llvm/libclang.dylib ; do
166 ebegin "fixing references in ${f##*/}"
167 install_name_tool \
168 -change "@rpath/libclang.dylib" \
169 "${EPREFIX}"/usr/lib/llvm/libclang.dylib \
170 -change "@executable_path/../lib/libLLVM-${PV}.dylib" \
171 "${EPREFIX}"/usr/lib/llvm/libLLVM-${PV}.dylib \
172 -change "${S}"/Release/lib/libclang.dylib \
173 "${EPREFIX}"/usr/lib/llvm/libclang.dylib \
174 "${ED}"/$f
175 eend $?
176 done
177 fi
178 }
179
180 pkg_postinst() {
181 python_mod_optimize clang
182 if use system-cxx-headers; then
183 elog "C++ headers search path is hardcoded to the active gcc profile one"
184 elog "If you change the active gcc profile, or update gcc to a new version,"
185 elog "you will have to remerge this package to update the search path"
186 else
187 elog "If clang++ fails to find C++ headers on your system,"
188 elog "you can remerge clang with USE=system-cxx-headers to use C++ headers"
189 elog "from the active gcc profile"
190 fi
191 }
192
193 pkg_postrm() {
194 python_mod_cleanup clang
195 }

  ViewVC Help
Powered by ViewVC 1.1.20