OSDN Git Service

* alias.c (reg_base_value, old_reg_base_value): Change the
[pf3gnuchains/gcc-fork.git] / gcc / mklibgcc.in
index fa6930b..8ec9e40 100644 (file)
@@ -1,6 +1,7 @@
 #!/bin/sh
 # Construct makefile for libgcc.
-#   Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
+#   Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006
+#   Free Software Foundation, Inc.
 #
 # This file is part of GCC.
 
 # FPBIT
 # FPBIT_FUNCS
 # LIB2_DIVMOD_FUNCS
+# DFP_ENABLE
+# DFP_CFLAGS
 # DPBIT
 # DPBIT_FUNCS
 # TPBIT
 # TPBIT_FUNCS
+# D32PBIT
+# D32PBIT_FUNCS
+# D64PBIT
+# D64PBIT_FUNCS
+# D128PBIT
+# D128PBIT_FUNCS
 # LIBGCC
 # MULTILIBS
 # EXTRA_MULTILIB_PARTS
 # SHLIB_EXT
 # SHLIB_LINK
-# SHLIB_MULTILIB
 # SHLIB_MKMAP
 # SHLIB_MKMAP_OPTS
 # SHLIB_MAPFILES
@@ -41,6 +49,7 @@
 # SHLIB_INSTALL
 # MULTILIB_OSDIRNAMES
 # ASM_HIDDEN_OP
+# GCC_FOR_TARGET
 
 # Make needs VPATH to be literal.
 echo 'srcdir = @srcdir@'
@@ -61,7 +70,9 @@ lib2funcs='_muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3
        _enable_execute_stack _trampoline __main _absvsi2 _absvdi2 _addvsi3
        _addvdi3 _subvsi3 _subvdi3 _mulvsi3 _mulvdi3 _negvsi2 _negvdi2 _ctors
        _ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 _ctzsi2 _ctzdi2 _popcount_tab
-       _popcountsi2 _popcountdi2 _paritysi2 _paritydi2'
+       _popcountsi2 _popcountdi2 _paritysi2 _paritydi2 _powisf2 _powidf2
+       _powixf2 _powitf2 _mulsc3 _muldc3 _mulxc3 _multc3 _divsc3 _divdc3
+       _divxc3 _divtc3 _floatundidf _floatundisf _floatundixf _floatunditf'
 
 # Disable SHLIB_LINK if shared libgcc not enabled.
 if [ "@enable_shared@" = "no" ]; then
@@ -71,6 +82,7 @@ fi
 # Build lines.
 
 gcc_compile='$(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) $(INCLUDES)'
+gcc_s_compile="$gcc_compile -DSHARED"
 make_compile='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
          AR_FOR_TARGET="$(AR_FOR_TARGET)" \
          AR_CREATE_FOR_TARGET="$(AR_CREATE_FOR_TARGET)" \
@@ -85,7 +97,7 @@ make_compile='$(MAKE) GCC_FOR_TARGET="$(GCC_FOR_TARGET)" \
 libgcc_dep='$(CONFIG_H) coretypes.h $(TM_H) $(MACHMODE_H) longlong.h config.status stmp-int-hdrs tsystem.h'
 
 # Dependencies for libgcc2.c
-libgcc2_c_dep='stmp-dirs $(srcdir)/libgcc2.c gbl-ctors.h'" $libgcc_dep"
+libgcc2_c_dep='stmp-dirs $(srcdir)/libgcc2.c $(srcdir)/libgcc2.h gbl-ctors.h'" $libgcc_dep"
 
 # Dependencies for libgcov.c
 libgcov_c_dep='stmp-dirs $(srcdir)/libgcov.c $(srcdir)/gcov-io.h $(srcdir)/gcov-io.c gcov-iov.h'" $libgcc_dep"
@@ -93,16 +105,29 @@ libgcov_c_dep='stmp-dirs $(srcdir)/libgcov.c $(srcdir)/gcov-io.h $(srcdir)/gcov-
 # Dependencies for fp-bit.c
 fpbit_c_dep='stmp-dirs config.status tsystem.h'
 
+# Dependencies for decnumber and friends.  This is an overzealous set,
+# but at least we can be sure to recompile if anything gets modified.
+decnumber_dep='stmp-dirs $(srcdir)/../libdecnumber/decContext.h $(srcdir)/../libdecnumber/decNumber.h
+       $(srcdir)/../libdecnumber/decNumberLocal.h $(srcdir)/../libdecnumber/decimal32.h $(srcdir)/../libdecnumber/decimal64.h
+       $(srcdir)/../libdecnumber/decimal128.h $(srcdir)/../libdecnumber/decDPD.h $(srcdir)/../libdecnumber/decUtility.h'
+
+# Flag whether we need eh_dummy.c
+need_eh_dummy=
+
 if [ "$SHLIB_LINK" ]; then
   # Test -fvisibility=hidden.  We need both a -fvisibility=hidden on
   # the command line, and a #define to prevent libgcc2.h etc from
   # overriding that with #pragmas.  The dance with @ is to prevent
   # echo from seeing anything it might take for an option.
