Lines 16-28
SRC_URI="http://llvm.org/releases/${PV}/llvm-${PV}.tgz
Link Here
|
16 |
http://llvm.org/releases/${PV}/${P}.tgz" |
16 |
http://llvm.org/releases/${PV}/${P}.tgz" |
17 |
|
17 |
|
18 |
LICENSE="UoI-NCSA" |
18 |
LICENSE="UoI-NCSA" |
19 |
SLOT="0" |
19 |
SLOT="${PV}" |
20 |
KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux ~ppc-macos" |
20 |
KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux ~ppc-macos" |
21 |
IUSE="debug multitarget +static-analyzer +system-cxx-headers test" |
21 |
IUSE="debug multitarget +static-analyzer +system-cxx-headers test" |
22 |
|
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 |
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 )" |
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}" |
28 |
S="${WORKDIR}/llvm-${PV}" |
28 |
|
29 |
|
Lines 65-71
src_prepare() {
Link Here
|
65 |
-i Makefile.config.in || die "Makefile.config sed failed" |
66 |
-i Makefile.config.in || die "Makefile.config sed failed" |
66 |
|
67 |
|
67 |
einfo "Fixing rpath and CFLAGS" |
68 |
einfo "Fixing rpath and CFLAGS" |
68 |
sed -e 's,\$(RPATH) -Wl\,\$(\(ToolDir\|LibDir\)),$(RPATH) -Wl\,'"${EPREFIX}"/usr/$(get_libdir)/llvm, \ |
69 |
sed -e "s@\$(RPATH) -Wl,\$(\(ToolDir\|LibDir\))@\$(RPATH) -Wl,'${EPREFIX}/usr/$(get_libdir)/llvm-${SLOT}'@" \ |
69 |
-e '/OmitFramePointer/s/-fomit-frame-pointer//' \ |
70 |
-e '/OmitFramePointer/s/-fomit-frame-pointer//' \ |
70 |
-i Makefile.rules || die "rpath sed failed" |
71 |
-i Makefile.rules || die "rpath sed failed" |
71 |
} |
72 |
} |
Lines 142-151
src_install() {
Link Here
|
142 |
|
143 |
|
143 |
cd tools/scan-view || die "cd scan-view failed" |
144 |
cd tools/scan-view || die "cd scan-view failed" |
144 |
dobin scan-view |
145 |
dobin scan-view |
|
|
146 |
fi |
147 |
|
148 |
# Register slot for app-admin/eselect-clang |
149 |
local eselect_dir="/usr/share/eselect-clang/slots/${SLOT}" |
150 |
dodir "${eselect_dir}" |
151 |
eselect_dir="${ED}/${eselect_dir}" |
152 |
echo "${CATEGORY}/${PF}" > "${eselect_dir}/ebuild" |
153 |
|
154 |
with_slot_suffix() { |
155 |
local file=$(echo "$1" | sed -e "s/-${SLOT}//") |
156 |
local ext="" |
157 |
if [[ "${file}" =~ \. ]] ; then |
158 |
ext=".${file#*.}" |
159 |
fi |
160 |
local base="${file%%.*}" |
161 |
echo "${base}-${SLOT}${ext}" |
162 |
} |
163 |
|
164 |
make_versioned() { |
165 |
local dir=$1 |
166 |
local candidates=(${ED%/}/${dir}) |
167 |
if [[ ! ${dir##*/} ]] ; then |
168 |
dir=${dir%/} |
169 |
candidates=( "${candidates}"* ) |
170 |
else |
171 |
dir=$(dirname "${dir}") |
172 |
fi |
173 |
|
174 |
pushd ${ED%/}/${dir} >/dev/null || die |
175 |
|
176 |
local candidate |
177 |
for candidate in "${candidates[@]}" ; do |
178 |
if [[ -h "${candidate}" ]] ; then |
179 |
# Add slot suffix to symlink target |
180 |
local target=$(readlink -s "${candidate}") |
181 |
local slotted_target=$(with_slot_suffix "${target}") |
182 |
if [[ -e "${target}" ]] || [[ -e "${slotted_target}" ]] ; then |
183 |
ln -sf "${slotted_target}" "${candidate}" \ |
184 |
|| die "Could not update symlink" |
185 |
fi |
186 |
fi |
187 |
|
188 |
local base_name=$(basename "${candidate}") |
189 |
local slotted_name=$(with_slot_suffix "${base_name}") |
190 |
mv "${candidate}" "${ED}/${dir}/${slotted_name}" \ |
191 |
|| die "Could not rename ${candidate} to ${slotted_name}" |
192 |
echo "/${dir#/}/${base_name}" >> "${eselect_dir}/versioned" |
193 |
done |
194 |
|
195 |
popd >/dev/null || die |
196 |
} |
197 |
|
198 |
# Trailing slash => version the content |
199 |
# No trailing slash => version the directory itself |
200 |
local paths=( |
201 |
/usr/bin/ |
202 |
/usr/$(get_libdir)/llvm |
203 |
/usr/include/ |
204 |
/usr/share/clang |
205 |
/usr/share/man/man1/ |
206 |
) |
207 |
|
208 |
local path |
209 |
for path in "${paths[@]}" ; do |
210 |
make_versioned "${path}" |
211 |
done |
212 |
|
213 |
if use static-analyzer ; then |
214 |
cd "${S}"/tools/clang/tools/scan-view || die "cd scan-view failed" |
215 |
|
145 |
install-scan-view() { |
216 |
install-scan-view() { |
146 |
insinto "$(python_get_sitedir)"/clang |
217 |
insinto "$(python_get_sitedir)"/clang |
147 |
doins Reporter.py Resources ScanView.py startfile.py |
218 |
doins Reporter.py Resources ScanView.py startfile.py |
148 |
touch "${ED}"/"$(python_get_sitedir)"/clang/__init__.py |
219 |
touch "${ED}"/"$(python_get_sitedir)"/clang/__init__.py |
|
|
220 |
make_versioned "$(python_get_sitedir)/clang" |
149 |
} |
221 |
} |
150 |
python_execute_function install-scan-view |
222 |
python_execute_function install-scan-view |
151 |
fi |
223 |
fi |
Lines 175-181
src_install() {
Link Here
|
175 |
} |
247 |
} |
176 |
|
248 |
|
177 |
pkg_postinst() { |
249 |
pkg_postinst() { |
178 |
python_mod_optimize clang |
250 |
python_mod_optimize clang-${SLOT} |
|
|
251 |
|
252 |
if [[ $(eselect ${PN} show) = "(none)" ]] ; then |
253 |
eselect ${PN} set ${SLOT} |
254 |
fi |
255 |
|
179 |
if use system-cxx-headers; then |
256 |
if use system-cxx-headers; then |
180 |
elog "C++ headers search path is hardcoded to the active gcc profile one" |
257 |
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," |
258 |
elog "If you change the active gcc profile, or update gcc to a new version," |
Lines 187-192
pkg_postinst() {
Link Here
|
187 |
fi |
264 |
fi |
188 |
} |
265 |
} |
189 |
|
266 |
|
|
|
267 |
pkg_prerm() { |
268 |
if [[ $(eselect ${PN} show) = ${SLOT} ]] ; then |
269 |
eselect ${PN} clear |
270 |
fi |
271 |
} |
272 |
|
190 |
pkg_postrm() { |
273 |
pkg_postrm() { |
191 |
python_mod_cleanup clang |
274 |
python_mod_cleanup clang-${SLOT} |
|
|
275 |
|
276 |
if [[ -z ${REPLACED_BY_VERSION} ]] ; then |
277 |
eselect ${PN} update |
278 |
fi |
192 |
} |
279 |
} |