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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations) (download)
Mon Nov 14 15:02:31 2011 UTC (2 years, 8 months ago) by voyageur
Branch: MAIN
Changes since 1.3: +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.9-r1.ebuild,v 1.3 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 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="debug multitarget +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}[multitarget=]"
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 # Workaround GCC versions' list (bug #377949)
33 epatch "${FILESDIR}"/${P}-gccversions.patch
34
35 # Same as llvm doc patches
36 epatch "${FILESDIR}"/${PN}-2.7-fixdoc.patch
37
38 # Fix toolchain lookup for Darwin/Prefix.
39 epatch "${FILESDIR}"/${PN}-2.9-darwin-prefix.patch
40 sed -e "s|@GENTOO_PORTAGE_CHOST_ARCH@|${CHOST%%-darwin*}-darwin|g" \
41 -e "s|@GENTOO_PORTAGE_CHOST@|${CHOST}|g" \
42 -e "s|@GENTOO_PORTAGE_EPREFIX@|${EPREFIX}|g" \
43 -i tools/clang/lib/Driver/ToolChains.cpp \
44 || die "fixing toolchain lookup"
45
46 # multilib-strict
47 sed -e "/PROJ_headers/s#lib/clang#$(get_libdir)/clang#" \
48 -i tools/clang/lib/Headers/Makefile \
49 || die "clang Makefile failed"
50 # fix the static analyzer for in-tree install
51 sed -e 's/import ScanView/from clang \0/' \
52 -i tools/clang/tools/scan-view/scan-view \
53 || die "scan-view sed failed"
54 sed -e "/scanview.css\|sorttable.js/s#\$RealBin#${EPREFIX}/usr/share/${PN}#" \
55 -i tools/clang/tools/scan-build/scan-build \
56 || die "scan-build sed failed"
57 # Specify python version
58 python_convert_shebangs 2 tools/clang/tools/scan-view/scan-view
59
60 # From llvm src_prepare
61 einfo "Fixing install dirs"
62 sed -e 's,^PROJ_docsdir.*,PROJ_docsdir := $(PROJ_prefix)/share/doc/'${PF}, \
63 -e 's,^PROJ_etcdir.*,PROJ_etcdir := '"${EPREFIX}"'/etc/llvm,' \
64 -e 's,^PROJ_libdir.*,PROJ_libdir := $(PROJ_prefix)/'$(get_libdir)/llvm, \
65 -i Makefile.config.in || die "Makefile.config sed failed"
66
67 einfo "Fixing rpath and CFLAGS"
68 sed -e 's,\$(RPATH) -Wl\,\$(\(ToolDir\|LibDir\)),$(RPATH) -Wl\,'"${EPREFIX}"/usr/$(get_libdir)/llvm, \
69 -e '/OmitFramePointer/s/-fomit-frame-pointer//' \
70 -i Makefile.rules || die "rpath sed failed"
71 }
72
73 src_configure() {
74 local CONF_FLAGS="--enable-shared
75 --with-optimize-option=
76 $(use_enable !debug optimized)
77 $(use_enable debug assertions)
78 $(use_enable debug expensive-checks)"
79
80 # Setup the search path to include the Prefix includes
81 if use prefix ; then
82 CONF_FLAGS="${CONF_FLAGS} \
83 --with-c-include-dirs=${EPREFIX}/usr/include:/usr/include"
84 fi
85
86 if use multitarget; then
87 CONF_FLAGS="${CONF_FLAGS} --enable-targets=all"
88 else
89 CONF_FLAGS="${CONF_FLAGS} --enable-targets=host-only"
90 fi
91
92 if use amd64; then
93 CONF_FLAGS="${CONF_FLAGS} --enable-pic"
94 fi
95
96 # Skip llvm-gcc parts even if installed
97 CONF_FLAGS="${CONF_FLAGS} --with-llvmgccdir=/dev/null"
98
99 if use system-cxx-headers; then
100 # Try to get current gcc headers path
101 local CXX_PATH=$(gcc-config -L| cut -d: -f1)
102 CONF_FLAGS="${CONF_FLAGS} --with-c-include-dirs=/usr/include:${CXX_PATH}/include"
103 CONF_FLAGS="${CONF_FLAGS} --with-cxx-include-root=${CXX_PATH}/include/g++-v4"
104 CONF_FLAGS="${CONF_FLAGS} --with-cxx-include-arch=$CHOST"
105 if has_multilib_profile; then
106 CONF_FLAGS="${CONF_FLAGS} --with-cxx-include-32bit-dir=32"
107 fi
108 fi
109
110 econf ${CONF_FLAGS} || die "econf failed"
111 }
112
113 src_compile() {
114 emake VERBOSE=1 KEEP_SYMBOLS=1 REQUIRES_RTTI=1 clang-only || die "emake failed"
115 }
116
117 src_test() {
118 cd "${S}"/test || die "cd failed"
119 emake site.exp || die "updating llvm site.exp failed"
120
121 cd "${S}"/tools/clang || die "cd clang failed"
122
123 echo ">>> Test phase [test]: ${CATEGORY}/${PF}"
124 if ! emake -j1 VERBOSE=1 test; then
125 has test $FEATURES && die "Make test failed. See above for details."
126 has test $FEATURES || eerror "Make test failed. See above for details."
127 fi
128 }
129
130 src_install() {
131 cd "${S}"/tools/clang || die "cd clang failed"
132 emake KEEP_SYMBOLS=1 DESTDIR="${D}" install || die "install failed"
133
134 if use static-analyzer ; then
135 dobin tools/scan-build/ccc-analyzer
136 dosym ccc-analyzer /usr/bin/c++-analyzer
137 dobin tools/scan-build/scan-build
138
139 insinto /usr/share/${PN}
140 doins tools/scan-build/scanview.css
141 doins tools/scan-build/sorttable.js
142
143 cd tools/scan-view || die "cd scan-view failed"
144 dobin scan-view
145 install-scan-view() {
146 insinto "$(python_get_sitedir)"/clang
147 doins Reporter.py Resources ScanView.py startfile.py
148 touch "${ED}"/"$(python_get_sitedir)"/clang/__init__.py
149 }
150 python_execute_function install-scan-view
151 fi
152
153 # Fix install_names on Darwin. The build system is too complicated
154 # to just fix this, so we correct it post-install
155 if [[ ${CHOST} == *-darwin* ]] ; then
156 for lib in libclang.dylib ; do
157 ebegin "fixing install_name of $lib"
158 install_name_tool -id "${EPREFIX}"/usr/lib/llvm/${lib} \
159 "${ED}"/usr/lib/llvm/${lib}
160 eend $?
161 done
162 for f in usr/bin/{c-index-test,clang} usr/lib/llvm/libclang.dylib ; do
163 ebegin "fixing references in ${f##*/}"
164 install_name_tool \
165 -change "@rpath/libclang.dylib" \
166 "${EPREFIX}"/usr/lib/llvm/libclang.dylib \
167 -change "@executable_path/../lib/libLLVM-${PV}.dylib" \
168 "${EPREFIX}"/usr/lib/llvm/libLLVM-${PV}.dylib \
169 -change "${S}"/Release/lib/libclang.dylib \
170 "${EPREFIX}"/usr/lib/llvm/libclang.dylib \
171 "${ED}"/$f
172 eend $?
173 done
174 fi
175 }
176
177 pkg_postinst() {
178 python_mod_optimize clang
179 if use system-cxx-headers; then
180 elog "C++ headers search path is hardcoded to the active gcc profile one"
181 elog "If you change the active gcc profile, or update gcc to a new version,"
182 elog "you will have to remerge this package to update the search path"
183 else
184 elog "If clang++ fails to find C++ headers on your system,"
185 elog "you can remerge clang with USE=system-cxx-headers to use C++ headers"
186 elog "from the active gcc profile"
187 fi
188 }
189
190 pkg_postrm() {
191 python_mod_cleanup clang
192 }

  ViewVC Help
Powered by ViewVC 1.1.20