+  # echo turns the \$\$\$\$ into $$$$ and when make sees it it
+  # becomes $$ and the shell substitutes the pid. Makes for a
+  # slightly safer temp file.
   echo "vis_hide := \$(strip \$(subst @,-,\\"
-  echo "    \$(shell if echo 'void foo(void);' | \\"
+  echo "    \$(shell if echo 'void foo(void); void foo(void) {}' | \\"
   echo "          $gcc_compile -fvisibility=hidden -Werror \\"
-  echo "          -c -xc - -o /dev/null 2> /dev/null; \\"
+  echo "          -c -xc - -o vis_temp_file\$\$\$\$.o 2> /dev/null; \\"
   echo "          then echo @fvisibility=hidden @DHIDE_EXPORTS; \\"
+  echo "          rm vis_temp_file\$\$\$\$.o 2> /dev/null; \\"
   echo "          fi)))"
   echo
 
@@ -152,8 +177,7 @@ for ml in $MULTILIBS; do
   # Work out relevant parameters that depend only on the multilib.
   dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
   flags=`echo ${ml} | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`;
-  shlib_dir=
-  shlib_dir_qual=
+  shlib_slibdir_qual=
   libgcc_a=$dir/libgcc.a
   libgcov_a=$dir/libgcov.a
   libgcc_eh_a=
@@ -165,62 +189,17 @@ for ml in $MULTILIBS; do
     libunwind_a=$dir/libunwind.a
   fi
   if [ "$SHLIB_LINK" ]; then
-    if [ -z "$SHLIB_MULTILIB" ]; then
-      if [ "$dir" = . ]; then
-       libgcc_eh_a=$dir/libgcc_eh.a
-       libgcc_s_so_base=$dir/libgcc_s
-       libgcc_s_so=${libgcc_s_so_base}${SHLIB_EXT}
-       libgcc_s_soname=libgcc_s
-       if [ "$LIBUNWIND" ]; then
-         libunwind_so_base=$dir/libunwind
-         libunwind_so=${libunwind_so_base}${SHLIB_EXT}
-         libunwind_soname=libunwind
-       fi
-      else
-        suffix=`echo $dir | sed s,/,_,g`
-       libgcc_eh_a=$dir/libgcc_eh.a
-       libgcc_s_so_base=$dir/libgcc_s_${suffix}
-       libgcc_s_so=${libgcc_s_so_base}${SHLIB_EXT}
-       libgcc_s_soname=libgcc_s_${suffix}
-       if [ "$LIBUNWIND" ]; then
-         libunwind_so_base=$dir/libunwind_${suffix}
-         libunwind_so=${libunwind_so_base}${SHLIB_EXT}
-       fi
-      fi
-
-      if [ -n "$MULTILIB_OSDIRNAMES" ]; then
-       if [ "$dir" != . ]; then
-         gcc_multilib_dir=`./xgcc -B./ $flags --print-multi-directory`
-         os_multilib_dir=`./xgcc -B./ $flags --print-multi-os-directory`
-         shlib_dir="$dir"/
-         gcc_multilib_sup=`echo $gcc_multilib_dir | sed 's~^[^/]*/~~'`
-         os_multilib_base=`echo $os_multilib_dir | sed -n "s~/${gcc_multilib_sup}\$~~p"`
-         if [ -z "$os_multilib_base" ]; then
-           libgcc_s_soname=libgcc_s
-           libunwind_soname=libunwind
-           if [ "$os_multilib_dir" != "." ]; then
-             shlib_dir_qual="/$os_multilib_dir"
-           fi
-         else
-           libgcc_s_soname=libgcc_s_`echo $gcc_multilib_sup | sed s,/,_,g`
-           libunwind_soname=libunwind_`echo $gcc_multilib_sup | sed s,/,_,g`
-           shlib_dir_qual="/$os_multilib_base"
-         fi
-       fi
-      fi
-
-    elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
-      libgcc_eh_a=$dir/libgcc_eh.a
-      libgcc_s_so_base=$dir/libgcc_s
-      libgcc_s_so=${libgcc_s_so_base}${SHLIB_EXT}
-      libgcc_s_soname=libgcc_s
-      if [ "$LIBUNWIND" ]; then
-       libunwind_so_base=$dir/libunwind
-       libunwind_so=${libunwind_so_base}${SHLIB_EXT}
-       libunwind_soname=libunwind
-      fi
+    libgcc_eh_a=$dir/libgcc_eh.a
+    libgcc_s_so=$dir/libgcc_s${SHLIB_EXT}
+    if [ "$LIBUNWIND" ]; then
+      libunwind_so=$dir/libunwind${SHLIB_EXT}
+    fi
+    os_multilib_dir=`$GCC_FOR_TARGET $flags --print-multi-os-directory`
+    if [ "$os_multilib_dir" != . ]; then
+      shlib_slibdir_qual="/$os_multilib_dir"
     fi
   fi
