OSDN Git Service

* lang-specs.h ("@objective-c"): Use cc1obj when -E is used so
[pf3gnuchains/gcc-fork.git] / ltmain.sh
index 5d4281c..90925cb 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$//'`
@@ -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"