X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=blobdiff_plain;f=gcc%2Fgenmultilib;h=270de2b2a2cd44897427495a535aeb303461f0cd;hp=d02bb9223b78706e8632594370f31cf9f3f12fea;hb=2b252fdbe15075984b766120464ea987c2e484c3;hpb=f12b58b3384f7b4faba39eaa3ebc67c3049f2a3c diff --git a/gcc/genmultilib b/gcc/genmultilib index d02bb9223b7..270de2b2a2c 100644 --- a/gcc/genmultilib +++ b/gcc/genmultilib @@ -1,12 +1,13 @@ #!/bin/sh # Generates multilib.h. -# Copyright (C) 1994, 1995, 1996, 1997, 1999 Free Software Foundation, Inc. +# Copyright (C) 1994, 1995, 1996, 1997, 1999, 2002, 2007 +# 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 +#Software Foundation; either version 3, or (at your option) any later #version. #GCC is distributed in the hope that it will be useful, but WITHOUT @@ -15,9 +16,8 @@ #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, 59 Temple Place - Suite 330, Boston, MA -#02111-1307, USA. +#along with GCC; see the file COPYING3. If not see +#. # This shell script produces a header file which the gcc driver # program uses to pick which library to use based on the machine @@ -57,12 +57,25 @@ # 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 seperate exclusion rule. Each rule is -# a list of options (sans preceding '-') seperated by a '/'. The options +# 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;\ @@ -79,17 +92,18 @@ # 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' +# '' 'm32/!m64/mno-app-regs m32/!m64/mcmodel=medany' +# '../lib64 ../lib32 alt' yes # This produces: # ". !m64 !m32 !mno-app-regs !mcmodel=medany;", -# "64 m64 !m32 !mno-app-regs !mcmodel=medany;", -# "32 !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 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:../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 @@ -106,9 +120,15 @@ 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 @@ -150,11 +170,8 @@ 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 @@ -176,7 +193,6 @@ cat >>tmpmultilib2 <<\EOF EOF chmod +x tmpmultilib2 combinations=`./tmpmultilib2 ${combinations}` - rm -f ./tmpmultilib2 fi # Construct a sed pattern which will convert option names to directory @@ -202,6 +218,49 @@ if [ -n "${dirnames}" ]; then 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" @@ -241,7 +300,7 @@ for set in ${options}; do done done optout=`echo ${optout} | sed -e 's/^ //'` -echo "\". ${optout};\"," +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 @@ -252,11 +311,38 @@ for combo in ${combinations}; do if [ -n "${todirnames}" ]; then dirout=`echo ${combo} | sed ${todirnames}` else - dirout=${combo} + 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= @@ -313,6 +399,18 @@ done echo "NULL" echo "};" -rm -f tmpmultilib2 +# 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