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-${PV}[debug=,multitarget=] |
|
|
24 |
app-admin/eselect-clang |
24 |
${PYTHON_DEPS}" |
25 |
${PYTHON_DEPS}" |
25 |
|
26 |
|
26 |
S="${WORKDIR}/llvm" |
27 |
S="${WORKDIR}/llvm" |
Lines 51-57
src_prepare() {
Link Here
|
51 |
-i tools/clang/tools/scan-build/scan-build \ |
52 |
-i tools/clang/tools/scan-build/scan-build \ |
52 |
|| die "scan-build sed failed" |
53 |
|| die "scan-build sed failed" |
53 |
# Set correct path for gold plugin |
54 |
# Set correct path for gold plugin |
54 |
sed -e "/LLVMgold.so/s#lib/#$(get_libdir)/llvm/#" \ |
55 |
sed -e "/LLVMgold.so/s#lib/#$(get_libdir)/llvm-${SLOT}/#" \ |
55 |
-i tools/clang/lib/Driver/Tools.cpp \ |
56 |
-i tools/clang/lib/Driver/Tools.cpp \ |
56 |
|| die "gold plugin path sed failed" |
57 |
|| die "gold plugin path sed failed" |
57 |
|
58 |
|
Lines 63-69
src_prepare() {
Link Here
|
63 |
-i Makefile.config.in || die "Makefile.config sed failed" |
64 |
-i Makefile.config.in || die "Makefile.config sed failed" |
64 |
|
65 |
|
65 |
einfo "Fixing rpath and CFLAGS" |
66 |
einfo "Fixing rpath and CFLAGS" |
66 |
sed -e 's,\$(RPATH) -Wl\,\$(\(ToolDir\|LibDir\)),$(RPATH) -Wl\,'"${EPREFIX}"/usr/$(get_libdir)/llvm, \ |
67 |
sed -e "s@\$(RPATH) -Wl,'\$\$ORIGIN/../lib'@\$(RPATH) -Wl,'${EPREFIX}/usr/$(get_libdir)/llvm-${SLOT}'@" \ |
67 |
-e '/OmitFramePointer/s/-fomit-frame-pointer//' \ |
68 |
-e '/OmitFramePointer/s/-fomit-frame-pointer//' \ |
68 |
-i Makefile.rules || die "rpath sed failed" |
69 |
-i Makefile.rules || die "rpath sed failed" |
69 |
|
70 |
|
Lines 135-145
src_install() {
Link Here
|
135 |
doins tools/scan-build/sorttable.js |
136 |
doins tools/scan-build/sorttable.js |
136 |
fi |
137 |
fi |
137 |
|
138 |
|
|
|
139 |
# Register slot for app-admin/eselect-clang |
140 |
local eselect_dir="/usr/share/eselect-clang/slots/${SLOT}" |
141 |
dodir "${eselect_dir}" |
142 |
eselect_dir="${ED}/${eselect_dir}" |
143 |
echo "${CATEGORY}/${PF}" > "${eselect_dir}/ebuild" |
144 |
|
145 |
with_slot_suffix() { |
146 |
local file=$(echo "$1" | sed -e "s/-${SLOT}//") |
147 |
local ext="" |
148 |
if [[ "${file}" =~ \. ]] ; then |
149 |
ext=".${file#*.}" |
150 |
fi |
151 |
local base="${file%%.*}" |
152 |
echo "${base}-${SLOT}${ext}" |
153 |
} |
154 |
|
155 |
make_versioned() { |
156 |
local dir=$1 |
157 |
local candidates=(${ED%/}/${dir}) |
158 |
if [[ ! ${dir##*/} ]] ; then |
159 |
dir=${dir%/} |
160 |
candidates=( "${candidates}"* ) |
161 |
else |
162 |
dir=$(dirname "${dir}") |
163 |
fi |
164 |
|
165 |
pushd ${ED%/}/${dir} >/dev/null || die |
166 |
|
167 |
local candidate |
168 |
for candidate in "${candidates[@]}" ; do |
169 |
if [[ -h "${candidate}" ]] ; then |
170 |
# Add slot suffix to symlink target |
171 |
local target=$(readlink -s "${candidate}") |
172 |
local slotted_target=$(with_slot_suffix "${target}") |
173 |
if [[ -e "${target}" ]] || [[ -e "${slotted_target}" ]] ; then |
174 |
ln -sf "${slotted_target}" "${candidate}" \ |
175 |
|| die "Could not update symlink" |
176 |
fi |
177 |
fi |
178 |
|
179 |
local base_name=$(basename "${candidate}") |
180 |
local slotted_name=$(with_slot_suffix "${base_name}") |
181 |
mv "${candidate}" "${ED}/${dir}/${slotted_name}" \ |
182 |
|| die "Could not rename ${candidate} to ${slotted_name}" |
183 |
echo "/${dir#/}/${base_name}" >> "${eselect_dir}/versioned" |
184 |
done |
185 |
|
186 |
popd >/dev/null || die |
187 |
} |
188 |
|
189 |
# Trailing slash => version the content |
190 |
# No trailing slash => version the directory itself |
191 |
local paths=( |
192 |
/usr/bin/ |
193 |
/usr/$(get_libdir)/llvm |
194 |
/usr/include/ |
195 |
/usr/share/clang |
196 |
/usr/share/man/man1/ |
197 |
) |
198 |
|
199 |
local path |
200 |
for path in "${paths[@]}" ; do |
201 |
make_versioned "${path}" |
202 |
done |
203 |
|
204 |
python_doscript_versioned() { |
205 |
local path="$1" |
206 |
local file=$(basename "${path}") |
207 |
|
208 |
python_newscript "${path}" $(with_slot_suffix "${file}") |
209 |
|
210 |
local scriptroot=${python_scriptroot:-${DESTTREE%/}/bin} |
211 |
echo "${scriptroot%/}/${file}" >> "${eselect_dir}/versioned" |
212 |
} |
213 |
|
138 |
python_inst() { |
214 |
python_inst() { |
139 |
if use static-analyzer ; then |
215 |
if use static-analyzer ; then |
140 |
pushd tools/scan-view >/dev/null || die |
216 |
pushd tools/scan-view >/dev/null || die |
141 |
|
217 |
|
142 |
python_doscript scan-view |
218 |
python_doscript_versioned scan-view |
143 |
|
219 |
|
144 |
touch __init__.py || die |
220 |
touch __init__.py || die |
145 |
python_moduleinto clang |
221 |
python_moduleinto clang |
Lines 157-164
src_install() {
Link Here
|
157 |
popd >/dev/null || die |
233 |
popd >/dev/null || die |
158 |
fi |
234 |
fi |
159 |
|
235 |
|
|
|
236 |
use static-analyzer || use python && \ |
237 |
make_versioned "$(python_get_sitedir)/clang" |
238 |
|
160 |
# AddressSanitizer symbolizer (currently separate) |
239 |
# AddressSanitizer symbolizer (currently separate) |
161 |
python_doscript "${S}"/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py |
240 |
python_doscript_versioned "${S}"/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py |
162 |
} |
241 |
} |
163 |
python_foreach_impl python_inst |
242 |
python_foreach_impl python_inst |
164 |
|
243 |
|
Lines 167-187
src_install() {
Link Here
|
167 |
if [[ ${CHOST} == *-darwin* ]] ; then |
246 |
if [[ ${CHOST} == *-darwin* ]] ; then |
168 |
for lib in libclang.dylib ; do |
247 |
for lib in libclang.dylib ; do |
169 |
ebegin "fixing install_name of $lib" |
248 |
ebegin "fixing install_name of $lib" |
170 |
install_name_tool -id "${EPREFIX}"/usr/lib/llvm/${lib} \ |
249 |
install_name_tool -id "${EPREFIX}"/usr/lib/llvm-${SLOT}/${lib} \ |
171 |
"${ED}"/usr/lib/llvm/${lib} |
250 |
"${ED}"/usr/lib/llvm-${SLOT}/${lib} |
172 |
eend $? |
251 |
eend $? |
173 |
done |
252 |
done |
174 |
for f in usr/bin/{c-index-test,clang} usr/lib/llvm/libclang.dylib ; do |
253 |
for f in usr/bin/{c-index-test,clang} usr/lib/llvm-${SLOT}/libclang.dylib ; do |
175 |
ebegin "fixing references in ${f##*/}" |
254 |
ebegin "fixing references in ${f##*/}" |
176 |
install_name_tool \ |
255 |
install_name_tool \ |
177 |
-change "@rpath/libclang.dylib" \ |
256 |
-change "@rpath/libclang.dylib" \ |
178 |
"${EPREFIX}"/usr/lib/llvm/libclang.dylib \ |
257 |
"${EPREFIX}"/usr/lib/llvm-${SLOT}/libclang.dylib \ |
179 |
-change "@executable_path/../lib/libLLVM-${PV}.dylib" \ |
258 |
-change "@executable_path/../lib/libLLVM-${PV}.dylib" \ |
180 |
"${EPREFIX}"/usr/lib/llvm/libLLVM-${PV}.dylib \ |
259 |
"${EPREFIX}"/usr/lib/llvm-${SLOT}/libLLVM-${PV}.dylib \ |
181 |
-change "${S}"/Release/lib/libclang.dylib \ |
260 |
-change "${S}"/Release/lib/libclang.dylib \ |
182 |
"${EPREFIX}"/usr/lib/llvm/libclang.dylib \ |
261 |
"${EPREFIX}"/usr/lib/llvm-${SLOT}/libclang.dylib \ |
183 |
"${ED}"/$f |
262 |
"${ED}"/$f |
184 |
eend $? |
263 |
eend $? |
185 |
done |
264 |
done |
186 |
fi |
265 |
fi |
187 |
} |
266 |
} |
|
|
267 |
|
268 |
pkg_postinst() { |
269 |
if [[ $(eselect ${PN} show) = "(none)" ]] ; then |
270 |
eselect ${PN} set ${SLOT} |
271 |
fi |
272 |
} |
273 |
|
274 |
pkg_prerm() { |
275 |
if [[ $(eselect ${PN} show) = ${SLOT} ]] ; then |
276 |
eselect ${PN} clear |
277 |
fi |
278 |
} |
279 |
|
280 |
pkg_postrm() { |
281 |
if [[ -z ${REPLACED_BY_VERSION} ]] ; then |
282 |
eselect ${PN} update |
283 |
fi |
284 |
} |