Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | #! /bin/sh |
michael@0 | 2 | |
michael@0 | 3 | # Wrapper for compilers which do not understand `-c -o'. |
michael@0 | 4 | |
michael@0 | 5 | # Copyright 1999, 2000 Free Software Foundation, Inc. |
michael@0 | 6 | # Written by Tom Tromey <tromey@cygnus.com>. |
michael@0 | 7 | # |
michael@0 | 8 | # This program is free software; you can redistribute it and/or modify |
michael@0 | 9 | # it under the terms of the GNU General Public License as published by |
michael@0 | 10 | # the Free Software Foundation; either version 2, or (at your option) |
michael@0 | 11 | # any later version. |
michael@0 | 12 | # |
michael@0 | 13 | # This program is distributed in the hope that it will be useful, |
michael@0 | 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
michael@0 | 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
michael@0 | 16 | # GNU General Public License for more details. |
michael@0 | 17 | # |
michael@0 | 18 | # You should have received a copy of the GNU General Public License |
michael@0 | 19 | # along with this program; if not, write to the Free Software |
michael@0 | 20 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
michael@0 | 21 | |
michael@0 | 22 | # As a special exception to the GNU General Public License, if you |
michael@0 | 23 | # distribute this file as part of a program that contains a |
michael@0 | 24 | # configuration script generated by Autoconf, you may include it under |
michael@0 | 25 | # the same distribution terms that you use for the rest of that program. |
michael@0 | 26 | |
michael@0 | 27 | # Usage: |
michael@0 | 28 | # compile PROGRAM [ARGS]... |
michael@0 | 29 | # `-o FOO.o' is removed from the args passed to the actual compile. |
michael@0 | 30 | |
michael@0 | 31 | prog=$1 |
michael@0 | 32 | shift |
michael@0 | 33 | |
michael@0 | 34 | ofile= |
michael@0 | 35 | cfile= |
michael@0 | 36 | args= |
michael@0 | 37 | while test $# -gt 0; do |
michael@0 | 38 | case "$1" in |
michael@0 | 39 | -o) |
michael@0 | 40 | # configure might choose to run compile as `compile cc -o foo foo.c'. |
michael@0 | 41 | # So we do something ugly here. |
michael@0 | 42 | ofile=$2 |
michael@0 | 43 | shift |
michael@0 | 44 | case "$ofile" in |
michael@0 | 45 | *.o | *.obj) |
michael@0 | 46 | ;; |
michael@0 | 47 | *) |
michael@0 | 48 | args="$args -o $ofile" |
michael@0 | 49 | ofile= |
michael@0 | 50 | ;; |
michael@0 | 51 | esac |
michael@0 | 52 | ;; |
michael@0 | 53 | *.c) |
michael@0 | 54 | cfile=$1 |
michael@0 | 55 | args="$args $1" |
michael@0 | 56 | ;; |
michael@0 | 57 | *) |
michael@0 | 58 | args="$args $1" |
michael@0 | 59 | ;; |
michael@0 | 60 | esac |
michael@0 | 61 | shift |
michael@0 | 62 | done |
michael@0 | 63 | |
michael@0 | 64 | if test -z "$ofile" || test -z "$cfile"; then |
michael@0 | 65 | # If no `-o' option was seen then we might have been invoked from a |
michael@0 | 66 | # pattern rule where we don't need one. That is ok -- this is a |
michael@0 | 67 | # normal compilation that the losing compiler can handle. If no |
michael@0 | 68 | # `.c' file was seen then we are probably linking. That is also |
michael@0 | 69 | # ok. |
michael@0 | 70 | exec "$prog" $args |
michael@0 | 71 | fi |
michael@0 | 72 | |
michael@0 | 73 | # Name of file we expect compiler to create. |
michael@0 | 74 | cofile=`echo $cfile | sed -e 's|^.*/||' -e 's/\.c$/.o/'` |
michael@0 | 75 | |
michael@0 | 76 | # Create the lock directory. |
michael@0 | 77 | # Note: use `[/.-]' here to ensure that we don't use the same name |
michael@0 | 78 | # that we are using for the .o file. Also, base the name on the expected |
michael@0 | 79 | # object file name, since that is what matters with a parallel build. |
michael@0 | 80 | lockdir=`echo $cofile | sed -e 's|[/.-]|_|g'`.d |
michael@0 | 81 | while true; do |
michael@0 | 82 | if mkdir $lockdir > /dev/null 2>&1; then |
michael@0 | 83 | break |
michael@0 | 84 | fi |
michael@0 | 85 | sleep 1 |
michael@0 | 86 | done |
michael@0 | 87 | # FIXME: race condition here if user kills between mkdir and trap. |
michael@0 | 88 | trap "rmdir $lockdir; exit 1" 1 2 15 |
michael@0 | 89 | |
michael@0 | 90 | # Run the compile. |
michael@0 | 91 | "$prog" $args |
michael@0 | 92 | status=$? |
michael@0 | 93 | |
michael@0 | 94 | if test -f "$cofile"; then |
michael@0 | 95 | mv "$cofile" "$ofile" |
michael@0 | 96 | fi |
michael@0 | 97 | |
michael@0 | 98 | rmdir $lockdir |
michael@0 | 99 | exit $status |