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

Contents of /sys-devel/clang/clang-3.0-r4.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Thu May 24 13:00:09 2012 UTC (2 years, 3 months ago) by ryao
Branch: MAIN
Add runtime detection of active GCC on Linux (bug \#406163) and FreeBSD (bug \#409269).
Remove unnecessary headers on FreeBSD, bug \#417171.
Run time detection enables Clang to build C++ code without USE=system-cxx-headers, so no longer set it by default

(Portage version: 2.1.10.49/cvs/Linux x86_64)

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.0-r3.ebuild,v 1.5 2012/04/13 14:14:39 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 SRC_URI="http://llvm.org/releases/${PV}/llvm-${PV}.tar.gz
16 http://llvm.org/releases/${PV}/${P}.tar.gz"
17
18 LICENSE="UoI-NCSA"
19 SLOT="0"
20 KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux ~ppc-macos"
21 IUSE="debug kernel_FreeBSD multitarget +static-analyzer system-cxx-headers test"
22
23 DEPEND="static-analyzer? ( dev-lang/perl )"
24 RDEPEND="~sys-devel/llvm-${PV}[multitarget=]"
25
26 S=${WORKDIR}/llvm-${PV}.src
27
28 src_prepare() {
29 mv "${WORKDIR}"/clang-${PV}.src "${S}"/tools/clang || die "clang source directory move failed"
30
31 # Same as llvm doc patches
32 epatch "${FILESDIR}"/${PN}-2.7-fixdoc.patch
33
34 # multilib-strict
35 sed -e "/PROJ_headers/s#lib/clang#$(get_libdir)/clang#" \
36 -i tools/clang/lib/Headers/Makefile \
37 || die "clang Makefile failed"
38 # Fix cxx_include_root path for Gentoo
39 epatch "${FILESDIR}"/${P/_*}-fix_cxx_include_root.patch
40 # fix the static analyzer for in-tree install
41 sed -e 's/import ScanView/from clang \0/' \
42 -i tools/clang/tools/scan-view/scan-view \
43 || die "scan-view sed failed"
44 sed -e "/scanview.css\|sorttable.js/s#\$RealBin#${EPREFIX}/usr/share/${PN}#" \
45 -i tools/clang/tools/scan-build/scan-build \
46 || die "scan-build sed failed"
47 # Set correct path for gold plugin
48 sed -e "/LLVMgold.so/s#lib/#$(get_libdir)/llvm/#" \
49 -i tools/clang/lib/Driver/Tools.cpp \
50 || die "gold plugin path sed failed"
51 # Properly detect Gentoo's binutils-apple version (committed in trunk)
52 epatch "${FILESDIR}"/${PN}-3.0-gentoo-binutils-apple.patch
53 # Specify python version
54 python_convert_shebangs 2 tools/clang/tools/scan-view/scan-view
55 python_convert_shebangs -r 2 test/Scripts
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 and CFLAGS"
65 sed -e 's,\$(RPATH) -Wl\,\$(\(ToolDir\|LibDir\)),$(RPATH) -Wl\,'"${EPREFIX}"/usr/$(get_libdir)/llvm, \
66 -e '/OmitFramePointer/s/-fomit-frame-pointer//' \
67 -i Makefile.rules || die "rpath sed failed"
68
69 # Use system llc (from llvm ebuild) for tests
70 sed -e "/^registered_targets =/s/os.path.join(llvm_tools_dir, 'llc')/'llc'/" \
71 -i tools/clang/test/lit.cfg || die "test path sed failed"
72
73 # AMD K10 CPUs + SSE4a suppport, bug #398357
74 epatch "${FILESDIR}"/${P}-recognize-amd-k10-enable-sse4a.patch
75
76 # Automatically select active system GCC's libraries, bug #406163
77 epatch "${FILESDIR}"/${P}-linux-runtime-gcc-detection.patch
78
79 # Fix search paths on FreeBSD, bug #409269
80 epatch "${FILESDIR}"/${P}-freebsd-runtime-gcc-detection.patch
81
82 # User patches
83 epatch_user
84 }
85
86 src_configure() {
87 local CONF_FLAGS="--enable-shared
88 --with-optimize-option=
89 $(use_enable !debug optimized)
90 $(use_enable debug assertions)
91 $(use_enable debug expensive-checks)"
92
93 # Setup the search path to include the Prefix includes
94 if use prefix ; then
95 CONF_FLAGS="${CONF_FLAGS} \
96 --with-c-include-dirs=${EPREFIX}/usr/include:/usr/include"
97 fi
98
99 if use multitarget; then
100 CONF_FLAGS="${CONF_FLAGS} --enable-targets=all"
101 else
102 CONF_FLAGS="${CONF_FLAGS} --enable-targets=host-only"
103 fi
104
105 if use amd64; then
106 CONF_FLAGS="${CONF_FLAGS} --enable-pic"
107 fi
108
109 if use system-cxx-headers; then
110 # Try to get current gcc headers path
111 local CXX_PATH=$(gcc-config -L| cut -d: -f1)
112 CONF_FLAGS="${CONF_FLAGS} --with-c-include-dirs=/usr/include:${CXX_PATH}/include"
113 CONF_FLAGS="${CONF_FLAGS} --with-cxx-include-root=${CXX_PATH}/include/g++-v4"
114 CONF_FLAGS="${CONF_FLAGS} --with-cxx-include-arch=$CHOST"
115 if has_multilib_profile; then
116 CONF_FLAGS="${CONF_FLAGS} --with-cxx-include-32bit-dir=/32"
117 fi
118 fi
119
120 econf ${CONF_FLAGS} || die "econf failed"
121 }
122
123 src_compile() {
124 emake VERBOSE=1 KEEP_SYMBOLS=1 REQUIRES_RTTI=1 clang-only || die "emake failed"
125 }
126
127 src_test() {
128 cd "${S}"/test || die "cd failed"
129 emake site.exp || die "updating llvm site.exp failed"
130
131 cd "${S}"/tools/clang || die "cd clang failed"
132
133 # Broken test always assuming i386 host with multilib gcc 4.6.0
134 # http://llvm.org/bugs/show_bug.cgi?id=11094
135 rm -f test/Driver/linux-ld.c
136
137 echo ">>> Test phase [test]: ${CATEGORY}/${PF}"
138
139 testing() {
140 if ! emake -j1 VERBOSE=1 test; then
141 has test $FEATURES && die "Make test failed. See above for details."
142 has test $FEATURES || eerror "Make test failed. See above for details."
143 fi
144 }
145 python_execute_function testing
146 }
147
148 src_install() {
149 cd "${S}"/tools/clang || die "cd clang failed"
150 emake KEEP_SYMBOLS=1 DESTDIR="${D}" install || die "install failed"
151
152 if use static-analyzer ; then
153 dobin tools/scan-build/ccc-analyzer
154 dosym ccc-analyzer /usr/bin/c++-analyzer
155 dobin tools/scan-build/scan-build
156
157 insinto /usr/share/${PN}
158 doins tools/scan-build/scanview.css
159 doins tools/scan-build/sorttable.js
160
161 cd tools/scan-view || die "cd scan-view failed"
162 dobin scan-view
163 install-scan-view() {
164 insinto "$(python_get_sitedir)"/clang
165 doins Reporter.py Resources ScanView.py startfile.py
166 touch "${ED}"/"$(python_get_sitedir)"/clang/__init__.py
167 }
168 python_execute_function install-scan-view
169 fi
170
171 # Fix install_names on Darwin. The build system is too complicated
172 # to just fix this, so we correct it post-install
173 if [[ ${CHOST} == *-darwin* ]] ; then
174 for lib in libclang.dylib ; do
175 ebegin "fixing install_name of $lib"
176 install_name_tool -id "${EPREFIX}"/usr/lib/llvm/${lib} \
177 "${ED}"/usr/lib/llvm/${lib}
178 eend $?
179 done
180 for f in usr/bin/{c-index-test,clang} usr/lib/llvm/libclang.dylib ; do
181 ebegin "fixing references in ${f##*/}"
182 install_name_tool \
183 -change "@rpath/libclang.dylib" \
184 "${EPREFIX}"/usr/lib/llvm/libclang.dylib \
185 -change "@executable_path/../lib/libLLVM-${PV}.dylib" \
186 "${EPREFIX}"/usr/lib/llvm/libLLVM-${PV}.dylib \
187 -change "${S}"/Release/lib/libclang.dylib \
188 "${EPREFIX}"/usr/lib/llvm/libclang.dylib \
189 "${ED}"/$f
190 eend $?
191 done
192 fi
193
194 # Remove unnecessary headers on FreeBSD, bug #417171
195 use kernel_FreeBSD && rm "${ED}/usr/lib/clang/3.1/include/"{arm_neon,std,float,iso,limits,tgmath,varargs}*.h
196 }
197
198 pkg_postinst() {
199 python_mod_optimize clang
200 if use system-cxx-headers; then
201 elog "C++ headers search path is hardcoded to the active gcc profile one"
202 elog "If you change the active gcc profile, or update gcc to a new version,"
203 elog "you will have to remerge this package to update the search path"
204 else
205 elog "If clang++ fails to find C++ headers on your system,"
206 elog "you can remerge clang with USE=system-cxx-headers to use C++ headers"
207 elog "from the active gcc profile"
208 fi
209 }
210
211 pkg_postrm() {
212 python_mod_cleanup clang
213 }

  ViewVC Help
Powered by ViewVC 1.1.20