Gentoo Archives: gentoo-commits

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