OSDN Git Service

2005-06-08 Dale Johannesen <dalej@apple.com>
[pf3gnuchains/gcc-fork.git] / gcc / mklibgcc.in
index 91e5640..aa61d41 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/sh
 # Construct makefile for libgcc.
-#   Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
+#   Copyright (C) 2000, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 #
 # This file is part of GCC.
 
@@ -40,6 +40,7 @@
 # SHLIB_INSTALL
 # MULTILIB_OSDIRNAMES
 # ASM_HIDDEN_OP
+# GCC_FOR_TARGET
 
 # Make needs VPATH to be literal.
 echo 'srcdir = @srcdir@'
@@ -72,6 +73,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)" \
@@ -94,6 +96,9 @@ 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'
 
+# 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
@@ -174,7 +179,7 @@ for ml in $MULTILIBS; do
     if [ "$LIBUNWIND" ]; then
       libunwind_so=$dir/libunwind${SHLIB_EXT}
     fi
-    os_multilib_dir=`./xgcc -B./ $flags --print-multi-os-directory`
+    os_multilib_dir=`$GCC_FOR_TARGET $flags --print-multi-os-directory`
     if [ "$os_multilib_dir" != . ]; then
       shlib_slibdir_qual="/$os_multilib_dir"
     fi
@@ -215,7 +220,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}
@@ -248,7 +253,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)' \
@@ -282,7 +288,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
@@ -314,7 +320,7 @@ for ml in $MULTILIBS; do
        outS="libgcc/${dir}/${name}_s${objext}"
 
        echo $outS: $FPBIT $fpbit_c_dep
-       echo "  $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
+       echo "  $gcc_s_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
          -c $FPBIT -o $outS
 
         echo $out: $FPBIT $fpbit_c_dep
@@ -344,7 +350,7 @@ for ml in $MULTILIBS; do
        outS="libgcc/${dir}/${name}_s${objext}"
 
        echo $outS: $DPBIT $fpbit_c_dep
-       echo "  $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
+       echo "  $gcc_s_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
          -c $DPBIT -o $outS
 
         echo $out: $DPBIT $fpbit_c_dep
@@ -374,7 +380,7 @@ for ml in $MULTILIBS; do
        outS="libgcc/${dir}/${name}_s${objext}"
 
        echo $outS: $TPBIT $fpbit_c_dep
-       echo "  $gcc_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
+       echo "  $gcc_s_compile" -DFINE_GRAINED_LIBRARIES $flags -DL$name \
          -c $TPBIT -o $outS
 
         echo $out: $TPBIT $fpbit_c_dep
@@ -408,7 +414,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
@@ -418,7 +424,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
@@ -530,16 +536,29 @@ for ml in $MULTILIBS; do
 
       name=`echo $file | sed -e 's/[.]c$//'`
       oname=`echo $name | sed -e 's,.*/,,'`
-      out="libgcc/${dir}/${oname}_s${objext}"
+      outS="libgcc/${dir}/${oname}_s${objext}"
 
-      echo $out: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
-      echo "   $gcc_compile" $flags -fexceptions -c $file -o $out
-      echo $libgcc_s_so: $out
+      echo $outS: stmp-dirs $file $LIB2ADDEHDEP $libgcc_dep
+      echo "   $gcc_s_compile" $flags -fexceptions -c $file -o $outS
+      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
@@ -576,7 +595,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
@@ -760,6 +779,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 'struct eh_dummy;' > \$@"
+fi
+
 echo ""
 echo "install: all"
 for ml in $MULTILIBS; do
@@ -781,7 +805,7 @@ for ml in $MULTILIBS; do
     echo '     $(RANLIB_FOR_TARGET)' ${ldir}/libgcc_eh.a
 
     shlib_slibdir_qual=
-    os_multilib_dir=`./xgcc -B./ $flags --print-multi-os-directory`
+    os_multilib_dir=`$GCC_FOR_TARGET $flags --print-multi-os-directory`
     if [ "$os_multilib_dir" != . ]; then
       shlib_slibdir_qual="/$os_multilib_dir"
     fi