head	1.1;
branch	1.1.1;
access;
symbols
	RELENG_8_4:1.1.1.7.0.30
	RELENG_9_1_0_RELEASE:1.1.1.7
	RELENG_9_1:1.1.1.7.0.28
	RELENG_9_1_BP:1.1.1.7
	RELENG_8_3_0_RELEASE:1.1.1.7
	RELENG_8_3:1.1.1.7.0.26
	RELENG_8_3_BP:1.1.1.7
	RELENG_9_0_0_RELEASE:1.1.1.7
	RELENG_9_0:1.1.1.7.0.24
	RELENG_9_0_BP:1.1.1.7
	RELENG_9:1.1.1.7.0.22
	RELENG_9_BP:1.1.1.7
	RELENG_7_4_0_RELEASE:1.1.1.7
	RELENG_8_2_0_RELEASE:1.1.1.7
	RELENG_7_4:1.1.1.7.0.20
	RELENG_7_4_BP:1.1.1.7
	RELENG_8_2:1.1.1.7.0.18
	RELENG_8_2_BP:1.1.1.7
	RELENG_8_1_0_RELEASE:1.1.1.7
	RELENG_8_1:1.1.1.7.0.16
	RELENG_8_1_BP:1.1.1.7
	RELENG_7_3_0_RELEASE:1.1.1.7
	RELENG_7_3:1.1.1.7.0.14
	RELENG_7_3_BP:1.1.1.7
	RELENG_8_0_0_RELEASE:1.1.1.7
	RELENG_8_0:1.1.1.7.0.12
	RELENG_8_0_BP:1.1.1.7
	RELENG_8:1.1.1.7.0.10
	RELENG_8_BP:1.1.1.7
	RELENG_7_2_0_RELEASE:1.1.1.7
	RELENG_7_2:1.1.1.7.0.8
	RELENG_7_2_BP:1.1.1.7
	RELENG_7_1_0_RELEASE:1.1.1.7
	RELENG_6_4_0_RELEASE:1.1.1.6
	RELENG_7_1:1.1.1.7.0.6
	RELENG_7_1_BP:1.1.1.7
	RELENG_6_4:1.1.1.6.0.20
	RELENG_6_4_BP:1.1.1.6
	RELENG_7_0_0_RELEASE:1.1.1.7
	RELENG_6_3_0_RELEASE:1.1.1.6
	RELENG_7_0:1.1.1.7.0.4
	RELENG_7_0_BP:1.1.1.7
	RELENG_6_3:1.1.1.6.0.18
	RELENG_6_3_BP:1.1.1.6
	RELENG_7:1.1.1.7.0.2
	RELENG_7_BP:1.1.1.7
	gcc_4_2_1_20070718_SVN126787:1.1.1.7
	gcc_4_2_0_20070514_SVN124707:1.1.1.7
	RELENG_6_2_0_RELEASE:1.1.1.6
	RELENG_6_2:1.1.1.6.0.16
	RELENG_6_2_BP:1.1.1.6
	gcc_3_4_6_20060825_SVN116475:1.1.1.6
	RELENG_5_5_0_RELEASE:1.1.1.6
	RELENG_5_5:1.1.1.6.0.14
	RELENG_5_5_BP:1.1.1.6
	RELENG_6_1_0_RELEASE:1.1.1.6
	RELENG_6_1:1.1.1.6.0.12
	RELENG_6_1_BP:1.1.1.6
	RELENG_6_0_0_RELEASE:1.1.1.6
	RELENG_6_0:1.1.1.6.0.10
	RELENG_6_0_BP:1.1.1.6
	RELENG_6:1.1.1.6.0.8
	RELENG_6_BP:1.1.1.6
	gcc_3_4_4_20050518:1.1.1.6
	RELENG_5_4_0_RELEASE:1.1.1.6
	RELENG_5_4:1.1.1.6.0.6
	RELENG_5_4_BP:1.1.1.6
	RELENG_4_11_0_RELEASE:1.1.1.2
	RELENG_4_11:1.1.1.2.0.22
	RELENG_4_11_BP:1.1.1.2
	RELENG_5_3_0_RELEASE:1.1.1.6
	RELENG_5_3:1.1.1.6.0.4
	RELENG_5_3_BP:1.1.1.6
	RELENG_5:1.1.1.6.0.2
	RELENG_5_BP:1.1.1.6
	gcc_3_4_2_20040728:1.1.1.6
	RELENG_4_10_0_RELEASE:1.1.1.2
	RELENG_4_10:1.1.1.2.0.20
	RELENG_4_10_BP:1.1.1.2
	RELENG_5_2_1_RELEASE:1.1.1.5
	RELENG_5_2_0_RELEASE:1.1.1.5
	RELENG_5_2:1.1.1.5.0.6
	RELENG_5_2_BP:1.1.1.5
	gcc_3_3_3_20031106:1.1.1.5
	RELENG_4_9_0_RELEASE:1.1.1.2
	RELENG_4_9:1.1.1.2.0.18
	RELENG_4_9_BP:1.1.1.2
	gcc_3_3_1:1.1.1.5
	gcc_3_3_1_20030711:1.1.1.5
	RELENG_5_1_0_RELEASE:1.1.1.5
	RELENG_5_1:1.1.1.5.0.4
	RELENG_5_1_BP:1.1.1.5
	RELENG_4_8_0_RELEASE:1.1.1.2
	RELENG_4_8:1.1.1.2.0.16
	RELENG_4_8_BP:1.1.1.2
	gcc_3_2_2_20030205:1.1.1.5
	RELENG_5_0_0_RELEASE:1.1.1.5
	RELENG_5_0:1.1.1.5.0.2
	RELENG_5_0_BP:1.1.1.5
	gcc_3_2_1:1.1.1.5
	BEFORE_GCC_3_2_1:1.1.1.5
	gcc_3_2_anoncvs_20021009:1.1.1.5
	RELENG_4_7_0_RELEASE:1.1.1.2
	RELENG_4_7:1.1.1.2.0.14
	RELENG_4_7_BP:1.1.1.2
	gcc_3_2_anoncvs_20020916:1.1.1.4
	gcc_3_2_anoncvs_20020901:1.1.1.4
	RELENG_4_6_2_RELEASE:1.1.1.2
	RELENG_4_6_1_RELEASE:1.1.1.2
	RELENG_4_6_0_RELEASE:1.1.1.2
	RELENG_4_6:1.1.1.2.0.12
	RELENG_4_6_BP:1.1.1.2
	gcc_3_1_anoncvs_20020509:1.1.1.3
	gcc_cvs_20020201_0820:1.1.1.3
	BEFORE_3_1_0_snap:1.1.1.2
	RELENG_4_5_0_RELEASE:1.1.1.2
	RELENG_4_5:1.1.1.2.0.10
	RELENG_4_5_BP:1.1.1.2
	GCC_2_95_3_WITH_FBSD_MODS:1.1.1.2
	REPOCOPY:1.1.1.2
	RELENG_4_4_0_RELEASE:1.1.1.2
	RELENG_4_4:1.1.1.2.0.8
	RELENG_4_4_BP:1.1.1.2
	RELENG_4_3_0_RELEASE:1.1.1.2
	RELENG_4_3:1.1.1.2.0.6
	RELENG_4_3_BP:1.1.1.2
	BEFORE_GCC_2_95_3:1.1.1.2
	RELENG_4_2_0_RELEASE:1.1.1.2
	RELENG_4_1_1_RELEASE:1.1.1.2
	RELENG_4_1_0_RELEASE:1.1.1.2
	RELENG_3_5_0_RELEASE:1.1.1.1
	RELENG_4_0_0_RELEASE:1.1.1.2
	RELENG_4:1.1.1.2.0.4
	RELENG_4_BP:1.1.1.2
	EGCS_11x:1.1.1.2.0.2
	RELENG_3_4_0_RELEASE:1.1.1.1
	BEFORE_GCC_2_95_1:1.1.1.2
	egcs_1_1_2:1.1.1.2
	RELENG_3_3_0_RELEASE:1.1.1.1
	BEFORE_EGCS_IMPORT:1.1.1.1
	gcc_2_7_2_3:1.1.1.1
	RELENG_3_2_PAO:1.1.1.1.0.6
	RELENG_3_2_PAO_BP:1.1.1.1
	RELENG_3_2_0_RELEASE:1.1.1.1
	RELENG_3_1_0_RELEASE:1.1.1.1
	RELENG_3:1.1.1.1.0.4
	RELENG_3_BP:1.1.1.1
	RELENG_2_2_8_RELEASE:1.1.1.1
	RELENG_3_0_0_RELEASE:1.1.1.1
	RELENG_2_2_7_RELEASE:1.1.1.1
	RELENG_2_2_6_RELEASE:1.1.1.1
	RELENG_2_2_5_RELEASE:1.1.1.1
	RELENG_2_2_2_RELEASE:1.1.1.1
	RELENG_2_2_1_RELEASE:1.1.1.1
	RELENG_2_2_0_RELEASE:1.1.1.1
	RELENG_2_2:1.1.1.1.0.2
	RELENG_2_2_BP:1.1.1.1
	v2_7_2_1:1.1.1.1
	v2_7_2:1.1.1.1
	FSF:1.1.1;
