0
|
1 #!/bin/sh
|
|
2 # Copyright (C) 2006, 2007 Free Software Foundation, Inc.
|
|
3 # This file is part of GCC.
|
|
4
|
|
5 # GCC is free software; you can redistribute it and/or modify
|
|
6 # it under the terms of the GNU General Public License as published by
|
|
7 # the Free Software Foundation; either version 3, or (at your option)
|
|
8 # any later version.
|
|
9
|
|
10 # GCC is distributed in the hope that it will be useful,
|
|
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 # GNU General Public License for more details.
|
|
14
|
|
15 # You should have received a copy of the GNU General Public License
|
|
16 # along with GCC; see the file COPYING3. If not see
|
|
17 # <http://www.gnu.org/licenses/>.
|
|
18
|
|
19 # This script takes the following arguments:
|
|
20 #
|
|
21 # - the target sysroot
|
|
22 # - the value of $(MULTILIB_MATCHES)
|
|
23 # - the value of $(MULTILIB_OPTIONS)
|
|
24 #
|
|
25 # It uses these arguments to construct a definition of SYSROOT_SUFFIX_SPEC,
|
|
26 # which it prints to the standard output. For each multilib directory FOO,
|
|
27 # the script checks whether $sysroot has a subdirectory FOO, and if so will
|
|
28 # use /FOO for all compatible command-line options. It will not add a
|
|
29 # suffix for /FOO's options otherwise. These suffixes are concatenated,
|
|
30 # with one subspec for each space-separated entry in $(MULTILIB_OPTIONS).
|
|
31 set -e
|
|
32 sysroot=$1
|
|
33 matches=$2
|
|
34 options=$3
|
|
35
|
|
36 # For each multilib option OPT, add to $substs a sed command of the
|
|
37 # form "-e 's/OPT/OPT/'".
|
|
38 substs=""
|
|
39 for option in `echo "$options" | tr '/' ' '`
|
|
40 do
|
|
41 substs="$substs -e 's/$option/$option/g'"
|
|
42 done
|
|
43
|
|
44 # For each ALIAS=CANONICAL entry in $MULTILIB_MATCHES, look for sed
|
|
45 # arguments in $substs of the form "-e 's/CANONICAL/.../'". Replace
|
|
46 # such entries with "-e 's/CANONICAL/ALIAS|.../'". Both the ALIAS and
|
|
47 # CANONICAL parts of $MULTILIB_MATCHES use '?' to stand for '='.
|
|
48 #
|
|
49 # After this loop, a command of the form "echo FOO | eval sed $substs"
|
|
50 # will replace a canonical option FOO with a %{...}-style spec pattern.
|
|
51 for match in $matches
|
|
52 do
|
|
53 canonical=`echo "$match" | sed -e 's/=.*//' -e 's/?/=/g'`
|
|
54 alias=`echo "$match" | sed -e 's/.*=//' -e 's/?/=/g'`
|
|
55 substs=`echo "$substs" | sed -e "s,s/$canonical/,&$alias|,"`
|
|
56 done
|
|
57
|
|
58 # Build up the final SYSROOT_SUFFIX_SPEC in $spec.
|
|
59 spec=
|
|
60 for combo in $options
|
|
61 do
|
|
62 # See which option alternatives in $combo have their own sysroot
|
|
63 # directory. Create a subspec of the form "%{PAT1:/DIR1;...;PATn:DIRn}"
|
|
64 # from each such option OPTi, where DIRi is the directory associated
|
|
65 # with OPTi and PATi is the result of passing OPTi through $substs.
|
|
66 subspec=
|
|
67 for option in `echo "$combo" | tr '/' ' '`
|
|
68 do
|
|
69 dir=`echo "$option" | sed 's/cpu=//'`
|
|
70 if test -d "$sysroot/$dir"; then
|
|
71 test -z "$subspec" || subspec="$subspec;"
|
|
72 subspec="$subspec"`echo "$option" | eval sed $substs`":/$dir"
|
|
73 fi
|
|
74 done
|
|
75 # Concatenate all the subspecs.
|
|
76 test -z "$subspec" || spec="$spec%{$subspec}"
|
|
77 done
|
|
78 if test -n "$spec"; then
|
|
79 echo "#undef SYSROOT_SUFFIX_SPEC"
|
|
80 echo "#define SYSROOT_SUFFIX_SPEC \"$spec\""
|
|
81 fi
|