| 1 |
# Copyright 1999-2011 Gentoo Foundation
|
| 2 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
# $Header: /var/cvsroot/gentoo-x86/sys-devel/clang/clang-3.0_rc3.ebuild,v 1.3 2011/11/14 15:02:31 voyageur Exp $
|
| 4 |
|
| 5 |
EAPI=3
|
| 6 |
|
| 7 |
RESTRICT_PYTHON_ABIS="3.*"
|
| 8 |
SUPPORT_PYTHON_ABIS="1"
|
| 9 |
|
| 10 |
inherit eutils multilib python
|
| 11 |
|
| 12 |
DESCRIPTION="C language family frontend for LLVM"
|
| 13 |
HOMEPAGE="http://clang.llvm.org/"
|
| 14 |
# Fetching LLVM as well: see http://llvm.org/bugs/show_bug.cgi?id=4840
|
| 15 |
SRC_URI="http://llvm.org/pre-releases/${PV/_rc*}/${PV/3.0_}/llvm-${PV/_}.src.tar.gz
|
| 16 |
http://llvm.org/pre-releases/${PV/_rc*}/${PV/3.0_}/${P/_}.src.tar.gz"
|
| 17 |
|
| 18 |
LICENSE="UoI-NCSA"
|
| 19 |
SLOT="0"
|
| 20 |
KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux ~ppc-macos"
|
| 21 |
IUSE="debug multitarget +static-analyzer +system-cxx-headers test"
|
| 22 |
|
| 23 |
DEPEND="static-analyzer? ( dev-lang/perl )"
|
| 24 |
RDEPEND="~sys-devel/llvm-${PV}[multitarget=]"
|
| 25 |
|
| 26 |
S=${WORKDIR}/llvm-${PV/_}.src
|
| 27 |
|
| 28 |
src_prepare() {
|
| 29 |
rm -f "${S}"/tools/clang
|
| 30 |
mv "${WORKDIR}"/clang-${PV/_}.src "${S}"/tools/clang || die "clang source directory move failed"
|
| 31 |
|
| 32 |
# Same as llvm doc patches
|
| 33 |
epatch "${FILESDIR}"/${PN}-2.7-fixdoc.patch
|
| 34 |
|
| 35 |
# multilib-strict
|
| 36 |
sed -e "/PROJ_headers/s#lib/clang#$(get_libdir)/clang#" \
|
| 37 |
-i tools/clang/lib/Headers/Makefile \
|
| 38 |
|| die "clang Makefile failed"
|
| 39 |
# Fix cxx_include_root path for Gentoo
|
| 40 |
epatch "${FILESDIR}"/${P/_*}-fix_cxx_include_root.patch
|
| 41 |
# fix the static analyzer for in-tree install
|
| 42 |
sed -e 's/import ScanView/from clang \0/' \
|
| 43 |
-i tools/clang/tools/scan-view/scan-view \
|
| 44 |
|| die "scan-view sed failed"
|
| 45 |
sed -e "/scanview.css\|sorttable.js/s#\$RealBin#${EPREFIX}/usr/share/${PN}#" \
|
| 46 |
-i tools/clang/tools/scan-build/scan-build \
|
| 47 |
|| die "scan-build sed failed"
|
| 48 |
# Specify python version
|
| 49 |
python_convert_shebangs 2 tools/clang/tools/scan-view/scan-view
|
| 50 |
|
| 51 |
# From llvm src_prepare
|
| 52 |
einfo "Fixing install dirs"
|
| 53 |
sed -e 's,^PROJ_docsdir.*,PROJ_docsdir := $(PROJ_prefix)/share/doc/'${PF}, \
|
| 54 |
-e 's,^PROJ_etcdir.*,PROJ_etcdir := '"${EPREFIX}"'/etc/llvm,' \
|
| 55 |
-e 's,^PROJ_libdir.*,PROJ_libdir := $(PROJ_prefix)/'$(get_libdir)/llvm, \
|
| 56 |
-i Makefile.config.in || die "Makefile.config sed failed"
|
| 57 |
|
| 58 |
einfo "Fixing rpath and CFLAGS"
|
| 59 |
sed -e 's,\$(RPATH) -Wl\,\$(\(ToolDir\|LibDir\)),$(RPATH) -Wl\,'"${EPREFIX}"/usr/$(get_libdir)/llvm, \
|
| 60 |
-e '/OmitFramePointer/s/-fomit-frame-pointer//' \
|
| 61 |
-i Makefile.rules || die "rpath sed failed"
|
| 62 |
}
|
| 63 |
|
| 64 |
src_configure() {
|
| 65 |
local CONF_FLAGS="--enable-shared
|
| 66 |
--with-optimize-option=
|
| 67 |
$(use_enable !debug optimized)
|
| 68 |
$(use_enable debug assertions)
|
| 69 |
$(use_enable debug expensive-checks)"
|
| 70 |
|
| 71 |
# Setup the search path to include the Prefix includes
|
| 72 |
if use prefix ; then
|
| 73 |
CONF_FLAGS="${CONF_FLAGS} \
|
| 74 |
--with-c-include-dirs=${EPREFIX}/usr/include:/usr/include"
|
| 75 |
fi
|
| 76 |
|
| 77 |
if use multitarget; then
|
| 78 |
CONF_FLAGS="${CONF_FLAGS} --enable-targets=all"
|
| 79 |
else
|
| 80 |
CONF_FLAGS="${CONF_FLAGS} --enable-targets=host-only"
|
| 81 |
fi
|
| 82 |
|
| 83 |
if use amd64; then
|
| 84 |
CONF_FLAGS="${CONF_FLAGS} --enable-pic"
|
| 85 |
fi
|
| 86 |
|
| 87 |
if use system-cxx-headers; then
|
| 88 |
# Try to get current gcc headers path
|
| 89 |
local CXX_PATH=$(gcc-config -L| cut -d: -f1)
|
| 90 |
CONF_FLAGS="${CONF_FLAGS} --with-c-include-dirs=/usr/include:${CXX_PATH}/include"
|
| 91 |
CONF_FLAGS="${CONF_FLAGS} --with-cxx-include-root=${CXX_PATH}/include/g++-v4"
|
| 92 |
CONF_FLAGS="${CONF_FLAGS} --with-cxx-include-arch=$CHOST"
|
| 93 |
if has_multilib_profile; then
|
| 94 |
CONF_FLAGS="${CONF_FLAGS} --with-cxx-include-32bit-dir=32"
|
| 95 |
fi
|
| 96 |
fi
|
| 97 |
|
| 98 |
econf ${CONF_FLAGS} || die "econf failed"
|
| 99 |
}
|
| 100 |
|
| 101 |
src_compile() {
|
| 102 |
local COMPILE_TARGET
|
| 103 |
if use test; then
|
| 104 |
COMPILE_TARGET="all"
|
| 105 |
else
|
| 106 |
COMPILE_TARGET="clang-only"
|
| 107 |
fi
|
| 108 |
emake VERBOSE=1 KEEP_SYMBOLS=1 REQUIRES_RTTI=1 \
|
| 109 |
${COMPILE_TARGET} || die "emake failed"
|
| 110 |
}
|
| 111 |
|
| 112 |
src_test() {
|
| 113 |
cd "${S}"/test || die "cd failed"
|
| 114 |
emake site.exp || die "updating llvm site.exp failed"
|
| 115 |
|
| 116 |
cd "${S}"/tools/clang || die "cd clang failed"
|
| 117 |
|
| 118 |
# Broken test always assuming i386 host with multilib gcc 4.6.0
|
| 119 |
# http://llvm.org/bugs/show_bug.cgi?id=11094
|
| 120 |
rm -f test/Driver/linux-ld.c
|
| 121 |
|
| 122 |
echo ">>> Test phase [test]: ${CATEGORY}/${PF}"
|
| 123 |
if ! emake -j1 VERBOSE=1 test; then
|
| 124 |
has test $FEATURES && die "Make test failed. See above for details."
|
| 125 |
has test $FEATURES || eerror "Make test failed. See above for details."
|
| 126 |
fi
|
| 127 |
}
|
| 128 |
|
| 129 |
src_install() {
|
| 130 |
cd "${S}"/tools/clang || die "cd clang failed"
|
| 131 |
emake KEEP_SYMBOLS=1 DESTDIR="${D}" install || die "install failed"
|
| 132 |
|
| 133 |
if use static-analyzer ; then
|
| 134 |
dobin tools/scan-build/ccc-analyzer
|
| 135 |
dosym ccc-analyzer /usr/bin/c++-analyzer
|
| 136 |
dobin tools/scan-build/scan-build
|
| 137 |
|
| 138 |
insinto /usr/share/${PN}
|
| 139 |
doins tools/scan-build/scanview.css
|
| 140 |
doins tools/scan-build/sorttable.js
|
| 141 |
|
| 142 |
cd tools/scan-view || die "cd scan-view failed"
|
| 143 |
dobin scan-view
|
| 144 |
install-scan-view() {
|
| 145 |
insinto "$(python_get_sitedir)"/clang
|
| 146 |
doins Reporter.py Resources ScanView.py startfile.py
|
| 147 |
touch "${ED}"/"$(python_get_sitedir)"/clang/__init__.py
|
| 148 |
}
|
| 149 |
python_execute_function install-scan-view
|
| 150 |
fi
|
| 151 |
|
| 152 |
# Fix install_names on Darwin. The build system is too complicated
|
| 153 |
# to just fix this, so we correct it post-install
|
| 154 |
if [[ ${CHOST} == *-darwin* ]] ; then
|
| 155 |
for lib in libclang.dylib ; do
|
| 156 |
ebegin "fixing install_name of $lib"
|
| 157 |
install_name_tool -id "${EPREFIX}"/usr/lib/llvm/${lib} \
|
| 158 |
"${ED}"/usr/lib/llvm/${lib}
|
| 159 |
eend $?
|
| 160 |
done
|
| 161 |
for f in usr/bin/{c-index-test,clang} usr/lib/llvm/libclang.dylib ; do
|
| 162 |
ebegin "fixing references in ${f##*/}"
|
| 163 |
install_name_tool \
|
| 164 |
-change "@rpath/libclang.dylib" \
|
| 165 |
"${EPREFIX}"/usr/lib/llvm/libclang.dylib \
|
| 166 |
-change "@executable_path/../lib/libLLVM-${PV}.dylib" \
|
| 167 |
"${EPREFIX}"/usr/lib/llvm/libLLVM-${PV}.dylib \
|
| 168 |
-change "${S}"/Release/lib/libclang.dylib \
|
| 169 |
"${EPREFIX}"/usr/lib/llvm/libclang.dylib \
|
| 170 |
"${ED}"/$f
|
| 171 |
eend $?
|
| 172 |
done
|
| 173 |
fi
|
| 174 |
}
|
| 175 |
|
| 176 |
pkg_postinst() {
|
| 177 |
python_mod_optimize clang
|
| 178 |
if use system-cxx-headers; then
|
| 179 |
elog "C++ headers search path is hardcoded to the active gcc profile one"
|
| 180 |
elog "If you change the active gcc profile, or update gcc to a new version,"
|
| 181 |
elog "you will have to remerge this package to update the search path"
|
| 182 |
else
|
| 183 |
elog "If clang++ fails to find C++ headers on your system,"
|
| 184 |
elog "you can remerge clang with USE=system-cxx-headers to use C++ headers"
|
| 185 |
elog "from the active gcc profile"
|
| 186 |
fi
|
| 187 |
}
|
| 188 |
|
| 189 |
pkg_postrm() {
|
| 190 |
python_mod_cleanup clang
|
| 191 |
}
|