source: mainline/uspace/app/binutils/toolchain.sh@ 5081276

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 5081276 was 8afa52c, checked in by Petr Koupy <petr.koupy@…>, 14 years ago

Port upgraded to version 2.21.1. Added mirror fallback for download.

  • Property mode set to 100755
File size: 5.2 KB
RevLine 
[53d9ee9]1#! /bin/bash
2
3#
4# Copyright (c) 2011 Petr Koupy
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions
9# are met:
10#
11# - Redistributions of source code must retain the above copyright
12# notice, this list of conditions and the following disclaimer.
13# - Redistributions in binary form must reproduce the above copyright
14# notice, this list of conditions and the following disclaimer in the
15# documentation and/or other materials provided with the distribution.
16# - The name of the author may not be used to endorse or promote products
17# derived from this software without specific prior written permission.
18#
19# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29#
30
31#
32# This script is intended to be called indirectly from the Makefile.
33# Given information from Makefile.common (e.g. CFLAGS), this shell
34# script generates false toolchain consisting of a short shell script
35# for each tool. Therefore, generated false tool already contains some
36# filtered information from the HelenOS side. When the actual call is
37# intercepted, information passed from the binutils side is filtered
38# and stored. Information from both sides is then joined together
39# and passed to the real tool.
40#
41# Basic idea behind filtering the information is that binutils is
42# dominant provider for the compilation, whereas HelenOS is dominant
43# for the linkage. In that way, the compilation command from binutils
44# is left untouched and only extended with a couple of flags that are
45# specific for HelenOS (i.e. include directories, preprocessor
46# directives, preprocessor flags, standard libc exclusion). Similarly,
47# the linkage command is taken from HelenOS and extended with the
48# filtered information from binutils (i.e. output binary, objects,
49# binutils libraries).
50#
51# Most of the false tools are straightforward. However, gcc needs a
52# special approach because binutils use it for both compilation and
53# linkage. In case the linking usage is detected, the call is redirected
[f3a605be]54# to the linker. There is also special case for configure script tests
55# that require compiler link step.
[53d9ee9]56#
57
58case "$1" in
59 "gcc")
[cb7c685]60 (
61 echo '#! /bin/bash'
[3e22494f]62 echo 'AS_LINK="`echo \"$*\" | grep '\'as-new\''`"'
63 echo 'LD_LINK="`echo \"$*\" | grep '\'ld-new\''`"'
[cb7c685]64 echo 'LINK="`echo -n "$AS_LINK""$LD_LINK"`"'
65 echo 'if [ -n "$LINK" ]; then'
[723560f]66 echo ' LD_ARGS="`echo \" $*\" | \'
67 echo ' sed '\'s/ -O[^ ]*//g\'' | \'
68 echo ' sed '\'s/ -W[^ ]*//g\'' | \'
69 echo ' sed '\'s/ -g//g\'' | \'
70 echo ' sed '\'s/ -l[^ ]*//g\'' | \'
[cb7c685]71 echo ' sed '\'s/ [ ]*/ /g\''`"'
[3e22494f]72 echo ' ld $LD_ARGS'
[cb7c685]73 echo 'else'
[723560f]74 CFLAGS="`echo " $3" | \
75 sed 's/ -O[^ ]*//g' | \
76 sed 's/ -W[^ ]*//g' | \
77 sed 's/ -pipe//g' | \
78 sed 's/ -g//g' | \
[53d9ee9]79 sed 's/ [ ]*/ /g'`"
[3e22494f]80 echo ' CONFTEST="`echo \"$*\" | grep '\' conftest \''`"'
[f3a605be]81 echo ' if [ -n "$CONFTEST" ]; then'
82 echo ' LFLAGS="-Xlinker -z -Xlinker muldefs"'
[79506d6]83 echo ' echo' \'"$2"\' '"$@"' \'"$CFLAGS -T $4"\' '"$LFLAGS"' \'"$5"\'
84 echo " $2" '$@' "$CFLAGS -T $4" '$LFLAGS' "$5"
[f3a605be]85 echo ' else'
[3e22494f]86 # Remove flags:
[c3b653a]87 # -Werror
88 # Avoid build failure due to some harmless bugs
89 # (e.g. unused parameter) in the HelenOS.
[3e22494f]90 # -Wc++-compat
91 # Required just for gold linker.
[723560f]92 echo ' GCC_ARGS="`echo \" $*\" | \'
[c3b653a]93 echo ' sed '\'s/ -Werror//g\'' | \'
[723560f]94 echo ' sed '\'s/ -Wc++-compat//g\'' | \'
[3e22494f]95 echo ' sed '\'s/ [ ]*/ /g\''`"'
96 # Add flags:
[8afa52c]97 # -example
98 # Flag description.
99# echo ' GCC_ARGS="$GCC_ARGS -example"'
[3e22494f]100 echo ' echo' \'"$2"\' '"$GCC_ARGS"' \'"$CFLAGS"\'
101 echo " $2" '$GCC_ARGS' "$CFLAGS"
[f3a605be]102 echo ' fi'
[cb7c685]103 echo 'fi'
104 ) > 'gcc'
[53d9ee9]105 chmod a+x 'gcc'
106 ;;
107 "as")
[cb7c685]108 (
109 echo '#! /bin/bash'
[2431f30]110 echo 'echo' \'"$2"\' '"$@"'
[cb7c685]111 echo "$2" '$@'
112 ) > 'as'
[53d9ee9]113 chmod a+x 'as'
114 ;;
115 "ar")
[cb7c685]116 (
117 echo '#! /bin/bash'
[2431f30]118 echo 'echo' \'"$2"\' '"$@"'
[cb7c685]119 echo "$2" '$@'
120 ) > 'ar'
[53d9ee9]121 chmod a+x 'ar'
122 ;;
123 "ranlib")
[cb7c685]124 (
125 echo '#! /bin/bash'
[c1198c2]126 echo 'echo' 'ar -s' '"$@"'
127 echo 'ar -s' '$@'
[cb7c685]128 ) > 'ranlib'
[53d9ee9]129 chmod a+x 'ranlib'
130 ;;
131 "ld")
[cb7c685]132 (
133 echo '#! /bin/bash'
[2431f30]134 echo 'echo' \'"$2 -n $3 -T $4"\' '"$@"' \'"$5"\'
[cb7c685]135 echo "$2 -n $3 -T $4" '$@' "$5"
136 ) > 'ld'
[53d9ee9]137 chmod a+x 'ld'
138 ;;
139 "objdump")
[cb7c685]140 (
141 echo '#! /bin/bash'
[2431f30]142 echo 'echo' \'"$2"\' '"$@"'
[cb7c685]143 echo "$2" '$@'
144 ) > 'objdump'
[53d9ee9]145 chmod a+x 'objdump'
146 ;;
147 "objcopy")
[cb7c685]148 (
149 echo '#! /bin/bash'
[2431f30]150 echo 'echo' \'"$2"\' '"$@"'
[cb7c685]151 echo "$2" '$@'
152 ) > 'objcopy'
[53d9ee9]153 chmod a+x 'objcopy'
154 ;;
155 "strip")
[cb7c685]156 (
157 echo '#! /bin/bash'
[2431f30]158 echo 'echo' \'"$2"\' '"$@"'
[cb7c685]159 echo "$2" '$@'
160 ) > 'strip'
[53d9ee9]161 chmod a+x 'strip'
162 ;;
163 *)
164 ;;
165esac
166
Note: See TracBrowser for help on using the repository browser.