2 # Copyright (C) 2006 Free Software Foundation, Inc.
3 # This file is part of GCC.
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)
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.
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.
20 # This script takes the following arguments:
22 # - the target sysroot
23 # - the value of $(MULTILIB_MATCHES)
24 # - the value of $(MULTILIB_OPTIONS)
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).
37 # For each multilib option OPT, add to $substs a sed command of the
38 # form "-e 's/OPT/OPT/'".
40 for option in `echo "$options" | tr '/' ' '`
42 substs="$substs -e 's/$option/$option/g'"
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 '='.
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.
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|,"`
59 # Build up the final SYSROOT_SUFFIX_SPEC in $spec.
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.
68 for option in `echo "$combo" | tr '/' ' '`
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"
76 # Concatenate all the subspecs.
77 test -z "$subspec" || spec="$spec%{$subspec}"
79 if test -n "$spec"; then
80 echo "#undef SYSROOT_SUFFIX_SPEC"
81 echo "#define SYSROOT_SUFFIX_SPEC \"$spec\""