annotate compile @ 138:fc828634a951

merge
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 08 Nov 2018 14:17:14 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #! /bin/sh
111
kono
parents: 55
diff changeset
2 # Wrapper for compilers which do not understand '-c -o'.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
111
kono
parents: 55
diff changeset
4 scriptversion=2012-10-14.11; # UTC
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
111
kono
parents: 55
diff changeset
6 # Copyright (C) 1999-2014 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 # Written by Tom Tromey <tromey@cygnus.com>.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 #
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 # This program is free software; you can redistribute it and/or modify
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 # it under the terms of the GNU General Public License as published by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 # the Free Software Foundation; either version 2, or (at your option)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 # any later version.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 #
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 # This program is distributed in the hope that it will be useful,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 # GNU General Public License for more details.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 #
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 # You should have received a copy of the GNU General Public License
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 # As a special exception to the GNU General Public License, if you
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 # distribute this file as part of a program that contains a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 # configuration script generated by Autoconf, you may include it under
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 # the same distribution terms that you use for the rest of that program.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 # This file is maintained in Automake, please report
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 # bugs to <bug-automake@gnu.org> or send patches to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 # <automake-patches@gnu.org>.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30
111
kono
parents: 55
diff changeset
31 nl='
kono
parents: 55
diff changeset
32 '
kono
parents: 55
diff changeset
33
kono
parents: 55
diff changeset
34 # We need space, tab and new line, in precisely that order. Quoting is
kono
parents: 55
diff changeset
35 # there to prevent tools from complaining about whitespace usage.
kono
parents: 55
diff changeset
36 IFS=" "" $nl"
kono
parents: 55
diff changeset
37
kono
parents: 55
diff changeset
38 file_conv=
kono
parents: 55
diff changeset
39
kono
parents: 55
diff changeset
40 # func_file_conv build_file lazy
kono
parents: 55
diff changeset
41 # Convert a $build file to $host form and store it in $file
kono
parents: 55
diff changeset
42 # Currently only supports Windows hosts. If the determined conversion
kono
parents: 55
diff changeset
43 # type is listed in (the comma separated) LAZY, no conversion will
kono
parents: 55
diff changeset
44 # take place.
kono
parents: 55
diff changeset
45 func_file_conv ()
kono
parents: 55
diff changeset
46 {
kono
parents: 55
diff changeset
47 file=$1
kono
parents: 55
diff changeset
48 case $file in
kono
parents: 55
diff changeset
49 / | /[!/]*) # absolute file, and not a UNC file
kono
parents: 55
diff changeset
50 if test -z "$file_conv"; then
kono
parents: 55
diff changeset
51 # lazily determine how to convert abs files
kono
parents: 55
diff changeset
52 case `uname -s` in
kono
parents: 55
diff changeset
53 MINGW*)
kono
parents: 55
diff changeset
54 file_conv=mingw
kono
parents: 55
diff changeset
55 ;;
kono
parents: 55
diff changeset
56 CYGWIN*)
kono
parents: 55
diff changeset
57 file_conv=cygwin
kono
parents: 55
diff changeset
58 ;;
kono
parents: 55
diff changeset
59 *)
kono
parents: 55
diff changeset
60 file_conv=wine
kono
parents: 55
diff changeset
61 ;;
kono
parents: 55
diff changeset
62 esac
kono
parents: 55
diff changeset
63 fi
kono
parents: 55
diff changeset
64 case $file_conv/,$2, in
kono
parents: 55
diff changeset
65 *,$file_conv,*)
kono
parents: 55
diff changeset
66 ;;
kono
parents: 55
diff changeset
67 mingw/*)
kono
parents: 55
diff changeset
68 file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
kono
parents: 55
diff changeset
69 ;;
kono
parents: 55
diff changeset
70 cygwin/*)
kono
parents: 55
diff changeset
71 file=`cygpath -m "$file" || echo "$file"`
kono
parents: 55
diff changeset
72 ;;
kono
parents: 55
diff changeset
73 wine/*)
kono
parents: 55
diff changeset
74 file=`winepath -w "$file" || echo "$file"`
kono
parents: 55
diff changeset
75 ;;
kono
parents: 55
diff changeset
76 esac
kono
parents: 55
diff changeset
77 ;;
kono
parents: 55
diff changeset
78 esac
kono
parents: 55
diff changeset
79 }
kono
parents: 55
diff changeset
80
kono
parents: 55
diff changeset
81 # func_cl_dashL linkdir
kono
parents: 55
diff changeset
82 # Make cl look for libraries in LINKDIR
kono
parents: 55
diff changeset
83 func_cl_dashL ()
kono
parents: 55
diff changeset
84 {
kono
parents: 55
diff changeset
85 func_file_conv "$1"
kono
parents: 55
diff changeset
86 if test -z "$lib_path"; then
kono
parents: 55
diff changeset
87 lib_path=$file
kono
parents: 55
diff changeset
88 else
kono
parents: 55
diff changeset
89 lib_path="$lib_path;$file"
kono
parents: 55
diff changeset
90 fi
kono
parents: 55
diff changeset
91 linker_opts="$linker_opts -LIBPATH:$file"
kono
parents: 55
diff changeset
92 }
kono
parents: 55
diff changeset
93
kono
parents: 55
diff changeset
94 # func_cl_dashl library
kono
parents: 55
diff changeset
95 # Do a library search-path lookup for cl
kono
parents: 55
diff changeset
96 func_cl_dashl ()
kono
parents: 55
diff changeset
97 {
kono
parents: 55
diff changeset
98 lib=$1
kono
parents: 55
diff changeset
99 found=no
kono
parents: 55
diff changeset
100 save_IFS=$IFS
kono
parents: 55
diff changeset
101 IFS=';'
kono
parents: 55
diff changeset
102 for dir in $lib_path $LIB
kono
parents: 55
diff changeset
103 do
kono
parents: 55
diff changeset
104 IFS=$save_IFS
kono
parents: 55
diff changeset
105 if $shared && test -f "$dir/$lib.dll.lib"; then
kono
parents: 55
diff changeset
106 found=yes
kono
parents: 55
diff changeset
107 lib=$dir/$lib.dll.lib
kono
parents: 55
diff changeset
108 break
kono
parents: 55
diff changeset
109 fi
kono
parents: 55
diff changeset
110 if test -f "$dir/$lib.lib"; then
kono
parents: 55
diff changeset
111 found=yes
kono
parents: 55
diff changeset
112 lib=$dir/$lib.lib
kono
parents: 55
diff changeset
113 break
kono
parents: 55
diff changeset
114 fi
kono
parents: 55
diff changeset
115 if test -f "$dir/lib$lib.a"; then
kono
parents: 55
diff changeset
116 found=yes
kono
parents: 55
diff changeset
117 lib=$dir/lib$lib.a
kono
parents: 55
diff changeset
118 break
kono
parents: 55
diff changeset
119 fi
kono
parents: 55
diff changeset
120 done
kono
parents: 55
diff changeset
121 IFS=$save_IFS
kono
parents: 55
diff changeset
122
kono
parents: 55
diff changeset
123 if test "$found" != yes; then
kono
parents: 55
diff changeset
124 lib=$lib.lib
kono
parents: 55
diff changeset
125 fi
kono
parents: 55
diff changeset
126 }
kono
parents: 55
diff changeset
127
kono
parents: 55
diff changeset
128 # func_cl_wrapper cl arg...
kono
parents: 55
diff changeset
129 # Adjust compile command to suit cl
kono
parents: 55
diff changeset
130 func_cl_wrapper ()
kono
parents: 55
diff changeset
131 {
kono
parents: 55
diff changeset
132 # Assume a capable shell
kono
parents: 55
diff changeset
133 lib_path=
kono
parents: 55
diff changeset
134 shared=:
kono
parents: 55
diff changeset
135 linker_opts=
kono
parents: 55
diff changeset
136 for arg
kono
parents: 55
diff changeset
137 do
kono
parents: 55
diff changeset
138 if test -n "$eat"; then
kono
parents: 55
diff changeset
139 eat=
kono
parents: 55
diff changeset
140 else
kono
parents: 55
diff changeset
141 case $1 in
kono
parents: 55
diff changeset
142 -o)
kono
parents: 55
diff changeset
143 # configure might choose to run compile as 'compile cc -o foo foo.c'.
kono
parents: 55
diff changeset
144 eat=1
kono
parents: 55
diff changeset
145 case $2 in
kono
parents: 55
diff changeset
146 *.o | *.[oO][bB][jJ])
kono
parents: 55
diff changeset
147 func_file_conv "$2"
kono
parents: 55
diff changeset
148 set x "$@" -Fo"$file"
kono
parents: 55
diff changeset
149 shift
kono
parents: 55
diff changeset
150 ;;
kono
parents: 55
diff changeset
151 *)
kono
parents: 55
diff changeset
152 func_file_conv "$2"
kono
parents: 55
diff changeset
153 set x "$@" -Fe"$file"
kono
parents: 55
diff changeset
154 shift
kono
parents: 55
diff changeset
155 ;;
kono
parents: 55
diff changeset
156 esac
kono
parents: 55
diff changeset
157 ;;
kono
parents: 55
diff changeset
158 -I)
kono
parents: 55
diff changeset
159 eat=1
kono
parents: 55
diff changeset
160 func_file_conv "$2" mingw
kono
parents: 55
diff changeset
161 set x "$@" -I"$file"
kono
parents: 55
diff changeset
162 shift
kono
parents: 55
diff changeset
163 ;;
kono
parents: 55
diff changeset
164 -I*)
kono
parents: 55
diff changeset
165 func_file_conv "${1#-I}" mingw
kono
parents: 55
diff changeset
166 set x "$@" -I"$file"
kono
parents: 55
diff changeset
167 shift
kono
parents: 55
diff changeset
168 ;;
kono
parents: 55
diff changeset
169 -l)
kono
parents: 55
diff changeset
170 eat=1
kono
parents: 55
diff changeset
171 func_cl_dashl "$2"
kono
parents: 55
diff changeset
172 set x "$@" "$lib"
kono
parents: 55
diff changeset
173 shift
kono
parents: 55
diff changeset
174 ;;
kono
parents: 55
diff changeset
175 -l*)
kono
parents: 55
diff changeset
176 func_cl_dashl "${1#-l}"
kono
parents: 55
diff changeset
177 set x "$@" "$lib"
kono
parents: 55
diff changeset
178 shift
kono
parents: 55
diff changeset
179 ;;
kono
parents: 55
diff changeset
180 -L)
kono
parents: 55
diff changeset
181 eat=1
kono
parents: 55
diff changeset
182 func_cl_dashL "$2"
kono
parents: 55
diff changeset
183 ;;
kono
parents: 55
diff changeset
184 -L*)
kono
parents: 55
diff changeset
185 func_cl_dashL "${1#-L}"
kono
parents: 55
diff changeset
186 ;;
kono
parents: 55
diff changeset
187 -static)
kono
parents: 55
diff changeset
188 shared=false
kono
parents: 55
diff changeset
189 ;;
kono
parents: 55
diff changeset
190 -Wl,*)
kono
parents: 55
diff changeset
191 arg=${1#-Wl,}
kono
parents: 55
diff changeset
192 save_ifs="$IFS"; IFS=','
kono
parents: 55
diff changeset
193 for flag in $arg; do
kono
parents: 55
diff changeset
194 IFS="$save_ifs"
kono
parents: 55
diff changeset
195 linker_opts="$linker_opts $flag"
kono
parents: 55
diff changeset
196 done
kono
parents: 55
diff changeset
197 IFS="$save_ifs"
kono
parents: 55
diff changeset
198 ;;
kono
parents: 55
diff changeset
199 -Xlinker)
kono
parents: 55
diff changeset
200 eat=1
kono
parents: 55
diff changeset
201 linker_opts="$linker_opts $2"
kono
parents: 55
diff changeset
202 ;;
kono
parents: 55
diff changeset
203 -*)
kono
parents: 55
diff changeset
204 set x "$@" "$1"
kono
parents: 55
diff changeset
205 shift
kono
parents: 55
diff changeset
206 ;;
kono
parents: 55
diff changeset
207 *.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
kono
parents: 55
diff changeset
208 func_file_conv "$1"
kono
parents: 55
diff changeset
209 set x "$@" -Tp"$file"
kono
parents: 55
diff changeset
210 shift
kono
parents: 55
diff changeset
211 ;;
kono
parents: 55
diff changeset
212 *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
kono
parents: 55
diff changeset
213 func_file_conv "$1" mingw
kono
parents: 55
diff changeset
214 set x "$@" "$file"
kono
parents: 55
diff changeset
215 shift
kono
parents: 55
diff changeset
216 ;;
kono
parents: 55
diff changeset
217 *)
kono
parents: 55
diff changeset
218 set x "$@" "$1"
kono
parents: 55
diff changeset
219 shift
kono
parents: 55
diff changeset
220 ;;
kono
parents: 55
diff changeset
221 esac
kono
parents: 55
diff changeset
222 fi
kono
parents: 55
diff changeset
223 shift
kono
parents: 55
diff changeset
224 done
kono
parents: 55
diff changeset
225 if test -n "$linker_opts"; then
kono
parents: 55
diff changeset
226 linker_opts="-link$linker_opts"
kono
parents: 55
diff changeset
227 fi
kono
parents: 55
diff changeset
228 exec "$@" $linker_opts
kono
parents: 55
diff changeset
229 exit 1
kono
parents: 55
diff changeset
230 }
kono
parents: 55
diff changeset
231
kono
parents: 55
diff changeset
232 eat=
kono
parents: 55
diff changeset
233
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
234 case $1 in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
235 '')
111
kono
parents: 55
diff changeset
236 echo "$0: No command. Try '$0 --help' for more information." 1>&2
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
237 exit 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 ;;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 -h | --h*)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 cat <<\EOF
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
241 Usage: compile [--help] [--version] PROGRAM [ARGS]
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
242
111
kono
parents: 55
diff changeset
243 Wrapper for compilers which do not understand '-c -o'.
kono
parents: 55
diff changeset
244 Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 arguments, and rename the output as expected.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
246
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 If you are trying to build a whole package this is not the
111
kono
parents: 55
diff changeset
248 right script to run: please start by reading the file 'INSTALL'.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
249
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 Report bugs to <bug-automake@gnu.org>.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 EOF
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
252 exit $?
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 ;;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
254 -v | --v*)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
255 echo "compile $scriptversion"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
256 exit $?
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
257 ;;
111
kono
parents: 55
diff changeset
258 cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
kono
parents: 55
diff changeset
259 func_cl_wrapper "$@" # Doesn't return...
kono
parents: 55
diff changeset
260 ;;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
261 esac
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
262
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 ofile=
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
264 cfile=
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
265
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
266 for arg
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
267 do
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
268 if test -n "$eat"; then
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
269 eat=
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
270 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
271 case $1 in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 -o)
111
kono
parents: 55
diff changeset
273 # configure might choose to run compile as 'compile cc -o foo foo.c'.
kono
parents: 55
diff changeset
274 # So we strip '-o arg' only if arg is an object.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
275 eat=1
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
276 case $2 in
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
277 *.o | *.obj)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
278 ofile=$2
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 ;;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 *)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 set x "$@" -o "$2"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 shift
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
283 ;;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 esac
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
285 ;;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
286 *.c)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
287 cfile=$1
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
288 set x "$@" "$1"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
289 shift
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
290 ;;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
291 *)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
292 set x "$@" "$1"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
293 shift
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 ;;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 esac
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
296 fi
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
297 shift
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
298 done
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
299
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
300 if test -z "$ofile" || test -z "$cfile"; then
111
kono
parents: 55
diff changeset
301 # If no '-o' option was seen then we might have been invoked from a
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 # pattern rule where we don't need one. That is ok -- this is a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
303 # normal compilation that the losing compiler can handle. If no
111
kono
parents: 55
diff changeset
304 # '.c' file was seen then we are probably linking. That is also
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
305 # ok.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
306 exec "$@"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
307 fi
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
308
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
309 # Name of file we expect compiler to create.
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
310 cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
311
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
312 # Create the lock directory.
111
kono
parents: 55
diff changeset
313 # Note: use '[/\\:.-]' here to ensure that we don't use the same name
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
314 # that we are using for the .o file. Also, base the name on the expected
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
315 # object file name, since that is what matters with a parallel build.
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
316 lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
317 while true; do
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
318 if mkdir "$lockdir" >/dev/null 2>&1; then
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
319 break
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
320 fi
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
321 sleep 1
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
322 done
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
323 # FIXME: race condition here if user kills between mkdir and trap.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
324 trap "rmdir '$lockdir'; exit 1" 1 2 15
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
325
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
326 # Run the compile.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
327 "$@"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
328 ret=$?
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
329
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
330 if test -f "$cofile"; then
111
kono
parents: 55
diff changeset
331 test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
332 elif test -f "${cofile}bj"; then
111
kono
parents: 55
diff changeset
333 test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
334 fi
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
335
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
336 rmdir "$lockdir"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
337 exit $ret
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
338
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
339 # Local Variables:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
340 # mode: shell-script
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
341 # sh-indentation: 2
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
342 # eval: (add-hook 'write-file-hooks 'time-stamp)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
343 # time-stamp-start: "scriptversion="
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
344 # time-stamp-format: "%:y-%02m-%02d.%02H"
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
345 # time-stamp-time-zone: "UTC"
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
346 # time-stamp-end: "; # UTC"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
347 # End: