2 # Wrapper for compilers which do not understand `-c -o'.
4 scriptversion=2010-08-01.07; # UTC
6 # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009, 2010 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, see <http://www.gnu.org/licenses/>.
23 # As a special exception to the GNU General Public License, if you
24 # distribute this file as part of a program that contains a
25 # configuration script generated by Autoconf, you may include it under
26 # the same distribution terms that you use for the rest of that program.
28 # This file is maintained in Automake, please report
29 # bugs to <bug-automake@gnu.org> or send patches to
30 # <automake-patches@gnu.org>.
35 # We need space, tab and new line, in precisely that order. Quoting is
36 # there to prevent tools from complaining about whitespace usage.
41 # func_file_conv build_file
42 # Convert a $build file to $host form and store it in $file
43 # Currently only supports Win32 hosts.
48 / | /[^/]*) # absolute file, and not a UNC file
49 if test -z "$file_conv"; then
50 # lazily determine how to convert abs files
65 file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
68 file=`cygpath -m "$file" || echo "$file"`
71 file=`winepath -w "$file" || echo "$file"`
78 # func_cl_wrapper cl arg...
79 # Adjust compile command to suite cl
82 # Assume a capable shell
86 if test -n "$eat"; then
91 # configure might choose to run compile as `compile cc -o foo foo.c'.
101 set x "$@" -Fe"$file"
107 func_file_conv "${1#-I}"
112 set x "$@" "${1#-l}.lib"
116 func_file_conv "${1#-L}"
117 linker_opts="$linker_opts -LIBPATH:$file"
121 save_ifs="$IFS"; IFS=','
124 linker_opts="$linker_opts $flag"
130 linker_opts="$linker_opts $2"
140 if test -n "$linker_opts"; then
141 linker_opts="-link$linker_opts"
143 exec "$@" $linker_opts
149 echo "$0: No command. Try \`$0 --help' for more information." 1>&2
154 Usage: compile [--help] [--version] PROGRAM [ARGS]
156 Wrapper for compilers which do not understand `-c -o'.
157 Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
158 arguments, and rename the output as expected.
160 If you are trying to build a whole package this is not the
161 right script to run: please start by reading the file `INSTALL'.
163 Report bugs to <bug-automake@gnu.org>.
168 echo "compile $scriptversion"
171 cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
172 func_cl_wrapper "$@" # Doesn't return...
182 if test -n "$eat"; then
187 # configure might choose to run compile as `compile cc -o foo foo.c'.
188 # So we strip `-o arg' only if arg is an object.
214 if test -z "$ofile" || test -z "$cfile"; then
215 # If no `-o' option was seen then we might have been invoked from a
216 # pattern rule where we don't need one. That is ok -- this is a
217 # normal compilation that the losing compiler can handle. If no
218 # `.c' file was seen then we are probably linking. That is also
223 # Name of file we expect compiler to create.
224 cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
226 # Create the lock directory.
227 # Note: use `[/\\:.-]' here to ensure that we don't use the same name
228 # that we are using for the .o file. Also, base the name on the expected
229 # object file name, since that is what matters with a parallel build.
230 lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
232 if mkdir "$lockdir" >/dev/null 2>&1; then
237 # FIXME: race condition here if user kills between mkdir and trap.
238 trap "rmdir '$lockdir'; exit 1" 1 2 15
244 if test -f "$cofile"; then
245 test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
246 elif test -f "${cofile}bj"; then
247 test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
256 # eval: (add-hook 'write-file-hooks 'time-stamp)
257 # time-stamp-start: "scriptversion="
258 # time-stamp-format: "%:y-%02m-%02d.%02H"
259 # time-stamp-time-zone: "UTC"
260 # time-stamp-end: "; # UTC"