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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.31 - (show annotations) (download)
Fri Jul 27 18:22:45 2012 UTC (23 months, 4 weeks ago) by mgorny
Branch: MAIN
Changes since 1.30: +3 -1 lines
Use tc-export to enforce Gentoo default CC/CXX when $CHOST-clang is available.

(Portage version: 2.2.0_alpha120_p6/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-9999.ebuild,v 1.30 2012/06/08 13:20:02 mgorny Exp $
4
5 EAPI=4
6
7 RESTRICT_PYTHON_ABIS="3.*"
8 SUPPORT_PYTHON_ABIS="1"
9
10 inherit subversion eutils multilib python
11
12 DESCRIPTION="C language family frontend for LLVM"
13 HOMEPAGE="http://clang.llvm.org/"
14 SRC_URI=""
15 ESVN_REPO_URI="http://llvm.org/svn/llvm-project/cfe/trunk"
16
17 LICENSE="UoI-NCSA"
18 SLOT="0"
19 KEYWORDS=""
20 IUSE="debug multitarget +static-analyzer test"
21
22 DEPEND="static-analyzer? ( dev-lang/perl )"
23 RDEPEND="~sys-devel/llvm-${PV}[multitarget=]"
24
25 S="${WORKDIR}/llvm"
26
27 src_unpack() {
28 # Fetching LLVM and subprojects
29 ESVN_PROJECT=llvm subversion_fetch "http://llvm.org/svn/llvm-project/llvm/trunk"
30 ESVN_PROJECT=compiler-rt S="${S}"/projects/compiler-rt subversion_fetch "http://llvm.org/svn/llvm-project/compiler-rt/trunk"
31 ESVN_PROJECT=clang S="${S}"/tools/clang subversion_fetch
32 }
33
34 src_prepare() {
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 # User patches
78 epatch_user
79 }
80
81 src_configure() {
82 local CONF_FLAGS="--enable-shared
83 --with-optimize-option=
84 $(use_enable !debug optimized)
85 $(use_enable debug assertions)
86 $(use_enable debug expensive-checks)"
87
88 # Setup the search path to include the Prefix includes
89 if use prefix ; then
90 CONF_FLAGS="${CONF_FLAGS} \
91 --with-c-include-dirs=${EPREFIX}/usr/include:/usr/include"
92 fi
93
94 if use multitarget; then
95 CONF_FLAGS="${CONF_FLAGS} --enable-targets=all"
96 else
97 CONF_FLAGS="${CONF_FLAGS} --enable-targets=host,cpp"
98 fi
99
100 if use amd64; then
101 CONF_FLAGS="${CONF_FLAGS} --enable-pic"
102 fi
103
104 # clang prefers clang over gcc, so we may need to force that
105 tc-export CC CXX
106 econf ${CONF_FLAGS}
107 }
108
109 src_compile() {
110 emake VERBOSE=1 KEEP_SYMBOLS=1 REQUIRES_RTTI=1 clang-only
111 }
112
113 src_test() {
114 cd "${S}"/test || die "cd failed"
115 emake site.exp
116
117 cd "${S}"/tools/clang || die "cd clang failed"
118
119 echo ">>> Test phase [test]: ${CATEGORY}/${PF}"
120
121 testing() {
122 if ! emake -j1 VERBOSE=1 test; then
123 has test $FEATURES && die "Make test failed. See above for details."
124 has test $FEATURES || eerror "Make test failed. See above for details."
125 fi
126 }
127 python_execute_function testing
128 }
129
130 src_install() {
131 cd "${S}"/tools/clang || die "cd clang failed"
132 emake KEEP_SYMBOLS=1 DESTDIR="${D}" install
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 # AddressSanitizer symbolizer (currently separate)
154 dobin "${S}"/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py
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 }
183
184 pkg_postrm() {
185 python_mod_cleanup clang
186 }

  ViewVC Help
Powered by ViewVC 1.1.20