Merge from trunk: 215733-215743
[official-gcc.git] / gcc-4_6_3-mobile / gcc / exec-tool.in
blob46aaedca983a8ea266238dd9c3d7642cbdb09b67
1 #! /bin/sh
3 # Copyright (C) 2007, 2008, 2010, 2011 Free Software Foundation, Inc.
4 # This file is part of GCC.
6 # GCC is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3, or (at your option)
9 # any later version.
11 # GCC is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with GCC; see the file COPYING3. If not see
18 # <http://www.gnu.org/licenses/>.
20 # Invoke as, ld or nm from the build tree.
22 ORIGINAL_AS_FOR_TARGET="@ORIGINAL_AS_FOR_TARGET@"
23 ORIGINAL_LD_FOR_TARGET="@ORIGINAL_LD_FOR_TARGET@"
24 ORIGINAL_GOLD_FOR_TARGET="@ORIGINAL_GOLD_FOR_TARGET@"
25 ORIGINAL_PLUGIN_LD_FOR_TARGET="@ORIGINAL_PLUGIN_LD_FOR_TARGET@"
26 ORIGINAL_NM_FOR_TARGET="@ORIGINAL_NM_FOR_TARGET@"
27 exeext=@host_exeext@
28 fast_install=@enable_fast_install@
29 objdir=@objdir@
30 version="1.1"
32 invoked=`basename "$0"`
33 id=$invoked
34 case "$invoked" in
35 as)
36 original=$ORIGINAL_AS_FOR_TARGET
37 prog=as-new$exeext
38 dir=gas
40 collect-ld)
41 prog=ld-new$exeext
42 # Look for the a command line option
43 # specifying the linker to be used.
44 case " $* " in
45 *\ -use-gold\ *)
46 original=$ORIGINAL_GOLD_FOR_TARGET
47 dir=gold
49 *\ -use-ld\ * | *\ -use-ld.bfd\ *)
50 original=$ORIGINAL_LD_FOR_TARGET
51 dir=ld
53 *\ -plugin\ *)
54 original=$ORIGINAL_PLUGIN_LD_FOR_TARGET
55 dir=ld
58 original=$ORIGINAL_LD_FOR_TARGET
59 dir=ld
61 esac
63 # If the selected linker has not been configured then
64 # try using the others, in the order PLUGIN-LD, LD, GOLD.
65 if test x"$original" = x; then
66 if test x"$ORIGINAL_PLUGIN_LD_FOR_TARGET" != x; then
67 original=$ORIGINAL_PLUGIN_LD_FOR_TARGET
68 dir=ld
69 elif test x"$ORIGINAL_LD_FOR_TARGET" != x; then
70 original=$ORIGINAL_LD_FOR_TARGET
71 dir=ld
72 elif test x"$ORIGINAL_GOLD_FOR_TARGET" != x; then
73 original=$ORIGINAL_GOLD_FOR_TARGET
74 dir=gold
75 # Otherwise do nothing - the case statement below
76 # will issue an error message for us.
79 id=ld
81 nm)
82 original=$ORIGINAL_NM_FOR_TARGET
83 prog=nm-new$exeext
84 dir=binutils
86 esac
88 case "$original" in
89 ../*)
90 # compute absolute path of the location of this script
91 tdir=`dirname "$0"`
92 scriptdir=`cd "$tdir" && pwd`
94 if test -x $scriptdir/../$dir/$prog; then
95 if test "$fast_install" = yes; then
96 # If libtool did everything it needs to do, there's a fast path.
97 lt_prog=$scriptdir/../$dir/$objdir/lt-$prog
99 if test -x $lt_prog; then
100 original=$lt_prog
101 else
102 # Libtool has not relinked ld-new yet, but we cannot just use the
103 # previous stage (because then the relinking would just never happen!).
104 # So we take extra care to use prev-ld/ld-new *on recursive calls*.
105 eval LT_RCU="\${LT_RCU_$id}"
106 if test x"$LT_RCU" = x"1"; then
107 original=$scriptdir/../prev-$dir/$prog
108 else
109 eval LT_RCU_$id=1
110 export LT_RCU_$id
111 case " $* " in
112 *\ -v\ *)
113 echo "$invoked $version"
114 echo $scriptdir/../$dir/$prog $*
116 esac
117 $scriptdir/../$dir/$prog ${1+"$@"}
118 result=$?
119 exit $result
122 else
123 original=$scriptdir/../$dir/$prog
125 else
126 original=$scriptdir/../prev-$dir/$prog
130 echo "$invoked: executable not configured"
131 exit 1
133 esac
135 # If -v has been used then display our version number
136 # and then echo the command we are about to invoke.
137 case " $* " in
138 *\ -v\ *)
139 echo "$invoked $version"
140 echo $original $*
142 esac
144 if test -x $original; then
145 exec "$original" ${1+"$@"}
146 else
147 echo "$invoked: unable to locate executable: $original"
148 exit 1