locks; strict;
comment	@# @;


1.1
date	96.09.18.05.35.18;	author peter;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	96.09.18.05.35.18;	author peter;	state Exp;
branches;
next	1.1.1.2;

1.1.1.2
date	99.10.03.09.16.24;	author obrien;	state Exp;
branches;
next	1.1.1.3;

1.1.1.3
date	2002.02.01.18.13.17;	author obrien;	state Exp;
branches;
next	1.1.1.4;

1.1.1.4
date	2002.05.13.03.36.06;	author obrien;	state Exp;
branches;
next	1.1.1.5;

1.1.1.5
date	2002.10.10.04.38.52;	author kan;	state Exp;
branches;
next	1.1.1.6;

1.1.1.6
date	2004.07.28.03.11.33;	author kan;	state Exp;
branches;
next	1.1.1.7;

1.1.1.7
date	2007.05.19.01.03.39;	author kan;	state Exp;
branches
	1.1.1.7.30.1;
next	;

1.1.1.7.30.1
date	2007.05.19.01.03.39;	author svnexp;	state dead;
branches;
next	1.1.1.7.30.2;

1.1.1.7.30.2
date	2013.03.28.13.00.50;	author svnexp;	state Exp;
branches;
next	;


desc
@@


1.1
log
@Initial revision
@
text
@#!/bin/sh 
# Generates multilib.h.
#   Copyright (C) 1994, 1995 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 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:
#   #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;\
#   "
# 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

