toolkit/crashreporter/google-breakpad/src/third_party/glog/compile

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/crashreporter/google-breakpad/src/third_party/glog/compile	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,99 @@
     1.4 +#! /bin/sh
     1.5 +
     1.6 +# Wrapper for compilers which do not understand `-c -o'.
     1.7 +
     1.8 +# Copyright 1999, 2000 Free Software Foundation, Inc.
     1.9 +# Written by Tom Tromey <tromey@cygnus.com>.
    1.10 +#
    1.11 +# This program is free software; you can redistribute it and/or modify
    1.12 +# it under the terms of the GNU General Public License as published by
    1.13 +# the Free Software Foundation; either version 2, or (at your option)
    1.14 +# any later version.
    1.15 +#
    1.16 +# This program is distributed in the hope that it will be useful,
    1.17 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.18 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.19 +# GNU General Public License for more details.
    1.20 +#
    1.21 +# You should have received a copy of the GNU General Public License
    1.22 +# along with this program; if not, write to the Free Software
    1.23 +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    1.24 +
    1.25 +# As a special exception to the GNU General Public License, if you
    1.26 +# distribute this file as part of a program that contains a
    1.27 +# configuration script generated by Autoconf, you may include it under
    1.28 +# the same distribution terms that you use for the rest of that program.
    1.29 +
    1.30 +# Usage:
    1.31 +# compile PROGRAM [ARGS]...
    1.32 +# `-o FOO.o' is removed from the args passed to the actual compile.
    1.33 +
    1.34 +prog=$1
    1.35 +shift
    1.36 +
    1.37 +ofile=
    1.38 +cfile=
    1.39 +args=
    1.40 +while test $# -gt 0; do
    1.41 +   case "$1" in
    1.42 +    -o)
    1.43 +       # configure might choose to run compile as `compile cc -o foo foo.c'.
    1.44 +       # So we do something ugly here.
    1.45 +       ofile=$2
    1.46 +       shift
    1.47 +       case "$ofile" in
    1.48 +	*.o | *.obj)
    1.49 +	   ;;
    1.50 +	*)
    1.51 +	   args="$args -o $ofile"
    1.52 +	   ofile=
    1.53 +	   ;;
    1.54 +       esac
    1.55 +       ;;
    1.56 +    *.c)
    1.57 +       cfile=$1
    1.58 +       args="$args $1"
    1.59 +       ;;
    1.60 +    *)
    1.61 +       args="$args $1"
    1.62 +       ;;
    1.63 +   esac
    1.64 +   shift
    1.65 +done
    1.66 +
    1.67 +if test -z "$ofile" || test -z "$cfile"; then
    1.68 +   # If no `-o' option was seen then we might have been invoked from a
    1.69 +   # pattern rule where we don't need one.  That is ok -- this is a
    1.70 +   # normal compilation that the losing compiler can handle.  If no
    1.71 +   # `.c' file was seen then we are probably linking.  That is also
    1.72 +   # ok.
    1.73 +   exec "$prog" $args
    1.74 +fi
    1.75 +
    1.76 +# Name of file we expect compiler to create.
    1.77 +cofile=`echo $cfile | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
    1.78 +
    1.79 +# Create the lock directory.
    1.80 +# Note: use `[/.-]' here to ensure that we don't use the same name
    1.81 +# that we are using for the .o file.  Also, base the name on the expected
    1.82 +# object file name, since that is what matters with a parallel build.
    1.83 +lockdir=`echo $cofile | sed -e 's|[/.-]|_|g'`.d
    1.84 +while true; do
    1.85 +   if mkdir $lockdir > /dev/null 2>&1; then
    1.86 +      break
    1.87 +   fi
    1.88 +   sleep 1
    1.89 +done
    1.90 +# FIXME: race condition here if user kills between mkdir and trap.
    1.91 +trap "rmdir $lockdir; exit 1" 1 2 15
    1.92 +
    1.93 +# Run the compile.
    1.94 +"$prog" $args
    1.95 +status=$?
    1.96 +
    1.97 +if test -f "$cofile"; then
    1.98 +   mv "$cofile" "$ofile"
    1.99 +fi
   1.100 +
   1.101 +rmdir $lockdir
   1.102 +exit $status

mercurial