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