# 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

# 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

# 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

# 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

# We are ready to start output.
echo '#define MULTILIB_SELECT "\'

# 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/^ //'`
if [ -n "${matchnegations}" ]; then
  optout=`echo ";${optout};" | sed -e 's/ /;/g' ${matchnegations} -e 's/^;//' -e 's/;$//' -e 's/;/ /g'`
fi
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/^ //'`

  # 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

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

rm -f tmpmultilib2

# That's it.
echo '"'

exit 0
@


1.1.1.1
log
@Import of unmodified (but trimmed) gcc-2.7.2.  The bigger parts of the
non-i386, non-unix, and generatable files have been trimmed, but can easily
be added in later if needed.

gcc-2.7.2.1 will follow shortly, it's a very small delta to this and it's
handy to have both available for reference for such little cost.

The freebsd-specific changes will then be committed, and once the dust has
settled, the bmakefiles will be committed to use this code.
@
text
@@


1.1.1.2
log
@Virgin import of EGCS 1.1.2
@
text
@d3 1
a3 1
#   Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
a44 6
# 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.

d62 10
a71 9
#   ". !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;",
#
a80 4
exceptions=$4
extra=$5

echo "static char *multilib_raw[] = {"
a114 27
# 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

d131 10
d157 1
a157 1
  echo "\"${dirout} ${optout};\","
