Lines 17-28
SRC_URI="http://llvm.org/releases/${PV}/llvm-${PV}.src.tar.gz
Link Here
|
17 |
http://llvm.org/releases/${PV}/${P}.src.tar.gz" |
17 |
http://llvm.org/releases/${PV}/${P}.src.tar.gz" |
18 |
|
18 |
|
19 |
LICENSE="UoI-NCSA" |
19 |
LICENSE="UoI-NCSA" |
20 |
SLOT="0" |
20 |
SLOT="${PV}" |
21 |
KEYWORDS="~amd64 ~arm ~x86 ~amd64-fbsd ~x64-freebsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos" |
21 |
KEYWORDS="~amd64 ~arm ~x86 ~amd64-fbsd ~x64-freebsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos" |
22 |
IUSE="debug kernel_FreeBSD multitarget +static-analyzer test" |
22 |
IUSE="debug kernel_FreeBSD multitarget +static-analyzer test" |
23 |
|
23 |
|
24 |
DEPEND="static-analyzer? ( dev-lang/perl )" |
24 |
DEPEND="static-analyzer? ( dev-lang/perl )" |
25 |
RDEPEND="~sys-devel/llvm-${PV}[debug=,multitarget=]" |
25 |
RDEPEND="~sys-devel/llvm-${PV}[debug=,multitarget=] |
|
|
26 |
app-admin/eselect-clang" |
26 |
|
27 |
|
27 |
S=${WORKDIR}/llvm-${PV}.src |
28 |
S=${WORKDIR}/llvm-${PV}.src |
28 |
|
29 |
|
Lines 50-56
src_prepare() {
Link Here
|
50 |
-i tools/clang/tools/scan-build/scan-build \ |
51 |
-i tools/clang/tools/scan-build/scan-build \ |
51 |
|| die "scan-build sed failed" |
52 |
|| die "scan-build sed failed" |
52 |
# Set correct path for gold plugin |
53 |
# Set correct path for gold plugin |
53 |
sed -e "/LLVMgold.so/s#lib/#$(get_libdir)/llvm/#" \ |
54 |
sed -e "/LLVMgold.so/s#lib/#$(get_libdir)/llvm-${SLOT}/#" \ |
54 |
-i tools/clang/lib/Driver/Tools.cpp \ |
55 |
-i tools/clang/lib/Driver/Tools.cpp \ |
55 |
|| die "gold plugin path sed failed" |
56 |
|| die "gold plugin path sed failed" |
56 |
# Specify python version |
57 |
# Specify python version |
Lines 66-72
src_prepare() {
Link Here
|
66 |
-i Makefile.config.in || die "Makefile.config sed failed" |
67 |
-i Makefile.config.in || die "Makefile.config sed failed" |
67 |
|
68 |
|
68 |
einfo "Fixing rpath and CFLAGS" |
69 |
einfo "Fixing rpath and CFLAGS" |
69 |
sed -e 's,\$(RPATH) -Wl\,\$(\(ToolDir\|LibDir\)),$(RPATH) -Wl\,'"${EPREFIX}"/usr/$(get_libdir)/llvm, \ |
70 |
sed -e "s@\$(RPATH) -Wl,\$(\(ToolDir\|LibDir\))@\$(RPATH) -Wl,'${EPREFIX}/usr/$(get_libdir)/llvm-${SLOT}'@" \ |
70 |
-e '/OmitFramePointer/s/-fomit-frame-pointer//' \ |
71 |
-e '/OmitFramePointer/s/-fomit-frame-pointer//' \ |
71 |
-i Makefile.rules || die "rpath sed failed" |
72 |
-i Makefile.rules || die "rpath sed failed" |
72 |
|
73 |
|
Lines 160-169
src_install() {
Link Here
|
160 |
|
161 |
|
161 |
cd tools/scan-view || die "cd scan-view failed" |
162 |
cd tools/scan-view || die "cd scan-view failed" |
162 |
dobin scan-view |
163 |
dobin scan-view |
|
|
164 |
fi |
165 |
|
166 |
# Register slot for app-admin/eselect-clang |
167 |
local eselect_dir="/usr/share/eselect-clang/slots/${SLOT}" |
168 |
dodir "${eselect_dir}" |
169 |
eselect_dir="${ED}/${eselect_dir}" |
170 |
echo "${CATEGORY}/${PF}" > "${eselect_dir}/ebuild" |
171 |
|
172 |
with_slot_suffix() { |
173 |
local file=$(echo "$1" | sed -e "s/-${SLOT}//") |
174 |
local ext="" |
175 |
if [[ "${file}" =~ \. ]] ; then |
176 |
ext=".${file#*.}" |
177 |
fi |
178 |
local base="${file%%.*}" |
179 |
echo "${base}-${SLOT}${ext}" |
180 |
} |
181 |
|
182 |
make_versioned() { |
183 |
local dir=$1 |
184 |
local candidates=(${ED%/}/${dir}) |
185 |
if [[ ! ${dir##*/} ]] ; then |
186 |
dir=${dir%/} |
187 |
candidates=( "${candidates}"* ) |
188 |
else |
189 |
dir=$(dirname "${dir}") |
190 |
fi |
191 |
|
192 |
pushd ${ED%/}/${dir} >/dev/null || die |
193 |
|
194 |
local candidate |
195 |
for candidate in "${candidates[@]}" ; do |
196 |
if [[ -h "${candidate}" ]] ; then |
197 |
# Add slot suffix to symlink target |
198 |
local target=$(readlink -s "${candidate}") |
199 |
local slotted_target=$(with_slot_suffix "${target}") |
200 |
if [[ -e "${target}" ]] || [[ -e "${slotted_target}" ]] ; then |
201 |
ln -sf "${slotted_target}" "${candidate}" \ |
202 |
|| die "Could not update symlink" |
203 |
fi |
204 |
fi |
205 |
|
206 |
local base_name=$(basename "${candidate}") |
207 |
local slotted_name=$(with_slot_suffix "${base_name}") |
208 |
mv "${candidate}" "${ED}/${dir}/${slotted_name}" \ |
209 |
|| die "Could not rename ${candidate} to ${slotted_name}" |
210 |
echo "/${dir#/}/${base_name}" >> "${eselect_dir}/versioned" |
211 |
done |
212 |
|
213 |
popd >/dev/null || die |
214 |
} |
215 |
|
216 |
# Trailing slash => version the content |
217 |
# No trailing slash => version the directory itself |
218 |
local paths=( |
219 |
/usr/bin/ |
220 |
/usr/$(get_libdir)/llvm |
221 |
/usr/include/ |
222 |
/usr/share/clang |
223 |
/usr/share/man/man1/ |
224 |
) |
225 |
|
226 |
local path |
227 |
for path in "${paths[@]}" ; do |
228 |
make_versioned "${path}" |
229 |
done |
230 |
|
231 |
if use static-analyzer ; then |
232 |
cd "${S}"/tools/clang/tools/scan-view || die "cd scan-view failed" |
233 |
|
163 |
install-scan-view() { |
234 |
install-scan-view() { |
164 |
insinto "$(python_get_sitedir)"/clang |
235 |
insinto "$(python_get_sitedir)"/clang |
165 |
doins Reporter.py Resources ScanView.py startfile.py |
236 |
doins Reporter.py Resources ScanView.py startfile.py |
166 |
touch "${ED}"/"$(python_get_sitedir)"/clang/__init__.py |
237 |
touch "${ED}"/"$(python_get_sitedir)"/clang/__init__.py |
|
|
238 |
make_versioned "$(python_get_sitedir)/clang" |
167 |
} |
239 |
} |
168 |
python_execute_function install-scan-view |
240 |
python_execute_function install-scan-view |
169 |
fi |
241 |
fi |
Lines 196-204
src_install() {
Link Here
|
196 |
} |
268 |
} |
197 |
|
269 |
|
198 |
pkg_postinst() { |
270 |
pkg_postinst() { |
199 |
python_mod_optimize clang |
271 |
python_mod_optimize clang-${SLOT} |
|
|
272 |
if [[ $(eselect ${PN} show) = "(none)" ]] ; then |
273 |
eselect ${PN} set ${SLOT} |
274 |
fi |
275 |
} |
276 |
|
277 |
pkg_prerm() { |
278 |
if [[ $(eselect ${PN} show) = ${SLOT} ]] ; then |
279 |
eselect ${PN} clear |
280 |
fi |
200 |
} |
281 |
} |
201 |
|
282 |
|
202 |
pkg_postrm() { |
283 |
pkg_postrm() { |
203 |
python_mod_cleanup clang |
284 |
python_mod_cleanup clang-${SLOT} |
|
|
285 |
if [[ -z ${REPLACED_BY_VERSION} ]] ; then |
286 |
eselect ${PN} update |
287 |
fi |
204 |
} |
288 |
} |