OSDN Git Service

* gcc.dg/20020201-1.c: Use cleanup-coverage_files.
[pf3gnuchains/gcc-fork.git] / ltmain.sh
index 92526b6..a848253 100644 (file)
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -1041,6 +1041,11 @@ EOF
                   if test -z "$pic_object" || test "$pic_object" = none ; then
                     arg="$non_pic_object"
                   fi
+               else
+                 # If the PIC object exists, use it instead.
+                 # $xdir was prepended to $pic_object above.
+                 non_pic_object="$pic_object"
+                 non_pic_objects="$non_pic_objects $non_pic_object"
                 fi
               else
                 # Only an error if not doing a dry-run.
@@ -1111,6 +1116,19 @@ EOF
          finalize_command="$finalize_command $wl$qarg"
          continue
          ;;
+       framework)
+         case $host in
+          *-*-darwin*)
+            case "$deplibs " in
+              *" $qarg.framework "*) ;;
+              *) deplibs="$deplibs $qarg.framework" # this is fixed later
+                 ;;
+            esac
+            ;;
+         esac
+         prev=
+         continue
+         ;;
        *)
          eval "$prev=\"\$arg\""
          prev=
@@ -1363,6 +1381,10 @@ EOF
        prev=xlinker
        continue
        ;;
+      -framework)
+       prev=framework
+       continue
+       ;;
 
       # Some other compiler flag.
       -* | +*)
@@ -1449,6 +1471,11 @@ EOF
             if test -z "$pic_object" || test "$pic_object" = none ; then
               arg="$non_pic_object"
             fi
+         else
+           # If the PIC object exists, use it instead.
+           # $xdir was prepended to $pic_object above.
+           non_pic_object="$pic_object"
+           non_pic_objects="$non_pic_objects $non_pic_object"
           fi
         else
           # Only an error if not doing a dry-run.
@@ -1841,6 +1868,13 @@ EOF
        *) . ./$lib ;;
        esac
 
+       case $host in
+           *-*-darwin*)
+         # Convert "-framework foo" to "foo.framework" in dependency_libs
+               test -n "$dependency_libs" && dependency_libs=`$echo "X$dependency_libs" | $Xsed -e 's/-framework \([^ $]*\)/\1.framework/g'`
+               ;;
+       esac
+
        if test "$linkmode,$pass" = "lib,link" ||
           test "$linkmode,$pass" = "prog,scan" ||
           { test $linkmode = oldlib && test $linkmode = obj; }; then
@@ -2082,9 +2116,10 @@ EOF
            else
              $show "extracting exported symbol list from \`$soname'"
              IFS="${IFS=       }"; save_ifs="$IFS"; IFS='~'
-             eval cmds=\"$extract_expsyms_cmds\"
+             cmds=$extract_expsyms_cmds
              for cmd in $cmds; do
                IFS="$save_ifs"
+               eval cmd=\"$cmd\"
                $show "$cmd"
                $run eval "$cmd" || exit $?
              done
@@ -2095,9 +2130,10 @@ EOF
            if test -f "$output_objdir/$newlib"; then :; else
              $show "generating import library for \`$soname'"
              IFS="${IFS=       }"; save_ifs="$IFS"; IFS='~'
-             eval cmds=\"$old_archive_from_expsyms_cmds\"
+             cmds=$old_archive_from_expsyms_cmds
              for cmd in $cmds; do
                IFS="$save_ifs"
+               eval cmd=\"$cmd\"
                $show "$cmd"
                $run eval "$cmd" || exit $?
              done
@@ -2446,6 +2482,7 @@ EOF
       case $outputname in
       lib*)
        name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
+       eval shared_ext=\"$shrext\"
        eval libname=\"$libname_spec\"
        ;;
       *)
@@ -2457,6 +2494,7 @@ EOF
        if test "$need_lib_prefix" != no; then
          # Add the "lib" prefix for modules if required
          name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
+         eval shared_ext=\"$shrext\"
          eval libname=\"$libname_spec\"
        else
          libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
@@ -2606,7 +2644,7 @@ EOF
          ;;
 
        osf)
-         major=`expr $current - $age`
+         major=.`expr $current - $age`
          versuffix=".$current.$age.$revision"
          verstring="$current.$age.$revision"
 
@@ -2644,7 +2682,16 @@ EOF
        # Clear the version info if we defaulted, and they specified a release.
        if test -z "$vinfo" && test -n "$release"; then
          major=
-         verstring="0.0"
+         case $version_type in
+         darwin)
+           # we can't check for "0.0" in archive_cmds due to quoting
+           # problems, so we reset it completely
+           verstring=
+           ;;
+         *)
+           verstring="0.0"
+           ;;
+         esac
          if test "$need_version" = no; then
            versuffix=
          else
@@ -3020,6 +3067,14 @@ EOF
            fi
          fi
        fi
+       # Time to change all our "foo.framework" stuff back to "-framework foo"
+       case $host in
+           *-*-darwin*)
+               newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).framework% -framework \1%g'`
+               dependency_libs=`$echo "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).framework% -framework \1%g'`
+               ;;
+       esac
+       # Done checking deplibs!
        # Done checking deplibs!
        deplibs=$newdeplibs
       fi
@@ -3088,6 +3143,7 @@ EOF
 
        # Get the real and link names of the library.
        eval library_names=\"$library_names_spec\"
+       eval shared_ext=\"$shrext\"
        set dummy $library_names
        realname="$2"
        shift; shift
