depcomp revision 1.1.1.3 1 1.1 mrg #! /bin/sh
2 1.1 mrg # depcomp - compile a program generating dependencies as side-effects
3 1.1 mrg
4 1.1.1.3 mrg scriptversion=2011-12-04.11; # UTC
5 1.1 mrg
6 1.1.1.3 mrg # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
7 1.1.1.3 mrg # 2011 Free Software Foundation, Inc.
8 1.1 mrg
9 1.1 mrg # This program is free software; you can redistribute it and/or modify
10 1.1 mrg # it under the terms of the GNU General Public License as published by
11 1.1 mrg # the Free Software Foundation; either version 2, or (at your option)
12 1.1 mrg # any later version.
13 1.1 mrg
14 1.1 mrg # This program is distributed in the hope that it will be useful,
15 1.1 mrg # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 1.1 mrg # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 1.1 mrg # GNU General Public License for more details.
18 1.1 mrg
19 1.1 mrg # You should have received a copy of the GNU General Public License
20 1.1.1.2 mrg # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 1.1 mrg
22 1.1 mrg # As a special exception to the GNU General Public License, if you
23 1.1 mrg # distribute this file as part of a program that contains a
24 1.1 mrg # configuration script generated by Autoconf, you may include it under
25 1.1 mrg # the same distribution terms that you use for the rest of that program.
26 1.1 mrg
27 1.1 mrg # Originally written by Alexandre Oliva <oliva (at] dcc.unicamp.br>.
28 1.1 mrg
29 1.1 mrg case $1 in
30 1.1 mrg '')
31 1.1 mrg echo "$0: No command. Try \`$0 --help' for more information." 1>&2
32 1.1 mrg exit 1;
33 1.1 mrg ;;
34 1.1 mrg -h | --h*)
35 1.1 mrg cat <<\EOF
36 1.1 mrg Usage: depcomp [--help] [--version] PROGRAM [ARGS]
37 1.1 mrg
38 1.1 mrg Run PROGRAMS ARGS to compile a file, generating dependencies
39 1.1 mrg as side-effects.
40 1.1 mrg
41 1.1 mrg Environment variables:
42 1.1 mrg depmode Dependency tracking mode.
43 1.1 mrg source Source file read by `PROGRAMS ARGS'.
44 1.1 mrg object Object file output by `PROGRAMS ARGS'.
45 1.1 mrg DEPDIR directory where to store dependencies.
46 1.1 mrg depfile Dependency file to output.
47 1.1.1.3 mrg tmpdepfile Temporary file to use when outputting dependencies.
48 1.1 mrg libtool Whether libtool is used (yes/no).
49 1.1 mrg
50 1.1 mrg Report bugs to <bug-automake (at] gnu.org>.
51 1.1 mrg EOF
52 1.1 mrg exit $?
53 1.1 mrg ;;
54 1.1 mrg -v | --v*)
55 1.1 mrg echo "depcomp $scriptversion"
56 1.1 mrg exit $?
57 1.1 mrg ;;
58 1.1 mrg esac
59 1.1 mrg
60 1.1 mrg if test -z "$depmode" || test -z "$source" || test -z "$object"; then
61 1.1 mrg echo "depcomp: Variables source, object and depmode must be set" 1>&2
62 1.1 mrg exit 1
63 1.1 mrg fi
64 1.1 mrg
65 1.1 mrg # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
66 1.1 mrg depfile=${depfile-`echo "$object" |
67 1.1 mrg sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
68 1.1 mrg tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
69 1.1 mrg
70 1.1 mrg rm -f "$tmpdepfile"
71 1.1 mrg
72 1.1 mrg # Some modes work just like other modes, but use different flags. We
73 1.1 mrg # parameterize here, but still list the modes in the big case below,
74 1.1 mrg # to make depend.m4 easier to write. Note that we *cannot* use a case
75 1.1 mrg # here, because this file can only contain one case statement.
76 1.1 mrg if test "$depmode" = hp; then
77 1.1 mrg # HP compiler uses -M and no extra arg.
78 1.1 mrg gccflag=-M
79 1.1 mrg depmode=gcc
80 1.1 mrg fi
81 1.1 mrg
82 1.1 mrg if test "$depmode" = dashXmstdout; then
83 1.1 mrg # This is just like dashmstdout with a different argument.
84 1.1 mrg dashmflag=-xM
85 1.1 mrg depmode=dashmstdout
86 1.1 mrg fi
87 1.1 mrg
88 1.1.1.2 mrg cygpath_u="cygpath -u -f -"
89 1.1.1.2 mrg if test "$depmode" = msvcmsys; then
90 1.1.1.2 mrg # This is just like msvisualcpp but w/o cygpath translation.
91 1.1.1.2 mrg # Just convert the backslash-escaped backslashes to single forward
92 1.1.1.2 mrg # slashes to satisfy depend.m4
93 1.1.1.3 mrg cygpath_u='sed s,\\\\,/,g'
94 1.1.1.2 mrg depmode=msvisualcpp
95 1.1.1.2 mrg fi
96 1.1.1.2 mrg
97 1.1.1.3 mrg if test "$depmode" = msvc7msys; then
98 1.1.1.3 mrg # This is just like msvc7 but w/o cygpath translation.
99 1.1.1.3 mrg # Just convert the backslash-escaped backslashes to single forward
100 1.1.1.3 mrg # slashes to satisfy depend.m4
101 1.1.1.3 mrg cygpath_u='sed s,\\\\,/,g'
102 1.1.1.3 mrg depmode=msvc7
103 1.1.1.3 mrg fi
104 1.1.1.3 mrg
105 1.1 mrg case "$depmode" in
106 1.1 mrg gcc3)
107 1.1 mrg ## gcc 3 implements dependency tracking that does exactly what
108 1.1 mrg ## we want. Yay! Note: for some reason libtool 1.4 doesn't like
109 1.1 mrg ## it if -MD -MP comes after the -MF stuff. Hmm.
110 1.1.1.2 mrg ## Unfortunately, FreeBSD c89 acceptance of flags depends upon
111 1.1.1.2 mrg ## the command line argument order; so add the flags where they
112 1.1.1.2 mrg ## appear in depend2.am. Note that the slowdown incurred here
113 1.1.1.2 mrg ## affects only configure: in makefiles, %FASTDEP% shortcuts this.
114 1.1.1.2 mrg for arg
115 1.1.1.2 mrg do
116 1.1.1.2 mrg case $arg in
117 1.1.1.2 mrg -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
118 1.1.1.2 mrg *) set fnord "$@" "$arg" ;;
119 1.1.1.2 mrg esac
120 1.1.1.2 mrg shift # fnord
121 1.1.1.2 mrg shift # $arg
122 1.1.1.2 mrg done
123 1.1.1.2 mrg "$@"
124 1.1 mrg stat=$?
125 1.1 mrg if test $stat -eq 0; then :
126 1.1 mrg else
127 1.1 mrg rm -f "$tmpdepfile"
128 1.1 mrg exit $stat
129 1.1 mrg fi
130 1.1 mrg mv "$tmpdepfile" "$depfile"
131 1.1 mrg ;;
132 1.1 mrg
133 1.1 mrg gcc)
134 1.1 mrg ## There are various ways to get dependency output from gcc. Here's
135 1.1 mrg ## why we pick this rather obscure method:
136 1.1 mrg ## - Don't want to use -MD because we'd like the dependencies to end
137 1.1 mrg ## up in a subdir. Having to rename by hand is ugly.
138 1.1 mrg ## (We might end up doing this anyway to support other compilers.)
139 1.1 mrg ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
140 1.1 mrg ## -MM, not -M (despite what the docs say).
141 1.1 mrg ## - Using -M directly means running the compiler twice (even worse
142 1.1 mrg ## than renaming).
143 1.1 mrg if test -z "$gccflag"; then
144 1.1 mrg gccflag=-MD,
145 1.1 mrg fi
146 1.1 mrg "$@" -Wp,"$gccflag$tmpdepfile"
147 1.1 mrg stat=$?
148 1.1 mrg if test $stat -eq 0; then :
149 1.1 mrg else
150 1.1 mrg rm -f "$tmpdepfile"
151 1.1 mrg exit $stat
152 1.1 mrg fi
153 1.1 mrg rm -f "$depfile"
154 1.1 mrg echo "$object : \\" > "$depfile"
155 1.1 mrg alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
156 1.1 mrg ## The second -e expression handles DOS-style file names with drive letters.
157 1.1 mrg sed -e 's/^[^:]*: / /' \
158 1.1 mrg -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
159 1.1 mrg ## This next piece of magic avoids the `deleted header file' problem.
160 1.1 mrg ## The problem is that when a header file which appears in a .P file
161 1.1 mrg ## is deleted, the dependency causes make to die (because there is
162 1.1 mrg ## typically no way to rebuild the header). We avoid this by adding
163 1.1 mrg ## dummy dependencies for each header file. Too bad gcc doesn't do
164 1.1 mrg ## this for us directly.
165 1.1 mrg tr ' ' '
166 1.1 mrg ' < "$tmpdepfile" |
167 1.1 mrg ## Some versions of gcc put a space before the `:'. On the theory
168 1.1 mrg ## that the space means something, we add a space to the output as
169 1.1.1.3 mrg ## well. hp depmode also adds that space, but also prefixes the VPATH
170 1.1.1.3 mrg ## to the object. Take care to not repeat it in the output.
171 1.1 mrg ## Some versions of the HPUX 10.20 sed can't process this invocation
172 1.1 mrg ## correctly. Breaking it into two sed invocations is a workaround.
173 1.1.1.3 mrg sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
174 1.1.1.3 mrg | sed -e 's/$/ :/' >> "$depfile"
175 1.1 mrg rm -f "$tmpdepfile"
176 1.1 mrg ;;
177 1.1 mrg
178 1.1 mrg hp)
179 1.1 mrg # This case exists only to let depend.m4 do its work. It works by
180 1.1 mrg # looking at the text of this script. This case will never be run,
181 1.1 mrg # since it is checked for above.
182 1.1 mrg exit 1
183 1.1 mrg ;;
184 1.1 mrg
185 1.1 mrg sgi)
186 1.1 mrg if test "$libtool" = yes; then
187 1.1 mrg "$@" "-Wp,-MDupdate,$tmpdepfile"
188 1.1 mrg else
189 1.1 mrg "$@" -MDupdate "$tmpdepfile"
190 1.1 mrg fi
191 1.1 mrg stat=$?
192 1.1 mrg if test $stat -eq 0; then :
193 1.1 mrg else
194 1.1 mrg rm -f "$tmpdepfile"
195 1.1 mrg exit $stat
196 1.1 mrg fi
197 1.1 mrg rm -f "$depfile"
198 1.1 mrg
199 1.1 mrg if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
200 1.1 mrg echo "$object : \\" > "$depfile"
201 1.1 mrg
202 1.1 mrg # Clip off the initial element (the dependent). Don't try to be
203 1.1 mrg # clever and replace this with sed code, as IRIX sed won't handle
204 1.1 mrg # lines with more than a fixed number of characters (4096 in
205 1.1 mrg # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
206 1.1 mrg # the IRIX cc adds comments like `#:fec' to the end of the
207 1.1 mrg # dependency line.
208 1.1 mrg tr ' ' '
209 1.1 mrg ' < "$tmpdepfile" \
210 1.1 mrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
211 1.1 mrg tr '
212 1.1.1.2 mrg ' ' ' >> "$depfile"
213 1.1.1.2 mrg echo >> "$depfile"
214 1.1 mrg
215 1.1 mrg # The second pass generates a dummy entry for each header file.
216 1.1 mrg tr ' ' '
217 1.1 mrg ' < "$tmpdepfile" \
218 1.1 mrg | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
219 1.1.1.2 mrg >> "$depfile"
220 1.1 mrg else
221 1.1 mrg # The sourcefile does not contain any dependencies, so just
222 1.1 mrg # store a dummy comment line, to avoid errors with the Makefile
223 1.1 mrg # "include basename.Plo" scheme.
224 1.1 mrg echo "#dummy" > "$depfile"
225 1.1 mrg fi
226 1.1 mrg rm -f "$tmpdepfile"
227 1.1 mrg ;;
228 1.1 mrg
229 1.1 mrg aix)
230 1.1 mrg # The C for AIX Compiler uses -M and outputs the dependencies
231 1.1 mrg # in a .u file. In older versions, this file always lives in the
232 1.1 mrg # current directory. Also, the AIX compiler puts `$object:' at the
233 1.1 mrg # start of each line; $object doesn't have directory information.
234 1.1 mrg # Version 6 uses the directory in both cases.
235 1.1.1.2 mrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
236 1.1.1.2 mrg test "x$dir" = "x$object" && dir=
237 1.1.1.2 mrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
238 1.1 mrg if test "$libtool" = yes; then
239 1.1.1.2 mrg tmpdepfile1=$dir$base.u
240 1.1.1.2 mrg tmpdepfile2=$base.u
241 1.1.1.2 mrg tmpdepfile3=$dir.libs/$base.u
242 1.1 mrg "$@" -Wc,-M
243 1.1 mrg else
244 1.1.1.2 mrg tmpdepfile1=$dir$base.u
245 1.1.1.2 mrg tmpdepfile2=$dir$base.u
246 1.1.1.2 mrg tmpdepfile3=$dir$base.u
247 1.1 mrg "$@" -M
248 1.1 mrg fi
249 1.1 mrg stat=$?
250 1.1 mrg
251 1.1 mrg if test $stat -eq 0; then :
252 1.1 mrg else
253 1.1.1.2 mrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
254 1.1 mrg exit $stat
255 1.1 mrg fi
256 1.1 mrg
257 1.1.1.2 mrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
258 1.1.1.2 mrg do
259 1.1.1.2 mrg test -f "$tmpdepfile" && break
260 1.1.1.2 mrg done
261 1.1 mrg if test -f "$tmpdepfile"; then
262 1.1 mrg # Each line is of the form `foo.o: dependent.h'.
263 1.1 mrg # Do two passes, one to just change these to
264 1.1 mrg # `$object: dependent.h' and one to simply `dependent.h:'.
265 1.1.1.2 mrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
266 1.1.1.2 mrg # That's a tab and a space in the [].
267 1.1.1.2 mrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
268 1.1 mrg else
269 1.1 mrg # The sourcefile does not contain any dependencies, so just
270 1.1 mrg # store a dummy comment line, to avoid errors with the Makefile
271 1.1 mrg # "include basename.Plo" scheme.
272 1.1 mrg echo "#dummy" > "$depfile"
273 1.1 mrg fi
274 1.1 mrg rm -f "$tmpdepfile"
275 1.1 mrg ;;
276 1.1 mrg
277 1.1 mrg icc)
278 1.1 mrg # Intel's C compiler understands `-MD -MF file'. However on
279 1.1 mrg # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
280 1.1 mrg # ICC 7.0 will fill foo.d with something like
281 1.1 mrg # foo.o: sub/foo.c
282 1.1 mrg # foo.o: sub/foo.h
283 1.1 mrg # which is wrong. We want:
284 1.1 mrg # sub/foo.o: sub/foo.c
285 1.1 mrg # sub/foo.o: sub/foo.h
286 1.1 mrg # sub/foo.c:
287 1.1 mrg # sub/foo.h:
288 1.1 mrg # ICC 7.1 will output
289 1.1 mrg # foo.o: sub/foo.c sub/foo.h
290 1.1 mrg # and will wrap long lines using \ :
291 1.1 mrg # foo.o: sub/foo.c ... \
292 1.1 mrg # sub/foo.h ... \
293 1.1 mrg # ...
294 1.1 mrg
295 1.1 mrg "$@" -MD -MF "$tmpdepfile"
296 1.1 mrg stat=$?
297 1.1 mrg if test $stat -eq 0; then :
298 1.1 mrg else
299 1.1 mrg rm -f "$tmpdepfile"
300 1.1 mrg exit $stat
301 1.1 mrg fi
302 1.1 mrg rm -f "$depfile"
303 1.1 mrg # Each line is of the form `foo.o: dependent.h',
304 1.1 mrg # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
305 1.1 mrg # Do two passes, one to just change these to
306 1.1 mrg # `$object: dependent.h' and one to simply `dependent.h:'.
307 1.1 mrg sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
308 1.1 mrg # Some versions of the HPUX 10.20 sed can't process this invocation
309 1.1 mrg # correctly. Breaking it into two sed invocations is a workaround.
310 1.1 mrg sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
311 1.1 mrg sed -e 's/$/ :/' >> "$depfile"
312 1.1 mrg rm -f "$tmpdepfile"
313 1.1 mrg ;;
314 1.1 mrg
315 1.1.1.2 mrg hp2)
316 1.1.1.2 mrg # The "hp" stanza above does not work with aCC (C++) and HP's ia64
317 1.1.1.2 mrg # compilers, which have integrated preprocessors. The correct option
318 1.1.1.2 mrg # to use with these is +Maked; it writes dependencies to a file named
319 1.1.1.2 mrg # 'foo.d', which lands next to the object file, wherever that
320 1.1.1.2 mrg # happens to be.
321 1.1.1.2 mrg # Much of this is similar to the tru64 case; see comments there.
322 1.1.1.2 mrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
323 1.1.1.2 mrg test "x$dir" = "x$object" && dir=
324 1.1.1.2 mrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
325 1.1.1.2 mrg if test "$libtool" = yes; then
326 1.1.1.2 mrg tmpdepfile1=$dir$base.d
327 1.1.1.2 mrg tmpdepfile2=$dir.libs/$base.d
328 1.1.1.2 mrg "$@" -Wc,+Maked
329 1.1.1.2 mrg else
330 1.1.1.2 mrg tmpdepfile1=$dir$base.d
331 1.1.1.2 mrg tmpdepfile2=$dir$base.d
332 1.1.1.2 mrg "$@" +Maked
333 1.1.1.2 mrg fi
334 1.1.1.2 mrg stat=$?
335 1.1.1.2 mrg if test $stat -eq 0; then :
336 1.1.1.2 mrg else
337 1.1.1.2 mrg rm -f "$tmpdepfile1" "$tmpdepfile2"
338 1.1.1.2 mrg exit $stat
339 1.1.1.2 mrg fi
340 1.1.1.2 mrg
341 1.1.1.2 mrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
342 1.1.1.2 mrg do
343 1.1.1.2 mrg test -f "$tmpdepfile" && break
344 1.1.1.2 mrg done
345 1.1.1.2 mrg if test -f "$tmpdepfile"; then
346 1.1.1.2 mrg sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
347 1.1.1.2 mrg # Add `dependent.h:' lines.
348 1.1.1.2 mrg sed -ne '2,${
349 1.1.1.2 mrg s/^ *//
350 1.1.1.2 mrg s/ \\*$//
351 1.1.1.2 mrg s/$/:/
352 1.1.1.2 mrg p
353 1.1.1.2 mrg }' "$tmpdepfile" >> "$depfile"
354 1.1.1.2 mrg else
355 1.1.1.2 mrg echo "#dummy" > "$depfile"
356 1.1.1.2 mrg fi
357 1.1.1.2 mrg rm -f "$tmpdepfile" "$tmpdepfile2"
358 1.1.1.2 mrg ;;
359 1.1.1.2 mrg
360 1.1 mrg tru64)
361 1.1 mrg # The Tru64 compiler uses -MD to generate dependencies as a side
362 1.1 mrg # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
363 1.1 mrg # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
364 1.1 mrg # dependencies in `foo.d' instead, so we check for that too.
365 1.1 mrg # Subdirectories are respected.
366 1.1 mrg dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
367 1.1 mrg test "x$dir" = "x$object" && dir=
368 1.1 mrg base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
369 1.1 mrg
370 1.1 mrg if test "$libtool" = yes; then
371 1.1 mrg # With Tru64 cc, shared objects can also be used to make a
372 1.1.1.2 mrg # static library. This mechanism is used in libtool 1.4 series to
373 1.1 mrg # handle both shared and static libraries in a single compilation.
374 1.1 mrg # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
375 1.1 mrg #
376 1.1 mrg # With libtool 1.5 this exception was removed, and libtool now
377 1.1 mrg # generates 2 separate objects for the 2 libraries. These two
378 1.1.1.2 mrg # compilations output dependencies in $dir.libs/$base.o.d and
379 1.1 mrg # in $dir$base.o.d. We have to check for both files, because
380 1.1 mrg # one of the two compilations can be disabled. We should prefer
381 1.1 mrg # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
382 1.1 mrg # automatically cleaned when .libs/ is deleted, while ignoring
383 1.1 mrg # the former would cause a distcleancheck panic.
384 1.1 mrg tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
385 1.1 mrg tmpdepfile2=$dir$base.o.d # libtool 1.5
386 1.1 mrg tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
387 1.1 mrg tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
388 1.1 mrg "$@" -Wc,-MD
389 1.1 mrg else
390 1.1 mrg tmpdepfile1=$dir$base.o.d
391 1.1 mrg tmpdepfile2=$dir$base.d
392 1.1 mrg tmpdepfile3=$dir$base.d
393 1.1 mrg tmpdepfile4=$dir$base.d
394 1.1 mrg "$@" -MD
395 1.1 mrg fi
396 1.1 mrg
397 1.1 mrg stat=$?
398 1.1 mrg if test $stat -eq 0; then :
399 1.1 mrg else
400 1.1 mrg rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
401 1.1 mrg exit $stat
402 1.1 mrg fi
403 1.1 mrg
404 1.1 mrg for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
405 1.1 mrg do
406 1.1 mrg test -f "$tmpdepfile" && break
407 1.1 mrg done
408 1.1 mrg if test -f "$tmpdepfile"; then
409 1.1 mrg sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
410 1.1 mrg # That's a tab and a space in the [].
411 1.1 mrg sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
412 1.1 mrg else
413 1.1 mrg echo "#dummy" > "$depfile"
414 1.1 mrg fi
415 1.1 mrg rm -f "$tmpdepfile"
416 1.1 mrg ;;
417 1.1 mrg
418 1.1.1.3 mrg msvc7)
419 1.1.1.3 mrg if test "$libtool" = yes; then
420 1.1.1.3 mrg showIncludes=-Wc,-showIncludes
421 1.1.1.3 mrg else
422 1.1.1.3 mrg showIncludes=-showIncludes
423 1.1.1.3 mrg fi
424 1.1.1.3 mrg "$@" $showIncludes > "$tmpdepfile"
425 1.1.1.3 mrg stat=$?
426 1.1.1.3 mrg grep -v '^Note: including file: ' "$tmpdepfile"
427 1.1.1.3 mrg if test "$stat" = 0; then :
428 1.1.1.3 mrg else
429 1.1.1.3 mrg rm -f "$tmpdepfile"
430 1.1.1.3 mrg exit $stat
431 1.1.1.3 mrg fi
432 1.1.1.3 mrg rm -f "$depfile"
433 1.1.1.3 mrg echo "$object : \\" > "$depfile"
434 1.1.1.3 mrg # The first sed program below extracts the file names and escapes
435 1.1.1.3 mrg # backslashes for cygpath. The second sed program outputs the file
436 1.1.1.3 mrg # name when reading, but also accumulates all include files in the
437 1.1.1.3 mrg # hold buffer in order to output them again at the end. This only
438 1.1.1.3 mrg # works with sed implementations that can handle large buffers.
439 1.1.1.3 mrg sed < "$tmpdepfile" -n '
440 1.1.1.3 mrg /^Note: including file: *\(.*\)/ {
441 1.1.1.3 mrg s//\1/
442 1.1.1.3 mrg s/\\/\\\\/g
443 1.1.1.3 mrg p
444 1.1.1.3 mrg }' | $cygpath_u | sort -u | sed -n '
445 1.1.1.3 mrg s/ /\\ /g
446 1.1.1.3 mrg s/\(.*\)/ \1 \\/p
447 1.1.1.3 mrg s/.\(.*\) \\/\1:/
448 1.1.1.3 mrg H
449 1.1.1.3 mrg $ {
450 1.1.1.3 mrg s/.*/ /
451 1.1.1.3 mrg G
452 1.1.1.3 mrg p
453 1.1.1.3 mrg }' >> "$depfile"
454 1.1.1.3 mrg rm -f "$tmpdepfile"
455 1.1.1.3 mrg ;;
456 1.1.1.3 mrg
457 1.1.1.3 mrg msvc7msys)
458 1.1.1.3 mrg # This case exists only to let depend.m4 do its work. It works by
459 1.1.1.3 mrg # looking at the text of this script. This case will never be run,
460 1.1.1.3 mrg # since it is checked for above.
461 1.1.1.3 mrg exit 1
462 1.1.1.3 mrg ;;
463 1.1.1.3 mrg
464 1.1 mrg #nosideeffect)
465 1.1 mrg # This comment above is used by automake to tell side-effect
466 1.1 mrg # dependency tracking mechanisms from slower ones.
467 1.1 mrg
468 1.1 mrg dashmstdout)
469 1.1 mrg # Important note: in order to support this mode, a compiler *must*
470 1.1 mrg # always write the preprocessed file to stdout, regardless of -o.
471 1.1 mrg "$@" || exit $?
472 1.1 mrg
473 1.1 mrg # Remove the call to Libtool.
474 1.1 mrg if test "$libtool" = yes; then
475 1.1.1.2 mrg while test "X$1" != 'X--mode=compile'; do
476 1.1 mrg shift
477 1.1 mrg done
478 1.1 mrg shift
479 1.1 mrg fi
480 1.1 mrg
481 1.1 mrg # Remove `-o $object'.
482 1.1 mrg IFS=" "
483 1.1 mrg for arg
484 1.1 mrg do
485 1.1 mrg case $arg in
486 1.1 mrg -o)
487 1.1 mrg shift
488 1.1 mrg ;;
489 1.1 mrg $object)
490 1.1 mrg shift
491 1.1 mrg ;;
492 1.1 mrg *)
493 1.1 mrg set fnord "$@" "$arg"
494 1.1 mrg shift # fnord
495 1.1 mrg shift # $arg
496 1.1 mrg ;;
497 1.1 mrg esac
498 1.1 mrg done
499 1.1 mrg
500 1.1 mrg test -z "$dashmflag" && dashmflag=-M
501 1.1 mrg # Require at least two characters before searching for `:'
502 1.1 mrg # in the target name. This is to cope with DOS-style filenames:
503 1.1 mrg # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
504 1.1 mrg "$@" $dashmflag |
505 1.1 mrg sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
506 1.1 mrg rm -f "$depfile"
507 1.1 mrg cat < "$tmpdepfile" > "$depfile"
508 1.1 mrg tr ' ' '
509 1.1 mrg ' < "$tmpdepfile" | \
510 1.1 mrg ## Some versions of the HPUX 10.20 sed can't process this invocation
511 1.1 mrg ## correctly. Breaking it into two sed invocations is a workaround.
512 1.1 mrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
513 1.1 mrg rm -f "$tmpdepfile"
514 1.1 mrg ;;
515 1.1 mrg
516 1.1 mrg dashXmstdout)
517 1.1 mrg # This case only exists to satisfy depend.m4. It is never actually
518 1.1 mrg # run, as this mode is specially recognized in the preamble.
519 1.1 mrg exit 1
520 1.1 mrg ;;
521 1.1 mrg
522 1.1 mrg makedepend)
523 1.1 mrg "$@" || exit $?
524 1.1 mrg # Remove any Libtool call
525 1.1 mrg if test "$libtool" = yes; then
526 1.1.1.2 mrg while test "X$1" != 'X--mode=compile'; do
527 1.1 mrg shift
528 1.1 mrg done
529 1.1 mrg shift
530 1.1 mrg fi
531 1.1 mrg # X makedepend
532 1.1 mrg shift
533 1.1.1.2 mrg cleared=no eat=no
534 1.1.1.2 mrg for arg
535 1.1.1.2 mrg do
536 1.1 mrg case $cleared in
537 1.1 mrg no)
538 1.1 mrg set ""; shift
539 1.1 mrg cleared=yes ;;
540 1.1 mrg esac
541 1.1.1.2 mrg if test $eat = yes; then
542 1.1.1.2 mrg eat=no
543 1.1.1.2 mrg continue
544 1.1.1.2 mrg fi
545 1.1 mrg case "$arg" in
546 1.1 mrg -D*|-I*)
547 1.1 mrg set fnord "$@" "$arg"; shift ;;
548 1.1 mrg # Strip any option that makedepend may not understand. Remove
549 1.1 mrg # the object too, otherwise makedepend will parse it as a source file.
550 1.1.1.2 mrg -arch)
551 1.1.1.2 mrg eat=yes ;;
552 1.1 mrg -*|$object)
553 1.1 mrg ;;
554 1.1 mrg *)
555 1.1 mrg set fnord "$@" "$arg"; shift ;;
556 1.1 mrg esac
557 1.1 mrg done
558 1.1.1.2 mrg obj_suffix=`echo "$object" | sed 's/^.*\././'`
559 1.1 mrg touch "$tmpdepfile"
560 1.1 mrg ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
561 1.1 mrg rm -f "$depfile"
562 1.1.1.3 mrg # makedepend may prepend the VPATH from the source file name to the object.
563 1.1.1.3 mrg # No need to regex-escape $object, excess matching of '.' is harmless.
564 1.1.1.3 mrg sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
565 1.1 mrg sed '1,2d' "$tmpdepfile" | tr ' ' '
566 1.1 mrg ' | \
567 1.1 mrg ## Some versions of the HPUX 10.20 sed can't process this invocation
568 1.1 mrg ## correctly. Breaking it into two sed invocations is a workaround.
569 1.1 mrg sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
570 1.1 mrg rm -f "$tmpdepfile" "$tmpdepfile".bak
571 1.1 mrg ;;
572 1.1 mrg
573 1.1 mrg cpp)
574 1.1 mrg # Important note: in order to support this mode, a compiler *must*
575 1.1 mrg # always write the preprocessed file to stdout.
576 1.1 mrg "$@" || exit $?
577 1.1 mrg
578 1.1 mrg # Remove the call to Libtool.
579 1.1 mrg if test "$libtool" = yes; then
580 1.1.1.2 mrg while test "X$1" != 'X--mode=compile'; do
581 1.1 mrg shift
582 1.1 mrg done
583 1.1 mrg shift
584 1.1 mrg fi
585 1.1 mrg
586 1.1 mrg # Remove `-o $object'.
587 1.1 mrg IFS=" "
588 1.1 mrg for arg
589 1.1 mrg do
590 1.1 mrg case $arg in
591 1.1 mrg -o)
592 1.1 mrg shift
593 1.1 mrg ;;
594 1.1 mrg $object)
595 1.1 mrg shift
596 1.1 mrg ;;
597 1.1 mrg *)
598 1.1 mrg set fnord "$@" "$arg"
599 1.1 mrg shift # fnord
600 1.1 mrg shift # $arg
601 1.1 mrg ;;
602 1.1 mrg esac
603 1.1 mrg done
604 1.1 mrg
605 1.1 mrg "$@" -E |
606 1.1 mrg sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
607 1.1 mrg -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
608 1.1 mrg sed '$ s: \\$::' > "$tmpdepfile"
609 1.1 mrg rm -f "$depfile"
610 1.1 mrg echo "$object : \\" > "$depfile"
611 1.1 mrg cat < "$tmpdepfile" >> "$depfile"
612 1.1 mrg sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
613 1.1 mrg rm -f "$tmpdepfile"
614 1.1 mrg ;;
615 1.1 mrg
616 1.1 mrg msvisualcpp)
617 1.1 mrg # Important note: in order to support this mode, a compiler *must*
618 1.1.1.2 mrg # always write the preprocessed file to stdout.
619 1.1 mrg "$@" || exit $?
620 1.1.1.2 mrg
621 1.1.1.2 mrg # Remove the call to Libtool.
622 1.1.1.2 mrg if test "$libtool" = yes; then
623 1.1.1.2 mrg while test "X$1" != 'X--mode=compile'; do
624 1.1.1.2 mrg shift
625 1.1.1.2 mrg done
626 1.1.1.2 mrg shift
627 1.1.1.2 mrg fi
628 1.1.1.2 mrg
629 1.1 mrg IFS=" "
630 1.1 mrg for arg
631 1.1 mrg do
632 1.1 mrg case "$arg" in
633 1.1.1.2 mrg -o)
634 1.1.1.2 mrg shift
635 1.1.1.2 mrg ;;
636 1.1.1.2 mrg $object)
637 1.1.1.2 mrg shift
638 1.1.1.2 mrg ;;
639 1.1 mrg "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
640 1.1 mrg set fnord "$@"
641 1.1 mrg shift
642 1.1 mrg shift
643 1.1 mrg ;;
644 1.1 mrg *)
645 1.1 mrg set fnord "$@" "$arg"
646 1.1 mrg shift
647 1.1 mrg shift
648 1.1 mrg ;;
649 1.1 mrg esac
650 1.1 mrg done
651 1.1.1.2 mrg "$@" -E 2>/dev/null |
652 1.1.1.2 mrg sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
653 1.1 mrg rm -f "$depfile"
654 1.1 mrg echo "$object : \\" > "$depfile"
655 1.1.1.2 mrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
656 1.1 mrg echo " " >> "$depfile"
657 1.1.1.2 mrg sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
658 1.1 mrg rm -f "$tmpdepfile"
659 1.1 mrg ;;
660 1.1 mrg
661 1.1.1.2 mrg msvcmsys)
662 1.1.1.2 mrg # This case exists only to let depend.m4 do its work. It works by
663 1.1.1.2 mrg # looking at the text of this script. This case will never be run,
664 1.1.1.2 mrg # since it is checked for above.
665 1.1.1.2 mrg exit 1
666 1.1.1.2 mrg ;;
667 1.1.1.2 mrg
668 1.1 mrg none)
669 1.1 mrg exec "$@"
670 1.1 mrg ;;
671 1.1 mrg
672 1.1 mrg *)
673 1.1 mrg echo "Unknown depmode $depmode" 1>&2
674 1.1 mrg exit 1
675 1.1 mrg ;;
676 1.1 mrg esac
677 1.1 mrg
678 1.1 mrg exit 0
679 1.1 mrg
680 1.1 mrg # Local Variables:
681 1.1 mrg # mode: shell-script
682 1.1 mrg # sh-indentation: 2
683 1.1 mrg # eval: (add-hook 'write-file-hooks 'time-stamp)
684 1.1 mrg # time-stamp-start: "scriptversion="
685 1.1 mrg # time-stamp-format: "%:y-%02m-%02d.%02H"
686 1.1.1.2 mrg # time-stamp-time-zone: "UTC"
687 1.1.1.2 mrg # time-stamp-end: "; # UTC"
688 1.1 mrg # End:
689