d172 3
d183 4
a186 1
echo "\". ${optout};\","
d217 5
d223 1
a223 1
  dirout="${dirout}" optout="${optout}" ./tmpmultilib2
d226 1
a226 22
# 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 "};"
d228 2
a229 4
# Output the default options now
echo ""
echo "static char *multilib_extra = \"${extra}\";"
rm -f tmpmultilib2
@


1.1.1.3
log
@Enlist the FreeBSD-CURRENT users as testers of what is to become Gcc 3.1.0.
These bits are taken from the FSF anoncvs repo on 1-Feb-2002 08:20 PST.
@
text
@d3 1
a3 1
#   Copyright (C) 1994, 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
d5 1
a5 1
#This file is part of GCC.
d7 9
a15 9
#GCC 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.

#GCC 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.
d18 3
a20 3
#along with GCC; see the file COPYING.  If not, write to the Free
#Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#02111-1307, USA.
d28 2
a29 4
# are separated by slashes or pipes.  No leading dash is used on the
# options.
# Each option in a set separated by slashes is mutually incompatible
# with all other options
a30 3
# Each option in a set separated by pipes will be used for the library
# compilation and any of the options in the set will be sufficient
# for it to be triggered.
a50 10
# The optional sixth argument is a list of exclusions used internally by
# the compiler similar to exceptions. The difference being that exclusions
# allow matching default options that genmultilib does not know about and
# is done at runtime as opposed to being sorted out at compile time.
# Each element in the list is a separate exclusion rule. Each rule is
# a list of options (sans preceding '-') separated by a '/'. The options
# on the rule are grouped as an AND operation, and all options much match
# for the rule to exclude a set. Options can be preceded with a '!' to
# match a logical NOT.

d64 3
a66 4
# Here is an example (this is from the actual sparc64 case):
#   genmultilib 'm64/m32 mno-app-regs|mcmodel=medany' '64 32 alt'
#		'mcmodel?medany=mcmodel?medmid' 'm32/mno-app-regs* m32/mcmodel=*'
#		'm32/!m64/mno-app-regs m32/!m64/mcmodel=medany'
d68 8
a75 9
#   ". !m64 !m32 !mno-app-regs !mcmodel=medany;",
#   "64 m64 !m32 !mno-app-regs !mcmodel=medany;",
#   "32 !m64 m32 !mno-app-regs !mcmodel=medany;",
#   "alt !m64 !m32 mno-app-regs mcmodel=medany;",
#   "alt !m64 !m32 mno-app-regs !mcmodel=medany;",
#   "alt !m64 !m32 !mno-app-regs mcmodel=medany;",
#   "64/alt m64 !m32 mno-app-regs mcmodel=medany;",
#   "64/alt m64 !m32 mno-app-regs !mcmodel=medany;",
#   "64/alt m64 !m32 !mno-app-regs mcmodel=medany;",
d77 4
a80 7
# The effect is that `gcc -mno-app-regs' (for example) will append "alt"
# to the directory name when searching for libraries or startup files and
# `gcc -m32 -mcmodel=medany' (for example) will append "32/alt". Also note
# that exclusion above is moot, unless the compiler had a default of -m32,
# which would mean that all of the "alt" directories (not the 64/alt ones)
# would be ignored (not generated, nor used) since the exclusion also
# matches the multilib_default args.
a87 1
exclusions=$6
d89 1
a89 1
echo "static const char *const multilib_raw[] = {"
d109 7
a115 17
  case "$first" in
  *\|*)
    all=${initial}`echo $first | sed -e 's_|_/_'g`
    first=`echo $first | sed -e 's_|_ _'g`
    echo ${all}/
    initial="${initial}${all}/" ./tmpmultilib $@@
    ./tmpmultilib $first $@@ | grep -v "^${all}"
    ;;
  *)
    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
  esac
