Gentoo Archives: gentoo-commits

From: Mike Frysinger <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-devel/binutils-config/files/, sys-devel/binutils-config/
Date: Sat, 26 Sep 2015 17:46:15
Message-Id: 1443289530.be8ff222303de294005a9f442f2fe483d58dcac0.vapier@gentoo
1 commit: be8ff222303de294005a9f442f2fe483d58dcac0
2 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
3 AuthorDate: Sat Sep 26 16:49:55 2015 +0000
4 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
5 CommitDate: Sat Sep 26 17:45:30 2015 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=be8ff222
7
8 sys-devel/binutils-config: drop old
9
10 .../binutils-config/binutils-config-1.9-r4.ebuild | 19 -
11 .../binutils-config/binutils-config-2-r1.ebuild | 19 -
12 .../binutils-config/binutils-config-3-r3.ebuild | 19 -
13 .../binutils-config/binutils-config-4-r1.ebuild | 24 -
14 .../binutils-config/files/binutils-config-1.9 | 410 -----------------
15 sys-devel/binutils-config/files/binutils-config-2 | 434 ------------------
16 sys-devel/binutils-config/files/binutils-config-3 | 509 ---------------------
17 7 files changed, 1434 deletions(-)
18
19 diff --git a/sys-devel/binutils-config/binutils-config-1.9-r4.ebuild b/sys-devel/binutils-config/binutils-config-1.9-r4.ebuild
20 deleted file mode 100644
21 index b3fff54..0000000
22 --- a/sys-devel/binutils-config/binutils-config-1.9-r4.ebuild
23 +++ /dev/null
24 @@ -1,19 +0,0 @@
25 -# Copyright 1999-2011 Gentoo Foundation
26 -# Distributed under the terms of the GNU General Public License v2
27 -# $Id$
28 -
29 -DESCRIPTION="Utility to change the binutils version being used"
30 -HOMEPAGE="https://www.gentoo.org/"
31 -SRC_URI=""
32 -
33 -LICENSE="GPL-2"
34 -SLOT="0"
35 -KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~sparc-fbsd ~x86-fbsd"
36 -IUSE=""
37 -
38 -RDEPEND="userland_GNU? ( >=sys-apps/findutils-4.2 )"
39 -
40 -src_install() {
41 - newbin "${FILESDIR}"/${PN}-${PV} ${PN} || die
42 - doman "${FILESDIR}"/${PN}.8
43 -}
44
45 diff --git a/sys-devel/binutils-config/binutils-config-2-r1.ebuild b/sys-devel/binutils-config/binutils-config-2-r1.ebuild
46 deleted file mode 100644
47 index b3fff54..0000000
48 --- a/sys-devel/binutils-config/binutils-config-2-r1.ebuild
49 +++ /dev/null
50 @@ -1,19 +0,0 @@
51 -# Copyright 1999-2011 Gentoo Foundation
52 -# Distributed under the terms of the GNU General Public License v2
53 -# $Id$
54 -
55 -DESCRIPTION="Utility to change the binutils version being used"
56 -HOMEPAGE="https://www.gentoo.org/"
57 -SRC_URI=""
58 -
59 -LICENSE="GPL-2"
60 -SLOT="0"
61 -KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~sparc-fbsd ~x86-fbsd"
62 -IUSE=""
63 -
64 -RDEPEND="userland_GNU? ( >=sys-apps/findutils-4.2 )"
65 -
66 -src_install() {
67 - newbin "${FILESDIR}"/${PN}-${PV} ${PN} || die
68 - doman "${FILESDIR}"/${PN}.8
69 -}
70
71 diff --git a/sys-devel/binutils-config/binutils-config-3-r3.ebuild b/sys-devel/binutils-config/binutils-config-3-r3.ebuild
72 deleted file mode 100644
73 index f5efe86..0000000
74 --- a/sys-devel/binutils-config/binutils-config-3-r3.ebuild
75 +++ /dev/null
76 @@ -1,19 +0,0 @@
77 -# Copyright 1999-2014 Gentoo Foundation
78 -# Distributed under the terms of the GNU General Public License v2
79 -# $Id$
80 -
81 -DESCRIPTION="Utility to change the binutils version being used"
82 -HOMEPAGE="https://www.gentoo.org/"
83 -SRC_URI=""
84 -
85 -LICENSE="GPL-2"
86 -SLOT="0"
87 -KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
88 -IUSE=""
89 -
90 -RDEPEND="userland_GNU? ( !<sys-apps/findutils-4.2 )"
91 -
92 -src_install() {
93 - newbin "${FILESDIR}"/${PN}-${PV} ${PN} || die
94 - doman "${FILESDIR}"/${PN}.8
95 -}
96
97 diff --git a/sys-devel/binutils-config/binutils-config-4-r1.ebuild b/sys-devel/binutils-config/binutils-config-4-r1.ebuild
98 deleted file mode 100644
99 index f123106..0000000
100 --- a/sys-devel/binutils-config/binutils-config-4-r1.ebuild
101 +++ /dev/null
102 @@ -1,24 +0,0 @@
103 -# Copyright 1999-2014 Gentoo Foundation
104 -# Distributed under the terms of the GNU General Public License v2
105 -# $Id$
106 -
107 -EAPI="4"
108 -
109 -DESCRIPTION="Utility to change the binutils version being used"
110 -HOMEPAGE="https://www.gentoo.org/"
111 -SRC_URI=""
112 -
113 -LICENSE="GPL-2"
114 -SLOT="0"
115 -KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
116 -IUSE=""
117 -
118 -# We also RDEPEND on sys-apps/findutils which is in base @system
119 -RDEPEND="sys-apps/gentoo-functions"
120 -
121 -S=${WORKDIR}
122 -
123 -src_install() {
124 - newbin "${FILESDIR}"/${PN}-${PV} ${PN}
125 - doman "${FILESDIR}"/${PN}.8
126 -}
127
128 diff --git a/sys-devel/binutils-config/files/binutils-config-1.9 b/sys-devel/binutils-config/files/binutils-config-1.9
129 deleted file mode 100644
130 index 8a371d4..0000000
131 --- a/sys-devel/binutils-config/files/binutils-config-1.9
132 +++ /dev/null
133 @@ -1,410 +0,0 @@
134 -#!/bin/bash
135 -# Copyright 1999-2007 Gentoo Foundation
136 -# Distributed under the terms of the GNU General Public License v2
137 -# $Id$
138 -
139 -# Format of /etc/env.d/binutils/:
140 -# config-TARGET: CURRENT=version for TARGET
141 -# TARGET-VER: has a TARGET and VER variable
142 -
143 -[[ -z ${ROOT} ]] && ROOT="/"
144 -[[ ${ROOT} != */ ]] && ROOT="${ROOT}/"
145 -[[ ${ROOT} != /* ]] && ROOT="${PWD}${ROOT}"
146 -
147 -cd /
148 -
149 -trap ":" INT QUIT TSTP
150 -
151 -argv0=${0##*/}
152 -source /etc/init.d/functions.sh || {
153 - echo "${argv0}: Could not source /etc/init.d/functions.sh!" 1>&2
154 - exit 1
155 -}
156 -esyslog() { :; }
157 -umask 022
158 -
159 -usage() {
160 -cat << USAGE_END
161 -
162 -Usage: ${HILITE}binutils-config${NORMAL} ${GOOD}[options]${NORMAL} ${BRACKET}[binutils profile]${NORMAL}
163 -
164 -${HILITE}General Options:${NORMAL}
165 - ${GOOD}-c, --get-current-profile${NORMAL} Print current profile
166 - ${GOOD}-l, --list-profiles${NORMAL} Print a list of available profiles
167 - ${GOOD}-u, --uninstall${NORMAL} Remove all signs of specified target
168 - ${GOOD}-d, --debug${NORMAL} Execute with debug output
169 -
170 -${HILITE}Arch Specific Cruft:${NORMAL}
171 - ${GOOD}--amd64${NORMAL} Install extra amd64 links (x86_64)
172 - ${GOOD}--arm${NORMAL} Install extra arm links (arm/armeb)
173 - ${GOOD}--mips${NORMAL} Install extra mips links (mips/mipsel)
174 - ${GOOD}--x86${NORMAL} Install extra x86 links (i[3-6]86)
175 -
176 -Profile names are of the form: ${BRACKET}<CTARGET>-<binutils version>${NORMAL}
177 -For example: ${BRACKET}i686-pc-linux-gnu-2.15.92.0.2${NORMAL}
178 -
179 -For more info, please see ${HILITE}binutils-config${NORMAL}(8).
180 -USAGE_END
181 -}
182 -
183 -switch_profile() {
184 - unset TARGET VER LIBPATH FAKE_TARGETS
185 - source "${ENV_D}/${PROFILE}"
186 - if [[ -z ${TARGET} ]] ; then
187 - eerror "${PROFILE} is invalid (no \$TARGET defined) :("
188 - return 1
189 - fi
190 - if [[ -z ${VER} ]] ; then
191 - eerror "${PROFILE} is invalid (no \$VER defined) :("
192 - return 1
193 - fi
194 -
195 - #
196 - # Older installs don't have 'FAKE_TARGETS' defined, so lets
197 - # update these env.d entries so that we don't force the poor
198 - # user to re-emerge their binutils just for 1 envvar :/
199 - #
200 - if [[ ${FAKE_TARGETS-poor user} == "poor user" ]] ; then
201 - local targ=${TARGET/-*}
202 - local FAKE_TARGETS=${TARGET}
203 - case ${targ} in
204 - mips|powerpc|sparc)
205 - FAKE_TARGETS="${FAKE_TARGETS} ${TARGET/-/64-}";;
206 - mips64|powerpc64|sparc64)
207 - FAKE_TARGETS="${FAKE_TARGETS} ${TARGET/64-/-}";;
208 - esac
209 - echo "FAKE_TARGETS=\"${FAKE_TARGETS}\"" >> "${ENV_D}/${PROFILE}"
210 - fi
211 - local fake_targ_append="${TARGET#*-}"
212 - FAKE_TARGETS="${FAKE_TARGETS} ${FAKE_TARGETS_USER// /-${fake_targ_append} }"
213 -
214 - ebegin "Switching to ${PROFILE}"
215 -
216 - #
217 - # Generate binary symlinks
218 - # On systems that do 32bit/64bit, we need to fake an
219 - # extra set of binary names (${FAKE_TARGETS})
220 - #
221 - BINPATH=""
222 - BINPATH_LINKS=""
223 - if [[ ${TARGET} != ${HOST} ]] ; then
224 - #
225 - # Newer paths: /usr/${HOST}/${TARGET}/...
226 - # Older paths: /usr/${TARGET}/...
227 - #
228 - if [[ -d ${ROOT}/usr/${HOST}/${TARGET}/binutils-bin/${VER} ]] ; then
229 - BINPATH=/usr/${HOST}/${TARGET}/binutils-bin/${VER}
230 - BINPATH_LINKS=/usr/libexec/gcc/${TARGET}
231 - fi
232 - fi
233 - if [[ -z ${BINPATH} ]] ; then
234 - BINPATH=/usr/${TARGET}/binutils-bin/${VER}
235 - BINPATH_LINKS=/usr/${TARGET}/bin
236 - fi
237 - cd "${ROOT}/${BINPATH}" || exit 1
238 - mkdir -p "${ROOT}/${BINPATH_LINKS}" "${ROOT}/usr/bin"
239 - for x in * ; do
240 - ln -sf "${BINPATH}/${x}" "${ROOT}/${BINPATH_LINKS}/${x}"
241 - ln -sf "${BINPATH_LINKS}/${x}" "${ROOT}"/usr/bin/${TARGET}-${x}
242 - for fake in ${FAKE_TARGETS} ; do
243 - [[ -f ${ENV_D}/config-${fake} ]] && continue
244 - ln -sf "${BINPATH_LINKS}/${x}" "${ROOT}"/usr/bin/${fake}-${x}
245 - done
246 - if [[ ${TARGET} == ${HOST} ]] ; then
247 - ln -sf ${TARGET}-${x} "${ROOT}"/usr/bin/${x}
248 - fi
249 - done
250 -
251 - #
252 - # Generate library / ldscripts symlinks
253 - #
254 - LIBPATH=${LIBPATH:-/usr/lib/binutils/${TARGET}/${VER}}
255 - cd "${ROOT}/${LIBPATH}" || exit 1
256 - if [[ ${TARGET} == ${HOST} ]] ; then
257 - dstlib=${ROOT}/usr/${HOST}/lib
258 - else
259 - dstlib=${ROOT}/usr/${HOST}/${TARGET}/lib
260 - # Clean out old path
261 - rm -rf "${ROOT}"/usr/${TARGET}/lib/ldscripts
262 - rmdir "${ROOT}"/usr/${TARGET}/lib >& /dev/null
263 - fi
264 - # When upgrading, we need to clean up ldscripts and libs
265 - rm -rf "${dstlib}/ldscripts" "${ROOT}/${BINPATH_LINKS}"/ldscripts
266 - mkdir -p "${dstlib}"
267 - ln -sf "${LIBPATH}/ldscripts" "${dstlib}"/ldscripts
268 - find -L "${dstlib}" -type l -exec rm {} \;
269 - for x in lib* ; do
270 - ln -sf "${LIBPATH}/${x}" "${dstlib}/${x}"
271 - done
272 -
273 - #
274 - # Generate include symlinks
275 - #
276 - INCPATH=${LIBPATH}/include
277 - if [[ -d ${ROOT}/${INCPATH} ]] ; then
278 - cd "${ROOT}/${INCPATH}" || exit 1
279 - if [[ ${HOST} == ${TARGET} ]] ; then
280 - mkdir -p "${ROOT}/usr/include"
281 - for x in * ; do
282 - ln -sf "${INCPATH}/${x}" "${ROOT}/usr/include/${x}"
283 - done
284 - else
285 - # Clean out old path
286 - find . -type f -exec rm -f "${ROOT}/usr/${TARGET}/usr/include/{}" \;
287 - rmdir "${ROOT}/usr/${TARGET}/usr/include" >& /dev/null
288 - rmdir "${ROOT}/usr/${TARGET}/usr" >& /dev/null
289 - rmdir "${ROOT}/usr/${TARGET}" >& /dev/null
290 - fi
291 - fi
292 -
293 - #
294 - # Make sure proper paths get updated
295 - #
296 - if [[ ${TARGET} == ${HOST} ]] ; then
297 - DATAPATH=/usr/share/binutils-data/${TARGET}/${VER}
298 - [[ -d ${DATAPATH}/man ]] && \
299 - echo "MANPATH=${DATAPATH}/man" > "${ROOT}"/etc/env.d/05binutils
300 - [[ -d ${DATAPATH}/info ]] && \
301 - echo "INFOPATH=${DATAPATH}/info" >> "${ROOT}"/etc/env.d/05binutils
302 - # hmm, `ld` has this in SEARCH_DIR(), but ld.so does not ...
303 - echo "LDPATH=/usr/${TARGET}/lib" >> "${ROOT}"/etc/env.d/05binutils
304 - fi
305 -
306 - eend 0
307 -
308 - echo "CURRENT=${VER}" > "${ENV_D}/config-${TARGET}"
309 -
310 - #
311 - # Regen env.d if need/can be
312 - #
313 - if [[ ${ROOT} == "/" ]] && [[ ${TARGET} == ${HOST} ]] ; then
314 - env-update
315 - echo
316 - ewarn "Please remember to run:"
317 - echo
318 - ewarn " # source /etc/profile"
319 - echo
320 - fi
321 -
322 - return 0
323 -}
324 -
325 -uninstall_target() {
326 - if [[ ${TARGET} == ${HOST} ]] ; then
327 - eerror "${argv0}: Refusing to uninstall native binutils"
328 - exit 1
329 - fi
330 -
331 - shopt -s nullglob
332 - PROFILE=""
333 -
334 - for PROFILE in "${ENV_D}"/${TARGET}-* ; do
335 - ewarn "Removing all signs of ${PROFILE##*/}"
336 - rm -f "${ENV_D}"/${PROFILE}
337 - done
338 - if [[ -z ${PROFILE} ]] && [[ ! -e ${ENV_D}/config-${TARGET} ]] ; then
339 - eerror "${argv0}: No profiles exist for '${TARGET}'"
340 - exit 1
341 - fi
342 -
343 - rm -f "${ENV_D}"/config-${TARGET}
344 -
345 - # XXX: we still leave behind FAKE_TARGETS in /usr/bin ...
346 - for x in addr2line ar as c++filt elf2flt flthdr gprof ld ld.real \
347 - nm objcopy objdump ranlib readelf size strings strip ; do
348 - rm -f "${ROOT}"/usr/bin/${TARGET}-${x}
349 - rm -f "${ROOT}"/usr/{${HOST}/,}${TARGET}/bin/${x}
350 - rm -f "${ROOT}"/usr/libexec/gcc/${TARGET}/${x}
351 - done
352 - for x in ansidecl.h bfd.h bfdlink.h dis-asm.h symcat.h ; do
353 - rm -f "${ROOT}"/usr/{${HOST}/,}${TARGET}/{usr/,}include/${x}
354 - done
355 - for x in bfd iberty opcodes ; do
356 - rm -f "${ROOT}"/usr/${HOST}/${TARGET}/lib/lib${x}{{-*,}.so,.a,.la}
357 - done
358 - # Delete broken symlinks
359 - local destdir="${ROOT}/usr/${HOST}/${TARGET}"
360 - rm -f "${destdir}"/lib/ldscripts
361 - find -L "${destdir}"/lib -type l -exec rm {} \;
362 - rmdir "${destdir}"/lib "${destdir}" 2>/dev/null
363 - rmdir "${destdir}"/{bin,include,lib,usr} "${destdir}" 2>/dev/null
364 - rmdir "${ROOT}"/var/db/pkg/cross-${TARGET} 2>/dev/null
365 -
366 - rm -f "${ENV_D}"/${TARGET}-*
367 -}
368 -
369 -get_current_profile() {
370 - if [[ ! -f ${ENV_D}/config-${PROFILE} ]] ; then
371 - eerror "${argv0}: No binutils profile is active!"
372 - return 1
373 - fi
374 -
375 - source "${ENV_D}/config-${PROFILE}"
376 -
377 - if [[ -z ${CURRENT} ]] ; then
378 - eerror "${argv0}: No binutils profile is active!"
379 - return 1
380 - fi
381 -
382 - echo "${PROFILE}-${CURRENT}"
383 -
384 - return 0
385 -}
386 -
387 -list_profiles() {
388 - local i=1
389 -
390 - set_HOST
391 -
392 - if [[ ${ROOT} != / ]] ; then
393 - echo "Using binutils-config info in ${ROOT}"
394 - fi
395 - target=
396 - for x in "${ENV_D}"/* ; do
397 - if [[ -f ${x} ]] && [[ ${x/\/config-} == ${x} ]] ; then
398 - source "${x}"
399 - if [[ ${target} != ${TARGET} ]] ; then
400 - [[ -n ${target} ]] && echo
401 - target=${TARGET}
402 - fi
403 -
404 - x=${x##*/}
405 - if [[ -e ${ENV_D}/config-${TARGET} ]] ; then
406 - source "${ENV_D}/config-${TARGET}"
407 - if [[ ${VER} == ${CURRENT} ]] ; then
408 - [[ ${TARGET} == ${HOST} ]] \
409 - && x="${x} ${GOOD}*${NORMAL}" \
410 - || x="${x} ${HILITE}*${NORMAL}"
411 - fi
412 - fi
413 - echo " [${i}] ${x}"
414 - ((++i))
415 - fi
416 - done
417 -}
418 -
419 -set_HOST() {
420 - [[ -n ${HOST} ]] && return 0
421 -
422 - if [[ -z ${CHOST} ]] ; then
423 - HOST=$(portageq envvar CHOST)
424 - else
425 - HOST=${CHOST}
426 - fi
427 -}
428 -
429 -ENV_D="${ROOT}etc/env.d/binutils"
430 -
431 -DEBUG="no"
432 -NEED_ACTION="yes"
433 -DOIT="switch_profile"
434 -PROFILE=""
435 -FAKE_TARGETS_USER=""
436 -HOST=""
437 -
438 -while [[ $# -gt 0 ]] ; do
439 - x=$1
440 - shift
441 - case ${x} in
442 - -c|--get-current-profile)
443 - if [[ ${NEED_ACTION} == "yes" ]] ; then
444 - NEED_ACTION="no"
445 - DOIT="get_current_profile"
446 - fi
447 - ;;
448 - -d|--debug)
449 - DEBUG="yes"
450 - ;;
451 - -l|--list-profiles)
452 - if [[ ${NEED_ACTION} == "yes" ]] ; then
453 - NEED_ACTION="no"
454 - DOIT="list_profiles"
455 - fi
456 - ;;
457 - -u|--uninstall)
458 - if [[ ${NEED_ACTION} == "yes" ]] ; then
459 - NEED_ACTION="no"
460 - DOIT="uninstall_target"
461 - TARGET=$1
462 - shift
463 - fi
464 - ;;
465 - -h|--help)
466 - usage
467 - exit 0
468 - ;;
469 - -V|--version)
470 - cvsver="$Id$"
471 - cvsver=${cvsver##*binutils-config-}
472 - bver=${cvsver%%,v *}
473 - cvsver=${cvsver#* }
474 - echo "binutils-config-${bver} (r${cvsver%% *})"
475 - exit 0
476 - ;;
477 - --amd64|--arm|--mips|--x86)
478 - if [[ ${NEED_ACTION} == "yes" ]] ; then
479 - # Make sure we have a space after each target
480 - NEED_ACTION="no"
481 - [[ -z ${PROFILE} ]] && PROFILE="current"
482 - case ${x} in
483 - --amd64) FAKE_TARGETS_USER="x86_64 ";;
484 - --arm) FAKE_TARGETS_USER="arm armeb ";;
485 - --x86) FAKE_TARGETS_USER="i386 i486 i586 i686 ";;
486 - --mips) FAKE_TARGETS_USER="mips mips64 mipsel mipsel64 ";;
487 - esac
488 - fi
489 - ;;
490 - -*)
491 - eerror "${0##*/}: Invalid switch! Try '--help'."
492 - exit 1
493 - ;;
494 - *)
495 - if [[ -n ${PROFILE} ]] && [[ ${PROFILE} != "current" ]] ; then
496 - eerror "${argv0}: Too many arguments! Run ${argv0} without parameters for help."
497 - exit 1
498 - fi
499 -
500 - if [[ -z $(echo ${x} | tr -d '[:digit:]') ]] ; then
501 - # User gave us a # representing the profile
502 - i=1
503 - for y in "${ENV_D}"/* ; do
504 - [[ ${y/config-} != ${y} ]] && continue
505 -
506 - if [[ -f ${y} ]] && [[ ${x} -eq ${i} ]] ; then
507 - PROFILE=${y##*/}
508 - NEED_ACTION="no"
509 - break
510 - fi
511 - ((++i))
512 - done
513 - fi
514 -
515 - if [[ -z ${PROFILE} ]] ; then
516 - # User gave us a full HOST-ver
517 - x=${x##*/}
518 - if [[ ! -f ${ENV_D}/${x} ]] && [[ ! -f ${ENV_D}/config-${x} ]] ; then
519 - # Maybe they just gave us a ver ...
520 - set_HOST
521 - if [[ -f ${ENV_D}/${HOST}-${x} ]] ; then
522 - x=${HOST}-${x}
523 - else
524 - eerror "${argv0}: Could not locate '$x' in '${ENV_D}/'!"
525 - exit 1
526 - fi
527 - fi
528 - PROFILE=${x}
529 - NEED_ACTION="no"
530 - fi
531 - ;;
532 - esac
533 -done
534 -
535 -[[ ${NEED_ACTION} == "yes" ]] && usage && exit 1
536 -[[ ${DEBUG} == "yes" ]] && set -x
537 -
538 -[[ ${DOIT} != "list_profiles" ]] && set_HOST
539 -[[ -z ${PROFILE} ]] && PROFILE=${HOST}
540 -[[ ${PROFILE} == "current" ]] && PROFILE=$(PROFILE=${HOST} get_current_profile)
541 -eval ${DOIT}
542 -
543 -# vim:ts=4
544
545 diff --git a/sys-devel/binutils-config/files/binutils-config-2 b/sys-devel/binutils-config/files/binutils-config-2
546 deleted file mode 100644
547 index 48b9d51..0000000
548 --- a/sys-devel/binutils-config/files/binutils-config-2
549 +++ /dev/null
550 @@ -1,434 +0,0 @@
551 -#!/bin/bash
552 -# Copyright 1999-2009 Gentoo Foundation
553 -# Distributed under the terms of the GNU General Public License v2
554 -# $Id$
555 -
556 -# Format of /etc/env.d/binutils/:
557 -# config-TARGET: CURRENT=version for TARGET
558 -# TARGET-VER: has a TARGET and VER variable
559 -
560 -: ${ROOT:=/}
561 -[[ ${ROOT} != */ ]] && ROOT="${ROOT}/"
562 -[[ ${ROOT} != /* ]] && ROOT="${PWD}${ROOT}"
563 -
564 -cd /
565 -
566 -trap ":" INT QUIT TSTP
567 -
568 -argv0=${0##*/}
569 -source /etc/init.d/functions.sh || {
570 - echo "${argv0}: Could not source /etc/init.d/functions.sh!" 1>&2
571 - exit 1
572 -}
573 -esyslog() { :; }
574 -umask 022
575 -
576 -usage() {
577 -cat << USAGE_END
578 -
579 -Usage: ${HILITE}binutils-config${NORMAL} ${GOOD}[options]${NORMAL} ${BRACKET}[binutils profile]${NORMAL}
580 -
581 -${HILITE}General Options:${NORMAL}
582 - ${GOOD}-c, --get-current-profile${NORMAL} Print current profile
583 - ${GOOD}-l, --list-profiles${NORMAL} Print a list of available profiles
584 - ${GOOD}-u, --uninstall${NORMAL} Remove all signs of specified target
585 - ${GOOD}-d, --debug${NORMAL} Execute with debug output
586 -
587 -${HILITE}Arch Specific Cruft:${NORMAL}
588 - ${GOOD}--amd64${NORMAL} Install extra amd64 links (x86_64)
589 - ${GOOD}--arm${NORMAL} Install extra arm links (arm/armeb)
590 - ${GOOD}--mips${NORMAL} Install extra mips links (mips/mipsel)
591 - ${GOOD}--x86${NORMAL} Install extra x86 links (i[3-6]86)
592 -
593 -Profile names are of the form: ${BRACKET}<CTARGET>-<binutils version>${NORMAL}
594 -For example: ${BRACKET}i686-pc-linux-gnu-2.15.92.0.2${NORMAL}
595 -
596 -For more info, please see ${HILITE}binutils-config${NORMAL}(8).
597 -USAGE_END
598 -
599 - exit ${1:-1}
600 -}
601 -
602 -mv_if_diff() {
603 - if cmp -s "$1" "$2" ; then
604 - rm -f "$1"
605 - else
606 - mv -f "$1" "$2"
607 - fi
608 -}
609 -
610 -switch_profile() {
611 - unset TARGET VER LIBPATH FAKE_TARGETS
612 - source "${ENV_D}/${PROFILE}"
613 - if [[ -z ${TARGET} ]] ; then
614 - eerror "${PROFILE} is invalid (no \$TARGET defined) :("
615 - return 1
616 - fi
617 - if [[ -z ${VER} ]] ; then
618 - eerror "${PROFILE} is invalid (no \$VER defined) :("
619 - return 1
620 - fi
621 -
622 - #
623 - # Older installs don't have 'FAKE_TARGETS' defined, so lets
624 - # update these env.d entries so that we don't force the poor
625 - # user to re-emerge their binutils just for 1 envvar :/
626 - #
627 - if [[ ${FAKE_TARGETS-poor user} == "poor user" ]] ; then
628 - local targ=${TARGET/-*}
629 - local FAKE_TARGETS=${TARGET}
630 - case ${targ} in
631 - mips|powerpc|sparc)
632 - FAKE_TARGETS="${FAKE_TARGETS} ${TARGET/-/64-}";;
633 - mips64|powerpc64|sparc64)
634 - FAKE_TARGETS="${FAKE_TARGETS} ${TARGET/64-/-}";;
635 - esac
636 - echo "FAKE_TARGETS=\"${FAKE_TARGETS}\"" >> "${ENV_D}/${PROFILE}"
637 - fi
638 - local fake_targ_append="${TARGET#*-}"
639 - FAKE_TARGETS="${FAKE_TARGETS} ${FAKE_TARGETS_USER// /-${fake_targ_append} }"
640 -
641 - ebegin "Switching to ${PROFILE}"
642 -
643 - #
644 - # Generate binary symlinks
645 - # On systems that do 32bit/64bit, we need to fake an
646 - # extra set of binary names (${FAKE_TARGETS})
647 - #
648 - BINPATH=""
649 - BINPATH_LINKS=""
650 - if [[ ${TARGET} != ${HOST} ]] ; then
651 - #
652 - # Newer paths: /usr/${HOST}/${TARGET}/...
653 - # Older paths: /usr/${TARGET}/...
654 - #
655 - if [[ -d ${ROOT}/usr/${HOST}/${TARGET}/binutils-bin/${VER} ]] ; then
656 - BINPATH=/usr/${HOST}/${TARGET}/binutils-bin/${VER}
657 - BINPATH_LINKS=/usr/libexec/gcc/${TARGET}
658 - fi
659 - fi
660 - if [[ -z ${BINPATH} ]] ; then
661 - BINPATH=/usr/${TARGET}/binutils-bin/${VER}
662 - BINPATH_LINKS=/usr/${TARGET}/bin
663 - fi
664 - cd "${ROOT}/${BINPATH}" || exit 1
665 - mkdir -p "${ROOT}/${BINPATH_LINKS}" "${ROOT}/usr/bin"
666 - for x in * ; do
667 - ln -sf "${BINPATH}/${x}" "${ROOT}/${BINPATH_LINKS}/${x}"
668 - ln -sf "${BINPATH_LINKS}/${x}" "${ROOT}"/usr/bin/${TARGET}-${x}
669 - for fake in ${FAKE_TARGETS} ; do
670 - [[ -f ${ENV_D}/config-${fake} ]] && continue
671 - ln -sf "${BINPATH_LINKS}/${x}" "${ROOT}"/usr/bin/${fake}-${x}
672 - done
673 - if [[ ${TARGET} == ${HOST} ]] ; then
674 - ln -sf ${TARGET}-${x} "${ROOT}"/usr/bin/${x}
675 - fi
676 - done
677 -
678 - #
679 - # Generate library / ldscripts symlinks
680 - #
681 - : ${LIBPATH:=/usr/lib/binutils/${TARGET}/${VER}}
682 - cd "${ROOT}/${LIBPATH}" || exit 1
683 - if [[ ${TARGET} == ${HOST} ]] ; then
684 - dstlib=${ROOT}/usr/${HOST}/lib
685 - else
686 - dstlib=${ROOT}/usr/${HOST}/${TARGET}/lib
687 - # Clean out old path
688 - rm -rf "${ROOT}"/usr/${TARGET}/lib/ldscripts
689 - rmdir "${ROOT}"/usr/${TARGET}/lib >& /dev/null
690 - fi
691 - # When upgrading, we need to clean up ldscripts and libs
692 - rm -rf "${dstlib}/ldscripts" "${ROOT}/${BINPATH_LINKS}"/ldscripts
693 - mkdir -p "${dstlib}"
694 - ln -sf "${LIBPATH}/ldscripts" "${dstlib}"/ldscripts
695 - find -L "${dstlib}" -type l -exec rm {} +
696 - for x in lib* ; do
697 - ln -sf "${LIBPATH}/${x}" "${dstlib}/${x}"
698 - done
699 -
700 - #
701 - # Generate include symlinks
702 - #
703 - INCPATH=${LIBPATH}/include
704 - if [[ -d ${ROOT}/${INCPATH} ]] ; then
705 - cd "${ROOT}/${INCPATH}" || exit 1
706 - if [[ ${HOST} == ${TARGET} ]] ; then
707 - mkdir -p "${ROOT}/usr/include"
708 - for x in * ; do
709 - ln -sf "${INCPATH}/${x}" "${ROOT}/usr/include/${x}"
710 - done
711 - else
712 - # Clean out old path -- cannot use '-exec {} +' syntax here
713 - find . -type f -exec rm -f "${ROOT}/usr/${TARGET}/usr/include/{}" \;
714 - rmdir "${ROOT}/usr/${TARGET}/usr/include" >& /dev/null
715 - rmdir "${ROOT}/usr/${TARGET}/usr" >& /dev/null
716 - rmdir "${ROOT}/usr/${TARGET}" >& /dev/null
717 - fi
718 - fi
719 -
720 - #
721 - # Make sure proper paths get updated
722 - #
723 - if [[ ${TARGET} == ${HOST} ]] ; then
724 - DATAPATH=/usr/share/binutils-data/${TARGET}/${VER}
725 - local e="${ROOT}"/etc/env.d/05binutils
726 - local ee="${e}.tmp"
727 - rm -f "${ee}"
728 - [[ -d ${DATAPATH}/man ]] && echo "MANPATH=${DATAPATH}/man" >> "${ee}"
729 - [[ -d ${DATAPATH}/info ]] && echo "INFOPATH=${DATAPATH}/info" >> "${ee}"
730 - # hmm, `ld` has this in SEARCH_DIR(), but ld.so does not ...
731 - if [[ -d ${ROOT}/etc/ld.so.conf.d ]] ; then
732 - local l="${ROOT}"/etc/ld.so.conf.d/05binutils.conf
733 - local ll="${l}.tmp"
734 - echo "/usr/${TARGET}/lib" > "${ll}"
735 - mv_if_diff "${ll}" "${l}"
736 - else
737 - echo "LDPATH=/usr/${TARGET}/lib" >> "${ee}"
738 - fi
739 - mv_if_diff "${ee}" "${e}"
740 - fi
741 -
742 - local c="${ENV_D}/config-${TARGET}"
743 - local cc="${c}.tmp"
744 - echo "CURRENT=${VER}" > "${cc}"
745 - mv_if_diff "${cc}" "${c}"
746 -
747 - eend 0
748 -
749 - #
750 - # Regen env.d if need/can be
751 - #
752 - if [[ ${ROOT} == "/" ]] && [[ ${TARGET} == ${HOST} ]] ; then
753 - env-update
754 - echo
755 - ewarn "Please remember to run:"
756 - echo
757 - ewarn " # . /etc/profile"
758 - echo
759 - fi
760 -
761 - return 0
762 -}
763 -
764 -uninstall_target() {
765 - if [[ ${TARGET} == ${HOST} ]] ; then
766 - eerror "${argv0}: Refusing to uninstall native binutils"
767 - exit 1
768 - fi
769 -
770 - shopt -s nullglob
771 - PROFILE=""
772 -
773 - for PROFILE in "${ENV_D}"/${TARGET}-* ; do
774 - ewarn "Removing all signs of ${PROFILE##*/}"
775 - rm -f "${ENV_D}"/${PROFILE}
776 - done
777 - if [[ -z ${PROFILE} ]] && [[ ! -e ${ENV_D}/config-${TARGET} ]] ; then
778 - eerror "${argv0}: No profiles exist for '${TARGET}'"
779 - exit 1
780 - fi
781 -
782 - rm -f "${ENV_D}"/config-${TARGET} "${ROOT}"/etc/ld.so.conf.d/05binutils.conf
783 -
784 - # XXX: we still leave behind FAKE_TARGETS in /usr/bin ...
785 - for x in addr2line ar as c++filt elf2flt flthdr gprof ld ld.real \
786 - nm objcopy objdump ranlib readelf size strings strip ; do
787 - rm -f "${ROOT}"/usr/bin/${TARGET}-${x}
788 - rm -f "${ROOT}"/usr/{${HOST}/,}${TARGET}/bin/${x}
789 - rm -f "${ROOT}"/usr/libexec/gcc/${TARGET}/${x}
790 - done
791 - for x in ansidecl.h bfd.h bfdlink.h dis-asm.h symcat.h ; do
792 - rm -f "${ROOT}"/usr/{${HOST}/,}${TARGET}/{usr/,}include/${x}
793 - done
794 - for x in bfd iberty opcodes ; do
795 - rm -f "${ROOT}"/usr/${HOST}/${TARGET}/lib/lib${x}{{-*,}.so,.a,.la}
796 - done
797 - # Delete broken symlinks
798 - local destdir="${ROOT}/usr/${HOST}/${TARGET}"
799 - rm -f "${destdir}"/lib/ldscripts
800 - find -L "${destdir}"/lib -type l -exec rm {} +
801 - rmdir \
802 - "${destdir}"/{bin,include,lib,usr} \
803 - "${destdir}" \
804 - "${ROOT}"/var/db/pkg/cross-${TARGET} \
805 - 2>/dev/null
806 -
807 - rm -f "${ENV_D}"/${TARGET}-*
808 -}
809 -
810 -get_current_profile() {
811 - if [[ ! -f ${ENV_D}/config-${PROFILE} ]] ; then
812 - eerror "${argv0}: No binutils profile is active!"
813 - return 1
814 - fi
815 -
816 - source "${ENV_D}/config-${PROFILE}"
817 -
818 - if [[ -z ${CURRENT} ]] ; then
819 - eerror "${argv0}: No binutils profile is active!"
820 - return 1
821 - fi
822 -
823 - echo "${PROFILE}-${CURRENT}"
824 -
825 - return 0
826 -}
827 -
828 -list_profiles() {
829 - local i=1
830 -
831 - set_HOST
832 -
833 - if [[ ${ROOT} != / ]] ; then
834 - echo "Using binutils-config info in ${ROOT}"
835 - fi
836 - target=
837 - for x in "${ENV_D}"/* ; do
838 - if [[ -f ${x} ]] && [[ ${x/\/config-} == ${x} ]] ; then
839 - source "${x}"
840 - if [[ ${target} != ${TARGET} ]] ; then
841 - [[ -n ${target} ]] && echo
842 - target=${TARGET}
843 - fi
844 -
845 - x=${x##*/}
846 - if [[ -e ${ENV_D}/config-${TARGET} ]] ; then
847 - source "${ENV_D}/config-${TARGET}"
848 - if [[ ${VER} == ${CURRENT} ]] ; then
849 - [[ ${TARGET} == ${HOST} ]] \
850 - && x="${x} ${GOOD}*${NORMAL}" \
851 - || x="${x} ${HILITE}*${NORMAL}"
852 - fi
853 - fi
854 - echo " [${i}] ${x}"
855 - ((++i))
856 - fi
857 - done
858 -}
859 -
860 -set_HOST() {
861 - [[ -n ${HOST} ]] && return 0
862 -
863 - if [[ -z ${CHOST} ]] ; then
864 - HOST=$(portageq envvar CHOST)
865 - else
866 - HOST=${CHOST}
867 - fi
868 -}
869 -
870 -ENV_D="${ROOT}etc/env.d/binutils"
871 -
872 -DEBUG="no"
873 -NEED_ACTION="yes"
874 -DOIT="switch_profile"
875 -PROFILE=""
876 -FAKE_TARGETS_USER=""
877 -HOST=""
878 -
879 -while [[ $# -gt 0 ]] ; do
880 - x=$1
881 - shift
882 - case ${x} in
883 - -c|--get-current-profile)
884 - if [[ ${NEED_ACTION} == "yes" ]] ; then
885 - NEED_ACTION="no"
886 - DOIT="get_current_profile"
887 - fi
888 - ;;
889 - -d|--debug)
890 - DEBUG="yes"
891 - ;;
892 - -l|--list-profiles)
893 - if [[ ${NEED_ACTION} == "yes" ]] ; then
894 - NEED_ACTION="no"
895 - DOIT="list_profiles"
896 - fi
897 - ;;
898 - -u|--uninstall)
899 - if [[ ${NEED_ACTION} == "yes" ]] ; then
900 - NEED_ACTION="no"
901 - DOIT="uninstall_target"
902 - TARGET=$1
903 - shift
904 - fi
905 - ;;
906 - -h|--help)
907 - usage 0
908 - ;;
909 - -V|--version)
910 - unset Header
911 - cvsver="$Id$"
912 - cvsver=${cvsver##*binutils-config-}
913 - bver=${cvsver%%,v *}
914 - cvsver=${cvsver#* }
915 - echo "binutils-config-${bver} (r${cvsver%% *})"
916 - exit 0
917 - ;;
918 - --amd64|--arm|--mips|--x86)
919 - if [[ ${NEED_ACTION} == "yes" ]] ; then
920 - # Make sure we have a space after each target
921 - NEED_ACTION="no"
922 - [[ -z ${PROFILE} ]] && PROFILE="current"
923 - case ${x} in
924 - --amd64) FAKE_TARGETS_USER="x86_64 ";;
925 - --arm) FAKE_TARGETS_USER="arm armeb ";;
926 - --x86) FAKE_TARGETS_USER="i386 i486 i586 i686 ";;
927 - --mips) FAKE_TARGETS_USER="mips mips64 mipsel mipsel64 ";;
928 - esac
929 - fi
930 - ;;
931 - -*)
932 - eerror "${0##*/}: Invalid switch! Try '--help'."
933 - exit 1
934 - ;;
935 - *)
936 - if [[ -n ${PROFILE} ]] && [[ ${PROFILE} != "current" ]] ; then
937 - eerror "${argv0}: Too many arguments! Run ${argv0} without parameters for help."
938 - exit 1
939 - fi
940 -
941 - if [[ -z $(echo ${x} | tr -d '[:digit:]') ]] ; then
942 - # User gave us a # representing the profile
943 - i=1
944 - for y in "${ENV_D}"/* ; do
945 - [[ ${y/config-} != ${y} ]] && continue
946 -
947 - if [[ -f ${y} ]] && [[ ${x} -eq ${i} ]] ; then
948 - PROFILE=${y##*/}
949 - NEED_ACTION="no"
950 - break
951 - fi
952 - ((++i))
953 - done
954 - fi
955 -
956 - if [[ -z ${PROFILE} ]] ; then
957 - # User gave us a full HOST-ver
958 - x=${x##*/}
959 - if [[ ! -f ${ENV_D}/${x} ]] && [[ ! -f ${ENV_D}/config-${x} ]] ; then
960 - # Maybe they just gave us a ver ...
961 - set_HOST
962 - if [[ -f ${ENV_D}/${HOST}-${x} ]] ; then
963 - x=${HOST}-${x}
964 - else
965 - eerror "${argv0}: Could not locate '$x' in '${ENV_D}/'!"
966 - exit 1
967 - fi
968 - fi
969 - PROFILE=${x}
970 - NEED_ACTION="no"
971 - fi
972 - ;;
973 - esac
974 -done
975 -
976 -[[ ${NEED_ACTION} == "yes" ]] && usage 1
977 -[[ ${DEBUG} == "yes" ]] && set -x
978 -
979 -[[ ${DOIT} != "list_profiles" ]] && set_HOST
980 -[[ -z ${PROFILE} ]] && PROFILE=${HOST}
981 -[[ ${PROFILE} == "current" ]] && PROFILE=$(PROFILE=${HOST} get_current_profile)
982 -eval ${DOIT}
983 -
984 -# vim:ts=4
985
986 diff --git a/sys-devel/binutils-config/files/binutils-config-3 b/sys-devel/binutils-config/files/binutils-config-3
987 deleted file mode 100644
988 index a9e9412..0000000
989 --- a/sys-devel/binutils-config/files/binutils-config-3
990 +++ /dev/null
991 @@ -1,509 +0,0 @@
992 -#!/bin/bash
993 -# Copyright 1999-2013 Gentoo Foundation
994 -# Distributed under the terms of the GNU General Public License v2
995 -# $Id$
996 -
997 -# Format of /etc/env.d/binutils/:
998 -# config-TARGET: CURRENT=version for TARGET
999 -# TARGET-VER: has a TARGET and VER variable
1000 -
1001 -: ${ROOT:=/}
1002 -[[ ${ROOT} != */ ]] && ROOT="${ROOT}/"
1003 -[[ ${ROOT} != /* ]] && ROOT="${PWD%/}/${ROOT}"
1004 -
1005 -cd /
1006 -
1007 -trap ":" INT QUIT TSTP
1008 -
1009 -argv0=${0##*/}
1010 -source /etc/init.d/functions.sh || {
1011 - echo "${argv0}: Could not source /etc/init.d/functions.sh!" 1>&2
1012 - exit 1
1013 -}
1014 -esyslog() { :; }
1015 -die() { eerror "${argv0}: $*"; exit 1; }
1016 -umask 022
1017 -
1018 -usage() {
1019 -cat << USAGE_END
1020 -Usage: ${HILITE}binutils-config${NORMAL} ${GOOD}[options]${NORMAL} ${BRACKET}[binutils profile]${NORMAL}
1021 -
1022 -${HILITE}General Options:${NORMAL}
1023 - ${GOOD}-c, --get-current-profile${NORMAL} Print current profile
1024 - ${GOOD}-l, --list-profiles${NORMAL} Print a list of available profiles
1025 - ${GOOD}-u, --uninstall${NORMAL} Remove all signs of specified target
1026 - ${GOOD}-d, --debug${NORMAL} Execute with debug output
1027 -
1028 -${HILITE}General Cruft:${NORMAL}
1029 - ${GOOD}--linker${NORMAL} <linker> Switch to specified linker (if supported)
1030 -
1031 -${HILITE}Arch Specific Cruft:${NORMAL}
1032 - ${GOOD}--amd64${NORMAL} Install extra amd64 links (x86_64)
1033 - ${GOOD}--arm${NORMAL} Install extra arm links (arm/armeb)
1034 - ${GOOD}--mips${NORMAL} Install extra mips links (mips/mipsel)
1035 - ${GOOD}--x86${NORMAL} Install extra x86 links (i[3-6]86)
1036 -
1037 -Profile names are of the form: ${BRACKET}<CTARGET>-<binutils version>${NORMAL}
1038 -For example: ${BRACKET}i686-pc-linux-gnu-2.15.92.0.2${NORMAL}
1039 -
1040 -For more info, please see ${HILITE}binutils-config${NORMAL}(8).
1041 -USAGE_END
1042 -
1043 - exit ${1:-1}
1044 -}
1045 -
1046 -mv_if_diff() {
1047 - if cmp -s "$1" "$2" ; then
1048 - rm -f "$1"
1049 - else
1050 - mv -f "$1" "$2"
1051 - fi
1052 -}
1053 -atomic_ln() {
1054 - local target=$1 linkdir=$2 linkname=$3 linktmp linkfull
1055 - linktmp="${linkdir}/.binutils-config.tmp.${linkname}"
1056 - linkfull="${linkdir}/${linkname}"
1057 - if [[ -d ${linkfull} ]] ; then
1058 - # if linking to a dir, we need a little magic to
1059 - # make it atomic since `mv -T` is not portable
1060 - rm -rf "${linktmp}"
1061 - mkdir -p "${linktmp}"
1062 - ln -sf "${target}" "${linktmp}/${linkname}"
1063 - mv "${linktmp}/${linkname}" "${linktmp}/../"
1064 - rmdir "${linktmp}"
1065 - else
1066 - # `ln` will expand into unlink();symlink(); which
1067 - # is not atomic for a small amount of time, but
1068 - # `mv` is a single rename() call
1069 - ln -sf "${target}" "${linktmp}"
1070 - mv "${linktmp}" "${linkfull}"
1071 - fi
1072 -}
1073 -
1074 -setup_env() {
1075 - unset TARGET VER LIBPATH FAKE_TARGETS
1076 - source "${ENV_D}/${PROFILE}"
1077 - if [[ -z ${TARGET} ]] ; then
1078 - eerror "${PROFILE} is invalid (no \$TARGET defined) :("
1079 - return 1
1080 - fi
1081 - if [[ -z ${VER} ]] ; then
1082 - eerror "${PROFILE} is invalid (no \$VER defined) :("
1083 - return 1
1084 - fi
1085 -
1086 - #
1087 - # Older installs don't have 'FAKE_TARGETS' defined, so lets
1088 - # update these env.d entries so that we don't force the poor
1089 - # user to re-emerge their binutils just for 1 envvar :/
1090 - #
1091 - if [[ ${FAKE_TARGETS-poor user} == "poor user" ]] ; then
1092 - local targ=${TARGET/-*}
1093 - local FAKE_TARGETS=${TARGET}
1094 - case ${targ} in
1095 - mips|powerpc|sparc)
1096 - FAKE_TARGETS="${FAKE_TARGETS} ${TARGET/-/64-}";;
1097 - mips64|powerpc64|sparc64)
1098 - FAKE_TARGETS="${FAKE_TARGETS} ${TARGET/64-/-}";;
1099 - esac
1100 - echo "FAKE_TARGETS=\"${FAKE_TARGETS}\"" >> "${ENV_D}/${PROFILE}"
1101 - fi
1102 - local fake_targ_append="${TARGET#*-}"
1103 - FAKE_TARGETS="${FAKE_TARGETS} ${FAKE_TARGETS_USER// /-${fake_targ_append} }"
1104 -
1105 - #
1106 - # Generate binary symlinks
1107 - # On systems that do 32bit/64bit, we need to fake an
1108 - # extra set of binary names (${FAKE_TARGETS})
1109 - #
1110 - BINPATH=""
1111 - BINPATH_LINKS=""
1112 - if [[ ${TARGET} != ${HOST} ]] ; then
1113 - #
1114 - # Newer paths: /usr/${HOST}/${TARGET}/...
1115 - # Older paths: /usr/${TARGET}/...
1116 - #
1117 - if [[ -d ${ROOT}/usr/${HOST}/${TARGET}/binutils-bin/${VER} ]] ; then
1118 - BINPATH=/usr/${HOST}/${TARGET}/binutils-bin/${VER}
1119 - BINPATH_LINKS=/usr/libexec/gcc/${TARGET}
1120 - fi
1121 - fi
1122 - if [[ -z ${BINPATH} ]] ; then
1123 - BINPATH=/usr/${TARGET}/binutils-bin/${VER}
1124 - BINPATH_LINKS=/usr/${TARGET}/bin
1125 - fi
1126 -}
1127 -
1128 -switch_profile() {
1129 - ebegin "Switching to ${PROFILE}"
1130 -
1131 - setup_env || return 1
1132 -
1133 - cd "${ROOT}/${BINPATH}" || exit 1
1134 - mkdir -p "${ROOT}/${BINPATH_LINKS}" "${ROOT}/usr/bin"
1135 - for x in * ; do
1136 - atomic_ln "${BINPATH}/${x}" "${ROOT}/${BINPATH_LINKS}" "${x}"
1137 - atomic_ln "${BINPATH_LINKS}/${x}" "${ROOT}/usr/bin/" "${TARGET}-${x}"
1138 - for fake in ${FAKE_TARGETS} ; do
1139 - [[ -f ${ENV_D}/config-${fake} ]] && continue
1140 - atomic_ln "${BINPATH_LINKS}/${x}" "${ROOT}/usr/bin" "${fake}-${x}"
1141 - done
1142 - if [[ ${TARGET} == ${HOST} ]] ; then
1143 - atomic_ln "${TARGET}-${x}" "${ROOT}/usr/bin" "${x}"
1144 - fi
1145 - done
1146 -
1147 - #
1148 - # Generate library / ldscripts symlinks
1149 - #
1150 - : ${LIBPATH:=/usr/lib/binutils/${TARGET}/${VER}}
1151 - cd "${ROOT}/${LIBPATH}" || exit 1
1152 - if [[ ${TARGET} == ${HOST} ]] ; then
1153 - dstlib=${ROOT}/usr/${HOST}/lib
1154 - else
1155 - dstlib=${ROOT}/usr/${HOST}/${TARGET}/lib
1156 - fi
1157 - # When upgrading, we need to clean up ldscripts and libs
1158 - mkdir -p "${dstlib}"
1159 - rm -rf "${ROOT}/${BINPATH_LINKS}"/ldscripts
1160 - atomic_ln "${LIBPATH}/ldscripts" "${dstlib}" "ldscripts"
1161 - find -L "${dstlib}" -type l -exec rm -v {} +
1162 - for x in lib* ; do
1163 - atomic_ln "${LIBPATH}/${x}" "${dstlib}" "${x}"
1164 - done
1165 -
1166 - #
1167 - # Generate include symlinks
1168 - #
1169 - INCPATH=${LIBPATH}/include
1170 - if [[ -d ${ROOT}/${INCPATH} ]] ; then
1171 - cd "${ROOT}/${INCPATH}" || exit 1
1172 - if [[ ${HOST} == ${TARGET} ]] ; then
1173 - mkdir -p "${ROOT}/usr/include"
1174 - for x in * ; do
1175 - atomic_ln "${INCPATH}/${x}" "${ROOT}/usr/include" "${x}"
1176 - done
1177 - else
1178 - # Clean out old path -- cannot use '-exec {} +' syntax here
1179 - find . -type f -exec rm -f "${ROOT}/usr/${TARGET}/usr/include/{}" \;
1180 - rmdir "${ROOT}/usr/${TARGET}/usr/include" >& /dev/null
1181 - rmdir "${ROOT}/usr/${TARGET}/usr" >& /dev/null
1182 - rmdir "${ROOT}/usr/${TARGET}" >& /dev/null
1183 - fi
1184 - fi
1185 -
1186 - #
1187 - # Make sure proper paths get updated
1188 - #
1189 - if [[ ${TARGET} == ${HOST} ]] ; then
1190 - DATAPATH=/usr/share/binutils-data/${TARGET}/${VER}
1191 - local e="${ROOT}"/etc/env.d/05binutils
1192 - local ee="${e}.tmp"
1193 - rm -f "${ee}"
1194 - [[ -d ${DATAPATH}/man ]] && echo "MANPATH=${DATAPATH}/man" >> "${ee}"
1195 - [[ -d ${DATAPATH}/info ]] && echo "INFOPATH=${DATAPATH}/info" >> "${ee}"
1196 - # hmm, `ld` has this in SEARCH_DIR(), but ld.so does not ...
1197 - if [[ -d ${ROOT}/etc/ld.so.conf.d ]] ; then
1198 - local l="${ROOT}"/etc/ld.so.conf.d/05binutils.conf
1199 - local ll="${l}.tmp"
1200 - echo "/usr/${TARGET}/lib" > "${ll}"
1201 - mv_if_diff "${ll}" "${l}"
1202 - else
1203 - echo "LDPATH=/usr/${TARGET}/lib" >> "${ee}"
1204 - fi
1205 - mv_if_diff "${ee}" "${e}"
1206 - fi
1207 -
1208 - local c="${ENV_D}/config-${TARGET}"
1209 - local cc="${c}.tmp"
1210 - echo "CURRENT=${VER}" > "${cc}"
1211 - mv_if_diff "${cc}" "${c}"
1212 -
1213 - eend 0
1214 -
1215 - #
1216 - # Regen env.d if need/can be
1217 - #
1218 - if [[ ${ROOT} == "/" ]] && [[ ${TARGET} == ${HOST} ]] ; then
1219 - env-update
1220 - echo
1221 - ewarn "Please remember to run:"
1222 - echo
1223 - ewarn " # . /etc/profile"
1224 - echo
1225 - fi
1226 -
1227 - return 0
1228 -}
1229 -
1230 -uninstall_target() {
1231 - : ${TARGET:=${UARG}}
1232 -
1233 - if [[ ${TARGET} == ${HOST} ]] ; then
1234 - die "refusing to uninstall native binutils"
1235 - fi
1236 -
1237 - shopt -s nullglob
1238 - PROFILE=""
1239 -
1240 - for PROFILE in "${ENV_D}"/${TARGET}-* ; do
1241 - ewarn "Removing all signs of ${PROFILE##*/}"
1242 - rm -f "${ENV_D}"/${PROFILE}
1243 - done
1244 - if [[ -z ${PROFILE} ]] && [[ ! -e ${ENV_D}/config-${TARGET} ]] ; then
1245 - die "no profiles exist for '${TARGET}'"
1246 - fi
1247 -
1248 - rm -f "${ENV_D}"/config-${TARGET} "${ROOT}"/etc/ld.so.conf.d/05binutils.conf
1249 -
1250 - # XXX: we still leave behind FAKE_TARGETS in /usr/bin ...
1251 - local x
1252 - for x in \
1253 - addr2line ar as c++filt elf2flt elfedit flthdr gprof \
1254 - ld ld.{bfd,gold,real} \
1255 - nm objcopy objdump ranlib readelf size strings strip
1256 - do
1257 - x=(
1258 - "${ROOT}"/usr/bin/${TARGET}-${x}
1259 - "${ROOT}"/usr/{${HOST}/,}${TARGET}/bin/${x}
1260 - "${ROOT}"/usr/libexec/gcc/${TARGET}/${x}
1261 - )
1262 - rm -f "${x[@]}"
1263 - done
1264 - for x in ansidecl.h bfd.h bfdlink.h dis-asm.h symcat.h ; do
1265 - rm -f "${ROOT}"/usr/{${HOST}/,}${TARGET}/{usr/,}include/${x}
1266 - done
1267 - for x in bfd iberty opcodes ; do
1268 - rm -f "${ROOT}"/usr/${HOST}/${TARGET}/lib/lib${x}{{-*,}.so,.a,.la}
1269 - done
1270 - # Delete broken symlinks
1271 - local destdir="${ROOT}/usr/${HOST}/${TARGET}"
1272 - rm -f "${destdir}"/lib/ldscripts
1273 - find -L "${destdir}"/lib -type l -exec rm {} +
1274 - rmdir \
1275 - "${destdir}"/{bin,include,lib,usr} \
1276 - "${destdir}" \
1277 - "${ROOT}"/var/db/pkg/cross-${TARGET} \
1278 - "${ROOT}"/usr/{${HOST}/,}${TARGET}/bin \
1279 - "${ROOT}"/usr/libexec/gcc/${TARGET} \
1280 - 2>/dev/null
1281 -
1282 - rm -f "${ENV_D}"/${TARGET}-*
1283 -}
1284 -
1285 -set_current_profile() {
1286 - if [[ ! -f ${ENV_D}/config-${TARGET} ]] ; then
1287 - eerror "${argv0}: unable to locate a profile for target: ${TARGET}"
1288 - return 1
1289 - fi
1290 -
1291 - source "${ENV_D}/config-${TARGET}"
1292 -
1293 - if [[ -z ${CURRENT} ]] ; then
1294 - eerror "${argv0}: no binutils profile is active!"
1295 - return 1
1296 - fi
1297 -
1298 - echo "${TARGET}-${CURRENT}"
1299 -
1300 - return 0
1301 -}
1302 -get_current_profile() { echo "${PROFILE}" ; }
1303 -
1304 -list_profiles() {
1305 - local x i target
1306 -
1307 - if [[ ${ROOT} != / ]] ; then
1308 - echo "Using binutils-config info in ${ROOT}"
1309 - fi
1310 -
1311 - set -- "${ENV_D}"/*
1312 - target=
1313 - i=1
1314 -
1315 - for x ; do
1316 - # skip broken links and config files
1317 - [[ -f ${x} ]] || continue
1318 - [[ ${x} == */config-* ]] && continue
1319 -
1320 - source "${x}"
1321 - if [[ ${target} != ${TARGET} ]] ; then
1322 - [[ -n ${target} ]] && echo
1323 - target=${TARGET}
1324 - fi
1325 -
1326 - x=${x##*/}
1327 - if [[ -e ${ENV_D}/config-${TARGET} ]] ; then
1328 - source "${ENV_D}/config-${TARGET}"
1329 - if [[ ${VER} == ${CURRENT} ]] ; then
1330 - [[ ${TARGET} == ${HOST} ]] \
1331 - && x="${x} ${GOOD}*${NORMAL}" \
1332 - || x="${x} ${HILITE}*${NORMAL}"
1333 - fi
1334 - fi
1335 -
1336 - # We would align the [...] field like so:
1337 - #printf ' [%*ss] %s\n' ${##} "${i}" "${x}"
1338 - # but this breaks simple scripting: `binutils -l | awk '{print $2}'`
1339 -
1340 - # Or we could align the target col like so:
1341 - #printf ' [%s]%*s %s\n' "${i}" $(( ${##} - ${#i} )) "" "${x}"
1342 - # but i'm not sold that it looks better
1343 -
1344 - # So keep it simple ... only makes a diff anyways for crazy people
1345 - # like me which have 100+ binutils packages installed ...
1346 - echo " [$i] ${x}"
1347 - ((++i))
1348 - done
1349 -}
1350 -
1351 -switch_linker() {
1352 - local bpath ld=$1
1353 -
1354 - case ${ld} in
1355 - ld.*) ;;
1356 - *) die "not supported: linker must start with 'ld.'" ;;
1357 - esac
1358 -
1359 - setup_env || return 1
1360 - bpath="${ROOT}/${BINPATH}"
1361 -
1362 - # does this binutils even support the requested linker ?
1363 - if [[ ! -e ${bpath}/${ld} ]] ; then
1364 - die "sorry, but ${PROFILE} doesn't support the ${ld} linker"
1365 - fi
1366 -
1367 - # switch it up
1368 - ebegin "Setting default linker to ${ld} for ${PROFILE}"
1369 - atomic_ln ${ld} "${bpath}" ld
1370 - eend $?
1371 -}
1372 -
1373 -set_HOST() {
1374 - # Set HOST to CHOST if it isn't already set
1375 - : ${HOST:=${CHOST:-$(portageq envvar CHOST)}}
1376 -}
1377 -
1378 -ENV_D="${ROOT}etc/env.d/binutils"
1379 -
1380 -DEBUG="no"
1381 -NEED_ACTION="yes"
1382 -DOIT="switch_profile"
1383 -PROFILE="current"
1384 -FAKE_TARGETS_USER=""
1385 -HOST=""
1386 -TARGET=""
1387 -unset UARG
1388 -
1389 -select_action() {
1390 - if [[ ${NEED_ACTION} != "no" ]] ; then
1391 - NEED_ACTION="no"
1392 - DOIT=$1
1393 - else
1394 - die "one action at a time!"
1395 - fi
1396 -}
1397 -
1398 -while [[ $# -gt 0 ]] ; do
1399 - x=$1
1400 - shift
1401 - case ${x} in
1402 - -c|--get-current-profile) select_action get_current_profile ;;
1403 - -l|--list|--list-profiles) select_action list_profiles ;;
1404 - -u|--uninstall) select_action uninstall_target ;;
1405 - --linker) select_action "switch_linker $1"; shift ;;
1406 - -d|--debug) DEBUG="yes" ;;
1407 - -h|--help) usage 0 ;;
1408 - -V|--version)
1409 - unset Header
1410 - cvsver="$Id$"
1411 - cvsver=${cvsver##*binutils-config-}
1412 - bver=${cvsver%%,v *}
1413 - cvsver=${cvsver#* }
1414 - echo "binutils-config-${bver} (r${cvsver%% *})"
1415 - exit 0
1416 - ;;
1417 - --amd64|--arm|--mips|--x86)
1418 - if [[ ${NEED_ACTION} == "yes" ]] ; then
1419 - # Make sure we have a space after each target
1420 - NEED_ACTION="no"
1421 - case ${x} in
1422 - --amd64) FAKE_TARGETS_USER="x86_64 ";;
1423 - --arm) FAKE_TARGETS_USER="arm armeb ";;
1424 - --x86) FAKE_TARGETS_USER="i386 i486 i586 i686 ";;
1425 - --mips) FAKE_TARGETS_USER="mips mips64 mipsel mipsel64 ";;
1426 - esac
1427 - fi
1428 - ;;
1429 - -*)
1430 - die "invalid switch! Try '--help'."
1431 - ;;
1432 - *)
1433 - if [[ ${UARG+set} == "set" ]] ; then
1434 - die "only one profile/target at a time please"
1435 - fi
1436 - NEED_ACTION="maybe"
1437 - UARG=${x}
1438 - ;;
1439 - esac
1440 -done
1441 -
1442 -[[ ${NEED_ACTION} == "yes" ]] && usage 1
1443 -[[ ${DEBUG} == "yes" ]] && set -x
1444 -
1445 -# All operations need to know the current HOST to figure out
1446 -# what is a native target and what is a cross target
1447 -set_HOST
1448 -
1449 -# All operations need to know the profile the user wants
1450 -case ${DOIT} in
1451 -switch_profile|switch_linker_*)
1452 - # decode user's profile choice
1453 - x=${UARG:-$(TARGET=${HOST} set_current_profile)}
1454 - PROFILE=""
1455 - if [[ -z $(echo ${x} | tr -d '[:digit:]') ]] ; then
1456 - # User gave us a # representing the profile
1457 - i=1
1458 - for y in "${ENV_D}"/* ; do
1459 - [[ ${y/config-} != ${y} ]] && continue
1460 -
1461 - if [[ -f ${y} ]] && [[ ${x} -eq ${i} ]] ; then
1462 - PROFILE=${y##*/}
1463 - break
1464 - fi
1465 - ((++i))
1466 - done
1467 - fi
1468 -
1469 - if [[ -z ${PROFILE} ]] ; then
1470 - # User gave us a full HOST-ver
1471 - x=${x##*/}
1472 - if [[ -f ${ENV_D}/${x} ]] ; then
1473 - # Valid HOST-ver yeah!
1474 - PROFILE=${x}
1475 - else
1476 - # Not a valid HOST-ver ...
1477 - if [[ ! -f ${ENV_D}/config-${x} ]] ; then
1478 - # Maybe they just gave us a ver ...
1479 - if [[ -f ${ENV_D}/${HOST}-${x} ]] ; then
1480 - x=${HOST}-${x}
1481 - else
1482 - die "could not locate '$x' in '${ENV_D}/'!"
1483 - fi
1484 - PROFILE=${x}
1485 - else
1486 - # Maybe they just gave us a target ... pick active profile
1487 - PROFILE=$(TARGET=${x} set_current_profile)
1488 - fi
1489 - fi
1490 - fi
1491 - ;;
1492 -*)
1493 - # lookup current profile as the user gave us a target
1494 - PROFILE=$(TARGET=${UARG:-${HOST}} set_current_profile) || exit 1
1495 - ;;
1496 -esac
1497 -
1498 -eval ${DOIT}
1499 -
1500 -# vim:ts=4