]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/lock-and-run.sh
Makefile.in (LLINKER): New variable.
[thirdparty/gcc.git] / gcc / lock-and-run.sh
1 #! /bin/sh
2 # Shell-based mutex using mkdir.
3
4 lockdir=$1 prog=$2; shift 2 || exit 1
5 count=0
6 # Remember when we started trying to acquire the lock.
7 touch lock-stamp.$$
8 trap 'rm -r "$lockdir" lock-stamp.$$' 0
9 until mkdir "$lockdir" 2>/dev/null; do
10 # Say something periodically so the user knows what's up.
11 if [ `expr $count % 30` = 0 ]; then
12 # Reset if the lock has been renewed.
13 if [ -n "`find \"$lockdir\" -newer lock-stamp.$$`" ]; then
14 touch lock-stamp.$$
15 count=1
16 # Steal the lock after 5 minutes.
17 elif [ $count = 300 ]; then
18 echo removing stale $lockdir >&2
19 rm -r "$lockdir"
20 else
21 echo waiting to acquire $lockdir >&2
22 fi
23 fi
24 sleep 1
25 count=`expr $count + 1`
26 done
27 echo $prog "$@"
28 $prog "$@"
29 # The trap runs on exit.