d158 4
a161 11
    for opts in `echo ${set} | sed -e 's|/| |'g`; do
      patt="/"
      for opt in `echo ${opts} | sed -e 's_|_ _'g`; do
        if [ "$1" != "${opt}" ]; then
          todirnames="${todirnames} -e s|/${opt}/|/${1}/|g"
	  patt="${patt}${1}/"
	  if [ "${patt}" != "/${1}/" ]; then
	    todirnames="${todirnames} -e s|${patt}|/${1}/|g"
          fi
        fi
      done
d201 1
a201 1
  for opt in `echo ${set} | sed -e 's_[/|]_ _g'`; do
d226 1
a226 1
    setopts=`echo ${set} | sed -e 's_[/|]_ _g'`
d250 1
a250 1
echo "static const char *const multilib_matches_raw[] = {"
d257 1
a257 1
  for opt in `echo ${set} | sed -e 's_[/|]_ _'g`; do
d266 1
a266 12
echo "static const char *multilib_extra = \"${extra}\";"

# Output the exclusion rules now
echo ""
echo "static const char *const multilib_exclusions_raw[] = {"
for rule in ${exclusions}; do
  s=`echo ${rule} | sed -e 's,/, ,g'`
  echo "\"${s};\","
done
echo "NULL"
echo "};"

@


1.1.1.4
log
@Cause CVS to sync up checked out source bases with Gcc 3.1 bits after
the repo surgery to cut out the abortive Gcc 2.9[67] imports.
@
text
@@


1.1.1.5
log
@Gcc 3.2.1-prerelease from the FSF anoncvs repo gcc-3_2-branch on October 9th 2002 20:15 EST.
@
text
@a65 8
# The optional sevenths argument is a list of OS subdirectory names.
# The format is the same as of the second argument.
# The difference is that second argument describes multilib directories
# in GCC conventions, while this one the OS multilib convention.

# The last option should be "yes" if multilibs are enabled.  If it is not
# "yes", all GCC multilib dir names will be ".".

d82 1
a82 2
#		'' 'm32/!m64/mno-app-regs m32/!m64/mcmodel=medany'
#		'../lib64 ../lib32 alt' yes
d85 2
a86 2
#   "64:../lib64 m64 !m32 !mno-app-regs !mcmodel=medany;",
#   "32:../lib32 !m64 m32 !mno-app-regs !mcmodel=medany;",
d90 3
a92 3
#   "64/alt:../lib64/alt m64 !m32 mno-app-regs mcmodel=medany;",
#   "64/alt:../lib64/alt m64 !m32 mno-app-regs !mcmodel=medany;",
#   "64/alt:../lib64/alt m64 !m32 !mno-app-regs mcmodel=medany;",
a108 2
osdirnames=$7
enable_multilib=$8
a204 23
# Construct a sed pattern which will convert option names to OS directory
# names.
toosdirnames=
if [ -n "${osdirnames}" ]; then
  set x ${osdirnames}
  shift
  for set in ${options}; do
    for opts in `echo ${set} | sed -e 's|/| |'g`; do
      patt="/"
      for opt in `echo ${opts} | sed -e 's_|_ _'g`; do
        if [ "$1" != "${opt}" ]; then
          toosdirnames="${toosdirnames} -e s|/${opt}/|/${1}/|g"
	  patt="${patt}${1}/"
	  if [ "${patt}" != "/${1}/" ]; then
	    toosdirnames="${toosdirnames} -e s|${patt}|/${1}/|g"
          fi
        fi
      done
      shift
    done
  done
fi

