* canon5.test (bin_PROGRAMS): New file.
[automake.git] / compile
blob7da75ce41b3d860b334c69fbfdd050db9b239f4f
1 #! /bin/sh
3 # Wrapper for compilers which do not understand `-c -o'.
5 # Copyright (C) 1999 Free Software Foundation, Inc.
6 # Written by Tom Tromey <tromey@cygnus.com>.
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.
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.
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.
22 # Usage:
23 # compile PROGRAM [ARGS]...
24 # `-o FOO.o' is removed from the args passed to the actual compile.
26 prog="$1"
27 shift
29 ofile=
30 cfile=
31 args=
32 while test $# -gt 0; do
33 case "$1" in
34 -o)
35 ofile="$2"
36 shift
38 *.c)
39 cfile="$1"
40 args="$args $1"
43 args="$args $1"
45 esac
46 shift
47 done
49 test -z "$ofile" && {
50 echo "compile: no \`-o' option seen" 1>&2
51 exit 1
54 test -z "$cfile" && {
55 echo "compile: no \`.c' file seen" 1>&2
56 exit 1
59 # Name of file we expect compiler to create.
60 cofile="`echo $cfile | sed -e 's|^.*/||' -e 's/\.c$/.o/'`"
62 # Create the lock directory.
63 lockdir="`echo $ofile | sed -e 's|/|_|g'`"
64 while true; do
65 if mkdir $lockdir > /dev/null 2>&1; then
66 break
68 sleep 1
69 done
70 # FIXME: race condition here if user kills between mkdir and trap.
71 trap "rmdir $lockdir; exit 1" 1 2 15
73 # Run the compile.
74 "$prog" $args
75 status=$?
77 if test -f "$cofile"; then
78 mv "$cofile" "$ofile"
81 rmdir $lockdir
82 exit $status