@@ -3205,11 +3261,13 @@ EOF
 
        # Do each of the archive commands.
        if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
-         eval cmds=\"$archive_expsym_cmds\"
+         eval test_cmds=\"$archive_expsym_cmds\"
+         cmds=$archive_expsym_cmds
        else
-         eval cmds=\"$archive_cmds\"
+         eval test_cmds=\"$archive_cmds\"
+         cmds=$archive_cmds
        fi
-        if len=`expr "X$cmds" : ".*"` &&
+        if len=`expr "X$test_cmds" : ".*"` &&
            test $len -le $max_cmd_len; then
           :
         else
@@ -3285,6 +3343,7 @@ EOF
           IFS="${IFS=  }"; save_ifs="$IFS"; IFS='~'
           for cmd in $concat_cmds; do
             IFS="$save_ifs"
+           eval cmd=\"$cmd\"
             $show "$cmd"
             $run eval "$cmd" || exit $?
           done
@@ -3302,9 +3361,9 @@ EOF
 
          # Do each of the archive commands.
           if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
-            eval cmds=\"$archive_expsym_cmds\"
-          else
-            eval cmds=\"$archive_cmds\"
+           cmds=$archive_expsym_cmds
+         else
+           cmds=$archive_cmds
           fi
 
          # Append the command to remove the reloadable object files
@@ -3314,6 +3373,7 @@ EOF
         IFS="${IFS=    }"; save_ifs="$IFS"; IFS='~'
         for cmd in $cmds; do
           IFS="$save_ifs"
+         eval cmd=\"$cmd\"
           $show "$cmd"
           $run eval "$cmd" || exit $?
         done
@@ -3533,6 +3593,19 @@ EOF
        ;;
       esac
 
+      case $host in
+      *-*-darwin*)
+      # Don't allow lazy linking, it breaks C++ global constructors
+       if test "$tagname" = CXX ; then
+          compile_command="$compile_command ${wl}-bind_at_load"
+          finalize_command="$finalize_command ${wl}-bind_at_load"
+       fi
+      # Time to change all our "foo.framework" stuff back to "-framework foo"
+       compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).framework% -framework \1%g'`
+       finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).framework% -framework \1%g'`
+       ;;
+      esac
+
       compile_command="$compile_command $compile_deplibs"
       finalize_command="$finalize_command $finalize_deplibs"
 
@@ -4234,6 +4307,63 @@ fi\
 #        fi
 #      done
 
+       # POSIX demands no paths to be encoded in archives.  We have
+       # to avoid creating archives with duplicate basenames if we
+       # might have to extract them afterwards, e.g., when creating a
+       # static archive out of a convenience library, or when linking
+       # the entirety of a libtool archive into another (currently
+       # not supported by libtool).
+        if (for obj in $oldobjs
+           do
+             $echo "X$obj" | $Xsed -e 's%^.*/%%'
+           done | sort | sort -uc >/dev/null 2>&1); then
+         :
+       else
+         $echo "copying selected object files to avoid basename conflicts..."
+
+         if test -z "$gentop"; then
+           gentop="$output_objdir/${outputname}x"
+
+           $show "${rm}r $gentop"
+           $run ${rm}r "$gentop"
+           $show "$mkdir $gentop"
+           $run $mkdir "$gentop"
+           status=$?
+           if test $status -ne 0 && test ! -d "$gentop"; then
+             exit $status
+           fi
+           generated="$generated $gentop"
+         fi
+
+         save_oldobjs=$oldobjs
+         oldobjs=
+         counter=1
+         for obj in $save_oldobjs
+         do
+           objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
+           case " $oldobjs " in
+           " ") oldobjs=$obj ;;
+           *[\ /]"$objbase "*)
+             while :; do
+               # Make sure we don't pick an alternate name that also
+               # overlaps.
+               newobj=lt$counter-$objbase
+               counter=`expr $counter + 1`
+               case " $oldobjs " in
+               *[\ /]"$newobj "*) ;;
+               *) if test ! -f "$gentop/$newobj"; then break; fi ;;
+               esac
+             done
+             $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
+             $run ln "$obj" "$gentop/$newobj" ||
+             $run cp "$obj" "$gentop/$newobj"
+             oldobjs="$oldobjs $gentop/$newobj"
+             ;;
+           *) oldobjs="$oldobjs $obj" ;;
+           esac
+         done
+       fi
+
         eval cmds=\"$old_archive_cmds\"
 
         if len=`expr "X$cmds" : ".*"` &&
@@ -4247,20 +4377,7 @@ fi\
           objlist=
           concat_cmds=
           save_oldobjs=$oldobjs
-         # GNU ar 2.10+ was changed to match POSIX; thus no paths are
-         # encoded into archives.  This makes 'ar r' malfunction in
-         # this piecewise linking case whenever conflicting object
-         # names appear in distinct ar calls; check, warn and compensate.
-          if (for obj in $save_oldobjs
-           do
-             $echo "X$obj" | $Xsed -e 's%^.*/%%'
-           done | sort | sort -uc >/dev/null 2>&1); then
-           :
-         else
-           $echo "$modename: warning: object name conflicts; overriding AR_FLAGS to 'cq'" 1>&2
-           $echo "$modename: warning: to ensure that POSIX-compatible ar will work" 1>&2
-           AR_FLAGS=cq
-         fi
+
           for obj in $save_oldobjs
           do
             oldobjs="$objlist $obj"