diff --git a/sys-devel/clang/clang-3.0-r4.ebuild b/sys-devel/clang/clang-3.0-r4.ebuild index 90230a0..741d710 100644 --- a/sys-devel/clang/clang-3.0-r4.ebuild +++ b/sys-devel/clang/clang-3.0-r4.ebuild @@ -16,12 +16,13 @@ SRC_URI="http://llvm.org/releases/${PV}/llvm-${PV}.tar.gz http://llvm.org/releases/${PV}/${P}.tar.gz" LICENSE="UoI-NCSA" -SLOT="0" +SLOT="${PV}" KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux ~ppc-macos" IUSE="debug kernel_FreeBSD multitarget +static-analyzer system-cxx-headers test" DEPEND="static-analyzer? ( dev-lang/perl )" -RDEPEND="~sys-devel/llvm-${PV}[debug=,multitarget=]" +RDEPEND="~sys-devel/llvm-${PV}[debug=,multitarget=] + app-admin/eselect-clang" S=${WORKDIR}/llvm-${PV}.src @@ -45,7 +46,7 @@ src_prepare() { -i tools/clang/tools/scan-build/scan-build \ || die "scan-build sed failed" # Set correct path for gold plugin - sed -e "/LLVMgold.so/s#lib/#$(get_libdir)/llvm/#" \ + sed -e "/LLVMgold.so/s#lib/#$(get_libdir)/llvm-${SLOT}/#" \ -i tools/clang/lib/Driver/Tools.cpp \ || die "gold plugin path sed failed" # Properly detect Gentoo's binutils-apple version (committed in trunk) @@ -62,7 +63,7 @@ src_prepare() { -i Makefile.config.in || die "Makefile.config sed failed" einfo "Fixing rpath and CFLAGS" - sed -e 's,\$(RPATH) -Wl\,\$(\(ToolDir\|LibDir\)),$(RPATH) -Wl\,'"${EPREFIX}"/usr/$(get_libdir)/llvm, \ + sed -e "s@\$(RPATH) -Wl,\$(\(ToolDir\|LibDir\))@\$(RPATH) -Wl,'${EPREFIX}/usr/$(get_libdir)/llvm-${SLOT}'@" \ -e '/OmitFramePointer/s/-fomit-frame-pointer//' \ -i Makefile.rules || die "rpath sed failed" @@ -160,10 +161,81 @@ src_install() { cd tools/scan-view || die "cd scan-view failed" dobin scan-view + fi + + # Register slot for app-admin/eselect-clang + local eselect_dir="/usr/share/eselect-clang/slots/${SLOT}" + dodir "${eselect_dir}" + eselect_dir="${ED}/${eselect_dir}" + echo "${CATEGORY}/${PF}" > "${eselect_dir}/ebuild" + + with_slot_suffix() { + local file=$(echo "$1" | sed -e "s/-${SLOT}//") + local ext="" + if [[ "${file}" =~ \. ]] ; then + ext=".${file#*.}" + fi + local base="${file%%.*}" + echo "${base}-${SLOT}${ext}" + } + + make_versioned() { + local dir=$1 + local candidates=(${ED%/}/${dir}) + if [[ ! ${dir##*/} ]] ; then + dir=${dir%/} + candidates=( "${candidates}"* ) + else + dir=$(dirname "${dir}") + fi + + pushd ${ED%/}/${dir} >/dev/null || die + + local candidate + for candidate in "${candidates[@]}" ; do + if [[ -h "${candidate}" ]] ; then + # Add slot suffix to symlink target + local target=$(readlink -s "${candidate}") + local slotted_target=$(with_slot_suffix "${target}") + if [[ -e "${target}" ]] || [[ -e "${slotted_target}" ]] ; then + ln -sf "${slotted_target}" "${candidate}" \ + || die "Could not update symlink" + fi + fi + + local base_name=$(basename "${candidate}") + local slotted_name=$(with_slot_suffix "${base_name}") + mv "${candidate}" "${ED}/${dir}/${slotted_name}" \ + || die "Could not rename ${candidate} to ${slotted_name}" + echo "/${dir#/}/${base_name}" >> "${eselect_dir}/versioned" + done + + popd >/dev/null || die + } + + # Trailing slash => version the content + # No trailing slash => version the directory itself + local paths=( + /usr/bin/ + /usr/$(get_libdir)/llvm + /usr/include/ + /usr/share/clang + /usr/share/man/man1/ + ) + + local path + for path in "${paths[@]}" ; do + make_versioned "${path}" + done + + if use static-analyzer ; then + cd "${S}"/tools/clang/tools/scan-view || die "cd scan-view failed" + install-scan-view() { insinto "$(python_get_sitedir)"/clang doins Reporter.py Resources ScanView.py startfile.py touch "${ED}"/"$(python_get_sitedir)"/clang/__init__.py + make_versioned "$(python_get_sitedir)/clang" } python_execute_function install-scan-view fi @@ -196,7 +268,12 @@ src_install() { } pkg_postinst() { - python_mod_optimize clang + python_mod_optimize clang-${SLOT} + + if [[ $(eselect ${PN} show) = "(none)" ]] ; then + eselect ${PN} set ${SLOT} + fi + if use system-cxx-headers; then elog "C++ headers search path is hardcoded to the active gcc profile one" elog "If you change the active gcc profile, or update gcc to a new version," @@ -208,6 +285,16 @@ pkg_postinst() { fi } +pkg_prerm() { + if [[ $(eselect ${PN} show) = ${SLOT} ]] ; then + eselect ${PN} clear + fi +} + pkg_postrm() { - python_mod_cleanup clang + python_mod_cleanup clang-${SLOT} + + if [[ -z ${REPLACED_BY_VERSION} ]] ; then + eselect ${PN} update + fi }