head	1.9;
access;
symbols
	gcc-2_8_1-990325:1.9
	gcc-2_8_1-990319:1.9
	gcc-2_8_1-990302:1.9
	gcc_2_8_1-990302:1.9
	gcc_2_8_1-990222:1.9
	gcc-2_8_1-990109:1.9
	gcc-2_8_1-981210:1.9
	gcc-2_8_1-981208:1.9
	gcc-2_8_1-980929:1.9
	gcc_2_8_1-980929:1.9
	gcc-2_8_1-980928:1.9
	gcc-2_8_1-980813:1.9
	gcc-2_8_1-980811:1.9
	gcc-2_8_1-980718:1.9
	gcc-2_8_1-980705:1.9
	gcc-2_8_1-980627:1.9
	gcc-2_8_1-980609:1.9
	gcc-2_8_1-980608:1.9
	gcc-2_8_1-980529:1.9
	gcc-2_8_1-980525:1.9
	gcc-2_8_1-980513:1.9
	gcc-2_8_1-980502:1.9
	gcc-2_8_1-980402:1.9
	gcc-2_8_1-980426:1.9
	gcc-2_8_1-980419:1.9
	gcc-2_8_1-980413:1.9
	gcc-2_8_1-980412:1.9
	gcc-2_8_1-980407:1.9
	gcc-2_8_1-980401:1.9
	gcc_2_8_1-980315:1.9
	gcc-2_8_1-RELEASE:1.9;
locks; strict;
comment	@# @;


1.9
date	97.12.03.13.42.40;	author kenner;	state Exp;
branches;
next	1.8;

1.8
date	96.08.12.16.36.42;	author meissner;	state Exp;
branches;
next	1.7;

1.7
date	96.06.08.02.45.34;	author wilson;	state Exp;
branches;
next	1.6;

1.6
date	95.11.30.17.49.53;	author meissner;	state Exp;
branches;
next	1.5;

1.5
date	95.10.20.22.57.04;	author kenner;	state Exp;
branches;
next	1.4;

1.4
date	95.06.22.23.06.34;	author kenner;	state Exp;
branches;
next	1.3;

1.3
date	95.06.15.21.05.27;	author kenner;	state Exp;
branches;
next	1.2;

1.2
date	95.05.10.18.26.30;	author meissner;	state Exp;
branches;
next	1.1;

1.1
date	94.06.15.08.01.42;	author dje;	state Exp;
branches;
next	;


desc
@generate multilib.h
@


1.9
log
@Fix spelling errors.
@
text
@#!/bin/sh 
# Generates multilib.h.
#   Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.

#This file is part of GNU CC.

#GNU CC is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2, or (at your option)
#any later version.

#GNU CC is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.

#You should have received a copy of the GNU General Public License
#along with GNU CC; see the file COPYING.  If not, write to
#the Free Software Foundation, 59 Temple Place - Suite 330,
#Boston, MA 02111-1307, USA.

# This shell script produces a header file which the gcc driver
# program uses to pick which library to use based on the machine
# specific options that it is given.

# The first argument is a list of sets of options.  The elements in
# the list are separated by spaces.  Within an element, the options
# are separated by slashes.  No leading dash is used on the options.
# Each option in a set is mutually incompatible with all other options
# in the set.

# The optional second argument is a list of subdirectory names.  If
# the second argument is non-empty, there must be as many elements in
# the second argument as there are options in the first argument.  The
# elements in the second list are separated by spaces.  If the second
# argument is empty, the option names will be used as the directory
# names.

# The optional third argument is a list of options which are
# identical.  The elements in the list are separated by spaces.  Each
# element must be of the form OPTION=OPTION.  The first OPTION should
# appear in the first argument, and the second should be a synonym for
# it.  Question marks are replaced with equal signs in both options.

# The optional fourth argument is a list of multilib directory 
# combinations that should not be built.

# The optional fifth argument is a list of options that should be
# used whenever building multilib libraries.