a259 19
  # Use the OS directory names rather than the option names.
  if [ -n "${toosdirnames}" ]; then
    osdirout=`echo ${combo} | sed ${toosdirnames}`
    # Remove the leading and trailing slashes.
    osdirout=`echo ${osdirout} | sed -e 's|^/||' -e 's|/$||g'`
    if [ "x${enable_multilib}" != xyes ]; then
      dirout=".:${osdirout}"
    else
      dirout="${dirout}:${osdirout}"
    fi
  else
    if [ "x${enable_multilib}" != xyes ]; then
      # genmultilib with --disable-multilib should be
      # called with '' '' '' '' '' '' '' no
      # if MULTILIB_OSDIRNAMES is empty.
      exit 1
    fi
  fi

a314 5

# Output the options now
moptions=`echo ${options} | sed -e 's,[ 	][ 	]*, ,g'`
echo ""
echo "static const char *multilib_options = \"${moptions}\";"
@


1.1.1.6
log
@Gcc 3.4.2 20040728.
@
text
@d3 1
a3 1
#   Copyright (C) 1994, 1995, 1996, 1997, 1999, 2002 Free Software Foundation, Inc.
d66 4
a69 9
# The optional seventh argument is a list of OS subdirectory names.
# The format is either the same as of the second argument, or a set of
# mappings. When it is the same as the second argument, it describes
# the multilib directories using OS conventions, rather than GCC
# conventions.  When it is a set of mappings of the form gccdir=osdir,
# the left side gives the GCC convention and the right gives the
# equivalent OS defined location.  If the osdir part begins with a !,
# the os directory names are used exclusively.  Use the mapping when
# there is no one-to-one equivalence between GCC levels and the OS.
a122 4
mkdir tmpmultilib.$$ || exit 1
# Use cd ./foo to avoid CDPATH output.
cd ./tmpmultilib.$$ || exit 1

d164 2
d168 1
d190 1
a218 1
defaultosdirname=
d222 9
a230 28
  while [ $# != 0 ] ; do
    case "$1" in
      .=*)
        defaultosdirname=`echo $1 | sed 's|^.=|:|'`
	shift
	;;
      *=*)
	patt=`echo $1 | sed -e 's|=|/$=/|'`
        toosdirnames="${toosdirnames} -e s=^/${patt}/="
	shift
        ;;
      *)
        break
	;;
    esac
  done
  
  if [ $# != 0 ]; then
    for set in ${options}; do
      for opts in `echo ${set} | sed -e 's|/| |'g`; do
        patt="/"
        for opt in `echo ${opts} | sed -e 's_|_ _'g`; do
          if [ "$1" != "${opt}" ]; then
            toosdirnames="${toosdirnames} -e s|/${opt}/|/${1}/|g"
	    patt="${patt}${1}/"
	    if [ "${patt}" != "/${1}/" ]; then
	      toosdirnames="${toosdirnames} -e s|${patt}|/${1}/|g"
            fi
d232 1
a232 2
        done
        shift
d234 1
d236 1
a236 1
  fi
d278 1
a278 1
echo "\".${defaultosdirname} ${optout};\","
a300 1
      disable_multilib=yes
d302 1
a302 8
      case "${osdirout}" in
        !*)
	  dirout=`echo ${osdirout} | sed 's/^!//'`
	  ;;
	*)
	  dirout="${dirout}:${osdirout}"
	  ;;
      esac
d374 1
a374 8
# Finally output the disable flag if specified
if [ "x${disable_multilib}" = xyes ]; then
  echo ""
  echo "#define DISABLE_MULTILIB  1"
fi

cd ..
rm -r tmpmultilib.$$
@


1.1.1.7
log
@GCC 4.2.0 release.
@
text
@d19 2
a20 2
#Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
#02110-1301, USA.
d314 1
a314 1
    dirout=`echo ${combo} | sed -e 's/=/-/g'`
@


1.1.1.7.30.1
log
@file genmultilib was added on branch RELENG_8_4 on 2013-03-28 13:00:50 +0000
@
text
@d1 416
@


1.1.1.7.30.2
log
@## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/248810
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
@
text
@a0 416
#!/bin/sh 
# Generates multilib.h.
#   Copyright (C) 1994, 1995, 1996, 1997, 1999, 2002 Free Software Foundation, Inc.

