Gentoo Archives: gentoo-commits

From: "Mike Frysinger (vapier)" <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in sys-devel/binutils-config/files: binutils-config.8 binutils-config-4
Date: Tue, 29 Jul 2014 11:15:46
Message-Id: 20140729111540.E21A220035@flycatcher.gentoo.org
1 vapier 14/07/29 11:15:38
2
3 Modified: binutils-config.8
4 Added: binutils-config-4
5 Log:
6 Drop FAKE_TARGETS support as gcc dropped it a while ago too #467488.
7
8 (Portage version: 2.2.10/cvs/Linux x86_64, signed Manifest commit with key D2E96200)
9
10 Revision Changes Path
11 1.6 sys-devel/binutils-config/files/binutils-config.8
12
13 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-devel/binutils-config/files/binutils-config.8?rev=1.6&view=markup
14 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-devel/binutils-config/files/binutils-config.8?rev=1.6&content-type=text/plain
15 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-devel/binutils-config/files/binutils-config.8?r1=1.5&r2=1.6
16
17 Index: binutils-config.8
18 ===================================================================
19 RCS file: /var/cvsroot/gentoo-x86/sys-devel/binutils-config/files/binutils-config.8,v
20 retrieving revision 1.5
21 retrieving revision 1.6
22 diff -u -r1.5 -r1.6
23 --- binutils-config.8 12 Aug 2011 20:34:00 -0000 1.5
24 +++ binutils-config.8 29 Jul 2014 11:15:38 -0000 1.6
25 @@ -56,31 +56,6 @@
26 \fB\-\-bfd\fR
27 Change the default linker for the specified \fIPROFILE\fR to the [older but
28 stable] bfd linker. If unsure, stick to this one.
29 -.TP
30 -\fB\-\-amd64\fR
31 -A nice feature of the amd64/x86 toolchain is that each can produce code for
32 -other. The typical user could care less, but some may want to be able to
33 -cross-compile for an amd64 on a x86 system. This will install the extra
34 -symlinks ('x86_64') to facilitate this process.
35 -.TP
36 -\fB\-\-arm\fR
37 -The arm architecture comes in both big and little endian versions. Typically
38 -you only need support for the native target, but sometimes it's helpful to
39 -have links for the other endian target. This will make sure you have both the
40 -big endian target ('armeb') and the little endian target ('arm').
41 -.TP
42 -\fB\-\-mips\fR
43 -The mips architecture (like arm) comes in both big and little endian versions.
44 -Typically you only need support for the native target, but sometimes it's
45 -helpful to have links for the other endian target. This will make sure you
46 -have both the big endian target ('mips') and the little endian target
47 -('mipsel').
48 -.TP
49 -\fB\-\-x86\fR
50 -One oddity of the x86 toolchain is that they may be named 'i386', or 'i486',
51 -or 'i586', or 'i686', yet still produce the same exact code. When dealing
52 -with distcc systems that are mixed (some i586 and some i686), you will need
53 -symlinks for all these targets. This option will install those extra targets.
54 .SH "REPORTING BUGS"
55 Please report bugs via http://bugs.gentoo.org/
56 .SH "SEE ALSO"
57
58
59
60 1.1 sys-devel/binutils-config/files/binutils-config-4
61
62 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-devel/binutils-config/files/binutils-config-4?rev=1.1&view=markup
63 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-devel/binutils-config/files/binutils-config-4?rev=1.1&content-type=text/plain
64
65 Index: binutils-config-4
66 ===================================================================
67 #!/bin/bash
68 # Copyright 1999-2014 Gentoo Foundation
69 # Distributed under the terms of the GNU General Public License v2
70 # $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-config/files/binutils-config-4,v 1.1 2014/07/29 11:15:38 vapier Exp $
71
72 # Format of /etc/env.d/binutils/:
73 # config-TARGET: CURRENT=version for TARGET
74 # TARGET-VER: has a TARGET and VER variable
75
76 : ${ROOT:=/}
77 [[ ${ROOT} != */ ]] && ROOT="${ROOT}/"
78 [[ ${ROOT} != /* ]] && ROOT="${PWD%/}/${ROOT}"
79
80 cd /
81
82 trap ":" INT QUIT TSTP
83
84 argv0=${0##*/}
85 source /etc/init.d/functions.sh || {
86 echo "${argv0}: Could not source /etc/init.d/functions.sh!" 1>&2
87 exit 1
88 }
89 esyslog() { :; }
90 die() { eerror "${argv0}: $*"; exit 1; }
91 umask 022
92
93 usage() {
94 cat << USAGE_END
95 Usage: ${HILITE}binutils-config${NORMAL} ${GOOD}[options]${NORMAL} ${BRACKET}[binutils profile]${NORMAL}
96
97 ${HILITE}General Options:${NORMAL}
98 ${GOOD}-c, --get-current-profile${NORMAL} Print current profile
99 ${GOOD}-l, --list-profiles${NORMAL} Print a list of available profiles
100 ${GOOD}-u, --uninstall${NORMAL} Remove all signs of specified target
101 ${GOOD}-d, --debug${NORMAL} Execute with debug output
102
103 ${HILITE}General Cruft:${NORMAL}
104 ${GOOD}--linker${NORMAL} <linker> Switch to specified linker (if supported)
105
106 Profile names are of the form: ${BRACKET}<CTARGET>-<binutils version>${NORMAL}
107 For example: ${BRACKET}i686-pc-linux-gnu-2.15.92.0.2${NORMAL}
108
109 For more info, please see ${HILITE}binutils-config${NORMAL}(8).
110 USAGE_END
111
112 exit ${1:-1}
113 }
114
115 mv_if_diff() {
116 if cmp -s "$1" "$2" ; then
117 rm -f "$1"
118 else
119 mv -f "$1" "$2"
120 fi
121 }
122 atomic_ln() {
123 local target=$1 linkdir=$2 linkname=$3 linktmp linkfull
124 linktmp="${linkdir}/.binutils-config.tmp.${linkname}"
125 linkfull="${linkdir}/${linkname}"
126 if [[ -d ${linkfull} ]] ; then
127 # if linking to a dir, we need a little magic to
128 # make it atomic since `mv -T` is not portable
129 rm -rf "${linktmp}"
130 mkdir -p "${linktmp}"
131 ln -sf "${target}" "${linktmp}/${linkname}"
132 mv "${linktmp}/${linkname}" "${linktmp}/../"
133 rmdir "${linktmp}"
134 else
135 # `ln` will expand into unlink();symlink(); which
136 # is not atomic for a small amount of time, but
137 # `mv` is a single rename() call
138 ln -sf "${target}" "${linktmp}"
139 mv "${linktmp}" "${linkfull}"
140 fi
141 }
142
143 setup_env() {
144 unset TARGET VER LIBPATH
145 source "${ENV_D}/${PROFILE}"
146 if [[ -z ${TARGET} ]] ; then
147 eerror "${PROFILE} is invalid (no \$TARGET defined) :("
148 return 1
149 fi
150 if [[ -z ${VER} ]] ; then
151 eerror "${PROFILE} is invalid (no \$VER defined) :("
152 return 1
153 fi
154
155 #
156 # Generate binary symlinks
157 #
158 BINPATH=""
159 BINPATH_LINKS=""
160 if [[ ${TARGET} != ${HOST} ]] ; then
161 #
162 # Newer paths: /usr/${HOST}/${TARGET}/...
163 # Older paths: /usr/${TARGET}/...
164 #
165 if [[ -d ${ROOT}/usr/${HOST}/${TARGET}/binutils-bin/${VER} ]] ; then
166 BINPATH=/usr/${HOST}/${TARGET}/binutils-bin/${VER}
167 BINPATH_LINKS=/usr/libexec/gcc/${TARGET}
168 fi
169 fi
170 if [[ -z ${BINPATH} ]] ; then
171 BINPATH=/usr/${TARGET}/binutils-bin/${VER}
172 BINPATH_LINKS=/usr/${TARGET}/bin
173 fi
174 }
175
176 switch_profile() {
177 ebegin "Switching to ${PROFILE}"
178
179 setup_env || return 1
180
181 cd "${ROOT}/${BINPATH}" || exit 1
182 mkdir -p "${ROOT}/${BINPATH_LINKS}" "${ROOT}/usr/bin"
183 for x in * ; do
184 atomic_ln "${BINPATH}/${x}" "${ROOT}/${BINPATH_LINKS}" "${x}"
185 atomic_ln "${BINPATH_LINKS}/${x}" "${ROOT}/usr/bin" "${TARGET}-${x}"
186 if [[ ${TARGET} == ${HOST} ]] ; then
187 atomic_ln "${TARGET}-${x}" "${ROOT}/usr/bin" "${x}"
188 fi
189 done
190
191 #
192 # Generate library / ldscripts symlinks
193 #
194 : ${LIBPATH:=/usr/lib/binutils/${TARGET}/${VER}}
195 cd "${ROOT}/${LIBPATH}" || exit 1
196 if [[ ${TARGET} == ${HOST} ]] ; then
197 dstlib=${ROOT}/usr/${HOST}/lib
198 else
199 dstlib=${ROOT}/usr/${HOST}/${TARGET}/lib
200 fi
201 # When upgrading, we need to clean up ldscripts and libs
202 mkdir -p "${dstlib}"
203 rm -rf "${ROOT}/${BINPATH_LINKS}"/ldscripts
204 atomic_ln "${LIBPATH}/ldscripts" "${dstlib}" "ldscripts"
205 find -L "${dstlib}" -type l -exec rm -v {} +
206 for x in lib* ; do
207 atomic_ln "${LIBPATH}/${x}" "${dstlib}" "${x}"
208 done
209
210 #
211 # Generate include symlinks
212 #
213 INCPATH=${LIBPATH}/include
214 if [[ -d ${ROOT}/${INCPATH} ]] ; then
215 cd "${ROOT}/${INCPATH}" || exit 1
216 if [[ ${HOST} == ${TARGET} ]] ; then
217 mkdir -p "${ROOT}/usr/include"
218 for x in * ; do
219 atomic_ln "${INCPATH}/${x}" "${ROOT}/usr/include" "${x}"
220 done
221 else
222 # Clean out old path -- cannot use '-exec {} +' syntax here
223 find . -type f -exec rm -f "${ROOT}/usr/${TARGET}/usr/include/{}" \;
224 rmdir "${ROOT}/usr/${TARGET}/usr/include" >& /dev/null
225 rmdir "${ROOT}/usr/${TARGET}/usr" >& /dev/null
226 rmdir "${ROOT}/usr/${TARGET}" >& /dev/null
227 fi
228 fi
229
230 #
231 # Make sure proper paths get updated
232 #
233 if [[ ${TARGET} == ${HOST} ]] ; then
234 DATAPATH=/usr/share/binutils-data/${TARGET}/${VER}
235 local e="${ROOT}"/etc/env.d/05binutils
236 local ee="${e}.tmp"
237 rm -f "${ee}"
238 [[ -d ${DATAPATH}/man ]] && echo "MANPATH=${DATAPATH}/man" >> "${ee}"
239 [[ -d ${DATAPATH}/info ]] && echo "INFOPATH=${DATAPATH}/info" >> "${ee}"
240 # hmm, `ld` has this in SEARCH_DIR(), but ld.so does not ...
241 if [[ -d ${ROOT}/etc/ld.so.conf.d ]] ; then
242 local l="${ROOT}"/etc/ld.so.conf.d/05binutils.conf
243 local ll="${l}.tmp"
244 echo "/usr/${TARGET}/lib" > "${ll}"
245 mv_if_diff "${ll}" "${l}"
246 else
247 echo "LDPATH=/usr/${TARGET}/lib" >> "${ee}"
248 fi
249 mv_if_diff "${ee}" "${e}"
250 fi
251
252 local c="${ENV_D}/config-${TARGET}"
253 local cc="${c}.tmp"
254 echo "CURRENT=${VER}" > "${cc}"
255 mv_if_diff "${cc}" "${c}"
256
257 eend 0
258
259 #
260 # Regen env.d if need/can be
261 #
262 if [[ ${ROOT} == "/" ]] && [[ ${TARGET} == ${HOST} ]] ; then
263 env-update
264 echo
265 ewarn "Please remember to run:"
266 echo
267 ewarn " # . /etc/profile"
268 echo
269 fi
270
271 return 0
272 }
273
274 uninstall_target() {
275 : ${TARGET:=${UARG}}
276
277 if [[ ${TARGET} == ${HOST} ]] ; then
278 die "refusing to uninstall native binutils"
279 fi
280
281 shopt -s nullglob
282 PROFILE=""
283
284 for PROFILE in "${ENV_D}"/${TARGET}-* ; do
285 ewarn "Removing all signs of ${PROFILE##*/}"
286 rm -f "${ENV_D}"/${PROFILE}
287 done
288 if [[ -z ${PROFILE} ]] && [[ ! -e ${ENV_D}/config-${TARGET} ]] ; then
289 die "no profiles exist for '${TARGET}'"
290 fi
291
292 rm -f "${ENV_D}"/config-${TARGET} "${ROOT}"/etc/ld.so.conf.d/05binutils.conf
293
294 local x
295 for x in \
296 addr2line ar as c++filt elf2flt elfedit flthdr gprof \
297 ld ld.{bfd,gold,real} \
298 nm objcopy objdump ranlib readelf size strings strip
299 do
300 x=(
301 "${ROOT}"/usr/bin/${TARGET}-${x}
302 "${ROOT}"/usr/{${HOST}/,}${TARGET}/bin/${x}
303 "${ROOT}"/usr/libexec/gcc/${TARGET}/${x}
304 )
305 rm -f "${x[@]}"
306 done
307 for x in ansidecl.h bfd.h bfdlink.h dis-asm.h symcat.h ; do
308 rm -f "${ROOT}"/usr/{${HOST}/,}${TARGET}/{usr/,}include/${x}
309 done
310 for x in bfd iberty opcodes ; do
311 rm -f "${ROOT}"/usr/${HOST}/${TARGET}/lib/lib${x}{{-*,}.so,.a,.la}
312 done
313 # Delete broken symlinks
314 local destdir="${ROOT}/usr/${HOST}/${TARGET}"
315 rm -f "${destdir}"/lib/ldscripts
316 find -L "${destdir}"/lib -type l -exec rm {} +
317 rmdir \
318 "${destdir}"/{bin,include,lib,usr} \
319 "${destdir}" \
320 "${ROOT}"/var/db/pkg/cross-${TARGET} \
321 "${ROOT}"/usr/{${HOST}/,}${TARGET}/bin \
322 "${ROOT}"/usr/libexec/gcc/${TARGET} \
323 2>/dev/null
324
325 rm -f "${ENV_D}"/${TARGET}-*
326 }
327
328 set_current_profile() {
329 if [[ ! -f ${ENV_D}/config-${TARGET} ]] ; then
330 eerror "${argv0}: unable to locate a profile for target: ${TARGET}"
331 return 1
332 fi
333
334 source "${ENV_D}/config-${TARGET}"
335
336 if [[ -z ${CURRENT} ]] ; then
337 eerror "${argv0}: no binutils profile is active!"
338 return 1
339 fi
340
341 echo "${TARGET}-${CURRENT}"
342
343 return 0
344 }
345 get_current_profile() { echo "${PROFILE}" ; }
346
347 list_profiles() {
348 local x i target
349
350 if [[ ${ROOT} != / ]] ; then
351 echo "Using binutils-config info in ${ROOT}"
352 fi
353
354 set -- "${ENV_D}"/*
355 target=
356 i=1
357
358 for x ; do
359 # skip broken links and config files
360 [[ -f ${x} ]] || continue
361 [[ ${x} == */config-* ]] && continue
362
363 source "${x}"
364 if [[ ${target} != ${TARGET} ]] ; then
365 [[ -n ${target} ]] && echo
366 target=${TARGET}
367 fi
368
369 x=${x##*/}
370 if [[ -e ${ENV_D}/config-${TARGET} ]] ; then
371 source "${ENV_D}/config-${TARGET}"
372 if [[ ${VER} == ${CURRENT} ]] ; then
373 [[ ${TARGET} == ${HOST} ]] \
374 && x="${x} ${GOOD}*${NORMAL}" \
375 || x="${x} ${HILITE}*${NORMAL}"
376 fi
377 fi
378
379 # We would align the [...] field like so:
380 #printf ' [%*ss] %s\n' ${##} "${i}" "${x}"
381 # but this breaks simple scripting: `binutils -l | awk '{print $2}'`
382
383 # Or we could align the target col like so:
384 #printf ' [%s]%*s %s\n' "${i}" $(( ${##} - ${#i} )) "" "${x}"
385 # but i'm not sold that it looks better
386
387 # So keep it simple ... only makes a diff anyways for crazy people
388 # like me which have 100+ binutils packages installed ...
389 echo " [$i] ${x}"
390 ((++i))
391 done
392 }
393
394 switch_linker() {
395 local bpath ld=$1
396
397 case ${ld} in
398 ld.*) ;;
399 *) die "not supported: linker must start with 'ld.'" ;;
400 esac
401
402 setup_env || return 1
403 bpath="${ROOT}/${BINPATH}"
404
405 # does this binutils even support the requested linker ?
406 if [[ ! -e ${bpath}/${ld} ]] ; then
407 die "sorry, but ${PROFILE} doesn't support the ${ld} linker"
408 fi
409
410 # switch it up
411 ebegin "Setting default linker to ${ld} for ${PROFILE}"
412 atomic_ln ${ld} "${bpath}" ld
413 eend $?
414 }
415
416 set_HOST() {
417 # Set HOST to CHOST if it isn't already set
418 : ${HOST:=${CHOST:-$(portageq envvar CHOST)}}
419 }
420
421 ENV_D="${ROOT}etc/env.d/binutils"
422
423 DEBUG="no"
424 NEED_ACTION="yes"
425 DOIT="switch_profile"
426 PROFILE="current"
427 HOST=""
428 TARGET=""
429 unset UARG
430
431 select_action() {
432 if [[ ${NEED_ACTION} != "no" ]] ; then
433 NEED_ACTION="no"
434 DOIT=$1
435 else
436 die "one action at a time!"
437 fi
438 }
439
440 while [[ $# -gt 0 ]] ; do
441 x=$1
442 shift
443 case ${x} in
444 -c|--get-current-profile) select_action get_current_profile ;;
445 -l|--list|--list-profiles) select_action list_profiles ;;
446 -u|--uninstall) select_action uninstall_target ;;
447 --linker) select_action "switch_linker $1"; shift ;;
448 -d|--debug) DEBUG="yes" ;;
449 -h|--help) usage 0 ;;
450 -V|--version)
451 unset Header
452 cvsver="$Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-config/files/binutils-config-4,v 1.1 2014/07/29 11:15:38 vapier Exp $"
453 cvsver=${cvsver##*binutils-config-}
454 bver=${cvsver%%,v *}
455 cvsver=${cvsver#* }
456 echo "binutils-config-${bver} (r${cvsver%% *})"
457 exit 0
458 ;;
459 -*)
460 die "invalid switch! Try '--help'."
461 ;;
462 *)
463 if [[ ${UARG+set} == "set" ]] ; then
464 die "only one profile/target at a time please"
465 fi
466 NEED_ACTION="maybe"
467 UARG=${x}
468 ;;
469 esac
470 done
471
472 [[ ${NEED_ACTION} == "yes" ]] && usage 1
473 [[ ${DEBUG} == "yes" ]] && set -x
474
475 # All operations need to know the current HOST to figure out
476 # what is a native target and what is a cross target
477 set_HOST
478
479 # All operations need to know the profile the user wants
480 case ${DOIT} in
481 switch_profile|switch_linker_*)
482 # decode user's profile choice
483 x=${UARG:-$(TARGET=${HOST} set_current_profile)}
484 PROFILE=""
485 if [[ -z $(echo ${x} | tr -d '[:digit:]') ]] ; then
486 # User gave us a # representing the profile
487 i=1
488 for y in "${ENV_D}"/* ; do
489 [[ ${y/config-} != ${y} ]] && continue
490
491 if [[ -f ${y} ]] && [[ ${x} -eq ${i} ]] ; then
492 PROFILE=${y##*/}
493 break
494 fi
495 ((++i))
496 done
497 fi
498
499 if [[ -z ${PROFILE} ]] ; then
500 # User gave us a full HOST-ver
501 x=${x##*/}
502 if [[ -f ${ENV_D}/${x} ]] ; then
503 # Valid HOST-ver yeah!
504 PROFILE=${x}
505 else
506 # Not a valid HOST-ver ...
507 if [[ ! -f ${ENV_D}/config-${x} ]] ; then
508 # Maybe they just gave us a ver ...
509 if [[ -f ${ENV_D}/${HOST}-${x} ]] ; then
510 x=${HOST}-${x}
511 else
512 die "could not locate '$x' in '${ENV_D}/'!"
513 fi
514 PROFILE=${x}
515 else
516 # Maybe they just gave us a target ... pick active profile
517 PROFILE=$(TARGET=${x} set_current_profile)
518 fi
519 fi
520 fi
521 ;;
522 *)
523 # lookup current profile as the user gave us a target
524 PROFILE=$(TARGET=${UARG:-${HOST}} set_current_profile) || exit 1
525 ;;
526 esac
527
528 eval ${DOIT}
529
530 # vim:ts=4