+
   libgcc_s_so_extra=
   libunwind_so_extra=
 
@@ -234,20 +213,9 @@ for ml in $MULTILIBS; do
   echo \# libgcc_eh_a: $libgcc_eh_a
   echo \# libunwind_a: $libunwind_a
   echo \#
-  echo \# gcc_multilib_dir: $gcc_multilib_dir
-  echo \# gcc_multilib_sup: $gcc_multilib_sup
-  echo \# os_multilib_dir: $os_multilib_dir
-  echo \# os_multilib_base: $os_multilib_base
-  echo \# shlib_dir: $shlib_dir
-  echo \# shlib_dir_qual: $shlib_dir_qual
-  echo \#
+  echo \# shlib_slibdir_qual: $shlib_slibdir_qual
   echo \# libgcc_s_so: $libgcc_s_so
-  echo \# libgcc_s_so_base: $libgcc_s_so_base
-  echo \# libgcc_s_soname: $libgcc_s_soname
-  echo \# 
   echo \# libunwind_so: $libunwind_so
-  echo \# libunwind_so_base: $libunwind_so_base
-  echo \# libunwind_soname: $libunwind_soname
   echo \#
   echo
 
@@ -267,7 +235,7 @@ for ml in $MULTILIBS; do
       outV="libgcc/${dir}/${name}.vis"
 
       echo ${outS}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)'
-      echo "   $gcc_compile" $flags -DL$name -xassembler-with-cpp \
+      echo "   $gcc_s_compile" $flags -DL$name -xassembler-with-cpp \
          -c '$(srcdir)/config/$(LIB1ASMSRC)' -o $outS
 
       echo ${out}: stmp-dirs '$(srcdir)/config/$(LIB1ASMSRC)' ${outV}
@@ -300,7 +268,8 @@ for ml in $MULTILIBS; do
       outS="libgcc/${dir}/${name}_s${objext}"
 
       echo $outS: $libgcc2_c_dep
-      echo "   $gcc_compile" $flags -DL$name -c '$(srcdir)/libgcc2.c' -o $outS
+      echo "   $gcc_s_compile" $flags -DL$name -c '$(srcdir)/libgcc2.c' \
+       -o $outS
 
       echo $out: $libgcc2_c_dep
       echo "   $gcc_compile" $flags -DL$name '$(vis_hide)' \
@@ -334,7 +303,7 @@ for ml in $MULTILIBS; do
       outS="libgcc/${dir}/${name}_s${objext}"
 
       echo $outS: $libgcc2_c_dep
-      echo "   $gcc_compile" $flags -DL$name \
+      echo "   $gcc_s_compile" $flags -DL$name \
         -fexceptions -fnon-call-exceptions -c '$(srcdir)/libgcc2.c' -o $outS
 
       echo $out: $libgcc2_c_dep
@@ -359,92 +328,95 @@ for ml in $MULTILIBS; do
   # Build software floating point functions.
   #
 
