Home | History | Annotate | Line # | Download | only in gcc
genmultilib revision 1.1.1.1.4.2
      1  1.1.1.1.4.2  yamt #!/bin/sh 
      2  1.1.1.1.4.2  yamt # Generates multilib.h.
      3  1.1.1.1.4.2  yamt #   Copyright (C) 1994, 1995, 1996, 1997, 1999, 2002, 2007
      4  1.1.1.1.4.2  yamt #   Free Software Foundation, Inc.
      5  1.1.1.1.4.2  yamt 
      6  1.1.1.1.4.2  yamt #This file is part of GCC.
      7  1.1.1.1.4.2  yamt 
      8  1.1.1.1.4.2  yamt #GCC is free software; you can redistribute it and/or modify it under
      9  1.1.1.1.4.2  yamt #the terms of the GNU General Public License as published by the Free
     10  1.1.1.1.4.2  yamt #Software Foundation; either version 3, or (at your option) any later
     11  1.1.1.1.4.2  yamt #version.
     12  1.1.1.1.4.2  yamt 
     13  1.1.1.1.4.2  yamt #GCC is distributed in the hope that it will be useful, but WITHOUT
     14  1.1.1.1.4.2  yamt #ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
     15  1.1.1.1.4.2  yamt #FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     16  1.1.1.1.4.2  yamt #for more details.
     17  1.1.1.1.4.2  yamt 
     18  1.1.1.1.4.2  yamt #You should have received a copy of the GNU General Public License
     19  1.1.1.1.4.2  yamt #along with GCC; see the file COPYING3.  If not see
     20  1.1.1.1.4.2  yamt #<http://www.gnu.org/licenses/>.  
     21  1.1.1.1.4.2  yamt 
     22  1.1.1.1.4.2  yamt # This shell script produces a header file which the gcc driver
     23  1.1.1.1.4.2  yamt # program uses to pick which library to use based on the machine
     24  1.1.1.1.4.2  yamt # specific options that it is given.
     25  1.1.1.1.4.2  yamt 
     26  1.1.1.1.4.2  yamt # The first argument is a list of sets of options.  The elements in
     27  1.1.1.1.4.2  yamt # the list are separated by spaces.  Within an element, the options
     28  1.1.1.1.4.2  yamt # are separated by slashes or pipes.  No leading dash is used on the
     29  1.1.1.1.4.2  yamt # options.
     30  1.1.1.1.4.2  yamt # Each option in a set separated by slashes is mutually incompatible
     31  1.1.1.1.4.2  yamt # with all other options
     32  1.1.1.1.4.2  yamt # in the set.
     33  1.1.1.1.4.2  yamt # Each option in a set separated by pipes will be used for the library
     34  1.1.1.1.4.2  yamt # compilation and any of the options in the set will be sufficient
     35  1.1.1.1.4.2  yamt # for it to be triggered.
     36  1.1.1.1.4.2  yamt 
     37  1.1.1.1.4.2  yamt # The optional second argument is a list of subdirectory names.  If
     38  1.1.1.1.4.2  yamt # the second argument is non-empty, there must be as many elements in
     39  1.1.1.1.4.2  yamt # the second argument as there are options in the first argument.  The
     40  1.1.1.1.4.2  yamt # elements in the second list are separated by spaces.  If the second
     41  1.1.1.1.4.2  yamt # argument is empty, the option names will be used as the directory
     42  1.1.1.1.4.2  yamt # names.
     43  1.1.1.1.4.2  yamt 
     44  1.1.1.1.4.2  yamt # The optional third argument is a list of options which are
     45  1.1.1.1.4.2  yamt # identical.  The elements in the list are separated by spaces.  Each
     46  1.1.1.1.4.2  yamt # element must be of the form OPTION=OPTION.  The first OPTION should
     47  1.1.1.1.4.2  yamt # appear in the first argument, and the second should be a synonym for
     48  1.1.1.1.4.2  yamt # it.  Question marks are replaced with equal signs in both options.
     49  1.1.1.1.4.2  yamt 
     50  1.1.1.1.4.2  yamt # The optional fourth argument is a list of multilib directory 
     51  1.1.1.1.4.2  yamt # combinations that should not be built.
     52  1.1.1.1.4.2  yamt 
     53  1.1.1.1.4.2  yamt # The optional fifth argument is a list of options that should be
     54  1.1.1.1.4.2  yamt # used whenever building multilib libraries.
     55  1.1.1.1.4.2  yamt 
     56  1.1.1.1.4.2  yamt # The optional sixth argument is a list of exclusions used internally by
     57  1.1.1.1.4.2  yamt # the compiler similar to exceptions. The difference being that exclusions
     58  1.1.1.1.4.2  yamt # allow matching default options that genmultilib does not know about and
     59  1.1.1.1.4.2  yamt # is done at runtime as opposed to being sorted out at compile time.
     60  1.1.1.1.4.2  yamt # Each element in the list is a separate exclusion rule. Each rule is
     61  1.1.1.1.4.2  yamt # a list of options (sans preceding '-') separated by a '/'. The options
     62  1.1.1.1.4.2  yamt # on the rule are grouped as an AND operation, and all options much match
     63  1.1.1.1.4.2  yamt # for the rule to exclude a set. Options can be preceded with a '!' to
     64  1.1.1.1.4.2  yamt # match a logical NOT.
     65  1.1.1.1.4.2  yamt 
     66  1.1.1.1.4.2  yamt # The optional seventh argument is a list of OS subdirectory names.
     67  1.1.1.1.4.2  yamt # The format is either the same as of the second argument, or a set of
     68  1.1.1.1.4.2  yamt # mappings. When it is the same as the second argument, it describes
     69  1.1.1.1.4.2  yamt # the multilib directories using OS conventions, rather than GCC
     70  1.1.1.1.4.2  yamt # conventions.  When it is a set of mappings of the form gccdir=osdir,
     71  1.1.1.1.4.2  yamt # the left side gives the GCC convention and the right gives the
     72  1.1.1.1.4.2  yamt # equivalent OS defined location.  If the osdir part begins with a !,
     73  1.1.1.1.4.2  yamt # the os directory names are used exclusively.  Use the mapping when
     74  1.1.1.1.4.2  yamt # there is no one-to-one equivalence between GCC levels and the OS.
     75  1.1.1.1.4.2  yamt 
     76  1.1.1.1.4.2  yamt # The last option should be "yes" if multilibs are enabled.  If it is not
     77  1.1.1.1.4.2  yamt # "yes", all GCC multilib dir names will be ".".
     78  1.1.1.1.4.2  yamt 
     79  1.1.1.1.4.2  yamt # The output looks like
     80  1.1.1.1.4.2  yamt #   #define MULTILIB_MATCHES "\
     81  1.1.1.1.4.2  yamt #   SUBDIRECTORY OPTIONS;\
     82  1.1.1.1.4.2  yamt #   ...
     83  1.1.1.1.4.2  yamt #   "
     84  1.1.1.1.4.2  yamt # The SUBDIRECTORY is the subdirectory to use.  The OPTIONS are
     85  1.1.1.1.4.2  yamt # multiple options separated by spaces.  Each option may start with an
     86  1.1.1.1.4.2  yamt # exclamation point.  gcc will consider each line in turn.  If none of
     87  1.1.1.1.4.2  yamt # the options beginning with an exclamation point are present, and all
     88  1.1.1.1.4.2  yamt # of the other options are present, that subdirectory will be used.
     89  1.1.1.1.4.2  yamt # The order of the subdirectories is such that they can be created in
     90  1.1.1.1.4.2  yamt # order; that is, a subdirectory is preceded by all its parents.
     91  1.1.1.1.4.2  yamt 
     92  1.1.1.1.4.2  yamt # Here is an example (this is from the actual sparc64 case):
     93  1.1.1.1.4.2  yamt #   genmultilib 'm64/m32 mno-app-regs|mcmodel=medany' '64 32 alt'
     94  1.1.1.1.4.2  yamt #		'mcmodel?medany=mcmodel?medmid' 'm32/mno-app-regs* m32/mcmodel=*'
     95  1.1.1.1.4.2  yamt #		'' 'm32/!m64/mno-app-regs m32/!m64/mcmodel=medany'
     96  1.1.1.1.4.2  yamt #		'../lib64 ../lib32 alt' yes
     97  1.1.1.1.4.2  yamt # This produces:
     98  1.1.1.1.4.2  yamt #   ". !m64 !m32 !mno-app-regs !mcmodel=medany;",
     99  1.1.1.1.4.2  yamt #   "64:../lib64 m64 !m32 !mno-app-regs !mcmodel=medany;",
    100  1.1.1.1.4.2  yamt #   "32:../lib32 !m64 m32 !mno-app-regs !mcmodel=medany;",
    101  1.1.1.1.4.2  yamt #   "alt !m64 !m32 mno-app-regs mcmodel=medany;",
    102  1.1.1.1.4.2  yamt #   "alt !m64 !m32 mno-app-regs !mcmodel=medany;",
    103  1.1.1.1.4.2  yamt #   "alt !m64 !m32 !mno-app-regs mcmodel=medany;",
    104  1.1.1.1.4.2  yamt #   "64/alt:../lib64/alt m64 !m32 mno-app-regs mcmodel=medany;",
    105  1.1.1.1.4.2  yamt #   "64/alt:../lib64/alt m64 !m32 mno-app-regs !mcmodel=medany;",
    106  1.1.1.1.4.2  yamt #   "64/alt:../lib64/alt m64 !m32 !mno-app-regs mcmodel=medany;",
    107  1.1.1.1.4.2  yamt #
    108  1.1.1.1.4.2  yamt # The effect is that `gcc -mno-app-regs' (for example) will append "alt"
    109  1.1.1.1.4.2  yamt # to the directory name when searching for libraries or startup files and
    110  1.1.1.1.4.2  yamt # `gcc -m32 -mcmodel=medany' (for example) will append "32/alt". Also note
    111  1.1.1.1.4.2  yamt # that exclusion above is moot, unless the compiler had a default of -m32,
    112  1.1.1.1.4.2  yamt # which would mean that all of the "alt" directories (not the 64/alt ones)
    113  1.1.1.1.4.2  yamt # would be ignored (not generated, nor used) since the exclusion also
    114  1.1.1.1.4.2  yamt # matches the multilib_default args.
    115  1.1.1.1.4.2  yamt 
    116  1.1.1.1.4.2  yamt # Copy the positional parameters into variables.
    117  1.1.1.1.4.2  yamt options=$1
    118  1.1.1.1.4.2  yamt dirnames=$2
    119  1.1.1.1.4.2  yamt matches=$3
    120  1.1.1.1.4.2  yamt exceptions=$4
    121  1.1.1.1.4.2  yamt extra=$5
    122  1.1.1.1.4.2  yamt exclusions=$6
    123  1.1.1.1.4.2  yamt osdirnames=$7
    124  1.1.1.1.4.2  yamt enable_multilib=$8
    125  1.1.1.1.4.2  yamt 
    126  1.1.1.1.4.2  yamt echo "static const char *const multilib_raw[] = {"
    127  1.1.1.1.4.2  yamt 
    128  1.1.1.1.4.2  yamt mkdir tmpmultilib.$$ || exit 1
    129  1.1.1.1.4.2  yamt # Use cd ./foo to avoid CDPATH output.
    130  1.1.1.1.4.2  yamt cd ./tmpmultilib.$$ || exit 1
    131  1.1.1.1.4.2  yamt 
    132  1.1.1.1.4.2  yamt # What we want to do is select all combinations of the sets in
    133  1.1.1.1.4.2  yamt # options.  Each combination which includes a set of mutually
    134  1.1.1.1.4.2  yamt # exclusive options must then be output multiple times, once for each
    135  1.1.1.1.4.2  yamt # item in the set.  Selecting combinations is a recursive process.
    136  1.1.1.1.4.2  yamt # Since not all versions of sh support functions, we achieve recursion
    137  1.1.1.1.4.2  yamt # by creating a temporary shell script which invokes itself.
    138  1.1.1.1.4.2  yamt rm -f tmpmultilib
    139  1.1.1.1.4.2  yamt cat >tmpmultilib <<EOF
    140  1.1.1.1.4.2  yamt #!${CONFIG_SHELL:-/bin/sh}
    141  1.1.1.1.4.2  yamt EOF
    142  1.1.1.1.4.2  yamt cat >>tmpmultilib <<\EOF
    143  1.1.1.1.4.2  yamt # This recursive script basically outputs all combinations of its
    144  1.1.1.1.4.2  yamt # input arguments, handling mutually exclusive sets of options by
    145  1.1.1.1.4.2  yamt # repetition.  When the script is called, ${initial} is the list of
    146  1.1.1.1.4.2  yamt # options which should appear before all combinations this will
    147  1.1.1.1.4.2  yamt # output.  The output looks like a list of subdirectory names with
    148  1.1.1.1.4.2  yamt # leading and trailing slashes.
    149  1.1.1.1.4.2  yamt if [ "$#" != "0" ]; then
    150  1.1.1.1.4.2  yamt   first=$1
    151  1.1.1.1.4.2  yamt   shift
    152  1.1.1.1.4.2  yamt   case "$first" in
    153  1.1.1.1.4.2  yamt   *\|*)
    154  1.1.1.1.4.2  yamt     all=${initial}`echo $first | sed -e 's_|_/_'g`
    155  1.1.1.1.4.2  yamt     first=`echo $first | sed -e 's_|_ _'g`
    156  1.1.1.1.4.2  yamt     echo ${all}/
    157  1.1.1.1.4.2  yamt     initial="${initial}${all}/" ./tmpmultilib $@
    158  1.1.1.1.4.2  yamt     ./tmpmultilib $first $@ | grep -v "^${all}"
    159  1.1.1.1.4.2  yamt     ;;
    160  1.1.1.1.4.2  yamt   *)
    161  1.1.1.1.4.2  yamt     for opt in `echo $first | sed -e 's|/| |'g`; do
    162  1.1.1.1.4.2  yamt       echo ${initial}${opt}/
    163  1.1.1.1.4.2  yamt     done
    164  1.1.1.1.4.2  yamt     ./tmpmultilib $@
    165  1.1.1.1.4.2  yamt     for opt in `echo $first | sed -e 's|/| |'g`; do
    166  1.1.1.1.4.2  yamt       initial="${initial}${opt}/" ./tmpmultilib $@
    167  1.1.1.1.4.2  yamt     done
    168  1.1.1.1.4.2  yamt   esac
    169  1.1.1.1.4.2  yamt fi
    170  1.1.1.1.4.2  yamt EOF
    171  1.1.1.1.4.2  yamt chmod +x tmpmultilib
    172  1.1.1.1.4.2  yamt 
    173  1.1.1.1.4.2  yamt combinations=`initial=/ ./tmpmultilib ${options}`
    174  1.1.1.1.4.2  yamt 
    175  1.1.1.1.4.2  yamt # If there exceptions, weed them out now
    176  1.1.1.1.4.2  yamt if [ -n "${exceptions}" ]; then
    177  1.1.1.1.4.2  yamt   cat >tmpmultilib2 <<EOF
    178  1.1.1.1.4.2  yamt #!${CONFIG_SHELL:-/bin/sh}
    179  1.1.1.1.4.2  yamt EOF
    180  1.1.1.1.4.2  yamt   cat >>tmpmultilib2 <<\EOF
    181  1.1.1.1.4.2  yamt # This recursive script weeds out any combination of multilib
    182  1.1.1.1.4.2  yamt # switches that should not be generated.  The output looks like
    183  1.1.1.1.4.2  yamt # a list of subdirectory names with leading and trailing slashes.
    184  1.1.1.1.4.2  yamt 
    185  1.1.1.1.4.2  yamt   for opt in $@; do
    186  1.1.1.1.4.2  yamt     case "$opt" in
    187  1.1.1.1.4.2  yamt EOF
    188  1.1.1.1.4.2  yamt 
    189  1.1.1.1.4.2  yamt   for except in ${exceptions}; do
    190  1.1.1.1.4.2  yamt     echo "      /${except}/) : ;;" >> tmpmultilib2
    191  1.1.1.1.4.2  yamt   done
    192  1.1.1.1.4.2  yamt 
    193  1.1.1.1.4.2  yamt cat >>tmpmultilib2 <<\EOF
    194  1.1.1.1.4.2  yamt       *) echo ${opt};;
    195  1.1.1.1.4.2  yamt     esac
    196  1.1.1.1.4.2  yamt   done
    197  1.1.1.1.4.2  yamt EOF
    198  1.1.1.1.4.2  yamt   chmod +x tmpmultilib2
    199  1.1.1.1.4.2  yamt   combinations=`./tmpmultilib2 ${combinations}`
    200  1.1.1.1.4.2  yamt fi
    201  1.1.1.1.4.2  yamt 
    202  1.1.1.1.4.2  yamt # Construct a sed pattern which will convert option names to directory
    203  1.1.1.1.4.2  yamt # names.
    204  1.1.1.1.4.2  yamt todirnames=
    205  1.1.1.1.4.2  yamt if [ -n "${dirnames}" ]; then
    206  1.1.1.1.4.2  yamt   set x ${dirnames}
    207  1.1.1.1.4.2  yamt   shift
    208  1.1.1.1.4.2  yamt   for set in ${options}; do
    209  1.1.1.1.4.2  yamt     for opts in `echo ${set} | sed -e 's|/| |'g`; do
    210  1.1.1.1.4.2  yamt       patt="/"
    211  1.1.1.1.4.2  yamt       for opt in `echo ${opts} | sed -e 's_|_ _'g`; do
    212  1.1.1.1.4.2  yamt         if [ "$1" != "${opt}" ]; then
    213  1.1.1.1.4.2  yamt           todirnames="${todirnames} -e s|/${opt}/|/${1}/|g"
    214  1.1.1.1.4.2  yamt 	  patt="${patt}${1}/"
    215  1.1.1.1.4.2  yamt 	  if [ "${patt}" != "/${1}/" ]; then
    216  1.1.1.1.4.2  yamt 	    todirnames="${todirnames} -e s|${patt}|/${1}/|g"
    217  1.1.1.1.4.2  yamt           fi
    218  1.1.1.1.4.2  yamt         fi
    219  1.1.1.1.4.2  yamt       done
    220  1.1.1.1.4.2  yamt       shift
    221  1.1.1.1.4.2  yamt     done
    222  1.1.1.1.4.2  yamt   done
    223  1.1.1.1.4.2  yamt fi
    224  1.1.1.1.4.2  yamt 
    225  1.1.1.1.4.2  yamt # Construct a sed pattern which will convert option names to OS directory
    226  1.1.1.1.4.2  yamt # names.
    227  1.1.1.1.4.2  yamt toosdirnames=
    228  1.1.1.1.4.2  yamt defaultosdirname=
    229  1.1.1.1.4.2  yamt if [ -n "${osdirnames}" ]; then
    230  1.1.1.1.4.2  yamt   set x ${osdirnames}
    231  1.1.1.1.4.2  yamt   shift
    232  1.1.1.1.4.2  yamt   while [ $# != 0 ] ; do
    233  1.1.1.1.4.2  yamt     case "$1" in
    234  1.1.1.1.4.2  yamt       .=*)
    235  1.1.1.1.4.2  yamt         defaultosdirname=`echo $1 | sed 's|^.=|:|'`
    236  1.1.1.1.4.2  yamt 	shift
    237  1.1.1.1.4.2  yamt 	;;
    238  1.1.1.1.4.2  yamt       *=*)
    239  1.1.1.1.4.2  yamt 	patt=`echo $1 | sed -e 's|=|/$=/|'`
    240  1.1.1.1.4.2  yamt         toosdirnames="${toosdirnames} -e s=^/${patt}/="
    241  1.1.1.1.4.2  yamt 	shift
    242  1.1.1.1.4.2  yamt         ;;
    243  1.1.1.1.4.2  yamt       *)
    244  1.1.1.1.4.2  yamt         break
    245  1.1.1.1.4.2  yamt 	;;
    246  1.1.1.1.4.2  yamt     esac
    247  1.1.1.1.4.2  yamt   done
    248  1.1.1.1.4.2  yamt   
    249  1.1.1.1.4.2  yamt   if [ $# != 0 ]; then
    250  1.1.1.1.4.2  yamt     for set in ${options}; do
    251  1.1.1.1.4.2  yamt       for opts in `echo ${set} | sed -e 's|/| |'g`; do
    252  1.1.1.1.4.2  yamt         patt="/"
    253  1.1.1.1.4.2  yamt         for opt in `echo ${opts} | sed -e 's_|_ _'g`; do
    254  1.1.1.1.4.2  yamt           if [ "$1" != "${opt}" ]; then
    255  1.1.1.1.4.2  yamt             toosdirnames="${toosdirnames} -e s|/${opt}/|/${1}/|g"
    256  1.1.1.1.4.2  yamt 	    patt="${patt}${1}/"
    257  1.1.1.1.4.2  yamt 	    if [ "${patt}" != "/${1}/" ]; then
    258  1.1.1.1.4.2  yamt 	      toosdirnames="${toosdirnames} -e s|${patt}|/${1}/|g"
    259  1.1.1.1.4.2  yamt             fi
    260  1.1.1.1.4.2  yamt           fi
    261  1.1.1.1.4.2  yamt         done
    262  1.1.1.1.4.2  yamt         shift
    263  1.1.1.1.4.2  yamt       done
    264  1.1.1.1.4.2  yamt     done
    265  1.1.1.1.4.2  yamt   fi
    266  1.1.1.1.4.2  yamt fi
    267  1.1.1.1.4.2  yamt 
    268  1.1.1.1.4.2  yamt # We need another recursive shell script to correctly handle positive
    269  1.1.1.1.4.2  yamt # matches.  If we are invoked as
    270  1.1.1.1.4.2  yamt #   genmultilib "opt1 opt2" "" "opt1=nopt1 opt2=nopt2"
    271  1.1.1.1.4.2  yamt # we must output
    272  1.1.1.1.4.2  yamt #   opt1/opt2 opt1 opt2
    273  1.1.1.1.4.2  yamt #   opt1/opt2 nopt1 opt2
    274  1.1.1.1.4.2  yamt #   opt1/opt2 opt1 nopt2
    275  1.1.1.1.4.2  yamt #   opt1/opt2 nopt1 nopt2
    276  1.1.1.1.4.2  yamt # In other words, we must output all combinations of matches.
    277  1.1.1.1.4.2  yamt rm -f tmpmultilib2
    278  1.1.1.1.4.2  yamt cat >tmpmultilib2 <<EOF
    279  1.1.1.1.4.2  yamt #!${CONFIG_SHELL:-/bin/sh}
    280  1.1.1.1.4.2  yamt EOF
    281  1.1.1.1.4.2  yamt cat >>tmpmultilib2 <<\EOF
    282  1.1.1.1.4.2  yamt # The positional parameters are a list of matches to consider.
    283  1.1.1.1.4.2  yamt # ${dirout} is the directory name and ${optout} is the current list of
    284  1.1.1.1.4.2  yamt # options.
    285  1.1.1.1.4.2  yamt if [ "$#" = "0" ]; then
    286  1.1.1.1.4.2  yamt   echo "\"${dirout} ${optout};\","
    287  1.1.1.1.4.2  yamt else
    288  1.1.1.1.4.2  yamt   first=$1
    289  1.1.1.1.4.2  yamt   shift
    290  1.1.1.1.4.2  yamt   dirout="${dirout}" optout="${optout}" ./tmpmultilib2 $@
    291  1.1.1.1.4.2  yamt   l=`echo ${first} | sed -e 's/=.*$//' -e 's/?/=/g'`
    292  1.1.1.1.4.2  yamt   r=`echo ${first} | sed -e 's/^.*=//' -e 's/?/=/g'`
    293  1.1.1.1.4.2  yamt   if expr " ${optout} " : ".* ${l} .*" > /dev/null; then
    294  1.1.1.1.4.2  yamt     newopt=`echo " ${optout} " | sed -e "s/ ${l} / ${r} /" -e 's/^ //' -e 's/ $//'`
    295  1.1.1.1.4.2  yamt     dirout="${dirout}" optout="${newopt}" ./tmpmultilib2 $@
    296  1.1.1.1.4.2  yamt   fi
    297  1.1.1.1.4.2  yamt fi
    298  1.1.1.1.4.2  yamt EOF
    299  1.1.1.1.4.2  yamt chmod +x tmpmultilib2
    300  1.1.1.1.4.2  yamt 
    301  1.1.1.1.4.2  yamt # Start with the current directory, which includes only negations.
    302  1.1.1.1.4.2  yamt optout=
    303  1.1.1.1.4.2  yamt for set in ${options}; do
    304  1.1.1.1.4.2  yamt   for opt in `echo ${set} | sed -e 's_[/|]_ _g'`; do
    305  1.1.1.1.4.2  yamt     optout="${optout} !${opt}"
    306  1.1.1.1.4.2  yamt   done
    307  1.1.1.1.4.2  yamt done
    308  1.1.1.1.4.2  yamt optout=`echo ${optout} | sed -e 's/^ //'`
    309  1.1.1.1.4.2  yamt echo "\".${defaultosdirname} ${optout};\","
    310  1.1.1.1.4.2  yamt 
    311  1.1.1.1.4.2  yamt # Work over the list of combinations.  We have to translate each one
    312  1.1.1.1.4.2  yamt # to use the directory names rather than the option names, we have to
    313  1.1.1.1.4.2  yamt # include the information in matches, and we have to generate the
    314  1.1.1.1.4.2  yamt # correct list of options and negations.
    315  1.1.1.1.4.2  yamt for combo in ${combinations}; do
    316  1.1.1.1.4.2  yamt   # Use the directory names rather than the option names.
    317  1.1.1.1.4.2  yamt   if [ -n "${todirnames}" ]; then
    318  1.1.1.1.4.2  yamt     dirout=`echo ${combo} | sed ${todirnames}`
    319  1.1.1.1.4.2  yamt   else
    320  1.1.1.1.4.2  yamt     dirout=`echo ${combo} | sed -e 's/=/-/g'`
    321  1.1.1.1.4.2  yamt   fi
    322  1.1.1.1.4.2  yamt   # Remove the leading and trailing slashes.
    323  1.1.1.1.4.2  yamt   dirout=`echo ${dirout} | sed -e 's|^/||' -e 's|/$||g'`
    324  1.1.1.1.4.2  yamt 
    325  1.1.1.1.4.2  yamt   # Use the OS directory names rather than the option names.
    326  1.1.1.1.4.2  yamt   if [ -n "${toosdirnames}" ]; then
    327  1.1.1.1.4.2  yamt     osdirout=`echo ${combo} | sed ${toosdirnames}`
    328  1.1.1.1.4.2  yamt     # Remove the leading and trailing slashes.
    329  1.1.1.1.4.2  yamt     osdirout=`echo ${osdirout} | sed -e 's|^/||' -e 's|/$||g'`
    330  1.1.1.1.4.2  yamt     if [ "x${enable_multilib}" != xyes ]; then
    331  1.1.1.1.4.2  yamt       dirout=".:${osdirout}"
    332  1.1.1.1.4.2  yamt       disable_multilib=yes
    333  1.1.1.1.4.2  yamt     else
    334  1.1.1.1.4.2  yamt       case "${osdirout}" in
    335  1.1.1.1.4.2  yamt         !*)
    336  1.1.1.1.4.2  yamt 	  dirout=`echo ${osdirout} | sed 's/^!//'`
    337  1.1.1.1.4.2  yamt 	  ;;
    338  1.1.1.1.4.2  yamt 	*)
    339  1.1.1.1.4.2  yamt 	  dirout="${dirout}:${osdirout}"
    340  1.1.1.1.4.2  yamt 	  ;;
    341  1.1.1.1.4.2  yamt       esac
    342  1.1.1.1.4.2  yamt     fi
    343  1.1.1.1.4.2  yamt   else
    344  1.1.1.1.4.2  yamt     if [ "x${enable_multilib}" != xyes ]; then
    345  1.1.1.1.4.2  yamt       # genmultilib with --disable-multilib should be
    346  1.1.1.1.4.2  yamt       # called with '' '' '' '' '' '' '' no
    347  1.1.1.1.4.2  yamt       # if MULTILIB_OSDIRNAMES is empty.
    348  1.1.1.1.4.2  yamt       exit 1
    349  1.1.1.1.4.2  yamt     fi
    350  1.1.1.1.4.2  yamt   fi
    351  1.1.1.1.4.2  yamt 
    352  1.1.1.1.4.2  yamt   # Look through the options.  We must output each option that is
    353  1.1.1.1.4.2  yamt   # present, and negate each option that is not present.
    354  1.1.1.1.4.2  yamt   optout=
    355  1.1.1.1.4.2  yamt   for set in ${options}; do
    356  1.1.1.1.4.2  yamt     setopts=`echo ${set} | sed -e 's_[/|]_ _g'`
    357  1.1.1.1.4.2  yamt     for opt in ${setopts}; do
    358  1.1.1.1.4.2  yamt       if expr "${combo} " : ".*/${opt}/.*" > /dev/null; then
    359  1.1.1.1.4.2  yamt 	optout="${optout} ${opt}"
    360  1.1.1.1.4.2  yamt       else
    361  1.1.1.1.4.2  yamt 	optout="${optout} !${opt}"
    362  1.1.1.1.4.2  yamt       fi
    363  1.1.1.1.4.2  yamt     done
    364  1.1.1.1.4.2  yamt   done
    365  1.1.1.1.4.2  yamt   optout=`echo ${optout} | sed -e 's/^ //'`
    366  1.1.1.1.4.2  yamt 
    367  1.1.1.1.4.2  yamt   # Output the line with all appropriate matches.
    368  1.1.1.1.4.2  yamt   dirout="${dirout}" optout="${optout}" ./tmpmultilib2
    369  1.1.1.1.4.2  yamt done
    370  1.1.1.1.4.2  yamt 
    371  1.1.1.1.4.2  yamt # Terminate the list of string.
    372  1.1.1.1.4.2  yamt echo "NULL"
    373  1.1.1.1.4.2  yamt echo "};"
    374  1.1.1.1.4.2  yamt 
    375  1.1.1.1.4.2  yamt # Output all of the matches now as option and that is the same as that, with
    376  1.1.1.1.4.2  yamt # a semicolon trailer.  Include all of the normal options as well.
    377  1.1.1.1.4.2  yamt # Note, the format of the matches is reversed compared
    378  1.1.1.1.4.2  yamt # to what we want, so switch them around.
    379  1.1.1.1.4.2  yamt echo ""
    380  1.1.1.1.4.2  yamt echo "static const char *const multilib_matches_raw[] = {"
    381  1.1.1.1.4.2  yamt for match in ${matches}; do
    382  1.1.1.1.4.2  yamt   l=`echo ${match} | sed -e 's/=.*$//' -e 's/?/=/g'`
    383  1.1.1.1.4.2  yamt   r=`echo ${match} | sed -e 's/^.*=//' -e 's/?/=/g'`
    384  1.1.1.1.4.2  yamt   echo "\"${r} ${l};\","
    385  1.1.1.1.4.2  yamt done
    386  1.1.1.1.4.2  yamt for set in ${options}; do
    387  1.1.1.1.4.2  yamt   for opt in `echo ${set} | sed -e 's_[/|]_ _'g`; do
    388  1.1.1.1.4.2  yamt     echo "\"${opt} ${opt};\","
    389  1.1.1.1.4.2  yamt   done
    390  1.1.1.1.4.2  yamt done
    391  1.1.1.1.4.2  yamt echo "NULL"
    392  1.1.1.1.4.2  yamt echo "};"
    393  1.1.1.1.4.2  yamt 
    394  1.1.1.1.4.2  yamt # Output the default options now
    395  1.1.1.1.4.2  yamt echo ""
    396  1.1.1.1.4.2  yamt echo "static const char *multilib_extra = \"${extra}\";"
    397  1.1.1.1.4.2  yamt 
    398  1.1.1.1.4.2  yamt # Output the exclusion rules now
    399  1.1.1.1.4.2  yamt echo ""
    400  1.1.1.1.4.2  yamt echo "static const char *const multilib_exclusions_raw[] = {"
    401  1.1.1.1.4.2  yamt for rule in ${exclusions}; do
    402  1.1.1.1.4.2  yamt   s=`echo ${rule} | sed -e 's,/, ,g'`
    403  1.1.1.1.4.2  yamt   echo "\"${s};\","
    404  1.1.1.1.4.2  yamt done
    405  1.1.1.1.4.2  yamt echo "NULL"
    406  1.1.1.1.4.2  yamt echo "};"
    407  1.1.1.1.4.2  yamt 
    408  1.1.1.1.4.2  yamt # Output the options now
    409  1.1.1.1.4.2  yamt moptions=`echo ${options} | sed -e 's,[ 	][ 	]*, ,g'`
    410  1.1.1.1.4.2  yamt echo ""
    411  1.1.1.1.4.2  yamt echo "static const char *multilib_options = \"${moptions}\";"
    412  1.1.1.1.4.2  yamt 
    413  1.1.1.1.4.2  yamt # Finally output the disable flag if specified
    414  1.1.1.1.4.2  yamt if [ "x${disable_multilib}" = xyes ]; then
    415  1.1.1.1.4.2  yamt   echo ""
    416  1.1.1.1.4.2  yamt   echo "#define DISABLE_MULTILIB  1"
    417  1.1.1.1.4.2  yamt fi
    418  1.1.1.1.4.2  yamt 
    419  1.1.1.1.4.2  yamt cd ..
    420  1.1.1.1.4.2  yamt rm -r tmpmultilib.$$
    421  1.1.1.1.4.2  yamt 
    422  1.1.1.1.4.2  yamt exit 0
    423