2 # Wrapper for compilers which do not understand `-c -o'.
4 scriptversion=2005-05-14.22
6 # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009 Free Software
8 # Written by Tom Tromey <tromey@cygnus.com>.
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2, or (at your option)
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 # As a special exception to the GNU General Public License, if you
25 # distribute this file as part of a program that contains a
26 # configuration script generated by Autoconf, you may include it under
27 # the same distribution terms that you use for the rest of that program.
29 # This file is maintained in Automake, please report
30 # bugs to <bug-automake@gnu.org> or send patches to
31 # <automake-patches@gnu.org>.
35 echo "$0: No command. Try \`$0 --help' for more information." 1>&2
40 Usage: compile [--help] [--version] PROGRAM [ARGS]
42 Wrapper for compilers which do not understand `-c -o'.
43 Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
44 arguments, and rename the output as expected.
46 If you are trying to build a whole package this is not the
47 right script to run: please start by reading the file `INSTALL'.
49 Report bugs to <bug-automake@gnu.org>.
54 echo "compile $scriptversion"
65 if test -n "$eat"; then
70 # configure might choose to run compile as `compile cc -o foo foo.c'.
71 # So we strip `-o arg' only if arg is an object.
97 if test -z "$ofile" || test -z "$cfile"; then
98 # If no `-o' option was seen then we might have been invoked from a
99 # pattern rule where we don't need one. That is ok -- this is a
100 # normal compilation that the losing compiler can handle. If no
101 # `.c' file was seen then we are probably linking. That is also
106 # Name of file we expect compiler to create.
107 cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
109 # Create the lock directory.
110 # Note: use `[/.-]' here to ensure that we don't use the same name
111 # that we are using for the .o file. Also, base the name on the expected
112 # object file name, since that is what matters with a parallel build.
113 lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d
115 if mkdir "$lockdir" >/dev/null 2>&1; then
120 # FIXME: race condition here if user kills between mkdir and trap.
121 trap "rmdir '$lockdir'; exit 1" 1 2 15
127 if test -f "$cofile"; then
128 mv "$cofile" "$ofile"
129 elif test -f "${cofile}bj"; then
130 mv "${cofile}bj" "$ofile"
139 # eval: (add-hook 'write-file-hooks 'time-stamp)
140 # time-stamp-start: "scriptversion="
141 # time-stamp-format: "%:y-%02m-%02d.%02H"
142 # time-stamp-end: "$"