compile revision 1.1.1.1.2.2 1 1.1.1.1.2.2 bouyer #! /bin/sh
2 1.1.1.1.2.2 bouyer # Wrapper for compilers which do not understand `-c -o'.
3 1.1.1.1.2.2 bouyer
4 1.1.1.1.2.2 bouyer scriptversion=2009-10-06.20; # UTC
5 1.1.1.1.2.2 bouyer
6 1.1.1.1.2.2 bouyer # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009 Free Software
7 1.1.1.1.2.2 bouyer # Foundation, Inc.
8 1.1.1.1.2.2 bouyer # Written by Tom Tromey <tromey (at] cygnus.com>.
9 1.1.1.1.2.2 bouyer #
10 1.1.1.1.2.2 bouyer # This program is free software; you can redistribute it and/or modify
11 1.1.1.1.2.2 bouyer # it under the terms of the GNU General Public License as published by
12 1.1.1.1.2.2 bouyer # the Free Software Foundation; either version 2, or (at your option)
13 1.1.1.1.2.2 bouyer # any later version.
14 1.1.1.1.2.2 bouyer #
15 1.1.1.1.2.2 bouyer # This program is distributed in the hope that it will be useful,
16 1.1.1.1.2.2 bouyer # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 1.1.1.1.2.2 bouyer # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 1.1.1.1.2.2 bouyer # GNU General Public License for more details.
19 1.1.1.1.2.2 bouyer #
20 1.1.1.1.2.2 bouyer # You should have received a copy of the GNU General Public License
21 1.1.1.1.2.2 bouyer # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 1.1.1.1.2.2 bouyer
23 1.1.1.1.2.2 bouyer # As a special exception to the GNU General Public License, if you
24 1.1.1.1.2.2 bouyer # distribute this file as part of a program that contains a
25 1.1.1.1.2.2 bouyer # configuration script generated by Autoconf, you may include it under
26 1.1.1.1.2.2 bouyer # the same distribution terms that you use for the rest of that program.
27 1.1.1.1.2.2 bouyer
28 1.1.1.1.2.2 bouyer # This file is maintained in Automake, please report
29 1.1.1.1.2.2 bouyer # bugs to <bug-automake (at] gnu.org> or send patches to
30 1.1.1.1.2.2 bouyer # <automake-patches (at] gnu.org>.
31 1.1.1.1.2.2 bouyer
32 1.1.1.1.2.2 bouyer case $1 in
33 1.1.1.1.2.2 bouyer '')
34 1.1.1.1.2.2 bouyer echo "$0: No command. Try \`$0 --help' for more information." 1>&2
35 1.1.1.1.2.2 bouyer exit 1;
36 1.1.1.1.2.2 bouyer ;;
37 1.1.1.1.2.2 bouyer -h | --h*)
38 1.1.1.1.2.2 bouyer cat <<\EOF
39 1.1.1.1.2.2 bouyer Usage: compile [--help] [--version] PROGRAM [ARGS]
40 1.1.1.1.2.2 bouyer
41 1.1.1.1.2.2 bouyer Wrapper for compilers which do not understand `-c -o'.
42 1.1.1.1.2.2 bouyer Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
43 1.1.1.1.2.2 bouyer arguments, and rename the output as expected.
44 1.1.1.1.2.2 bouyer
45 1.1.1.1.2.2 bouyer If you are trying to build a whole package this is not the
46 1.1.1.1.2.2 bouyer right script to run: please start by reading the file `INSTALL'.
47 1.1.1.1.2.2 bouyer
48 1.1.1.1.2.2 bouyer Report bugs to <bug-automake (at] gnu.org>.
49 1.1.1.1.2.2 bouyer EOF
50 1.1.1.1.2.2 bouyer exit $?
51 1.1.1.1.2.2 bouyer ;;
52 1.1.1.1.2.2 bouyer -v | --v*)
53 1.1.1.1.2.2 bouyer echo "compile $scriptversion"
54 1.1.1.1.2.2 bouyer exit $?
55 1.1.1.1.2.2 bouyer ;;
56 1.1.1.1.2.2 bouyer esac
57 1.1.1.1.2.2 bouyer
58 1.1.1.1.2.2 bouyer ofile=
59 1.1.1.1.2.2 bouyer cfile=
60 1.1.1.1.2.2 bouyer eat=
61 1.1.1.1.2.2 bouyer
62 1.1.1.1.2.2 bouyer for arg
63 1.1.1.1.2.2 bouyer do
64 1.1.1.1.2.2 bouyer if test -n "$eat"; then
65 1.1.1.1.2.2 bouyer eat=
66 1.1.1.1.2.2 bouyer else
67 1.1.1.1.2.2 bouyer case $1 in
68 1.1.1.1.2.2 bouyer -o)
69 1.1.1.1.2.2 bouyer # configure might choose to run compile as `compile cc -o foo foo.c'.
70 1.1.1.1.2.2 bouyer # So we strip `-o arg' only if arg is an object.
71 1.1.1.1.2.2 bouyer eat=1
72 1.1.1.1.2.2 bouyer case $2 in
73 1.1.1.1.2.2 bouyer *.o | *.obj)
74 1.1.1.1.2.2 bouyer ofile=$2
75 1.1.1.1.2.2 bouyer ;;
76 1.1.1.1.2.2 bouyer *)
77 1.1.1.1.2.2 bouyer set x "$@" -o "$2"
78 1.1.1.1.2.2 bouyer shift
79 1.1.1.1.2.2 bouyer ;;
80 1.1.1.1.2.2 bouyer esac
81 1.1.1.1.2.2 bouyer ;;
82 1.1.1.1.2.2 bouyer *.c)
83 1.1.1.1.2.2 bouyer cfile=$1
84 1.1.1.1.2.2 bouyer set x "$@" "$1"
85 1.1.1.1.2.2 bouyer shift
86 1.1.1.1.2.2 bouyer ;;
87 1.1.1.1.2.2 bouyer *)
88 1.1.1.1.2.2 bouyer set x "$@" "$1"
89 1.1.1.1.2.2 bouyer shift
90 1.1.1.1.2.2 bouyer ;;
91 1.1.1.1.2.2 bouyer esac
92 1.1.1.1.2.2 bouyer fi
93 1.1.1.1.2.2 bouyer shift
94 1.1.1.1.2.2 bouyer done
95 1.1.1.1.2.2 bouyer
96 1.1.1.1.2.2 bouyer if test -z "$ofile" || test -z "$cfile"; then
97 1.1.1.1.2.2 bouyer # If no `-o' option was seen then we might have been invoked from a
98 1.1.1.1.2.2 bouyer # pattern rule where we don't need one. That is ok -- this is a
99 1.1.1.1.2.2 bouyer # normal compilation that the losing compiler can handle. If no
100 1.1.1.1.2.2 bouyer # `.c' file was seen then we are probably linking. That is also
101 1.1.1.1.2.2 bouyer # ok.
102 1.1.1.1.2.2 bouyer exec "$@"
103 1.1.1.1.2.2 bouyer fi
104 1.1.1.1.2.2 bouyer
105 1.1.1.1.2.2 bouyer # Name of file we expect compiler to create.
106 1.1.1.1.2.2 bouyer cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
107 1.1.1.1.2.2 bouyer
108 1.1.1.1.2.2 bouyer # Create the lock directory.
109 1.1.1.1.2.2 bouyer # Note: use `[/\\:.-]' here to ensure that we don't use the same name
110 1.1.1.1.2.2 bouyer # that we are using for the .o file. Also, base the name on the expected
111 1.1.1.1.2.2 bouyer # object file name, since that is what matters with a parallel build.
112 1.1.1.1.2.2 bouyer lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
113 1.1.1.1.2.2 bouyer while true; do
114 1.1.1.1.2.2 bouyer if mkdir "$lockdir" >/dev/null 2>&1; then
115 1.1.1.1.2.2 bouyer break
116 1.1.1.1.2.2 bouyer fi
117 1.1.1.1.2.2 bouyer sleep 1
118 1.1.1.1.2.2 bouyer done
119 1.1.1.1.2.2 bouyer # FIXME: race condition here if user kills between mkdir and trap.
120 1.1.1.1.2.2 bouyer trap "rmdir '$lockdir'; exit 1" 1 2 15
121 1.1.1.1.2.2 bouyer
122 1.1.1.1.2.2 bouyer # Run the compile.
123 1.1.1.1.2.2 bouyer "$@"
124 1.1.1.1.2.2 bouyer ret=$?
125 1.1.1.1.2.2 bouyer
126 1.1.1.1.2.2 bouyer if test -f "$cofile"; then
127 1.1.1.1.2.2 bouyer test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
128 1.1.1.1.2.2 bouyer elif test -f "${cofile}bj"; then
129 1.1.1.1.2.2 bouyer test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
130 1.1.1.1.2.2 bouyer fi
131 1.1.1.1.2.2 bouyer
132 1.1.1.1.2.2 bouyer rmdir "$lockdir"
133 1.1.1.1.2.2 bouyer exit $ret
134 1.1.1.1.2.2 bouyer
135 1.1.1.1.2.2 bouyer # Local Variables:
136 1.1.1.1.2.2 bouyer # mode: shell-script
137 1.1.1.1.2.2 bouyer # sh-indentation: 2
138 1.1.1.1.2.2 bouyer # eval: (add-hook 'write-file-hooks 'time-stamp)
139 1.1.1.1.2.2 bouyer # time-stamp-start: "scriptversion="
140 1.1.1.1.2.2 bouyer # time-stamp-format: "%:y-%02m-%02d.%02H"
141 1.1.1.1.2.2 bouyer # time-stamp-time-zone: "UTC"
142 1.1.1.1.2.2 bouyer # time-stamp-end: "; # UTC"
143 1.1.1.1.2.2 bouyer # End:
144 1.1.1.1.2.2 bouyer #! /bin/sh
145 1.1.1.1.2.2 bouyer # Wrapper for compilers which do not understand `-c -o'.
146 1.1.1.1.2.2 bouyer
147 1.1.1.1.2.2 bouyer scriptversion=2009-10-06.20; # UTC
148 1.1.1.1.2.2 bouyer
149 1.1.1.1.2.2 bouyer # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009 Free Software
150 1.1.1.1.2.2 bouyer # Foundation, Inc.
151 1.1.1.1.2.2 bouyer # Written by Tom Tromey <tromey (at] cygnus.com>.
152 1.1.1.1.2.2 bouyer #
153 1.1.1.1.2.2 bouyer # This program is free software; you can redistribute it and/or modify
154 1.1.1.1.2.2 bouyer # it under the terms of the GNU General Public License as published by
155 1.1.1.1.2.2 bouyer # the Free Software Foundation; either version 2, or (at your option)
156 1.1.1.1.2.2 bouyer # any later version.
157 1.1.1.1.2.2 bouyer #
158 1.1.1.1.2.2 bouyer # This program is distributed in the hope that it will be useful,
159 1.1.1.1.2.2 bouyer # but WITHOUT ANY WARRANTY; without even the implied warranty of
160 1.1.1.1.2.2 bouyer # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
161 1.1.1.1.2.2 bouyer # GNU General Public License for more details.
162 1.1.1.1.2.2 bouyer #
163 1.1.1.1.2.2 bouyer # You should have received a copy of the GNU General Public License
164 1.1.1.1.2.2 bouyer # along with this program. If not, see <http://www.gnu.org/licenses/>.
165 1.1.1.1.2.2 bouyer
166 1.1.1.1.2.2 bouyer # As a special exception to the GNU General Public License, if you
167 1.1.1.1.2.2 bouyer # distribute this file as part of a program that contains a
168 1.1.1.1.2.2 bouyer # configuration script generated by Autoconf, you may include it under
169 1.1.1.1.2.2 bouyer # the same distribution terms that you use for the rest of that program.
170 1.1.1.1.2.2 bouyer
171 1.1.1.1.2.2 bouyer # This file is maintained in Automake, please report
172 1.1.1.1.2.2 bouyer # bugs to <bug-automake (at] gnu.org> or send patches to
173 1.1.1.1.2.2 bouyer # <automake-patches (at] gnu.org>.
174 1.1.1.1.2.2 bouyer
175 1.1.1.1.2.2 bouyer case $1 in
176 1.1.1.1.2.2 bouyer '')
177 1.1.1.1.2.2 bouyer echo "$0: No command. Try \`$0 --help' for more information." 1>&2
178 1.1.1.1.2.2 bouyer exit 1;
179 1.1.1.1.2.2 bouyer ;;
180 1.1.1.1.2.2 bouyer -h | --h*)
181 1.1.1.1.2.2 bouyer cat <<\EOF
182 1.1.1.1.2.2 bouyer Usage: compile [--help] [--version] PROGRAM [ARGS]
183 1.1.1.1.2.2 bouyer
184 1.1.1.1.2.2 bouyer Wrapper for compilers which do not understand `-c -o'.
185 1.1.1.1.2.2 bouyer Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
186 1.1.1.1.2.2 bouyer arguments, and rename the output as expected.
187 1.1.1.1.2.2 bouyer
188 1.1.1.1.2.2 bouyer If you are trying to build a whole package this is not the
189 1.1.1.1.2.2 bouyer right script to run: please start by reading the file `INSTALL'.
190 1.1.1.1.2.2 bouyer
191 1.1.1.1.2.2 bouyer Report bugs to <bug-automake (at] gnu.org>.
192 1.1.1.1.2.2 bouyer EOF
193 1.1.1.1.2.2 bouyer exit $?
194 1.1.1.1.2.2 bouyer ;;
195 1.1.1.1.2.2 bouyer -v | --v*)
196 1.1.1.1.2.2 bouyer echo "compile $scriptversion"
197 1.1.1.1.2.2 bouyer exit $?
198 1.1.1.1.2.2 bouyer ;;
199 1.1.1.1.2.2 bouyer esac
200 1.1.1.1.2.2 bouyer
201 1.1.1.1.2.2 bouyer ofile=
202 1.1.1.1.2.2 bouyer cfile=
203 1.1.1.1.2.2 bouyer eat=
204 1.1.1.1.2.2 bouyer
205 1.1.1.1.2.2 bouyer for arg
206 1.1.1.1.2.2 bouyer do
207 1.1.1.1.2.2 bouyer if test -n "$eat"; then
208 1.1.1.1.2.2 bouyer eat=
209 1.1.1.1.2.2 bouyer else
210 1.1.1.1.2.2 bouyer case $1 in
211 1.1.1.1.2.2 bouyer -o)
212 1.1.1.1.2.2 bouyer # configure might choose to run compile as `compile cc -o foo foo.c'.
213 1.1.1.1.2.2 bouyer # So we strip `-o arg' only if arg is an object.
214 1.1.1.1.2.2 bouyer eat=1
215 1.1.1.1.2.2 bouyer case $2 in
216 1.1.1.1.2.2 bouyer *.o | *.obj)
217 1.1.1.1.2.2 bouyer ofile=$2
218 1.1.1.1.2.2 bouyer ;;
219 1.1.1.1.2.2 bouyer *)
220 1.1.1.1.2.2 bouyer set x "$@" -o "$2"
221 1.1.1.1.2.2 bouyer shift
222 1.1.1.1.2.2 bouyer ;;
223 1.1.1.1.2.2 bouyer esac
224 1.1.1.1.2.2 bouyer ;;
225 1.1.1.1.2.2 bouyer *.c)
226 1.1.1.1.2.2 bouyer cfile=$1
227 1.1.1.1.2.2 bouyer set x "$@" "$1"
228 1.1.1.1.2.2 bouyer shift
229 1.1.1.1.2.2 bouyer ;;
230 1.1.1.1.2.2 bouyer *)
231 1.1.1.1.2.2 bouyer set x "$@" "$1"
232 1.1.1.1.2.2 bouyer shift
233 1.1.1.1.2.2 bouyer ;;
234 1.1.1.1.2.2 bouyer esac
235 1.1.1.1.2.2 bouyer fi
236 1.1.1.1.2.2 bouyer shift
237 1.1.1.1.2.2 bouyer done
238 1.1.1.1.2.2 bouyer
239 1.1.1.1.2.2 bouyer if test -z "$ofile" || test -z "$cfile"; then
240 1.1.1.1.2.2 bouyer # If no `-o' option was seen then we might have been invoked from a
241 1.1.1.1.2.2 bouyer # pattern rule where we don't need one. That is ok -- this is a
242 1.1.1.1.2.2 bouyer # normal compilation that the losing compiler can handle. If no
243 1.1.1.1.2.2 bouyer # `.c' file was seen then we are probably linking. That is also
244 1.1.1.1.2.2 bouyer # ok.
245 1.1.1.1.2.2 bouyer exec "$@"
246 1.1.1.1.2.2 bouyer fi
247 1.1.1.1.2.2 bouyer
248 1.1.1.1.2.2 bouyer # Name of file we expect compiler to create.
249 1.1.1.1.2.2 bouyer cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
250 1.1.1.1.2.2 bouyer
251 1.1.1.1.2.2 bouyer # Create the lock directory.
252 1.1.1.1.2.2 bouyer # Note: use `[/\\:.-]' here to ensure that we don't use the same name
253 1.1.1.1.2.2 bouyer # that we are using for the .o file. Also, base the name on the expected
254 1.1.1.1.2.2 bouyer # object file name, since that is what matters with a parallel build.
255 1.1.1.1.2.2 bouyer lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
256 1.1.1.1.2.2 bouyer while true; do
257 1.1.1.1.2.2 bouyer if mkdir "$lockdir" >/dev/null 2>&1; then
258 1.1.1.1.2.2 bouyer break
259 1.1.1.1.2.2 bouyer fi
260 1.1.1.1.2.2 bouyer sleep 1
261 1.1.1.1.2.2 bouyer done
262 1.1.1.1.2.2 bouyer # FIXME: race condition here if user kills between mkdir and trap.
263 1.1.1.1.2.2 bouyer trap "rmdir '$lockdir'; exit 1" 1 2 15
264 1.1.1.1.2.2 bouyer
265 1.1.1.1.2.2 bouyer # Run the compile.
266 1.1.1.1.2.2 bouyer "$@"
267 1.1.1.1.2.2 bouyer ret=$?
268 1.1.1.1.2.2 bouyer
269 1.1.1.1.2.2 bouyer if test -f "$cofile"; then
270 1.1.1.1.2.2 bouyer test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
271 1.1.1.1.2.2 bouyer elif test -f "${cofile}bj"; then
272 1.1.1.1.2.2 bouyer test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
273 1.1.1.1.2.2 bouyer fi
274 1.1.1.1.2.2 bouyer
275 1.1.1.1.2.2 bouyer rmdir "$lockdir"
276 1.1.1.1.2.2 bouyer exit $ret
277 1.1.1.1.2.2 bouyer
278 1.1.1.1.2.2 bouyer # Local Variables:
279 1.1.1.1.2.2 bouyer # mode: shell-script
280 1.1.1.1.2.2 bouyer # sh-indentation: 2
281 1.1.1.1.2.2 bouyer # eval: (add-hook 'write-file-hooks 'time-stamp)
282 1.1.1.1.2.2 bouyer # time-stamp-start: "scriptversion="
283 1.1.1.1.2.2 bouyer # time-stamp-format: "%:y-%02m-%02d.%02H"
284 1.1.1.1.2.2 bouyer # time-stamp-time-zone: "UTC"
285 1.1.1.1.2.2 bouyer # time-stamp-end: "; # UTC"
286 1.1.1.1.2.2 bouyer # End:
287