#!/bin/sh
# Generates multilib.h.
-# Copyright (C) 1994 Free Software Foundation, Inc.
+# Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
#This file is part of GNU CC.
#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, 675 Mass Ave, Cambridge, MA 02139, USA.
+#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
# 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;\
# genmultilib "m68000/m68020 msoft-float" "m68000 m68020 msoft-float"
# "m68000=mc68000"
# This produces:
-# #define MULTILIB_MATCHES "\
-# m68000/msoft-float m68000 msoft-float;\
-# m68000/msoft-float mc68000 msoft-float;\
-# m68020/msoft-float m68020 msoft-float;\
-# msoft-float !m68000 !mc68000 !m68020 msoft-float;\
-# m68000 m68000 !msoft-float;\
-# m68000 mc60000 !msoft-float;\
-# m68020 m68020 !msoft-float;\
-# . !m68000 !mc68000 !m68020 !msoft-float;\
-# "
+# ". !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
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
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=
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"
# ${dirout} is the directory name and ${optout} is the current list of
# options.
if [ "$#" = "0" ]; then
- echo "${dirout} ${optout};\\"
+ 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'`
- case " ${optout} " in
- *" ${l} "*)
+ if expr " ${optout} " : ".* ${l} .*" > /dev/null; then
newopt=`echo " ${optout} " | sed -e "s/ ${l} / ${r} /" -e 's/^ //' -e 's/ $//'`
dirout="${dirout}" optout="${newopt}" ./tmpmultilib2 $@
- ;;
- esac
+ 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
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};\\"
+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
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. If an
- # element of a set is present, we need not negate the other elements
- # of the set.
+ # present, and negate each option that is not present.
optout=
for set in ${options}; do
setopts=`echo ${set} | sed -e 's|/| |g'`
- found=
for opt in ${setopts}; do
- case "${combo}" in
- *"/${opt}/"*)
+ if expr "${combo} " : ".*/${opt}/.*" > /dev/null; then
optout="${optout} ${opt}"
- found=yes
- ;;
- esac
- done
- if [ "${found}" = "" ]; then
- for opt in ${setopts}; do
+ else
optout="${optout} !${opt}"
- done
- fi
+ 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}
+ dirout="${dirout}" optout="${optout}" ./tmpmultilib2
done
-rm -f tmpmultilib2
+# 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 semicolan 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 "};"
-# That's it.
-echo '"'
+# Output the default options now
+echo ""
+echo "static char *multilib_extra = \"${extra}\";"
+rm -f tmpmultilib2
exit 0