#This file is part of GCC.

#GCC 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.

#GCC 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 GCC; see the file COPYING.  If not, write to the Free
#Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
#02110-1301, 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 or pipes.  No leading dash is used on the
# options.
# Each option in a set separated by slashes is mutually incompatible
# with all other options
# in the set.
# Each option in a set separated by pipes will be used for the library
# compilation and any of the options in the set will be sufficient
# for it to be triggered.

# 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 optional sixth argument is a list of exclusions used internally by
# the compiler similar to exceptions. The difference being that exclusions
# allow matching default options that genmultilib does not know about and
# is done at runtime as opposed to being sorted out at compile time.
# Each element in the list is a separate exclusion rule. Each rule is
# a list of options (sans preceding '-') separated by a '/'. The options
# on the rule are grouped as an AND operation, and all options much match
# for the rule to exclude a set. Options can be preceded with a '!' to
# match a logical NOT.

# The optional seventh argument is a list of OS subdirectory names.
# The format is either the same as of the second argument, or a set of
# mappings. When it is the same as the second argument, it describes
# the multilib directories using OS conventions, rather than GCC
# conventions.  When it is a set of mappings of the form gccdir=osdir,
# the left side gives the GCC convention and the right gives the
# equivalent OS defined location.  If the osdir part begins with a !,
# the os directory names are used exclusively.  Use the mapping when
# there is no one-to-one equivalence between GCC levels and the OS.

# The last option should be "yes" if multilibs are enabled.  If it is not
# "yes", all GCC multilib dir names will be ".".

# 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 an example (this is from the actual sparc64 case):
#   genmultilib 'm64/m32 mno-app-regs|mcmodel=medany' '64 32 alt'
#		'mcmodel?medany=mcmodel?medmid' 'm32/mno-app-regs* m32/mcmodel=*'
#		'' 'm32/!m64/mno-app-regs m32/!m64/mcmodel=medany'
#		'../lib64 ../lib32 alt' yes
# This produces:
#   ". !m64 !m32 !mno-app-regs !mcmodel=medany;",
#   "64:../lib64 m64 !m32 !mno-app-regs !mcmodel=medany;",
#   "32:../lib32 !m64 m32 !mno-app-regs !mcmodel=medany;",
#   "alt !m64 !m32 mno-app-regs mcmodel=medany;",
#   "alt !m64 !m32 mno-app-regs !mcmodel=medany;",
#   "alt !m64 !m32 !mno-app-regs mcmodel=medany;",
#   "64/alt:../lib64/alt m64 !m32 mno-app-regs mcmodel=medany;",
#   "64/alt:../lib64/alt m64 !m32 mno-app-regs !mcmodel=medany;",
#   "64/alt:../lib64/alt m64 !m32 !mno-app-regs mcmodel=medany;",
#
# The effect is that `gcc -mno-app-regs' (for example) will append "alt"
# to the directory name when searching for libraries or startup files and
# `gcc -m32 -mcmodel=medany' (for example) will append "32/alt". Also note
# that exclusion above is moot, unless the compiler had a default of -m32,
# which would mean that all of the "alt" directories (not the 64/alt ones)
# would be ignored (not generated, nor used) since the exclusion also
# matches the multilib_default args.

# Copy the positional parameters into variables.
options=$1
dirnames=$2
matches=$3
exceptions=$4
extra=$5
exclusions=$6
osdirnames=$7
enable_multilib=$8

echo "static const char *const multilib_raw[] = {"

mkdir tmpmultilib.$$ || exit 1
# Use cd ./foo to avoid CDPATH output.
cd ./tmpmultilib.$$ || exit 1

# 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
  case "$first" in
  *\|*)
    all=${initial}`echo $first | sed -e 's_|_/_'g`
    first=`echo $first | sed -e 's_|_ _'g`
    echo ${all}/
    initial="${initial}${all}/" ./tmpmultilib $@@
    ./tmpmultilib $first $@@ | grep -v "^${all}"
    ;;
  *)
    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
  esac
