OSDN Git Service

* config/i386/i386.c (enum pta_flags): Move out of struct scope...
[pf3gnuchains/gcc-fork.git] / gcc / config / m68k / print-sysroot-suffix.sh
1 #!/bin/sh
2 # Copyright (C) 2006 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 2, 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 COPYING.  If not, write to
17 # the Free Software Foundation, 51 Franklin Street, Fifth Floor,
18 # Boston MA 02110-1301, USA.
19
20 # This script takes the following arguments:
21 #
22 #    - the target sysroot
23 #    - the value of $(MULTILIB_MATCHES)
24 #    - the value of $(MULTILIB_OPTIONS)
25 #
26 # It uses these arguments to construct a definition of SYSROOT_SUFFIX_SPEC,
27 # which it prints to the standard output.  For each multilib directory FOO,
28 # the script checks whether $sysroot has a subdirectory FOO, and if so will
29 # use /FOO for all compatible command-line options.  It will not add a
30 # suffix for /FOO's options otherwise.  These suffixes are concatenated,
31 # with one subspec for each space-separated entry in $(MULTILIB_OPTIONS).
32 set -e
33 sysroot=$1
34 matches=$2
35 options=$3
36
37 # For each multilib option OPT, add to $substs a sed command of the
38 # form "-e 's/OPT/OPT/'".
39 substs=""
40 for option in `echo "$options" | tr '/' ' '`
41 do
42   substs="$substs -e 's/$option/$option/g'"
43 done
44
45 # For each ALIAS=CANONICAL entry in $MULTILIB_MATCHES, look for sed
46 # arguments in $substs of the form "-e 's/CANONICAL/.../'".  Replace
47 # such entries with "-e 's/CANONICAL/ALIAS|.../'".  Both the ALIAS and
48 # CANONICAL parts of $MULTILIB_MATCHES use '?' to stand for '='.
49 #
50 # After this loop, a command of the form "echo FOO | eval sed $substs"
51 # will replace a canonical option FOO with a %{...}-style spec pattern.
52 for match in $matches
53 do
54   canonical=`echo "$match" | sed -e 's/=.*//' -e 's/?/=/g'`
55   alias=`echo "$match" | sed -e 's/.*=//' -e 's/?/=/g'`
56   substs=`echo "$substs" | sed -e "s,s/$canonical/,&$alias|,"`
57 done
58
59 # Build up the final SYSROOT_SUFFIX_SPEC in $spec.
60 spec=
61 for combo in $options
62 do
63   # See which option alternatives in $combo have their own sysroot
64   # directory.  Create a subspec of the form "%{PAT1:/DIR1;...;PATn:DIRn}"
65   # from each such option OPTi, where DIRi is the directory associated
66   # with OPTi and PATi is the result of passing OPTi through $substs.
67   subspec=
68   for option in `echo "$combo" | tr '/' ' '`
69   do
70     dir=`echo "$option" | sed 's/cpu=//'`
71     if test -d "$sysroot/$dir"; then
72       test -z "$subspec" || subspec="$subspec;"
73       subspec="$subspec"`echo "$option" | eval sed $substs`":/$dir"
74     fi
75   done
76   # Concatenate all the subspecs.
77   test -z "$subspec" || spec="$spec%{$subspec}"
78 done
79 if test -n "$spec"; then
80   echo "#undef SYSROOT_SUFFIX_SPEC"
81   echo "#define SYSROOT_SUFFIX_SPEC \"$spec\""
82 fi