]> jfr.im git - irc/evilnet/x3.git/blame - rx/compile
Fix for crash on BURST (B) message for a channel with +L, at least one ban or except...
[irc/evilnet/x3.git] / rx / compile
CommitLineData
d76ed9a9 1#! /bin/sh
2
3# Wrapper for compilers which do not understand `-c -o'.
4
5# Copyright 1999, 2000 Free Software Foundation, Inc.
6# Written by Tom Tromey <tromey@cygnus.com>.
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2, or (at your option)
11# any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
22# Usage:
23# compile PROGRAM [ARGS]...
24# `-o FOO.o' is removed from the args passed to the actual compile.
25
26prog=$1
27shift
28
29ofile=
30cfile=
31args=
32while test $# -gt 0; do
33 case "$1" in
34 -o)
35 ofile=$2
36 shift
37 ;;
38 *.c)
39 cfile=$1
40 args="$args $1"
41 ;;
42 *)
43 args="$args $1"
44 ;;
45 esac
46 shift
47done
48
49test -z "$ofile" && {
50 echo "compile: no \`-o' option seen" 1>&2
51 exit 1
52}
53
54test -z "$cfile" && {
55 echo "compile: no \`.c' file seen" 1>&2
56 exit 1
57}
58
59# Name of file we expect compiler to create.
60cofile=`echo $cfile | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
61
62# Create the lock directory.
63lockdir=`echo $ofile | sed -e 's|/|_|g'`
64while true; do
65 if mkdir $lockdir > /dev/null 2>&1; then
66 break
67 fi
68 sleep 1
69done
70# FIXME: race condition here if user kills between mkdir and trap.
71trap "rmdir $lockdir; exit 1" 1 2 15
72
73# Run the compile.
74"$prog" $args
75status=$?
76
77if test -f "$cofile"; then
78 mv "$cofile" "$ofile"
79fi
80
81rmdir $lockdir
82exit $status