| 1 |
# Copyright 1999-2005 Gentoo Foundation
|
| 2 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-binutils.eclass,v 1.50 2005/12/09 03:10:04 vapier Exp $
|
| 4 |
|
| 5 |
# We install binutils into CTARGET-VERSION specific directories. This lets
|
| 6 |
# us easily merge multiple versions for multiple targets (if we wish) and
|
| 7 |
# then switch the versions on the fly (with `binutils-config`).
|
| 8 |
#
|
| 9 |
# binutils-9999 -> live cvs
|
| 10 |
# binutils-9999_preYYMMDD -> nightly snapshot date YYMMDD
|
| 11 |
# binutils-# -> normal release
|
| 12 |
|
| 13 |
extra_eclass=""
|
| 14 |
if [[ ${PV} == "9999" ]] ; then
|
| 15 |
extra_eclass="cvs"
|
| 16 |
ECVS_SERVER="sourceware.org:/cvs/src"
|
| 17 |
ECVS_MODULE="binutils"
|
| 18 |
ECVS_USER="anoncvs"
|
| 19 |
ECVS_PASS="anoncvs"
|
| 20 |
BTYPE="cvs"
|
| 21 |
BVER="cvs"
|
| 22 |
elif [[ ${PV} == 9999_pre* ]] ; then
|
| 23 |
BTYPE="snap"
|
| 24 |
BVER=${PV/9999_pre}
|
| 25 |
else
|
| 26 |
BTYPE="rel"
|
| 27 |
BVER=${PV}
|
| 28 |
fi
|
| 29 |
|
| 30 |
inherit eutils libtool flag-o-matic gnuconfig multilib ${extra_eclass}
|
| 31 |
EXPORT_FUNCTIONS src_unpack src_compile src_test src_install pkg_postinst pkg_postrm
|
| 32 |
|
| 33 |
export CTARGET=${CTARGET:-${CHOST}}
|
| 34 |
if [[ ${CTARGET} == ${CHOST} ]] ; then
|
| 35 |
if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
|
| 36 |
export CTARGET=${CATEGORY/cross-}
|
| 37 |
fi
|
| 38 |
fi
|
| 39 |
|
| 40 |
DESCRIPTION="Tools necessary to build programs"
|
| 41 |
HOMEPAGE="http://sources.redhat.com/binutils/"
|
| 42 |
|
| 43 |
case ${BTYPE} in
|
| 44 |
cvs) SRC_URI="";;
|
| 45 |
snap) SRC_URI="ftp://gcc.gnu.org/pub/binutils/snapshots/binutils-${BVER}.tar.bz2";;
|
| 46 |
rel)
|
| 47 |
SRC_URI="mirror://kernel/linux/devel/binutils/binutils-${PV}.tar.bz2
|
| 48 |
mirror://kernel/linux/devel/binutils/test/binutils-${PV}.tar.bz2
|
| 49 |
mirror://gnu/binutils/binutils-${PV}.tar.bz2"
|
| 50 |
esac
|
| 51 |
[[ -n ${PATCHVER} ]] && \
|
| 52 |
SRC_URI="${SRC_URI} mirror://gentoo/binutils-${PV}-patches-${PATCHVER}.tar.bz2"
|
| 53 |
[[ -n ${UCLIBC_PATCHVER} ]] && \
|
| 54 |
SRC_URI="${SRC_URI} mirror://gentoo/binutils-${PV}-uclibc-patches-${UCLIBC_PATCHVER}.tar.bz2"
|
| 55 |
|
| 56 |
LICENSE="|| ( GPL-2 LGPL-2 )"
|
| 57 |
IUSE="nls multitarget multislot test"
|
| 58 |
if use multislot ; then
|
| 59 |
SLOT="${CTARGET}-${BVER}"
|
| 60 |
elif [[ ${CTARGET} != ${CHOST} ]] ; then
|
| 61 |
SLOT="${CTARGET}"
|
| 62 |
else
|
| 63 |
SLOT="0"
|
| 64 |
fi
|
| 65 |
|
| 66 |
RDEPEND=">=sys-devel/binutils-config-1.8-r6"
|
| 67 |
DEPEND="${RDEPEND}
|
| 68 |
test? ( dev-util/dejagnu )
|
| 69 |
nls? ( sys-devel/gettext )"
|
| 70 |
|
| 71 |
S=${WORKDIR}/binutils
|
| 72 |
[[ ${BVER} != "cvs" ]] && S=${S}-${BVER}
|
| 73 |
|
| 74 |
LIBPATH=${PREFIX}/usr/$(get_libdir)/binutils/${CTARGET}/${BVER}
|
| 75 |
INCPATH=${LIBPATH}/include
|
| 76 |
BINPATH=${PREFIX}/usr/${CTARGET}/binutils-bin/${BVER}
|
| 77 |
DATAPATH=${PREFIX}/usr/share/binutils-data/${CTARGET}/${BVER}
|
| 78 |
MY_BUILDDIR=${WORKDIR}/build
|
| 79 |
|
| 80 |
is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
|
| 81 |
|
| 82 |
tc-binutils_unpack() {
|
| 83 |
unpack ${A}
|
| 84 |
mkdir -p "${MY_BUILDDIR}"
|
| 85 |
[[ -d ${WORKDIR}/patch ]] && mkdir "${WORKDIR}"/patch/skip
|
| 86 |
}
|
| 87 |
|
| 88 |
tc-binutils_apply_patches() {
|
| 89 |
cd "${S}"
|
| 90 |
|
| 91 |
if [[ -n ${PATCHVER} ]] ; then
|
| 92 |
EPATCH_SOURCE=${WORKDIR}/patch
|
| 93 |
[[ -n $(ls "${EPATCH_SOURCE}"/*.bz2 2>/dev/null) ]] \
|
| 94 |
&& EPATCH_SUFFIX="patch.bz2" \
|
| 95 |
|| EPATCH_SUFFIX="patch"
|
| 96 |
epatch
|
| 97 |
fi
|
| 98 |
if [[ -n ${UCLIBC_PATCHVER} ]] ; then
|
| 99 |
EPATCH_SOURCE=${WORKDIR}/uclibc-patches
|
| 100 |
[[ -n $(ls "${EPATCH_SOURCE}"/*.bz2 2>/dev/null) ]] \
|
| 101 |
&& EPATCH_SUFFIX="patch.bz2" \
|
| 102 |
|| EPATCH_SUFFIX="patch"
|
| 103 |
EPATCH_MULTI_MSG="Applying uClibc fixes ..." \
|
| 104 |
epatch
|
| 105 |
elif [[ ${CTARGET} == *-uclibc ]] ; then
|
| 106 |
die "sorry, but this binutils doesn't yet support uClibc :("
|
| 107 |
fi
|
| 108 |
|
| 109 |
# Fix po Makefile generators
|
| 110 |
sed -i \
|
| 111 |
-e '/^datadir = /s:$(prefix)/@DATADIRNAME@:@datadir@:' \
|
| 112 |
-e '/^gnulocaledir = /s:$(prefix)/share:$(datadir):' \
|
| 113 |
*/po/Make-in || die "sed po's failed"
|
| 114 |
|
| 115 |
# Run misc portage update scripts
|
| 116 |
gnuconfig_update
|
| 117 |
elibtoolize --portage --no-uclibc
|
| 118 |
|
| 119 |
# make sure we filter $LINGUAS so that only ones that
|
| 120 |
# actually work with all the subdirs make it through
|
| 121 |
strip-linguas -i */po
|
| 122 |
}
|
| 123 |
|
| 124 |
toolchain-binutils_src_unpack() {
|
| 125 |
tc-binutils_unpack
|
| 126 |
tc-binutils_apply_patches
|
| 127 |
}
|
| 128 |
|
| 129 |
toolchain-binutils_src_compile() {
|
| 130 |
strip-flags && replace-flags -O3 -O2 #47581
|
| 131 |
|
| 132 |
cd "${MY_BUILDDIR}"
|
| 133 |
local myconf=""
|
| 134 |
use nls \
|
| 135 |
&& myconf="${myconf} --without-included-gettext" \
|
| 136 |
|| myconf="${myconf} --disable-nls"
|
| 137 |
use multitarget && myconf="${myconf} --enable-targets=all"
|
| 138 |
[[ -n ${CBUILD} ]] && myconf="${myconf} --build=${CBUILD}"
|
| 139 |
myconf="--prefix=${PREFIX}/usr \
|
| 140 |
--host=${CHOST} \
|
| 141 |
--target=${CTARGET} \
|
| 142 |
--datadir=${DATAPATH} \
|
| 143 |
--infodir=${DATAPATH}/info \
|
| 144 |
--mandir=${DATAPATH}/man \
|
| 145 |
--bindir=${BINPATH} \
|
| 146 |
--libdir=${LIBPATH} \
|
| 147 |
--libexecdir=${LIBPATH} \
|
| 148 |
--includedir=${INCPATH} \
|
| 149 |
--enable-64-bit-bfd \
|
| 150 |
--enable-shared \
|
| 151 |
--disable-werror \
|
| 152 |
${myconf} ${EXTRA_ECONF}"
|
| 153 |
echo ./configure ${myconf}
|
| 154 |
"${S}"/configure ${myconf} || die "configure failed"
|
| 155 |
|
| 156 |
# binutils' build system is a bit broken with internal
|
| 157 |
# dependencies, so we manually run these first two bfd
|
| 158 |
# targets so that we can than use -j# and have it work
|
| 159 |
emake -j1 configure-bfd || die "make configure-bfd failed"
|
| 160 |
emake -j1 headers -C bfd || die "make headers-bfd failed"
|
| 161 |
emake all || die "emake failed"
|
| 162 |
|
| 163 |
# only build info pages if we user wants them, and if
|
| 164 |
# we have makeinfo (may not exist when we bootstrap)
|
| 165 |
if ! has noinfo ${FEATURES} ; then
|
| 166 |
if type -p makeinfo ; then
|
| 167 |
make info || die "make info failed"
|
| 168 |
fi
|
| 169 |
fi
|
| 170 |
# we nuke the manpages when we're left with junk
|
| 171 |
# (like when we bootstrap, no perl -> no manpages)
|
| 172 |
find . -name '*.1' -a -size 0 | xargs rm -f
|
| 173 |
}
|
| 174 |
|
| 175 |
toolchain-binutils_src_test() {
|
| 176 |
cd "${MY_BUILDDIR}"
|
| 177 |
make check || die "check failed :("
|
| 178 |
}
|
| 179 |
|
| 180 |
toolchain-binutils_src_install() {
|
| 181 |
local x d
|
| 182 |
|
| 183 |
cd "${MY_BUILDDIR}"
|
| 184 |
make DESTDIR="${D}" tooldir="${LIBPATH}" install || die
|
| 185 |
rm -rf "${D}"/${LIBPATH}/bin
|
| 186 |
|
| 187 |
# Now we collect everything intp the proper SLOT-ed dirs
|
| 188 |
# When something is built to cross-compile, it installs into
|
| 189 |
# /usr/$CHOST/ by default ... we have to 'fix' that :)
|
| 190 |
if is_cross ; then
|
| 191 |
cd "${D}"/${BINPATH}
|
| 192 |
for x in * ; do
|
| 193 |
mv ${x} ${x/${CTARGET}-}
|
| 194 |
done
|
| 195 |
|
| 196 |
if [[ -d ${D}/usr/${CHOST}/${CTARGET} ]] ; then
|
| 197 |
mv "${D}"/usr/${CHOST}/${CTARGET}/include "${D}"/${INCPATH}
|
| 198 |
mv "${D}"/usr/${CHOST}/${CTARGET}/lib/* "${D}"/${LIBPATH}/
|
| 199 |
rm -r "${D}"/usr/${CHOST}
|
| 200 |
fi
|
| 201 |
else
|
| 202 |
insinto ${INCPATH}
|
| 203 |
doins "${S}/include/libiberty.h"
|
| 204 |
fi
|
| 205 |
if [[ -d ${D}/${LIBPATH}/lib ]] ; then
|
| 206 |
mv "${D}"/${LIBPATH}/lib/* "${D}"/${LIBPATH}/
|
| 207 |
rm -r "${D}"/${LIBPATH}/lib
|
| 208 |
fi
|
| 209 |
dodir /usr/${CTARGET}/{bin,include,lib}
|
| 210 |
prepman ${DATAPATH}
|
| 211 |
|
| 212 |
# Now, some binutils are tricky and actually provide
|
| 213 |
# for multiple TARGETS. Really, we're talking just
|
| 214 |
# 32bit/64bit support (like mips/ppc/sparc). Here
|
| 215 |
# we want to tell binutils-config that it's cool if
|
| 216 |
# it generates multiple sets of binutil symlinks.
|
| 217 |
# e.g. sparc gets {sparc,sparc64}-unknown-linux-gnu
|
| 218 |
local targ=${CTARGET/-*} src="" dst=""
|
| 219 |
local FAKE_TARGETS=${CTARGET}
|
| 220 |
case ${targ} in
|
| 221 |
mips*) src="mips" dst="mips64";;
|
| 222 |
powerpc*) src="powerpc" dst="powerpc64";;
|
| 223 |
s390*) src="s390" dst="s390x";;
|
| 224 |
sparc*) src="sparc" dst="sparc64";;
|
| 225 |
esac
|
| 226 |
case ${targ} in
|
| 227 |
mips64*|powerpc64*|s390x*|sparc64*) targ=${src} src=${dst} dst=${targ};;
|
| 228 |
esac
|
| 229 |
[[ -n ${src}${dst} ]] && FAKE_TARGETS="${FAKE_TARGETS} ${CTARGET/${src}/${dst}}"
|
| 230 |
|
| 231 |
# Generate an env.d entry for this binutils
|
| 232 |
cd "${S}"
|
| 233 |
insinto /etc/env.d/binutils
|
| 234 |
cat <<-EOF > env.d
|
| 235 |
TARGET="${CTARGET}"
|
| 236 |
VER="${BVER}"
|
| 237 |
LIBPATH="${LIBPATH}"
|
| 238 |
FAKE_TARGETS="${FAKE_TARGETS}"
|
| 239 |
EOF
|
| 240 |
newins env.d ${CTARGET}-${BVER}
|
| 241 |
|
| 242 |
# Handle documentation
|
| 243 |
if ! is_cross ; then
|
| 244 |
cd "${S}"
|
| 245 |
dodoc README
|
| 246 |
docinto bfd
|
| 247 |
dodoc bfd/ChangeLog* bfd/README bfd/PORTING bfd/TODO
|
| 248 |
docinto binutils
|
| 249 |
dodoc binutils/ChangeLog binutils/NEWS binutils/README
|
| 250 |
docinto gas
|
| 251 |
dodoc gas/ChangeLog* gas/CONTRIBUTORS gas/NEWS gas/README*
|
| 252 |
docinto gprof
|
| 253 |
dodoc gprof/ChangeLog* gprof/TEST gprof/TODO gprof/bbconv.pl
|
| 254 |
docinto ld
|
| 255 |
dodoc ld/ChangeLog* ld/README ld/NEWS ld/TODO
|
| 256 |
docinto libiberty
|
| 257 |
dodoc libiberty/ChangeLog* libiberty/README
|
| 258 |
docinto opcodes
|
| 259 |
dodoc opcodes/ChangeLog*
|
| 260 |
fi
|
| 261 |
# Punt all the fun stuff if user doesn't want it :)
|
| 262 |
has noinfo ${FEATURES} && rm -r "${D}"/${DATAPATH}/info
|
| 263 |
has noman ${FEATURES} && rm -r "${D}"/${DATAPATH}/man
|
| 264 |
# Remove shared info pages
|
| 265 |
rm -f "${D}"/${DATAPATH}/info/{dir,configure.info,standards.info}
|
| 266 |
}
|
| 267 |
|
| 268 |
toolchain-binutils_pkg_postinst() {
|
| 269 |
# Make sure this ${CTARGET} has a binutils version selected
|
| 270 |
[[ -e ${ROOT}/etc/env.d/binutils/config-${CTARGET} ]] && return 0
|
| 271 |
binutils-config ${CTARGET}-${BVER}
|
| 272 |
}
|
| 273 |
|
| 274 |
toolchain-binutils_pkg_postrm() {
|
| 275 |
local current_profile=$(binutils-config -c ${CTARGET})
|
| 276 |
|
| 277 |
# If no other versions exist, then uninstall for this
|
| 278 |
# target ... otherwise, switch to the newest version
|
| 279 |
# Note: only do this if this version is unmerged. We
|
| 280 |
# rerun binutils-config if this is a remerge, as
|
| 281 |
# we want the mtimes on the symlinks updated (if
|
| 282 |
# it is the same as the current selected profile)
|
| 283 |
if [[ ! -e ${BINPATH}/ld ]] && [[ ${current_profile} == ${CTARGET}-${BVER} ]] ; then
|
| 284 |
local choice=$(binutils-config -l | grep ${CTARGET} | awk '{print $2}')
|
| 285 |
choice=${choice//$'\n'/ }
|
| 286 |
choice=${choice/* }
|
| 287 |
if [[ -z ${choice} ]] ; then
|
| 288 |
env -i binutils-config -u ${CTARGET}
|
| 289 |
else
|
| 290 |
binutils-config ${choice}
|
| 291 |
fi
|
| 292 |
elif [[ $(CHOST=${CTARGET} binutils-config -c) == ${CTARGET}-${BVER} ]] ; then
|
| 293 |
binutils-config ${CTARGET}-${BVER}
|
| 294 |
fi
|
| 295 |
}
|