# The output looks like
#   #define MULTILIB_MATCHES "\
#   SUBDIRECTORY OPTIONS;\
#   ...
#   "
# The SUBDIRECTORY is the subdirectory to use.  The OPTIONS are
# multiple options separated by spaces.  Each option may start with an
# exclamation point.  gcc will consider each line in turn.  If none of
# the options beginning with an exclamation point are present, and all
# of the other options are present, that subdirectory will be used.
# The order of the subdirectories is such that they can be created in
# order; that is, a subdirectory is preceded by all its parents.

# Here is a example (this is simplified from the actual 680x0 case):
#   genmultilib "m68000/m68020 msoft-float" "m68000 m68020 msoft-float"
#		"m68000=mc68000"
# This produces:
#   ". !m68000 !mc68000 !m68020 !msoft-float;",
#   "m68000 m68000 !m68020 !msoft-float;",
#   "m68000 mc60000 !m68020 !msoft-float;",
#   "m68020 !m68000 !mc68000 m68020 !msoft-float;",
#   "msoft-float !m68000 !mc68000 !m68020 msoft-float;",
#   "m68000/msoft-float m68000 !m68020 msoft-float;",
#   "m68000/msoft-float mc68000 !m68020 msoft-float;",
#   "m68020/msoft-float !m68000 !mc68000 m68020 msoft-float;",
#
# The effect is that `gcc -msoft-float' (for example) will append
# msoft-float to the directory name when searching for libraries or
# startup files, and `gcc -m68000 -msoft-float' (for example) will
# append m68000/msoft-float.

# Copy the positional parameters into variables.
options=$1
dirnames=$2
matches=$3
exceptions=$4
extra=$5

echo "static char *multilib_raw[] = {"

# What we want to do is select all combinations of the sets in
# options.  Each combination which includes a set of mutually
# exclusive options must then be output multiple times, once for each
# item in the set.  Selecting combinations is a recursive process.
# Since not all versions of sh support functions, we achieve recursion
# by creating a temporary shell script which invokes itself.
rm -f tmpmultilib
cat >tmpmultilib <<\EOF
#!/bin/sh
# This recursive script basically outputs all combinations of its
# input arguments, handling mutually exclusive sets of options by
# repetition.  When the script is called, ${initial} is the list of
# options which should appear before all combinations this will
# output.  The output looks like a list of subdirectory names with
# leading and trailing slashes.
if [ "$#" != "0" ]; then
  first=$1
  shift
  for opt in `echo $first | sed -e 's|/| |'g`; do
    echo ${initial}${opt}/
  done
  ./tmpmultilib $@@
  for opt in `echo $first | sed -e 's|/| |'g`; do
    initial="${initial}${opt}/" ./tmpmultilib $@@
  done
fi
EOF
chmod +x tmpmultilib

combinations=`initial=/ ./tmpmultilib ${options}`

rm -f tmpmultilib

# If there exceptions, weed them out now
if [ -n "${exceptions}" ]; then
  rm -f tmpmultilib2
  cat >tmpmultilib2 <<\EOF
#!/bin/sh
# This recursive script weeds out any combination of multilib
# switches that should not be generated.  The output looks like
# a list of subdirectory names with leading and trailing slashes.

  for opt in $@@; do
    case "$opt" in
EOF

  for except in ${exceptions}; do
    echo "      /${except}/) : ;;" >> tmpmultilib2
  done

cat >>tmpmultilib2 <<\EOF
      *) echo ${opt};;
    esac
  done
EOF
  chmod +x tmpmultilib2
  combinations=`./tmpmultilib2 ${combinations}`
  rm -f ./tmpmultilib2
fi

# Construct a sed pattern which will convert option names to directory
# names.
todirnames=
if [ -n "${dirnames}" ]; then
  set x ${dirnames}
  shift
  for set in ${options}; do
    for opt in `echo ${set} | sed -e 's|/| |'g`; do
      if [ "$1" != "${opt}" ]; then
        todirnames="${todirnames} -e s|/${opt}/|/${1}/|g"
      fi
      shift
    done
  done
fi