-  if [ "$FPBIT" ]; then
-    for name in $FPBIT_FUNCS; do
-      if [ "$libgcc_s_so" ]; then
-       out="libgcc/${dir}/${name}${objext}"
-       outS="libgcc/${dir}/${name}_s${objext}"
-
-       echo $outS: $FPBIT $fpbit_c_dep
-       echo "  $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
-         -c $FPBIT -o $outS
-
-        echo $out: $FPBIT $fpbit_c_dep
-        echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
-         '$(vis_hide)' -c $FPBIT -o $out
-
-       echo $libgcc_a: $out
-       echo $libgcc_s_so: $outS
-       if [ "$SHLIB_MKMAP" ]; then
-         echo libgcc/${dir}/libgcc.map: $outS
-       fi
-      else
-       out="libgcc/${dir}/${name}${objext}"
-       echo $out: $FPBIT $fpbit_c_dep
-       echo "  $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
-         -c $FPBIT -o $out
-
-       echo $libgcc_a: $out
+  for fpbit_var in FPBIT DPBIT TPBIT ; do
+      fpfuncs_var="${fpbit_var}_FUNCS"
+      eval fpbit=\$$fpbit_var
+      eval fpfuncs=\$$fpfuncs_var
+
+      if [ "$fpbit" ] ; then
+         for name in $fpfuncs; do
+             case "$name" in
+               # _sf_to_tf and _df_to_tf require tp-bit.c
+               # being compiled in.
+               _[sd]f_to_tf) [ -z "$TPBIT" ] && continue;;
+             esac
+             if [ "$libgcc_s_so" ]; then
+                 out="libgcc/${dir}/${name}${objext}"
+                 outS="libgcc/${dir}/${name}_s${objext}"
+
+                 echo $outS: $fpbit $fpbit_c_dep
+                 echo "        $gcc_s_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
+                     -c $fpbit -o $outS
+
+                 echo $out: $fpbit $fpbit_c_dep
+                 echo "        $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
+                     '$(vis_hide)' -c $fpbit -o $out
+                 
+                 echo $libgcc_a: $out
+                 echo $libgcc_s_so: $outS
+                 if [ "$SHLIB_MKMAP" ]; then
+                     echo libgcc/${dir}/libgcc.map: $outS
+                 fi
+             else
+                 out="libgcc/${dir}/${name}${objext}"
+                 echo $out: $fpbit $fpbit_c_dep
+                 echo "        $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
+                     -c $fpbit -o $out
+                 
+                 echo $libgcc_a: $out
+             fi
+         done
       fi
-    done
-  fi
-
-  if [ "$DPBIT" ]; then
-    for name in $DPBIT_FUNCS; do
-      if [ "$libgcc_s_so" ]; then
-       out="libgcc/${dir}/${name}${objext}"
-       outS="libgcc/${dir}/${name}_s${objext}"
+  done
 
-       echo $outS: $DPBIT $fpbit_c_dep
-       echo "  $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
-         -c $DPBIT -o $outS
+  if [ "@enable_decimal_float@" = "yes" -a -z "$libgcc_so" ]; then
+    # If $DFP_ENABLE is set, then we want all data type sizes.
+    if [ "$DFP_ENABLE" ] ; then
+       D32PBIT=1; D64PBIT=1; D128PBIT=1
+    fi
 
-        echo $out: $DPBIT $fpbit_c_dep
-        echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
-         '$(vis_hide)' -c $DPBIT -o $out
+    # Bring in the DFP support code if D32PBIT, D64PBIT or D128PBIT are set.
+    if [ -n "$D32PBIT" -o -n "$D64PBIT" -o -n "$D128PBIT" ] ; then
+      dec_filenames="decContext decNumber decRound decLibrary decUtility"
+    fi
 
-       echo $libgcc_a: $out
-       echo $libgcc_s_so: $outS
-       if [ "$SHLIB_MKMAP" ]; then
-         echo libgcc/${dir}/libgcc.map: $outS
-       fi
-      else
-       out="libgcc/${dir}/${name}${objext}"
-       echo $out: $DPBIT $fpbit_c_dep
-       echo "  $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
-         -c $DPBIT -o $out
+    # Only bring in decimal*.c files for types we support.
+    if [ -n "$D32PBIT" ] ; then
+      dec_filenames="$dec_filenames decimal32"
+    fi
+    if [ -n "$D64PBIT" ] ; then
+      dec_filenames="$dec_filenames decimal64"
+    fi
+    if [ -n "$D128PBIT" ] ; then
+      dec_filenames="$dec_filenames decimal128"
+    fi
 
-       echo $libgcc_a: $out
-      fi
+    for name in $dec_filenames ; do
+      out="libgcc/${dir}/${name}${objext}"
+      echo $out: "\$(srcdir)/../libdecnumber/${name}.c" $decnumber_dep
+      echo "   $gcc_compile" $flags -c "\$(srcdir)/../libdecnumber/${name}.c" -o $out
+      echo $libgcc_a: $out
     done
-  fi
-
-  if [ "$TPBIT" ]; then
-    for name in $TPBIT_FUNCS; do
-      if [ "$libgcc_s_so" ]; then
-       out="libgcc/${dir}/${name}${objext}"
-       outS="libgcc/${dir}/${name}_s${objext}"
-
-       echo $outS: $TPBIT $fpbit_c_dep
-       echo "  $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
-         -c $TPBIT -o $outS
 
