2 # Copyright (C) 2007-2014 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 3, 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 COPYING3. If not see
17 # <http://www.gnu.org/licenses/>.
19 # This script takes the following arguments:
21 # - the target sysroot
22 # - the value of $(MULTILIB_MATCHES)
23 # - the value of $(MULTILIB_OPTIONS)
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).
36 # For each multilib option OPT, add to $substs a sed command of the
37 # form "-e 's/OPT/OPT/'".
39 for option
in `echo "$options" | tr '/' ' '`
41 substs
="$substs -e 's/$option/$option/g'"
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 '='.
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.
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|,"`
58 # Build up the final SYSROOT_SUFFIX_SPEC in $spec.
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.
67 for option
in `echo "$combo" | tr '/' ' '`
69 dir
=`echo "$option" | sed 's/mcpu=//'`
70 if test -d "$sysroot/$dir"; then
71 test -z "$subspec" || subspec
="$subspec;"
72 subspec
="$subspec"`echo "$option" | eval sed $substs`":/$dir"
75 # Concatenate all the subspecs.
76 test -z "$subspec" || spec
="$spec%{$subspec}"
78 if test -n "$spec"; then
79 echo "#undef SYSROOT_SUFFIX_SPEC"
80 echo "#define SYSROOT_SUFFIX_SPEC \"$spec\""