OSDN Git Service

* libsupc++/del_op.cc: Don't include cstdlib when !_GLIBCXX_HOSTED.
[pf3gnuchains/gcc-fork.git] / compile
diff --git a/compile b/compile
index a81e000..3d21703 100644 (file)
--- a/compile
+++ b/compile
@@ -1,9 +1,9 @@
 #! /bin/sh
 # Wrapper for compilers which do not understand `-c -o'.
 
-scriptversion=2003-11-09.00
+scriptversion=2004-10-12.08
 
-# Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
+# Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
 # Written by Tom Tromey <tromey@cygnus.com>.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -55,37 +55,41 @@ EOF
     ;;
 esac
 
-
-prog=$1
-shift
-
 ofile=
 cfile=
-args=
-while test $# -gt 0; do
-  case "$1" in
-    -o)
-      # configure might choose to run compile as `compile cc -o foo foo.c'.
-      # So we do something ugly here.
-      ofile=$2
-      shift
-      case "$ofile" in
-       *.o | *.obj)
-         ;;
-       *)
-         args="$args -o $ofile"
-         ofile=
-         ;;
-      esac
-       ;;
-    *.c)
-      cfile=$1
-      args="$args $1"
-      ;;
-    *)
-      args="$args $1"
-      ;;
-  esac
+eat=
+
+for arg
+do
+  if test -n "$eat"; then
+    eat=
+  else
+    case $1 in
+      -o)
+       # configure might choose to run compile as `compile cc -o foo foo.c'.
+       # So we strip `-o arg' only if arg is an object.
+       eat=1
+       case $2 in
+         *.o | *.obj)
+           ofile=$2
+           ;;
+         *)
+           set x "$@" -o "$2"
+           shift
+           ;;
+       esac
+       ;;
+      *.c)
+       cfile=$1
+       set x "$@" "$1"
+       shift
+       ;;
+      *)
+       set x "$@" "$1"
+       shift
+       ;;
+    esac
+  fi
   shift
 done
 
@@ -95,36 +99,38 @@ if test -z "$ofile" || test -z "$cfile"; then
   # normal compilation that the losing compiler can handle.  If no
   # `.c' file was seen then we are probably linking.  That is also
   # ok.
-  exec "$prog" $args
+  exec "$@"
 fi
 
 # Name of file we expect compiler to create.
-cofile=`echo $cfile | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
+cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
 
 # Create the lock directory.
 # Note: use `[/.-]' here to ensure that we don't use the same name
 # that we are using for the .o file.  Also, base the name on the expected
 # object file name, since that is what matters with a parallel build.
-lockdir=`echo $cofile | sed -e 's|[/.-]|_|g'`.d
+lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d
 while true; do
-  if mkdir $lockdir > /dev/null 2>&1; then
+  if mkdir "$lockdir" >/dev/null 2>&1; then
     break
   fi
   sleep 1
 done
 # FIXME: race condition here if user kills between mkdir and trap.
-trap "rmdir $lockdir; exit 1" 1 2 15
+trap "rmdir '$lockdir'; exit 1" 1 2 15
 
 # Run the compile.
-"$prog" $args
-status=$?
+"$@"
+ret=$?
 
 if test -f "$cofile"; then
   mv "$cofile" "$ofile"
+elif test -f "${cofile}bj"; then
+  mv "${cofile}bj" "$ofile"
 fi
 
-rmdir $lockdir
-exit $status
+rmdir "$lockdir"
+exit $ret
 
 # Local Variables:
 # mode: shell-script