-        echo $out: $TPBIT $fpbit_c_dep
-        echo " $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
-         '$(vis_hide)' -c $TPBIT -o $out
-
-       echo $libgcc_a: $out
-       echo $libgcc_s_so: $outS
-       if [ "$SHLIB_MKMAP" ]; then
-         echo libgcc/${dir}/libgcc.map: $outS
-       fi
-      else
-       out="libgcc/${dir}/${name}${objext}"
-       echo $out: $TPBIT $fpbit_c_dep
-       echo "  $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
-         -c $TPBIT -o $out
+    # For individual functions, loop over each variable by name.
+    for dpbit_var in D32PBIT D64PBIT D128PBIT ; do
+      dpfuncs_var="${dpbit_var}_FUNCS"
+      eval dpbit=\$$dpbit_var
+      eval dpfuncs=\$$dpfuncs_var
+      case "$dpbit_var" in
+         D32PBIT)  dpwidth=32 ;;
+         D64PBIT)  dpwidth=64 ;;
+         D128PBIT) dpwidth=128 ;;
+      esac
 
-       echo $libgcc_a: $out
+      if [ "$dpbit" ]; then
+        for name in $dpfuncs; do
+          out="libgcc/${dir}/${name}${objext}"
+         echo $out: config/dfp-bit.h config/dfp-bit.c $fpbit_c_dep
+         echo "        $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name -DWIDTH=$dpwidth \
+             $DFP_CFLAGS -c $\(srcdir\)/config/dfp-bit.c -o $out
+         echo $libgcc_a: $out
+        done
       fi
     done
   fi
@@ -460,7 +432,7 @@ for ml in $MULTILIBS; do
       case $file in
        *.c)
          echo $outS: stmp-dirs $file $libgcc_dep
-         echo "        $gcc_compile" $flags -c $file -o $outS
+         echo "        $gcc_s_compile" $flags -c $file -o $outS
 
          echo $out: stmp-dirs $file $libgcc_dep
          echo "        $gcc_compile" $flags '$(vis_hide)' -c $file -o $out
@@ -470,7 +442,7 @@ for ml in $MULTILIBS; do
          outV="libgcc/${dir}/${oname}.vis"
 
          echo $outS: stmp-dirs $file $libgcc_dep
-         echo "        $gcc_compile" $flags -xassembler-with-cpp \
+         echo "        $gcc_s_compile" $flags -xassembler-with-cpp \
                 -c $file -o $outS
 
          echo $out: stmp-dirs $file $libgcc_dep $outV
@@ -556,60 +528,98 @@ for ml in $MULTILIBS; do
 
   # If we don't have libgcc_eh.a, only LIB2ADDEH matters.  If we do, only
   # LIB2ADDEHSTATIC and LIB2ADDEHSHARED matter.  (Usually all three are
-  # identical.)  We do _not_ handle assembly files in this context.
+  # identical.)
 
   if [ "$libgcc_eh_a" ]; then
     for file in $LIB2ADDEHSTATIC; do
-      case $file in
-        *.c) ;;
-       *)   echo "Unhandled extension: $file">&2; exit 1 ;;
-       esac
-
-      name=`echo $file | sed -e 's/[.]c$//'`
+      name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
       oname=`echo $name | sed -e 's,.*/,,'`
       out="libgcc/${dir}/${oname}${objext}"
 
-      echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
-      echo "   $gcc_compile" $flags '$(vis_hide)' -fexceptions -c $file -o $out
+      case $file in
+        *.c)
+         echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
+         echo "        $gcc_compile" $flags -fexceptions '$(vis_hide)' -c $file -o $out
+         ;;
+       *.asm | *.S)
+         # We have to compile it twice in order to establish the list
+         # of symbols to be marked hidden.
+         outV="libgcc/${dir}/${oname}.vis"
+         outT="libgcc/${dir}/${oname}_t${objext}"
+         echo ${outT}: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
+         echo "        $gcc_compile" $flags -xassembler-with-cpp \
+                 -c $file -o ${outT}
+         echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep $outV
+         echo "        $gcc_compile" $flags -xassembler-with-cpp \
+                 -include $outV -c $file -o $out
+         echo "${outV}: ${outT}; \$(gen-hide-list)"
+         ;;
+       *)   echo "Unhandled extension: $file">&2; exit 1 ;;
+      esac
+
       echo $libgcc_eh_a: $out
     done
 
     for file in $LIB2ADDEHSHARED; do
+      name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
+      oname=`echo $name | sed -e 's,.*/,,'`
+      outS="libgcc/${dir}/${oname}_s${objext}"
+
       case $file in
