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

Contents of /sys-devel/clang/clang-2.8-r3.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations) (download)
Mon Nov 14 15:02:31 2011 UTC (2 years, 11 months ago) by voyageur
Branch: MAIN
Changes since 1.6: +2 -2 lines
gcc-config 1.5 dropped the -X option, thanks Leonid Volnitsky <leonid@volnitsky.com> in bug #388621

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

  ViewVC Help
Powered by ViewVC 1.1.20