/[gentoo-x86]/eclass/toolchain-binutils.eclass
Gentoo

Contents of /eclass/toolchain-binutils.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.127 - (show annotations) (download)
Thu Nov 21 04:07:25 2013 UTC (8 months, 1 week ago) by vapier
Branch: MAIN
Changes since 1.126: +3 -1 lines
disable dirs specific to gdb in case we have a combined tree #490566

1 # Copyright 1999-2013 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.126 2013/11/20 08:13:56 vapier Exp $
4 #
5 # Maintainer: Toolchain Ninjas <toolchain@gentoo.org>
6 #
7 # We install binutils into CTARGET-VERSION specific directories. This lets
8 # us easily merge multiple versions for multiple targets (if we wish) and
9 # then switch the versions on the fly (with `binutils-config`).
10 #
11 # binutils-99999999 -> live cvs
12 # binutils-9999 -> live git
13 # binutils-9999_preYYMMDD -> nightly snapshot date YYMMDD
14 # binutils-# -> normal release
15
16 extra_eclass=""
17 if [[ -n ${BINUTILS_TYPE} ]] ; then
18 BTYPE=${BINUTILS_TYPE}
19 else
20 case ${PV} in
21 99999999) BTYPE="cvs";;
22 9999) BTYPE="git";;
23 9999_pre*) BTYPE="snap";;
24 *.*.90) BTYPE="snap";;
25 *.*.*.*.*) BTYPE="hjlu";;
26 *) BTYPE="rel";;
27 esac
28 fi
29
30 case ${BTYPE} in
31 cvs)
32 extra_eclass="cvs"
33 ECVS_SERVER="sourceware.org:/cvs/src"
34 ECVS_MODULE="binutils"
35 ECVS_USER="anoncvs"
36 ECVS_PASS="anoncvs"
37 BVER="cvs"
38 ;;
39 git)
40 extra_eclass="git-2"
41 BVER="git"
42 EGIT_REPO_URI="git://sourceware.org/git/binutils-gdb.git"
43 ;;
44 snap)
45 BVER=${PV/9999_pre}
46 ;;
47 *)
48 BVER=${BINUTILS_VER:-${PV}}
49 ;;
50 esac
51
52 inherit eutils libtool flag-o-matic gnuconfig multilib versionator unpacker ${extra_eclass}
53 EXPORT_FUNCTIONS src_unpack src_compile src_test src_install pkg_postinst pkg_postrm
54
55 export CTARGET=${CTARGET:-${CHOST}}
56 if [[ ${CTARGET} == ${CHOST} ]] ; then
57 if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
58 export CTARGET=${CATEGORY/cross-}
59 fi
60 fi
61 is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; }
62
63 : ${ED:=${D}}
64 : ${EROOT:=${ROOT}}
65
66 DESCRIPTION="Tools necessary to build programs"
67 HOMEPAGE="http://sourceware.org/binutils/"
68
69 case ${BTYPE} in
70 cvs|git) SRC_URI="" ;;
71 snap)
72 SRC_URI="ftp://gcc.gnu.org/pub/binutils/snapshots/binutils-${BVER}.tar.bz2
73 ftp://sourceware.org/pub/binutils/snapshots/binutils-${BVER}.tar.bz2" ;;
74 hjlu)
75 SRC_URI="mirror://kernel/linux/devel/binutils/binutils-${BVER}.tar."
76 version_is_at_least 2.21.51.0.5 && SRC_URI+="xz" || SRC_URI+="bz2" ;;
77 rel) SRC_URI="mirror://gnu/binutils/binutils-${BVER}.tar.bz2" ;;
78 esac
79 add_src_uri() {
80 [[ -z $2 ]] && return
81 local a=$1
82 if version_is_at_least 2.22.52.0.2 ; then
83 a+=".xz"
84 else
85 a+=".bz2"
86 fi
87 set -- mirror://gentoo http://dev.gentoo.org/~vapier/dist
88 SRC_URI="${SRC_URI} ${@/%//${a}}"
89 }
90 add_src_uri binutils-${BVER}-patches-${PATCHVER}.tar ${PATCHVER}
91 add_src_uri binutils-${BVER}-uclibc-patches-${UCLIBC_PATCHVER}.tar ${UCLIBC_PATCHVER}
92 add_src_uri elf2flt-${ELF2FLT_VER}.tar ${ELF2FLT_VER}
93
94 if version_is_at_least 2.18 ; then
95 LICENSE="|| ( GPL-3 LGPL-3 )"
96 else
97 LICENSE="|| ( GPL-2 LGPL-2 )"
98 fi
99 IUSE="cxx nls multitarget multislot static-libs test vanilla"
100 if version_is_at_least 2.19 ; then
101 IUSE+=" zlib"
102 fi
103 if use multislot ; then
104 SLOT="${BVER}"
105 else
106 SLOT="0"
107 fi
108
109 RDEPEND=">=sys-devel/binutils-config-1.9"
110 in_iuse zlib && RDEPEND+=" zlib? ( sys-libs/zlib )"
111 DEPEND="${RDEPEND}
112 test? ( dev-util/dejagnu )
113 nls? ( sys-devel/gettext )
114 sys-devel/flex
115 virtual/yacc"
116
117 S=${WORKDIR}/binutils
118 case ${BVER} in
119 cvs|git) ;;
120 *) S=${S}-${BVER} ;;
121 esac
122
123 LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${BVER}
124 INCPATH=${LIBPATH}/include
125 DATAPATH=/usr/share/binutils-data/${CTARGET}/${BVER}
126 MY_BUILDDIR=${WORKDIR}/build
127 if is_cross ; then
128 BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${BVER}
129 else
130 BINPATH=/usr/${CTARGET}/binutils-bin/${BVER}
131 fi
132
133 tc-binutils_unpack() {
134 case ${BTYPE} in
135 cvs) cvs_src_unpack ;;
136 git) git-2_src_unpack ;;
137 *) unpacker ${A} ;;
138 esac
139 mkdir -p "${MY_BUILDDIR}"
140 [[ -d ${WORKDIR}/patch ]] && mkdir "${WORKDIR}"/patch/skip
141 }
142
143 # In case the ebuild wants to add a few of their own.
144 PATCHES=()
145
146 tc-binutils_apply_patches() {
147 cd "${S}"
148
149 if ! use vanilla ; then
150 if [[ -n ${PATCHVER} ]] ; then
151 EPATCH_SOURCE=${WORKDIR}/patch
152 if [[ ${CTARGET} == mips* ]] ; then
153 # remove gnu-hash for mips (bug #233233)
154 EPATCH_EXCLUDE+=" 77_all_generate-gnu-hash.patch"
155 fi
156 [[ -n $(ls "${EPATCH_SOURCE}"/*.bz2 2>/dev/null) ]] \
157 && EPATCH_SUFFIX="patch.bz2" \
158 || EPATCH_SUFFIX="patch"
159 epatch
160 fi
161 if [[ -n ${UCLIBC_PATCHVER} ]] ; then
162 EPATCH_SOURCE=${WORKDIR}/uclibc-patches
163 [[ -n $(ls "${EPATCH_SOURCE}"/*.bz2 2>/dev/null) ]] \
164 && EPATCH_SUFFIX="patch.bz2" \
165 || EPATCH_SUFFIX="patch"
166 EPATCH_MULTI_MSG="Applying uClibc fixes ..." \
167 epatch
168 elif [[ ${CTARGET} == *-uclibc* ]] ; then
169 # starting with binutils-2.17.50.0.17, we no longer need
170 # uClibc patchsets :D
171 if grep -qs 'linux-gnu' "${S}"/ltconfig ; then
172 die "sorry, but this binutils doesn't yet support uClibc :("
173 fi
174 fi
175 [[ ${#PATCHES[@]} -gt 0 ]] && epatch "${PATCHES[@]}"
176 epatch_user
177 fi
178
179 # fix locale issues if possible #122216
180 if [[ -e ${FILESDIR}/binutils-configure-LANG.patch ]] ; then
181 einfo "Fixing misc issues in configure files"
182 for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do
183 ebegin " Updating ${f/${S}\/}"
184 patch "${f}" "${FILESDIR}"/binutils-configure-LANG.patch >& "${T}"/configure-patch.log \
185 || eerror "Please file a bug about this"
186 eend $?
187 done
188 fi
189 # fix conflicts with newer glibc #272594
190 if [[ -e libiberty/testsuite/test-demangle.c ]] ; then
191 sed -i 's:\<getline\>:get_line:g' libiberty/testsuite/test-demangle.c
192 fi
193
194 # Fix po Makefile generators
195 sed -i \
196 -e '/^datadir = /s:$(prefix)/@DATADIRNAME@:@datadir@:' \
197 -e '/^gnulocaledir = /s:$(prefix)/share:$(datadir):' \
198 */po/Make-in || die "sed po's failed"
199
200 # Run misc portage update scripts
201 gnuconfig_update
202 elibtoolize --portage --no-uclibc
203 }
204
205 toolchain-binutils_src_unpack() {
206 tc-binutils_unpack
207 tc-binutils_apply_patches
208 }
209
210 toolchain-binutils_src_compile() {
211 # prevent makeinfo from running in releases. it may not always be
212 # installed, and older binutils may fail with newer texinfo.
213 # besides, we never patch the doc files anyways, so regenerating
214 # in the first place is useless. #193364
215 find . '(' -name '*.info' -o -name '*.texi' ')' -print0 | xargs -0 touch -r .
216
217 # make sure we filter $LINGUAS so that only ones that
218 # actually work make it through #42033
219 strip-linguas -u */po
220
221 # keep things sane
222 strip-flags
223
224 local x
225 echo
226 for x in CATEGORY CBUILD CHOST CTARGET CFLAGS LDFLAGS ; do
227 einfo "$(printf '%10s' ${x}:) ${!x}"
228 done
229 echo
230
231 cd "${MY_BUILDDIR}"
232 local myconf=()
233
234 # enable gold if available (installed as ld.gold)
235 if use cxx ; then
236 if grep -q 'enable-gold=default' "${S}"/configure ; then
237 myconf+=( --enable-gold )
238 # old ways - remove when 2.21 is stable
239 elif grep -q 'enable-gold=both/ld' "${S}"/configure ; then
240 myconf+=( --enable-gold=both/ld )
241 elif grep -q 'enable-gold=both/bfd' "${S}"/configure ; then
242 myconf+=( --enable-gold=both/bfd )
243 fi
244 if grep -q -e '--enable-plugins' "${S}"/ld/configure ; then
245 myconf+=( --enable-plugins )
246 fi
247 fi
248
249 use nls \
250 && myconf+=( --without-included-gettext ) \
251 || myconf+=( --disable-nls )
252
253 if in_iuse zlib ; then
254 # older versions did not have an explicit configure flag
255 export ac_cv_search_zlibVersion=$(usex zlib -lz no)
256 myconf+=( $(use_with zlib) )
257 fi
258
259 # For bi-arch systems, enable a 64bit bfd. This matches
260 # the bi-arch logic in toolchain.eclass. #446946
261 # We used to do it for everyone, but it's slow on 32bit arches. #438522
262 case $(tc-arch) in
263 ppc|sparc|x86) myconf+=( --enable-64-bit-bfd ) ;;
264 esac
265
266 use multitarget && myconf+=( --enable-targets=all --enable-64-bit-bfd )
267 [[ -n ${CBUILD} ]] && myconf+=( --build=${CBUILD} )
268 is_cross && myconf+=( --with-sysroot="${EPREFIX}"/usr/${CTARGET} )
269
270 # glibc-2.3.6 lacks support for this ... so rather than force glibc-2.5+
271 # on everyone in alpha (for now), we'll just enable it when possible
272 has_version ">=${CATEGORY}/glibc-2.5" && myconf+=( --enable-secureplt )
273 has_version ">=sys-libs/glibc-2.5" && myconf+=( --enable-secureplt )
274
275 myconf+=(
276 --prefix="${EPREFIX}"/usr
277 --host=${CHOST}
278 --target=${CTARGET}
279 --datadir="${EPREFIX}"${DATAPATH}
280 --infodir="${EPREFIX}"${DATAPATH}/info
281 --mandir="${EPREFIX}"${DATAPATH}/man
282 --bindir="${EPREFIX}"${BINPATH}
283 --libdir="${EPREFIX}"${LIBPATH}
284 --libexecdir="${EPREFIX}"${LIBPATH}
285 --includedir="${EPREFIX}"${INCPATH}
286 --enable-obsolete
287 --enable-shared
288 --enable-threads
289 --disable-werror
290 --with-bugurl=http://bugs.gentoo.org/
291 $(use_enable static-libs static)
292 ${EXTRA_ECONF}
293 # Disable modules that are in a combined binutils/gdb tree. #490566
294 --disable-{gdb,libdecnumber,readline,sim}
295 )
296 echo ./configure "${myconf[@]}"
297 "${S}"/configure "${myconf[@]}" || die
298
299 emake all || die "emake failed"
300
301 # only build info pages if we user wants them, and if
302 # we have makeinfo (may not exist when we bootstrap)
303 if type -p makeinfo > /dev/null ; then
304 emake info || die "make info failed"
305 fi
306 # we nuke the manpages when we're left with junk
307 # (like when we bootstrap, no perl -> no manpages)
308 find . -name '*.1' -a -size 0 | xargs rm -f
309
310 # elf2flt only works on some arches / targets
311 if [[ -n ${ELF2FLT_VER} ]] && [[ ${CTARGET} == *linux* || ${CTARGET} == *-elf* ]] ; then
312 cd "${WORKDIR}"/elf2flt-${ELF2FLT_VER}
313
314 local x supported_arches=$(sed -n '/defined(TARGET_/{s:^.*TARGET_::;s:)::;p}' elf2flt.c | sort -u)
315 for x in ${supported_arches} UNSUPPORTED ; do
316 [[ ${CTARGET} == ${x}* ]] && break
317 done
318
319 if [[ ${x} != "UNSUPPORTED" ]] ; then
320 append-flags -I"${S}"/include
321 myconf+=(
322 --with-bfd-include-dir=${MY_BUILDDIR}/bfd
323 --with-libbfd=${MY_BUILDDIR}/bfd/libbfd.a
324 --with-libiberty=${MY_BUILDDIR}/libiberty/libiberty.a
325 --with-binutils-ldscript-dir="${EPREFIX}"${LIBPATH}/ldscripts
326 )
327 echo ./configure "${myconf[@]}"
328 ./configure "${myconf[@]}" || die
329 emake || die "make elf2flt failed"
330 fi
331 fi
332 }
333
334 toolchain-binutils_src_test() {
335 cd "${MY_BUILDDIR}"
336 emake -k check || die "check failed :("
337 }
338
339 toolchain-binutils_src_install() {
340 local x d
341
342 cd "${MY_BUILDDIR}"
343 emake DESTDIR="${D}" tooldir="${EPREFIX}${LIBPATH}" install || die
344 rm -rf "${ED}"/${LIBPATH}/bin
345 use static-libs || find "${ED}" -name '*.la' -delete
346
347 # Newer versions of binutils get fancy with ${LIBPATH} #171905
348 cd "${ED}"/${LIBPATH}
349 for d in ../* ; do
350 [[ ${d} == ../${BVER} ]] && continue
351 mv ${d}/* . || die
352 rmdir ${d} || die
353 done
354
355 # Now we collect everything intp the proper SLOT-ed dirs
356 # When something is built to cross-compile, it installs into
357 # /usr/$CHOST/ by default ... we have to 'fix' that :)
358 if is_cross ; then
359 cd "${ED}"/${BINPATH}
360 for x in * ; do
361 mv ${x} ${x/${CTARGET}-}
362 done
363
364 if [[ -d ${ED}/usr/${CHOST}/${CTARGET} ]] ; then
365 mv "${ED}"/usr/${CHOST}/${CTARGET}/include "${ED}"/${INCPATH}
366 mv "${ED}"/usr/${CHOST}/${CTARGET}/lib/* "${ED}"/${LIBPATH}/
367 rm -r "${ED}"/usr/${CHOST}/{include,lib}
368 fi
369 fi
370 insinto ${INCPATH}
371 local libiberty_headers=(
372 # Not all the libiberty headers. See libiberty/Makefile.in:install_to_libdir.
373 demangle.h
374 dyn-string.h
375 fibheap.h
376 hashtab.h
377 libiberty.h
378 objalloc.h
379 splay-tree.h
380 )
381 doins "${libiberty_headers[@]/#/${S}/include/}" || die
382 if [[ -d ${ED}/${LIBPATH}/lib ]] ; then
383 mv "${ED}"/${LIBPATH}/lib/* "${ED}"/${LIBPATH}/
384 rm -r "${ED}"/${LIBPATH}/lib
385 fi
386
387 # Insert elf2flt where appropriate
388 if [[ -x ${WORKDIR}/elf2flt-${ELF2FLT_VER}/elf2flt ]] ; then
389 cd "${WORKDIR}"/elf2flt-${ELF2FLT_VER}
390 insinto ${LIBPATH}/ldscripts
391 doins elf2flt.ld || die "doins elf2flt.ld failed"
392 exeinto ${BINPATH}
393 doexe elf2flt flthdr || die "doexe elf2flt flthdr failed"
394 mv "${ED}"/${BINPATH}/{ld,ld.real} || die
395 newexe ld-elf2flt ld || die "doexe ld-elf2flt failed"
396 newdoc README README.elf2flt
397 fi
398
399 # Now, some binutils are tricky and actually provide
400 # for multiple TARGETS. Really, we're talking just
401 # 32bit/64bit support (like mips/ppc/sparc). Here
402 # we want to tell binutils-config that it's cool if
403 # it generates multiple sets of binutil symlinks.
404 # e.g. sparc gets {sparc,sparc64}-unknown-linux-gnu
405 local targ=${CTARGET/-*} src="" dst=""
406 local FAKE_TARGETS=${CTARGET}
407 case ${targ} in
408 mips*) src="mips" dst="mips64";;
409 powerpc*) src="powerpc" dst="powerpc64";;
410 s390*) src="s390" dst="s390x";;
411 sparc*) src="sparc" dst="sparc64";;
412 esac
413 case ${targ} in
414 mips64*|powerpc64*|s390x*|sparc64*) targ=${src} src=${dst} dst=${targ};;
415 esac
416 [[ -n ${src}${dst} ]] && FAKE_TARGETS="${FAKE_TARGETS} ${CTARGET/${src}/${dst}}"
417
418 # Generate an env.d entry for this binutils
419 insinto /etc/env.d/binutils
420 cat <<-EOF > "${T}"/env.d
421 TARGET="${CTARGET}"
422 VER="${BVER}"
423 LIBPATH="${EPREFIX}${LIBPATH}"
424 FAKE_TARGETS="${FAKE_TARGETS}"
425 EOF
426 newins "${T}"/env.d ${CTARGET}-${BVER}
427
428 # Handle documentation
429 if ! is_cross ; then
430 cd "${S}"
431 dodoc README
432 docinto bfd
433 dodoc bfd/ChangeLog* bfd/README bfd/PORTING bfd/TODO
434 docinto binutils
435 dodoc binutils/ChangeLog binutils/NEWS binutils/README
436 docinto gas
437 dodoc gas/ChangeLog* gas/CONTRIBUTORS gas/NEWS gas/README*
438 docinto gprof
439 dodoc gprof/ChangeLog* gprof/TEST gprof/TODO gprof/bbconv.pl
440 docinto ld
441 dodoc ld/ChangeLog* ld/README ld/NEWS ld/TODO
442 docinto libiberty
443 dodoc libiberty/ChangeLog* libiberty/README
444 docinto opcodes
445 dodoc opcodes/ChangeLog*
446 fi
447 # Remove shared info pages
448 rm -f "${ED}"/${DATAPATH}/info/{dir,configure.info,standards.info}
449 # Trim all empty dirs
450 find "${ED}" -type d | xargs rmdir >& /dev/null
451 }
452
453 toolchain-binutils_pkg_postinst() {
454 # Make sure this ${CTARGET} has a binutils version selected
455 [[ -e ${EROOT}/etc/env.d/binutils/config-${CTARGET} ]] && return 0
456 binutils-config ${CTARGET}-${BVER}
457 }
458
459 toolchain-binutils_pkg_postrm() {
460 local current_profile=$(binutils-config -c ${CTARGET})
461
462 # If no other versions exist, then uninstall for this
463 # target ... otherwise, switch to the newest version
464 # Note: only do this if this version is unmerged. We
465 # rerun binutils-config if this is a remerge, as
466 # we want the mtimes on the symlinks updated (if
467 # it is the same as the current selected profile)
468 if [[ ! -e ${EPREFIX}${BINPATH}/ld ]] && [[ ${current_profile} == ${CTARGET}-${BVER} ]] ; then
469 local choice=$(binutils-config -l | grep ${CTARGET} | awk '{print $2}')
470 choice=${choice//$'\n'/ }
471 choice=${choice/* }
472 if [[ -z ${choice} ]] ; then
473 env -i ROOT="${ROOT}" binutils-config -u ${CTARGET}
474 else
475 binutils-config ${choice}
476 fi
477 elif [[ $(CHOST=${CTARGET} binutils-config -c) == ${CTARGET}-${BVER} ]] ; then
478 binutils-config ${CTARGET}-${BVER}
479 fi
480 }

  ViewVC Help
Powered by ViewVC 1.1.20