diff --git a/sys-devel/clang/clang-3.2.ebuild b/sys-devel/clang/clang-3.2.ebuild index 5a06209..47d0e3c 100644 --- a/sys-devel/clang/clang-3.2.ebuild +++ b/sys-devel/clang/clang-3.2.ebuild @@ -1,6 +1,6 @@ # Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/sys-devel/clang/clang-3.2.ebuild,v 1.6 2013/05/24 21:27:58 aballier Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-devel/clang/clang-3.2.ebuild,v 1.5 2013/02/04 08:50:49 mgorny Exp $ EAPI=5 @@ -16,13 +16,14 @@ SRC_URI="http://llvm.org/releases/${PV}/llvm-${PV}.src.tar.gz http://llvm.org/releases/${PV}/${P}.src.tar.gz" LICENSE="UoI-NCSA" -SLOT="0" -KEYWORDS="~amd64 ~arm ~x86 ~amd64-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos" +SLOT="${PV}" +KEYWORDS="~amd64 ~arm ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos" IUSE="debug kernel_FreeBSD multitarget python +static-analyzer test" DEPEND="static-analyzer? ( dev-lang/perl ) ${PYTHON_DEPS}" RDEPEND="~sys-devel/llvm-${PV}[debug=,multitarget=] + app-admin/eselect-clang ${PYTHON_DEPS}" S=${WORKDIR}/llvm-${PV}.src @@ -53,7 +54,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" @@ -65,7 +66,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" @@ -147,11 +148,86 @@ src_install() { doins tools/scan-build/sorttable.js 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 + + python_doscript_versioned() { + local path="$1" + local file=$(basename "${path}") + + python_newscript "${path}" $(with_slot_suffix "${file}") + + local scriptroot=${python_scriptroot:-${DESTTREE%/}/bin} + echo "${scriptroot%/}/${file}" >> "${eselect_dir}/versioned" + } + python_inst() { if use static-analyzer ; then pushd tools/scan-view >/dev/null || die - python_doscript scan-view + python_doscript_versioned scan-view touch __init__.py || die python_moduleinto clang @@ -169,8 +245,11 @@ src_install() { popd >/dev/null || die fi + use static-analyzer || use python && \ + make_versioned "$(python_get_sitedir)/clang" + # AddressSanitizer symbolizer (currently separate) - python_doscript "${S}"/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py + python_doscript_versioned "${S}"/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py } python_foreach_impl python_inst @@ -200,3 +279,21 @@ src_install() { # Remove unnecessary headers on FreeBSD, bug #417171 use kernel_FreeBSD && rm "${ED}"usr/$(get_libdir)/clang/${PV}/include/{arm_neon,std,float,iso,limits,tgmath,varargs}*.h } + +pkg_postinst() { + if [[ $(eselect ${PN} show) = "(none)" ]] ; then + eselect ${PN} set ${SLOT} + fi +} + +pkg_prerm() { + if [[ $(eselect ${PN} show) = ${SLOT} ]] ; then + eselect ${PN} clear + fi +} + +pkg_postrm() { + if [[ -z ${REPLACED_BY_VERSION} ]] ; then + eselect ${PN} update + fi +}