# We need another recursive shell script to correctly handle positive
# matches.  If we are invoked as
#   genmultilib "opt1 opt2" "" "opt1=nopt1 opt2=nopt2"
# we must output
#   opt1/opt2 opt1 opt2
#   opt1/opt2 nopt1 opt2
#   opt1/opt2 opt1 nopt2
#   opt1/opt2 nopt1 nopt2
# In other words, we must output all combinations of matches.
rm -f tmpmultilib2
cat >tmpmultilib2 <<\EOF
#!/bin/sh
# The positional parameters are a list of matches to consider.
# ${dirout} is the directory name and ${optout} is the current list of
# options.
if [ "$#" = "0" ]; then
  echo "\"${dirout} ${optout};\","
else
  first=$1
  shift
  dirout="${dirout}" optout="${optout}" ./tmpmultilib2 $@@
  l=`echo ${first} | sed -e 's/=.*$//' -e 's/?/=/g'`
  r=`echo ${first} | sed -e 's/^.*=//' -e 's/?/=/g'`
  if expr " ${optout} " : ".* ${l} .*" > /dev/null; then
    newopt=`echo " ${optout} " | sed -e "s/ ${l} / ${r} /" -e 's/^ //' -e 's/ $//'`
    dirout="${dirout}" optout="${newopt}" ./tmpmultilib2 $@@
  fi
fi
EOF
chmod +x tmpmultilib2

# Start with the current directory, which includes only negations.
optout=
for set in ${options}; do
  for opt in `echo ${set} | sed -e 's|/| |'g`; do
    optout="${optout} !${opt}"
  done
done
optout=`echo ${optout} | sed -e 's/^ //'`
echo "\". ${optout};\","

# Work over the list of combinations.  We have to translate each one
# to use the directory names rather than the option names, we have to
# include the information in matches, and we have to generate the
# correct list of options and negations.
for combo in ${combinations}; do
  # Use the directory names rather than the option names.
  if [ -n "${todirnames}" ]; then
    dirout=`echo ${combo} | sed ${todirnames}`
  else
    dirout=${combo}
  fi
  # Remove the leading and trailing slashes.
  dirout=`echo ${dirout} | sed -e 's|^/||' -e 's|/$||g'`

  # Look through the options.  We must output each option that is
  # present, and negate each option that is not present.
  optout=
  for set in ${options}; do
    setopts=`echo ${set} | sed -e 's|/| |g'`
    for opt in ${setopts}; do
      if expr "${combo} " : ".*/${opt}/.*" > /dev/null; then
	optout="${optout} ${opt}"
      else
	optout="${optout} !${opt}"
      fi
    done
  done
  optout=`echo ${optout} | sed -e 's/^ //'`

  # Output the line with all appropriate matches.
  dirout="${dirout}" optout="${optout}" ./tmpmultilib2
done

# Terminate the list of string.
echo "NULL"
echo "};"

# Output all of the matches now as option and that is the same as that, with
# a semicolon trailer.  Include all of the normal options as well.
# Note, the format of the matches is reversed compared
# to what we want, so switch them around.
echo ""
echo "static char *multilib_matches_raw[] = {"
for match in ${matches}; do
  l=`echo ${match} | sed -e 's/=.*$//' -e 's/?/=/g'`
  r=`echo ${match} | sed -e 's/^.*=//' -e 's/?/=/g'`
  echo "\"${r} ${l};\","
done
for set in ${options}; do
  for opt in `echo ${set} | sed -e 's|/| |'g`; do
    echo "\"${opt} ${opt};\","
  done
done
echo "NULL"
echo "};"

# Output the default options now
echo ""
echo "static char *multilib_extra = \"${extra}\";"
rm -f tmpmultilib2

exit 0
@


1.8
log
@Speed up genmultilib; Add MULTIB_EXTRA_OPTS
@
text
@d3 1
a3 1
#   Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
d246 1
a246 1
# a semicolan trailer.  Include all of the normal options as well.
@