fi
EOF
chmod +x tmpmultilib

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

# If there exceptions, weed them out now
if [ -n "${exceptions}" ]; then
  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}`
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 opts in `echo ${set} | sed -e 's|/| |'g`; do
      patt="/"
      for opt in `echo ${opts} | sed -e 's_|_ _'g`; do
        if [ "$1" != "${opt}" ]; then
          todirnames="${todirnames} -e s|/${opt}/|/${1}/|g"
	  patt="${patt}${1}/"
	  if [ "${patt}" != "/${1}/" ]; then
	    todirnames="${todirnames} -e s|${patt}|/${1}/|g"
          fi
        fi
      done
      shift
    done
  done
fi

# Construct a sed pattern which will convert option names to OS directory
# names.
toosdirnames=
defaultosdirname=
if [ -n "${osdirnames}" ]; then
  set x ${osdirnames}
  shift
  while [ $# != 0 ] ; do
    case "$1" in
      .=*)
        defaultosdirname=`echo $1 | sed 's|^.=|:|'`
	shift
	;;
      *=*)
	patt=`echo $1 | sed -e 's|=|/$=/|'`
        toosdirnames="${toosdirnames} -e s=^/${patt}/="
	shift
        ;;
      *)
        break
	;;
    esac
  done
  
  if [ $# != 0 ]; then
    for set in ${options}; do
      for opts in `echo ${set} | sed -e 's|/| |'g`; do
        patt="/"
        for opt in `echo ${opts} | sed -e 's_|_ _'g`; do
          if [ "$1" != "${opt}" ]; then
            toosdirnames="${toosdirnames} -e s|/${opt}/|/${1}/|g"
	    patt="${patt}${1}/"
	    if [ "${patt}" != "/${1}/" ]; then
	      toosdirnames="${toosdirnames} -e s|${patt}|/${1}/|g"
            fi
          fi
        done
        shift
      done
    done
  fi
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 "\".${defaultosdirname} ${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=`echo ${combo} | sed -e 's/=/-/g'`
  fi
  # Remove the leading and trailing slashes.
  dirout=`echo ${dirout} | sed -e 's|^/||' -e 's|/$||g'`

  # Use the OS directory names rather than the option names.
  if [ -n "${toosdirnames}" ]; then
    osdirout=`echo ${combo} | sed ${toosdirnames}`
    # Remove the leading and trailing slashes.
    osdirout=`echo ${osdirout} | sed -e 's|^/||' -e 's|/$||g'`
    if [ "x${enable_multilib}" != xyes ]; then
      dirout=".:${osdirout}"
      disable_multilib=yes
    else
      case "${osdirout}" in
        !*)
	  dirout=`echo ${osdirout} | sed 's/^!//'`
	  ;;
	*)
	  dirout="${dirout}:${osdirout}"
	  ;;
      esac
    fi
  else
    if [ "x${enable_multilib}" != xyes ]; then
      # genmultilib with --disable-multilib should be
      # called with '' '' '' '' '' '' '' no
      # if MULTILIB_OSDIRNAMES is empty.
      exit 1
    fi
  fi

  # 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 const char *const 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 const char *multilib_extra = \"${extra}\";"

# Output the exclusion rules now
echo ""
echo "static const char *const multilib_exclusions_raw[] = {"
for rule in ${exclusions}; do
  s=`echo ${rule} | sed -e 's,/, ,g'`
  echo "\"${s};\","
done
echo "NULL"
echo "};"

# Output the options now
moptions=`echo ${options} | sed -e 's,[ 	][ 	]*, ,g'`
echo ""
echo "static const char *multilib_options = \"${moptions}\";"

# Finally output the disable flag if specified
if [ "x${disable_multilib}" = xyes ]; then
  echo ""
  echo "#define DISABLE_MULTILIB  1"
fi

cd ..
rm -r tmpmultilib.$$

exit 0
@


