Lines 14-26
SRC_URI=""
Link Here
|
14 |
ESVN_REPO_URI="http://llvm.org/svn/llvm-project/cfe/trunk" |
14 |
ESVN_REPO_URI="http://llvm.org/svn/llvm-project/cfe/trunk" |
15 |
|
15 |
|
16 |
LICENSE="UoI-NCSA" |
16 |
LICENSE="UoI-NCSA" |
17 |
SLOT="0" |
17 |
SLOT="${PV}" |
18 |
KEYWORDS="" |
18 |
KEYWORDS="" |
19 |
IUSE="debug multitarget python +static-analyzer test" |
19 |
IUSE="debug multitarget python +static-analyzer test" |
20 |
|
20 |
|
21 |
DEPEND="static-analyzer? ( dev-lang/perl ) |
21 |
DEPEND="static-analyzer? ( dev-lang/perl ) |
22 |
${PYTHON_DEPS}" |
22 |
${PYTHON_DEPS}" |
23 |
RDEPEND="~sys-devel/llvm-${PV}[debug=,multitarget=] |
23 |
RDEPEND="sys-devel/llvm:${SLOT}=[debug=,multitarget=] |
|
|
24 |
app-admin/eselect-clang |
24 |
${PYTHON_DEPS}" |
25 |
${PYTHON_DEPS}" |
25 |
|
26 |
|
26 |
S="${WORKDIR}/llvm" |
27 |
S="${WORKDIR}/llvm" |
Lines 54-63
src_prepare() {
Link Here
|
54 |
-i tools/clang/tools/scan-build/scan-build \ |
55 |
-i tools/clang/tools/scan-build/scan-build \ |
55 |
|| die "scan-build sed failed" |
56 |
|| die "scan-build sed failed" |
56 |
# Set correct path for gold plugin and coverage lib |
57 |
# Set correct path for gold plugin and coverage lib |
57 |
sed -e "/LLVMgold.so/s#lib/#$(get_libdir)/llvm/#" \ |
58 |
sed -e "/LLVMgold.so/s#lib/#$(get_libdir)/llvm-${SLOT}/#" \ |
58 |
-e "s#lib\(/libprofile_rt.a\)#$(get_libdir)/llvm\1#" \ |
59 |
-e "s#lib\(/libprofile_rt.a\)#$(get_libdir)/llvm-${SLOT}\1#" \ |
59 |
-i tools/clang/lib/Driver/Tools.cpp \ |
60 |
-i tools/clang/lib/Driver/Tools.cpp \ |
60 |
|| die "driver tools paths sed failed" |
61 |
|| die "driver tools paths sed failed" |
|
|
62 |
# Add slot suffix for the live ebuild |
63 |
sed -e "/LLVM_VERSION =/s/\('[0-9.]*\)svn'$/\1-${SLOT}'/" \ |
64 |
-i bindings/python/llvm/common.py || die "python bindings version sed failed" |
65 |
sed -e "/PACKAGE_VERSION=/s/\('[0-9.]*\)svn'$/\1-${SLOT}'/" \ |
66 |
-i configure || die "configure version sed faile" |
67 |
sed -e "/#define CLANG_MAKE_VERSION_STRING2/s/#X/#X \"-${SLOT}\"/" \ |
68 |
-i tools/clang/include/clang/Basic/Version.h \ |
69 |
|| die "Version sed #1 failed" |
70 |
sed -e "/@CLANG_VERSION@/s/#g/-${SLOT}#g/" \ |
71 |
-e "/subst rc/aCLANG_VERSION := \$(subst -${SLOT},,\$(CLANG_VERSION))" \ |
72 |
-i tools/clang/include/clang/Basic/Makefile \ |
73 |
|| die "Version sed #2 failed" |
61 |
|
74 |
|
62 |
# From llvm src_prepare |
75 |
# From llvm src_prepare |
63 |
einfo "Fixing install dirs" |
76 |
einfo "Fixing install dirs" |
Lines 67-73
src_prepare() {
Link Here
|
67 |
-i Makefile.config.in || die "Makefile.config sed failed" |
80 |
-i Makefile.config.in || die "Makefile.config sed failed" |
68 |
|
81 |
|
69 |
einfo "Fixing rpath and CFLAGS" |
82 |
einfo "Fixing rpath and CFLAGS" |
70 |
sed -e 's,\$(RPATH) -Wl\,\$(\(ToolDir\|LibDir\)),$(RPATH) -Wl\,'"${EPREFIX}"/usr/$(get_libdir)/llvm, \ |
83 |
sed -e "s@\$(RPATH) -Wl,'\$\$ORIGIN/../lib'@\$(RPATH) -Wl,'${EPREFIX}/usr/$(get_libdir)/llvm-${SLOT}'@" \ |
71 |
-e '/OmitFramePointer/s/-fomit-frame-pointer//' \ |
84 |
-e '/OmitFramePointer/s/-fomit-frame-pointer//' \ |
72 |
-i Makefile.rules || die "rpath sed failed" |
85 |
-i Makefile.rules || die "rpath sed failed" |
73 |
|
86 |
|
Lines 80-92
src_prepare() {
Link Here
|
80 |
} |
93 |
} |
81 |
|
94 |
|
82 |
src_configure() { |
95 |
src_configure() { |
83 |
# Update resource dir version after first RC |
96 |
local LLVM_VERSION=`sed -n "s/PACKAGE_VERSION='\([0-9.]*-${SLOT}\)'$/\1/p" configure` |
|
|
97 |
[[ -n "${LLVM_VERSION}" ]] || die "Could not extract LLVM version" |
98 |
|
84 |
local CONF_FLAGS="--enable-shared |
99 |
local CONF_FLAGS="--enable-shared |
85 |
--with-optimize-option= |
100 |
--with-optimize-option= |
86 |
$(use_enable !debug optimized) |
101 |
$(use_enable !debug optimized) |
87 |
$(use_enable debug assertions) |
102 |
$(use_enable debug assertions) |
88 |
$(use_enable debug expensive-checks) |
103 |
$(use_enable debug expensive-checks) |
89 |
--with-clang-resource-dir=../$(get_libdir)/clang/3.4" |
104 |
--with-clang-resource-dir=../$(get_libdir)/clang/${LLVM_VERSION}" |
90 |
|
105 |
|
91 |
# Setup the search path to include the Prefix includes |
106 |
# Setup the search path to include the Prefix includes |
92 |
if use prefix ; then |
107 |
if use prefix ; then |
Lines 141-151
src_install() {
Link Here
|
141 |
doins tools/scan-build/sorttable.js |
156 |
doins tools/scan-build/sorttable.js |
142 |
fi |
157 |
fi |
143 |
|
158 |
|
|
|
159 |
# Register slot for app-admin/eselect-clang |
160 |
local eselect_dir="/usr/share/eselect-clang/slots/${SLOT}" |
161 |
dodir "${eselect_dir}" |
162 |
eselect_dir="${ED}/${eselect_dir}" |
163 |
echo "${CATEGORY}/${PF}" > "${eselect_dir}/ebuild" |
164 |
|
165 |
with_slot_suffix() { |
166 |
local file=$(echo "$1" | sed -e "s/-${SLOT}//") |
167 |
local ext="" |
168 |
if [[ "${file}" =~ \. ]] ; then |
169 |
ext=".${file#*.}" |
170 |
fi |
171 |
local base="${file%%.*}" |
172 |
echo "${base}-${SLOT}${ext}" |
173 |
} |
174 |
|
175 |
make_versioned() { |
176 |
local dir=$1 |
177 |
local candidates=(${ED%/}/${dir}) |
178 |
if [[ ! ${dir##*/} ]] ; then |
179 |
dir=${dir%/} |
180 |
candidates=( "${candidates}"* ) |
181 |
else |
182 |
dir=$(dirname "${dir}") |
183 |
fi |
184 |
|
185 |
pushd ${ED%/}/${dir} >/dev/null || die |
186 |
|
187 |
local candidate |
188 |
for candidate in "${candidates[@]}" ; do |
189 |
if [[ -h "${candidate}" ]] ; then |
190 |
# Add slot suffix to symlink target |
191 |
local target=$(readlink -s "${candidate}") |
192 |
local slotted_target=$(with_slot_suffix "${target}") |
193 |
if [[ -e "${target}" ]] || [[ -e "${slotted_target}" ]] ; then |
194 |
ln -sf "${slotted_target}" "${candidate}" \ |
195 |
|| die "Could not update symlink" |
196 |
fi |
197 |
fi |
198 |
|
199 |
local base_name=$(basename "${candidate}") |
200 |
local slotted_name=$(with_slot_suffix "${base_name}") |
201 |
mv "${candidate}" "${ED}/${dir}/${slotted_name}" \ |
202 |
|| die "Could not rename ${candidate} to ${slotted_name}" |
203 |
echo "/${dir#/}/${base_name}" >> "${eselect_dir}/versioned" |
204 |
done |
205 |
|
206 |
popd >/dev/null || die |
207 |
} |
208 |
|
209 |
# Trailing slash => version the content |
210 |
# No trailing slash => version the directory itself |
211 |
local paths=( |
212 |
/usr/bin/ |
213 |
/usr/$(get_libdir)/llvm |
214 |
/usr/include/ |
215 |
/usr/share/clang |
216 |
/usr/share/man/man1/ |
217 |
) |
218 |
|
219 |
local path |
220 |
for path in "${paths[@]}" ; do |
221 |
make_versioned "${path}" |
222 |
done |
223 |
|
224 |
python_doscript_versioned() { |
225 |
local path="$1" |
226 |
local file=$(basename "${path}") |
227 |
|
228 |
python_newscript "${path}" $(with_slot_suffix "${file}") |
229 |
|
230 |
local scriptroot=${python_scriptroot:-${DESTTREE%/}/bin} |
231 |
echo "${scriptroot%/}/${file}" >> "${eselect_dir}/versioned" |
232 |
} |
233 |
|
144 |
python_inst() { |
234 |
python_inst() { |
145 |
if use static-analyzer ; then |
235 |
if use static-analyzer ; then |
146 |
pushd tools/scan-view >/dev/null || die |
236 |
pushd tools/scan-view >/dev/null || die |
147 |
|
237 |
|
148 |
python_doscript scan-view |
238 |
python_doscript_versioned scan-view |
149 |
|
239 |
|
150 |
touch __init__.py || die |
240 |
touch __init__.py || die |
151 |
python_moduleinto clang |
241 |
python_moduleinto clang |
Lines 163-193
src_install() {
Link Here
|
163 |
popd >/dev/null || die |
253 |
popd >/dev/null || die |
164 |
fi |
254 |
fi |
165 |
|
255 |
|
|
|
256 |
use static-analyzer || use python && \ |
257 |
make_versioned "$(python_get_sitedir)/clang" |
258 |
|
166 |
# AddressSanitizer symbolizer (currently separate) |
259 |
# AddressSanitizer symbolizer (currently separate) |
167 |
python_doscript "${S}"/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py |
260 |
python_doscript_versioned "${S}"/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py |
168 |
} |
261 |
} |
169 |
python_foreach_impl python_inst |
262 |
python_foreach_impl python_inst |
170 |
|
263 |
|
|
|
264 |
install_symlinks() { |
265 |
local dir=${ED%/}/${1#/} |
266 |
local category=$(basename "${dir}") |
267 |
local symlink_dir=${ED%/}/usr/$(get_libdir)/llvm-${SLOT}/${category} |
268 |
mkdir ${symlink_dir} |
269 |
|
270 |
local output |
271 |
for output in $(grep $1 ${eselect_dir}/versioned) ; do |
272 |
ln -s $(with_slot_suffix ${output}) ${symlink_dir%/}/$(basename ${output}) |
273 |
done |
274 |
} |
275 |
|
276 |
# Expose clang binaries and includes to llvm-config |
277 |
install_symlinks /usr/bin/ |
278 |
install_symlinks /usr/include/ |
279 |
|
171 |
# Fix install_names on Darwin. The build system is too complicated |
280 |
# Fix install_names on Darwin. The build system is too complicated |
172 |
# to just fix this, so we correct it post-install |
281 |
# to just fix this, so we correct it post-install |
173 |
if [[ ${CHOST} == *-darwin* ]] ; then |
282 |
if [[ ${CHOST} == *-darwin* ]] ; then |
174 |
for lib in libclang.dylib ; do |
283 |
for lib in libclang.dylib ; do |
175 |
ebegin "fixing install_name of $lib" |
284 |
ebegin "fixing install_name of $lib" |
176 |
install_name_tool -id "${EPREFIX}"/usr/lib/llvm/${lib} \ |
285 |
install_name_tool -id "${EPREFIX}"/usr/lib/llvm-${SLOT}/${lib} \ |
177 |
"${ED}"/usr/lib/llvm/${lib} |
286 |
"${ED}"/usr/lib/llvm-${SLOT}/${lib} |
178 |
eend $? |
287 |
eend $? |
179 |
done |
288 |
done |
180 |
for f in usr/bin/{c-index-test,clang} usr/lib/llvm/libclang.dylib ; do |
289 |
for f in usr/bin/{c-index-test,clang} usr/lib/llvm-${SLOT}/libclang.dylib ; do |
181 |
ebegin "fixing references in ${f##*/}" |
290 |
ebegin "fixing references in ${f##*/}" |
182 |
install_name_tool \ |
291 |
install_name_tool \ |
183 |
-change "@rpath/libclang.dylib" \ |
292 |
-change "@rpath/libclang.dylib" \ |
184 |
"${EPREFIX}"/usr/lib/llvm/libclang.dylib \ |
293 |
"${EPREFIX}"/usr/lib/llvm-${SLOT}/libclang.dylib \ |
185 |
-change "@executable_path/../lib/libLLVM-${PV}.dylib" \ |
294 |
-change "@executable_path/../lib/libLLVM-${PV}.dylib" \ |
186 |
"${EPREFIX}"/usr/lib/llvm/libLLVM-${PV}.dylib \ |
295 |
"${EPREFIX}"/usr/lib/llvm-${SLOT}/libLLVM-${PV}.dylib \ |
187 |
-change "${S}"/Release/lib/libclang.dylib \ |
296 |
-change "${S}"/Release/lib/libclang.dylib \ |
188 |
"${EPREFIX}"/usr/lib/llvm/libclang.dylib \ |
297 |
"${EPREFIX}"/usr/lib/llvm-${SLOT}/libclang.dylib \ |
189 |
"${ED}"/$f |
298 |
"${ED}"/$f |
190 |
eend $? |
299 |
eend $? |
191 |
done |
300 |
done |
192 |
fi |
301 |
fi |
193 |
} |
302 |
} |
|
|
303 |
|
304 |
pkg_postinst() { |
305 |
if [[ $(eselect ${PN} show) = "(none)" ]] ; then |
306 |
eselect ${PN} set ${SLOT} |
307 |
fi |
308 |
} |
309 |
|
310 |
pkg_prerm() { |
311 |
if [[ $(eselect ${PN} show) = ${SLOT} ]] ; then |
312 |
eselect ${PN} clear |
313 |
fi |
314 |
} |
315 |
|
316 |
pkg_postrm() { |
317 |
if [[ -z ${REPLACED_BY_VERSION} ]] ; then |
318 |
eselect ${PN} update |
319 |
fi |
320 |
} |