1.7
log
@Change output to be a sequence of short strings
separated by commas rather than a single long macro definition.
@
text
@d3 1
a3 1
#   Copyright (C) 1994, 1995 Free Software Foundation, Inc.
d48 3
d87 3
a166 10
# Construct a sed pattern which will add negations based on the
# matches.  The semicolons are easier than getting the shell to accept
# quoted spaces when expanding a variable.
matchnegations=
for i in ${matches}; do
  l=`echo $i | sed -e 's/=.*$//' -e 's/?/=/g'`
  r=`echo $i | sed -e 's/^.*=//' -e 's/?/=/g'`
  matchnegations="${matchnegations} -e s/;!${l};/;!${l};!${r};/"
done

a205 3
if [ -n "${matchnegations}" ]; then
  optout=`echo ";${optout};" | sed -e 's/ /;/g' ${matchnegations} -e 's/^;//' -e 's/;$//' -e 's/;/ /g'`
fi
a236 5
  # Add any negations of matches.
  if [ -n "${matchnegations}" ]; then
    optout=`echo ";${optout};" | sed -e 's/ /;/g' ${matchnegations} -e 's/^;//' -e 's/;$//' -e 's/;/ /g'`
  fi

d238 1
a238 1
  dirout="${dirout}" optout="${optout}" ./tmpmultilib2 ${matches}
d243 20
d264 3
@


1.6
log
@Add MULTILIB_EXCEPTiONS
@
text
@d65 9
a73 10
#   #define MULTILIB_SELECT "\
#   . !m68000 !mc68000 !m68020 !msoft-float;\
#   m68000 m68000 !m68020 !msoft-float;\
#   m68000 mc60000 !m68020 !msoft-float;\
#   m68020 !m68000 !mc68000 m68020 !msoft-float;\
#   msoft-float !m68000 !mc68000 !m68020 msoft-float;\
#   m68000/msoft-float m68000 !m68020 msoft-float;\
#   m68000/msoft-float mc68000 !m68020 msoft-float;\
#   m68020/msoft-float !m68000 !mc68000 m68020 msoft-float;\
#   "
d187 1
a187 1
  echo "${dirout} ${optout};\\"
a201 3
# We are ready to start output.
echo '#define MULTILIB_SELECT "\'

d213 1
a213 1
echo ". ${optout};\\"
d253 3
a256 3

# That's it.
echo '"'
@


1.5
log
@Output negations of unused alternatives, even if one of the
alternatives is selected.
@
text
@d45 3
d84 1
d118 27
@


1.4
log
@Work around hpux8 /bin/sh case bug.
@
text
@d62 5
a66 4
#   #define MULTILIB_MATCHES "\
#   m68000/msoft-float m68000 msoft-float;\
#   m68000/msoft-float mc68000 msoft-float;\
#   m68020/msoft-float m68020 msoft-float;\
d68 3
a70 4
#   m68000 m68000 !msoft-float;\
#   m68000 mc60000 !msoft-float;\
#   m68020 m68020 !msoft-float;\
#   . !m68000 !mc68000 !m68020 !msoft-float;\
d203 1
a203 3
  # present, and negate each option that is not present.  If an
  # element of a set is present, we need not negate the other elements
  # of the set.
a206 1
    found=
d210 2
a211 1
	found=yes
a213 5
    if [ "${found}" = "" ]; then
      for opt in ${setopts}; do
	optout="${optout} !${opt}"
      done
    fi
@


1.3
log
@Change FSF address.
@
text
@d3 1
a3 1
#   Copyright (C) 1994 Free Software Foundation, Inc.
d164 1
a164 2
  case " ${optout} " in
  *" ${l} "*)
d167 1
a167 2
    ;;
  esac
d211 1
a211 2
      case "${combo}" in
      *"/${opt}/"*)
d214 1
a214 2
	;;
      esac
@


1.2
log
@Add little endian PowerPC support.
@
text
@d19 2
a20 1
#the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@


1.1
log
@Initial revision
@
text
@d42 1
a42 1
# it.
d135 2
a136 2
  l=`echo $i | sed -e 's/=.*$//'`
  r=`echo $i | sed -e 's/^.*=//'`
d161 2
a162 2
  l=`echo ${first} | sed -e 's/=.*$//'`
  r=`echo ${first} | sed -e 's/^.*=//'`
@