-        *.c) ;;
+        *.c)
+         echo $outS: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
+         echo "        $gcc_s_compile" $flags -fexceptions -c $file -o $outS
+         ;;
+       *.asm | *.S)
+         echo $outS: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
+         echo "        $gcc_s_compile" $flags -xassembler-with-cpp -c $file -o $outS
+         ;;
        *)   echo "Unhandled extension: $file">&2; exit 1 ;;
-       esac
-
-      name=`echo $file | sed -e 's/[.]c$//'`
-      oname=`echo $name | sed -e 's,.*/,,'`
-      out="libgcc/${dir}/${oname}_s${objext}"
+      esac
 
-      echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
-      echo "   $gcc_compile" $flags -fexceptions -c $file -o $out
-      echo $libgcc_s_so: $out
+      echo $libgcc_s_so: $outS
       if [ "$SHLIB_MKMAP" ]; then
-       echo libgcc/${dir}/libgcc.map: $out
+       echo libgcc/${dir}/libgcc.map: $outS
       fi
     done
 
+    # If nothing went into libgcc_eh.a, create a dummy object -
+    # some linkers don't like totally empty archives.
+    if [ -z "$LIB2ADDEHSTATIC" ]; then
+      file=eh_dummy.c
+      out="libgcc/${dir}/eh_dummy${objext}"
+      need_eh_dummy=1
+
+      echo $out: stmp-dirs $file
+      echo "   $gcc_compile" $flags '$(vis_hide)' -fexceptions -c $file -o $out
+      echo $libgcc_eh_a: $out
+    fi
+   
+
   else # no libgcc_eh.a
     for file in $LIB2ADDEH; do
-      case $file in
-        *.c) ;;
-       *)   echo "Unhandled extension: $file">&2; exit 1 ;;
-       esac
-
-      name=`echo $file | sed -e 's/[.]c$//'`
+      name=`echo $file | sed -e 's/[.][cSo]$//' -e 's/[.]asm$//'`
       oname=`echo $name | sed -e 's,.*/,,'`
       out="libgcc/${dir}/${oname}${objext}"
 
-      echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
-      echo "   $gcc_compile" $flags -fexceptions '$(vis_hide)' -c $file -o $out
+      case $file in
+        *.c)
+         echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
+         echo "        $gcc_compile" $flags '$(vis_hide)' -fexceptions -c $file -o $out
+         ;;
+       *.asm | *.S)
+         echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
+         echo "        $gcc_compile" $flags -xassembler-with-cpp \
+                 -c $file -o $out
+         ;;
+       *)   echo "Unhandled extension: $file">&2; exit 1 ;;
+      esac
+
       echo $libgcc_a: $out
     done
   fi
 
-  # Again, this does not handle assembly.
+  # We do _not_ handle assembly files in this context.
   if [ "$LIBUNWIND" ]; then
     for file in $LIBUNWIND; do
       case $file in
@@ -628,7 +638,7 @@ for ml in $MULTILIBS; do
        echo "  $gcc_compile $flags -fexceptions \$(vis_hide) -c $file -o $out"
 
        echo $outS: stmp-dirs $file $LIBUNWINDDEP
-       echo "  $gcc_compile $flags -fexceptions -DSHARED -c $file -o $outS"
+       echo "  $gcc_s_compile $flags -fexceptions -c $file -o $outS"
 
        echo $libunwind_a: $out
        echo $libunwind_so: $outS
@@ -655,37 +665,48 @@ for ml in $MULTILIBS; do
   done
 
   # EXTRA_MULTILIB_PARTS.
-  echo
-  for f in $EXTRA_MULTILIB_PARTS; do
-    case $dir in
-    .) out=$f ; t= ;;
-    *) out=$dir/$f ; t=$dir/ ;;
-    esac
-    case $out in
-    # Prevent `make' from interpreting $out as a macro assignment
-    *'$(EQ)'*) targ="T_TARGET=$out T_TARGET" ;;
-    *) targ=$out ;;
-    esac
+  if [ -n "$EXTRA_MULTILIB_PARTS" ]; then
+    # Each of the EXTRA_MULTILIB_PARTS is built by recursive invocation
+    # of the parent Makefile.  We must do this just once for each
+    # multilib, passing it all the EXTRA_MULTILIB_PARTS as
+    # simultaneous goal targets, so that rules which cannot execute
+    # simultaneously are properly serialized.
+    
+    extra=
+    echo
+    for f in $EXTRA_MULTILIB_PARTS; do
+      case $dir in
+      .) out=$f ; t= ;;
+      *) out=$dir/$f ; t=$dir/ ;;
+      esac
+      case $out in
+      # Prevent `make' from interpreting $out as a macro assignment
+      *'$(EQ)'*) targ="T_TARGET=$out T_TARGET" ;;
+      *) targ=$out ;;
+      esac
+      extra="$extra $targ"
+    done
 
-    echo $out: stmp-dirs
+    if [ "$dir" = . ]; then
+      suffix=
+    else
+      suffix=`echo $dir | sed s,/,_,g`
+    fi
+    echo extra$suffix: stmp-dirs
     echo "     $make_compile" \\
     echo '       LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
-    echo '       MULTILIB_CFLAGS="'$flags'"' T=$t $targ
-    echo "all: $out"
+    echo '       MULTILIB_CFLAGS="'$flags'"' T=$t $extra
+    echo "all: extra$suffix"
 
-    # Make libunwind.so and libgcc_s.so depend on these, since they are
-    # likely to be implicitly used by the link process.  However, we must
-    # then arrange to remove them from the explicit object list generated
-    # from $^ - see below.
+    # Make libunwind.so and libgcc_s.so depend on these, since they
+    # are likely to be implicitly used by the link process.
     if [ "$libgcc_s_so" ]; then
-      libgcc_s_so_extra="$libgcc_s_so_extra $out"
-      echo "$libgcc_s_so: $out"
+      echo "$libgcc_s_so: extra$suffix"
     fi
     if [ "$libunwind_so" ]; then
-      libunwind_so_extra="$libunwind_so_extra $out"
-      echo "$libunwind_so: $out"
+      echo "$libunwind_so: extra$suffix"
     fi
-  done
+  fi
 
   # Library build rules.
   dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
@@ -760,11 +781,9 @@ EOF
     echo "     $SHLIB_LINK" \
         | sed -e "s%@multilib_flags@%$flags%g" \
               -e "s%@multilib_dir@%$dir%g" \
-              -e "s%@shlib_objs@%\$(filter-out $libgcc_s_so_extra,\$(objects))%g" \
-              -e "s%@shlib_base_name@%$libgcc_s_so_base%g" \
-              -e "s%@shlib_so_name@%$libgcc_s_soname%g" \
+              -e "s%@shlib_objs@%\$(objects)%g" \
+              -e "s%@shlib_base_name@%libgcc_s%g" \
               -e "s%@shlib_map_file@%$mapfile%g" \
-              -e "s%@shlib_dir@%$shlib_dir%g" \
               -e "s%@shlib_slibdir_qual@%$shlib_dir_qual%g"
     echo "all: $libgcc_s_so"
   fi
@@ -775,10 +794,8 @@ EOF
     echo "     $SHLIBUNWIND_LINK" \
           | sed -e "s%@multilib_flags@%$flags%g" \
                 -e "s%@multilib_dir@%$dir%g" \
-                -e "s%@shlib_objs@%\$(filter-out $libunwind_so_extra,\$(objects))%g" \
-                -e "s%@shlib_base_name@%$libunwind_so_base%g" \
-                -e "s%@shlib_so_name@%$libunwind_soname%g" \
-                -e "s%@shlib_dir@%$shlib_dir%g" \
+                -e "s%@shlib_objs@%\$(objects)%g" \
+                -e "s%@shlib_base_name@%libunwind%g" \
                 -e "s%@shlib_slibdir_qual@%$shlib_dir_qual%g"
     echo "all: $libunwind_so"
   fi
@@ -805,6 +822,11 @@ echo "       if [ -d \$\$d ]; then true; else $mkinstalldirs \$\$d; fi; \\"
 echo " done"
 echo " if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi"
 
+if [ "$need_eh_dummy" ]; then
+  echo "eh_dummy.c:"
+  echo "       echo 'int __libgcc_eh_dummy;' > \$@"
+fi
+
 echo ""
 echo "install: all"
 for ml in $MULTILIBS; do
@@ -825,70 +847,23 @@ for ml in $MULTILIBS; do
     echo '     $(INSTALL_DATA)' ${dir}/libgcc_eh.a ${ldir}/
     echo '     $(RANLIB_FOR_TARGET)' ${ldir}/libgcc_eh.a
 
-    if [ -z "$SHLIB_MULTILIB" ]; then
-      if [ "$dir" = . ]; then
-       shlib_base_name=libgcc_s
-       shlibunwind_base_name=libunwind
-      else
-       shlib_base_name=libgcc_s_`echo $dir | sed s,/,_,g`
-       shlibunwind_base_name=libunwind_`echo $dir | sed s,/,_,g`
-      fi
-      shlib_so_name="$shlib_base_name"
-      shlibunwind_so_name="$shlibunwind_base_name"
-      shlib_dir=
-      shlib_slibdir_qual=
-      if [ -n "$MULTILIB_OSDIRNAMES" ]; then
-       gcc_multilib_dir=`./xgcc -B./ $flags --print-multi-directory`
-       os_multilib_dir=`./xgcc -B./ $flags --print-multi-os-directory`
-       if [ "$dir" != . ]; then
-         shlib_dir="$dir"/
-       fi
-       gcc_multilib_sup=`echo $gcc_multilib_dir | sed 's~^[^/]*/~~'`
-       os_multilib_base=`echo $os_multilib_dir | sed -n "s~/${gcc_multilib_sup}\$~~p"`
-       if [ -z "$os_multilib_base" ]; then
-         shlib_so_name=libgcc_s
-         shlibunwind_so_name=libunwind
-         if [ "$os_multilib_dir" != "." ]; then
-           shlib_slibdir_qual="/$os_multilib_dir"
-         fi
-       else
-         shlib_so_name=libgcc_s_`echo $gcc_multilib_sup | sed s,/,_,g`
-         shlibunwind_so_name=libunwind_`echo $gcc_multilib_sup | sed s,/,_,g`
-         shlib_slibdir_qual="/$os_multilib_base"
-       fi
-      fi
-      echo "   $SHLIB_INSTALL" \
-       | sed -e "s%@shlib_base_name@%$shlib_base_name%g" \
-             -e "s%@shlib_so_name@%$shlib_so_name%g" \
-             -e "s%@shlib_dir@%$shlib_dir%g" \
+    shlib_slibdir_qual=
+    os_multilib_dir=`$GCC_FOR_TARGET $flags --print-multi-os-directory`
+    if [ "$os_multilib_dir" != . ]; then
+      shlib_slibdir_qual="/$os_multilib_dir"
+    fi
+    echo "     $SHLIB_INSTALL" \
+      | sed -e "s%@multilib_dir@%$dir%g" \
+           -e "s%@shlib_base_name@%libgcc_s%g" \
+           -e "s%@shlib_slibdir_qual@%$shlib_slibdir_qual%g"
+    if [ "$LIBUNWIND" ]; then
+      echo "   $SHLIBUNWIND_INSTALL" \
+       | sed -e "s%@multilib_dir@%$dir%g" \
+             -e "s%@shlib_base_name@%libunwind%g" \
              -e "s%@shlib_slibdir_qual@%$shlib_slibdir_qual%g"
-      if [ "$LIBUNWIND" ]; then
-       echo "  $SHLIBUNWIND_INSTALL" \
-          | sed -e "s%@shlib_base_name@%$shlibunwind_base_name%g" \
-                -e "s%@shlib_so_name@%$shlibunwind_so_name%g" \
-                -e "s%@shlib_dir@%$shlib_dir%g" \
-                -e "s%@shlib_slibdir_qual@%$shlib_slibdir_qual%g"
-       libunwinddir='$(DESTDIR)$(slibdir)$(shlib_slibdir_qual)/$(shlib_dir)'
-       echo '  $(INSTALL_DATA)' ${dir}/libunwind.a ${libunwinddir}/
-       echo '  $(RANLIB_FOR_TARGET)' ${libunwinddir}/libunwind.a
-      fi
-    elif [ "$SHLIB_MULTILIB" = "$dir" ]; then
-      shlib_base_name="libgcc_s";
-      echo "   $SHLIB_INSTALL" \
-       | sed -e "s%@shlib_base_name@%$shlib_base_name%g" \
-             -e "s%@shlib_so_name@%$shlib_base_name%g" \
-             -e "s%@shlib_dir@%%g" \
-             -e "s%@shlib_slibdir_qual@%%g"
-      if [ "$LIBUNWIND" ]; then
-       echo "  $SHLIBUNWIND_INSTALL" \
-          | sed -e "s%@shlib_base_name@%$shlibunwind_base_name%g" \
-                -e "s%@shlib_so_name@%$shlibunwind_base_name%g" \
-                -e "s%@shlib_dir@%%g" \
-                -e "s%@shlib_slibdir_qual@%%g"
-       libunwinddir='$(DESTDIR)$(slibdir)'
-       echo '  $(INSTALL_DATA)' ${dir}/libunwind.a ${libunwinddir}/
-       echo '  $(RANLIB_FOR_TARGET)' ${libunwinddir}/libunwind.a
-      fi
+      libunwinddir='$(DESTDIR)$(slibdir)$(shlib_slibdir_qual)/$(shlib_dir)'
+      echo '   $(INSTALL_DATA)' ${dir}/libunwind.a ${libunwinddir}/
+      echo '   $(RANLIB_FOR_TARGET)' ${libunwinddir}/libunwind.a
     fi
   fi
 done