depcomp: less duplication between AIX and Tru64 modes
[automake.git] / lib / depcomp
blobadda121d67aefb14b9b7f01199d9db4c6bb418df
1 #! /bin/sh
2 # depcomp - compile a program generating dependencies as side-effects
4 scriptversion=2012-10-18.11; # UTC
6 # Copyright (C) 1999-2012 Free Software Foundation, Inc.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2, or (at your option)
11 # any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # As a special exception to the GNU General Public License, if you
22 # distribute this file as part of a program that contains a
23 # configuration script generated by Autoconf, you may include it under
24 # the same distribution terms that you use for the rest of that program.
26 # Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
28 case $1 in
29 '')
30 echo "$0: No command. Try '$0 --help' for more information." 1>&2
31 exit 1;
33 -h | --h*)
34 cat <<\EOF
35 Usage: depcomp [--help] [--version] PROGRAM [ARGS]
37 Run PROGRAMS ARGS to compile a file, generating dependencies
38 as side-effects.
40 Environment variables:
41 depmode Dependency tracking mode.
42 source Source file read by 'PROGRAMS ARGS'.
43 object Object file output by 'PROGRAMS ARGS'.
44 DEPDIR directory where to store dependencies.
45 depfile Dependency file to output.
46 tmpdepfile Temporary file to use when outputting dependencies.
47 libtool Whether libtool is used (yes/no).
49 Report bugs to <bug-automake@gnu.org>.
50 EOF
51 exit $?
53 -v | --v*)
54 echo "depcomp $scriptversion"
55 exit $?
57 esac
59 # Get the directory component of the given path, and save it in the
60 # global variables '$dir'. Note that this directory component will
61 # be either empty or ending with a '/' character. This is deliberate.
62 set_dir_from ()
64 case $1 in
65 */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
66 *) dir=;;
67 esac
70 # Get the suffix-stripped basename of the given path, and save it the
71 # global variable '$base'.
72 set_base_from ()
74 base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
77 # Factor out some common post-processing of the generated depfile.
78 # Requires the auxiliary global variable '$tmpdepfile' to be set.
79 aix_post_process_depfile ()
81 # If the compiler actually managed to produce a dependency file,
82 # post-process it.
83 if test -f "$tmpdepfile"; then
84 # Each line is of the form 'foo.o: dependency.h'.
85 # Do two passes, one to just change these to
86 # $object: dependency.h
87 # and one to simply output
88 # dependency.h:
89 # which is needed to avoid the deleted-header problem.
90 { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
91 sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
92 } > "$depfile"
93 rm -f "$tmpdepfile"
94 else
95 # No dependency file was actually created by the compiler invocation.
96 # No real dependency information will be available.
97 echo "#dummy" > "$depfile"
101 # A tabulation character.
102 tab=' '
103 # A newline character.
104 nl='
106 # Character ranges might be problematic outside the C locale.
107 # These definitions help.
108 upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
109 lower=abcdefghijklmnopqrstuvwxyz
110 digits=0123456789
111 alpha=${upper}${lower}
112 alnum=${alpha}${digits}
114 if test -z "$depmode" || test -z "$source" || test -z "$object"; then
115 echo "depcomp: Variables source, object and depmode must be set" 1>&2
116 exit 1
119 # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
120 depfile=${depfile-`echo "$object" |
121 sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
122 tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
124 rm -f "$tmpdepfile"
126 # Avoid interferences from the environment.
127 gccflag= dashmflag=
129 # Some modes work just like other modes, but use different flags. We
130 # parameterize here, but still list the modes in the big case below,
131 # to make depend.m4 easier to write. Note that we *cannot* use a case
132 # here, because this file can only contain one case statement.
133 if test "$depmode" = hp; then
134 # HP compiler uses -M and no extra arg.
135 gccflag=-M
136 depmode=gcc
139 if test "$depmode" = dashXmstdout; then
140 # This is just like dashmstdout with a different argument.
141 dashmflag=-xM
142 depmode=dashmstdout
145 cygpath_u="cygpath -u -f -"
146 if test "$depmode" = msvcmsys; then
147 # This is just like msvisualcpp but w/o cygpath translation.
148 # Just convert the backslash-escaped backslashes to single forward
149 # slashes to satisfy depend.m4
150 cygpath_u='sed s,\\\\,/,g'
151 depmode=msvisualcpp
154 if test "$depmode" = msvc7msys; then
155 # This is just like msvc7 but w/o cygpath translation.
156 # Just convert the backslash-escaped backslashes to single forward
157 # slashes to satisfy depend.m4
158 cygpath_u='sed s,\\\\,/,g'
159 depmode=msvc7
162 if test "$depmode" = xlc; then
163 # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
164 gccflag=-qmakedep=gcc,-MF
165 depmode=gcc
168 case "$depmode" in
169 gcc3)
170 ## gcc 3 implements dependency tracking that does exactly what
171 ## we want. Yay! Note: for some reason libtool 1.4 doesn't like
172 ## it if -MD -MP comes after the -MF stuff. Hmm.
173 ## Unfortunately, FreeBSD c89 acceptance of flags depends upon
174 ## the command line argument order; so add the flags where they
175 ## appear in depend2.am. Note that the slowdown incurred here
176 ## affects only configure: in makefiles, %FASTDEP% shortcuts this.
177 for arg
179 case $arg in
180 -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
181 *) set fnord "$@" "$arg" ;;
182 esac
183 shift # fnord
184 shift # $arg
185 done
186 "$@"
187 stat=$?
188 if test $stat -ne 0; then
189 rm -f "$tmpdepfile"
190 exit $stat
192 mv "$tmpdepfile" "$depfile"
195 gcc)
196 ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
197 ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
198 ## (see the conditional assignment to $gccflag above).
199 ## There are various ways to get dependency output from gcc. Here's
200 ## why we pick this rather obscure method:
201 ## - Don't want to use -MD because we'd like the dependencies to end
202 ## up in a subdir. Having to rename by hand is ugly.
203 ## (We might end up doing this anyway to support other compilers.)
204 ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
205 ## -MM, not -M (despite what the docs say). Also, it might not be
206 ## supported by the other compilers which use the 'gcc' depmode.
207 ## - Using -M directly means running the compiler twice (even worse
208 ## than renaming).
209 if test -z "$gccflag"; then
210 gccflag=-MD,
212 "$@" -Wp,"$gccflag$tmpdepfile"
213 stat=$?
214 if test $stat -ne 0; then
215 rm -f "$tmpdepfile"
216 exit $stat
218 rm -f "$depfile"
219 echo "$object : \\" > "$depfile"
220 ## The second -e expression handles DOS-style file names with drive letters.
221 sed -e 's/^[^:]*: / /' \
222 -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
223 ## This next piece of magic avoids the "deleted header file" problem.
224 ## The problem is that when a header file which appears in a .P file
225 ## is deleted, the dependency causes make to die (because there is
226 ## typically no way to rebuild the header). We avoid this by adding
227 ## dummy dependencies for each header file. Too bad gcc doesn't do
228 ## this for us directly.
229 tr ' ' "$nl" < "$tmpdepfile" |
230 ## Some versions of gcc put a space before the ':'. On the theory
231 ## that the space means something, we add a space to the output as
232 ## well. hp depmode also adds that space, but also prefixes the VPATH
233 ## to the object. Take care to not repeat it in the output.
234 ## Some versions of the HPUX 10.20 sed can't process this invocation
235 ## correctly. Breaking it into two sed invocations is a workaround.
236 sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
237 | sed -e 's/$/ :/' >> "$depfile"
238 rm -f "$tmpdepfile"
242 # This case exists only to let depend.m4 do its work. It works by
243 # looking at the text of this script. This case will never be run,
244 # since it is checked for above.
245 exit 1
248 sgi)
249 if test "$libtool" = yes; then
250 "$@" "-Wp,-MDupdate,$tmpdepfile"
251 else
252 "$@" -MDupdate "$tmpdepfile"
254 stat=$?
255 if test $stat -ne 0; then
256 rm -f "$tmpdepfile"
257 exit $stat
259 rm -f "$depfile"
261 if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
262 echo "$object : \\" > "$depfile"
264 # Clip off the initial element (the dependent). Don't try to be
265 # clever and replace this with sed code, as IRIX sed won't handle
266 # lines with more than a fixed number of characters (4096 in
267 # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
268 # the IRIX cc adds comments like '#:fec' to the end of the
269 # dependency line.
270 tr ' ' "$nl" < "$tmpdepfile" \
271 | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
272 tr "$nl" ' ' >> "$depfile"
273 echo >> "$depfile"
275 # The second pass generates a dummy entry for each header file.
276 tr ' ' "$nl" < "$tmpdepfile" \
277 | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
278 >> "$depfile"
279 else
280 # The sourcefile does not contain any dependencies, so just
281 # store a dummy comment line, to avoid errors with the Makefile
282 # "include basename.Plo" scheme.
283 echo "#dummy" > "$depfile"
285 rm -f "$tmpdepfile"
288 xlc)
289 # This case exists only to let depend.m4 do its work. It works by
290 # looking at the text of this script. This case will never be run,
291 # since it is checked for above.
292 exit 1
295 aix)
296 # The C for AIX Compiler uses -M and outputs the dependencies
297 # in a .u file. In older versions, this file always lives in the
298 # current directory. Also, the AIX compiler puts '$object:' at the
299 # start of each line; $object doesn't have directory information.
300 # Version 6 uses the directory in both cases.
301 set_dir_from "$object"
302 set_base_from "$object"
303 if test "$libtool" = yes; then
304 tmpdepfile1=$dir$base.u
305 tmpdepfile2=$base.u
306 tmpdepfile3=$dir.libs/$base.u
307 "$@" -Wc,-M
308 else
309 tmpdepfile1=$dir$base.u
310 tmpdepfile2=$dir$base.u
311 tmpdepfile3=$dir$base.u
312 "$@" -M
314 stat=$?
316 if test $stat -ne 0; then
317 rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
318 exit $stat
321 for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
323 test -f "$tmpdepfile" && break
324 done
325 aix_post_process_depfile
328 icc)
329 # Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'.
330 # However on
331 # $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c
332 # ICC 7.0 will fill foo.d with something like
333 # foo.o: sub/foo.c
334 # foo.o: sub/foo.h
335 # which is wrong. We want
336 # sub/foo.o: sub/foo.c
337 # sub/foo.o: sub/foo.h
338 # sub/foo.c:
339 # sub/foo.h:
340 # ICC 7.1 will output
341 # foo.o: sub/foo.c sub/foo.h
342 # and will wrap long lines using '\':
343 # foo.o: sub/foo.c ... \
344 # sub/foo.h ... \
345 # ...
346 # tcc 0.9.26 (FIXME still under development at the moment of writing)
347 # will emit a similar output, but also prepend the continuation lines
348 # with horizontal tabulation characters.
349 "$@" -MD -MF "$tmpdepfile"
350 stat=$?
351 if test $stat -ne 0; then
352 rm -f "$tmpdepfile"
353 exit $stat
355 rm -f "$depfile"
356 # Each line is of the form 'foo.o: dependent.h',
357 # or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'.
358 # Do two passes, one to just change these to
359 # '$object: dependent.h' and one to simply 'dependent.h:'.
360 sed -e "s/^[ $tab][ $tab]*/ /" -e "s,^[^:]*:,$object :," \
361 < "$tmpdepfile" > "$depfile"
362 sed '
363 s/[ '"$tab"'][ '"$tab"']*/ /g
364 s/^ *//
365 s/ *\\*$//
366 s/^[^:]*: *//
367 /^$/d
368 /:$/d
369 s/$/ :/
370 ' < "$tmpdepfile" >> "$depfile"
371 rm -f "$tmpdepfile"
374 ## The order of this option in the case statement is important, since the
375 ## shell code in configure will try each of these formats in the order
376 ## listed in this file. A plain '-MD' option would be understood by many
377 ## compilers, so we must ensure this comes after the gcc and icc options.
378 pgcc)
379 # Portland's C compiler understands '-MD'.
380 # Will always output deps to 'file.d' where file is the root name of the
381 # source file under compilation, even if file resides in a subdirectory.
382 # The object file name does not affect the name of the '.d' file.
383 # pgcc 10.2 will output
384 # foo.o: sub/foo.c sub/foo.h
385 # and will wrap long lines using '\' :
386 # foo.o: sub/foo.c ... \
387 # sub/foo.h ... \
388 # ...
389 set_dir_from "$object"
390 # Use the source, not the object, to determine the base name, since
391 # that's sadly what pgcc will do too.
392 set_base_from "$source"
393 tmpdepfile=$base.d
395 # For projects that build the same source file twice into different object
396 # files, the pgcc approach of using the *source* file root name can cause
397 # problems in parallel builds. Use a locking strategy to avoid stomping on
398 # the same $tmpdepfile.
399 lockdir=$base.d-lock
400 trap "
401 echo '$0: caught signal, cleaning up...' >&2
402 rmdir '$lockdir'
403 exit 1
404 " 1 2 13 15
405 numtries=100
406 i=$numtries
407 while test $i -gt 0 ; do
408 # mkdir is a portable test-and-set.
409 if mkdir "$lockdir" 2>/dev/null; then
410 # This process acquired the lock.
411 "$@" -MD
412 stat=$?
413 # Release the lock.
414 rmdir "$lockdir"
415 break
416 else
417 ## If the lock is being held by a different process, wait
418 ## until the winning process is done or we timeout.
419 while test -d "$lockdir" && test $i -gt 0; do
420 sleep 1
421 i=`expr $i - 1`
422 done
424 i=`expr $i - 1`
425 done
426 trap - 1 2 13 15
427 if test $i -le 0; then
428 echo "$0: failed to acquire lock after $numtries attempts" >&2
429 echo "$0: check lockdir '$lockdir'" >&2
430 exit 1
433 if test $stat -ne 0; then
434 rm -f "$tmpdepfile"
435 exit $stat
437 rm -f "$depfile"
438 # Each line is of the form `foo.o: dependent.h',
439 # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
440 # Do two passes, one to just change these to
441 # `$object: dependent.h' and one to simply `dependent.h:'.
442 sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
443 # Some versions of the HPUX 10.20 sed can't process this invocation
444 # correctly. Breaking it into two sed invocations is a workaround.
445 sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
446 sed -e 's/$/ :/' >> "$depfile"
447 rm -f "$tmpdepfile"
450 hp2)
451 # The "hp" stanza above does not work with aCC (C++) and HP's ia64
452 # compilers, which have integrated preprocessors. The correct option
453 # to use with these is +Maked; it writes dependencies to a file named
454 # 'foo.d', which lands next to the object file, wherever that
455 # happens to be.
456 # Much of this is similar to the tru64 case; see comments there.
457 set_dir_from "$object"
458 set_base_from "$object"
459 if test "$libtool" = yes; then
460 tmpdepfile1=$dir$base.d
461 tmpdepfile2=$dir.libs/$base.d
462 "$@" -Wc,+Maked
463 else
464 tmpdepfile1=$dir$base.d
465 tmpdepfile2=$dir$base.d
466 "$@" +Maked
468 stat=$?
469 if test $stat -ne 0; then
470 rm -f "$tmpdepfile1" "$tmpdepfile2"
471 exit $stat
474 for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
476 test -f "$tmpdepfile" && break
477 done
478 if test -f "$tmpdepfile"; then
479 sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
480 # Add 'dependent.h:' lines.
481 sed -ne '2,${
482 s/^ *//
483 s/ \\*$//
484 s/$/:/
486 }' "$tmpdepfile" >> "$depfile"
487 else
488 echo "#dummy" > "$depfile"
490 rm -f "$tmpdepfile" "$tmpdepfile2"
493 tru64)
494 # The Tru64 compiler uses -MD to generate dependencies as a side
495 # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
496 # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
497 # dependencies in 'foo.d' instead, so we check for that too.
498 # Subdirectories are respected.
499 set_dir_from "$object"
500 set_base_from "$object"
502 if test "$libtool" = yes; then
503 # With Tru64 cc, shared objects can also be used to make a
504 # static library. This mechanism is used in libtool 1.4 series to
505 # handle both shared and static libraries in a single compilation.
506 # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
508 # With libtool 1.5 this exception was removed, and libtool now
509 # generates 2 separate objects for the 2 libraries. These two
510 # compilations output dependencies in $dir.libs/$base.o.d and
511 # in $dir$base.o.d. We have to check for both files, because
512 # one of the two compilations can be disabled. We should prefer
513 # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
514 # automatically cleaned when .libs/ is deleted, while ignoring
515 # the former would cause a distcleancheck panic.
516 tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
517 tmpdepfile2=$dir$base.o.d # libtool 1.5
518 tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
519 tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
520 "$@" -Wc,-MD
521 else
522 tmpdepfile1=$dir$base.o.d
523 tmpdepfile2=$dir$base.d
524 tmpdepfile3=$dir$base.d
525 tmpdepfile4=$dir$base.d
526 "$@" -MD
529 stat=$?
530 if test $stat -ne 0; then
531 rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
532 exit $stat
535 for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
537 test -f "$tmpdepfile" && break
538 done
539 # Same post-processing that is required for AIX mode.
540 aix_post_process_depfile
543 msvc7)
544 if test "$libtool" = yes; then
545 showIncludes=-Wc,-showIncludes
546 else
547 showIncludes=-showIncludes
549 "$@" $showIncludes > "$tmpdepfile"
550 stat=$?
551 grep -v '^Note: including file: ' "$tmpdepfile"
552 if test $stat -ne 0; then
553 rm -f "$tmpdepfile"
554 exit $stat
556 rm -f "$depfile"
557 echo "$object : \\" > "$depfile"
558 # The first sed program below extracts the file names and escapes
559 # backslashes for cygpath. The second sed program outputs the file
560 # name when reading, but also accumulates all include files in the
561 # hold buffer in order to output them again at the end. This only
562 # works with sed implementations that can handle large buffers.
563 sed < "$tmpdepfile" -n '
564 /^Note: including file: *\(.*\)/ {
565 s//\1/
566 s/\\/\\\\/g
568 }' | $cygpath_u | sort -u | sed -n '
569 s/ /\\ /g
570 s/\(.*\)/'"$tab"'\1 \\/p
571 s/.\(.*\) \\/\1:/
574 s/.*/'"$tab"'/
577 }' >> "$depfile"
578 rm -f "$tmpdepfile"
581 msvc7msys)
582 # This case exists only to let depend.m4 do its work. It works by
583 # looking at the text of this script. This case will never be run,
584 # since it is checked for above.
585 exit 1
588 #nosideeffect)
589 # This comment above is used by automake to tell side-effect
590 # dependency tracking mechanisms from slower ones.
592 dashmstdout)
593 # Important note: in order to support this mode, a compiler *must*
594 # always write the preprocessed file to stdout, regardless of -o.
595 "$@" || exit $?
597 # Remove the call to Libtool.
598 if test "$libtool" = yes; then
599 while test "X$1" != 'X--mode=compile'; do
600 shift
601 done
602 shift
605 # Remove '-o $object'.
606 IFS=" "
607 for arg
609 case $arg in
611 shift
613 $object)
614 shift
617 set fnord "$@" "$arg"
618 shift # fnord
619 shift # $arg
621 esac
622 done
624 test -z "$dashmflag" && dashmflag=-M
625 # Require at least two characters before searching for ':'
626 # in the target name. This is to cope with DOS-style filenames:
627 # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
628 "$@" $dashmflag |
629 sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile"
630 rm -f "$depfile"
631 cat < "$tmpdepfile" > "$depfile"
632 tr ' ' "$nl" < "$tmpdepfile" | \
633 ## Some versions of the HPUX 10.20 sed can't process this invocation
634 ## correctly. Breaking it into two sed invocations is a workaround.
635 sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
636 rm -f "$tmpdepfile"
639 dashXmstdout)
640 # This case only exists to satisfy depend.m4. It is never actually
641 # run, as this mode is specially recognized in the preamble.
642 exit 1
645 makedepend)
646 "$@" || exit $?
647 # Remove any Libtool call
648 if test "$libtool" = yes; then
649 while test "X$1" != 'X--mode=compile'; do
650 shift
651 done
652 shift
654 # X makedepend
655 shift
656 cleared=no eat=no
657 for arg
659 case $cleared in
661 set ""; shift
662 cleared=yes ;;
663 esac
664 if test $eat = yes; then
665 eat=no
666 continue
668 case "$arg" in
669 -D*|-I*)
670 set fnord "$@" "$arg"; shift ;;
671 # Strip any option that makedepend may not understand. Remove
672 # the object too, otherwise makedepend will parse it as a source file.
673 -arch)
674 eat=yes ;;
675 -*|$object)
678 set fnord "$@" "$arg"; shift ;;
679 esac
680 done
681 obj_suffix=`echo "$object" | sed 's/^.*\././'`
682 touch "$tmpdepfile"
683 ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
684 rm -f "$depfile"
685 # makedepend may prepend the VPATH from the source file name to the object.
686 # No need to regex-escape $object, excess matching of '.' is harmless.
687 sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
688 sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \
689 ## Some versions of the HPUX 10.20 sed can't process this invocation
690 ## correctly. Breaking it into two sed invocations is a workaround.
691 sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
692 rm -f "$tmpdepfile" "$tmpdepfile".bak
695 cpp)
696 # Important note: in order to support this mode, a compiler *must*
697 # always write the preprocessed file to stdout.
698 "$@" || exit $?
700 # Remove the call to Libtool.
701 if test "$libtool" = yes; then
702 while test "X$1" != 'X--mode=compile'; do
703 shift
704 done
705 shift
708 # Remove '-o $object'.
709 IFS=" "
710 for arg
712 case $arg in
714 shift
716 $object)
717 shift
720 set fnord "$@" "$arg"
721 shift # fnord
722 shift # $arg
724 esac
725 done
727 "$@" -E |
728 sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
729 -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
730 sed '$ s: \\$::' > "$tmpdepfile"
731 rm -f "$depfile"
732 echo "$object : \\" > "$depfile"
733 cat < "$tmpdepfile" >> "$depfile"
734 sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
735 rm -f "$tmpdepfile"
738 msvisualcpp)
739 # Important note: in order to support this mode, a compiler *must*
740 # always write the preprocessed file to stdout.
741 "$@" || exit $?
743 # Remove the call to Libtool.
744 if test "$libtool" = yes; then
745 while test "X$1" != 'X--mode=compile'; do
746 shift
747 done
748 shift
751 IFS=" "
752 for arg
754 case "$arg" in
756 shift
758 $object)
759 shift
761 "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
762 set fnord "$@"
763 shift
764 shift
767 set fnord "$@" "$arg"
768 shift
769 shift
771 esac
772 done
773 "$@" -E 2>/dev/null |
774 sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
775 rm -f "$depfile"
776 echo "$object : \\" > "$depfile"
777 sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
778 echo "$tab" >> "$depfile"
779 sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
780 rm -f "$tmpdepfile"
783 msvcmsys)
784 # This case exists only to let depend.m4 do its work. It works by
785 # looking at the text of this script. This case will never be run,
786 # since it is checked for above.
787 exit 1
790 none)
791 exec "$@"
795 echo "Unknown depmode $depmode" 1>&2
796 exit 1
798 esac
800 exit 0
802 # Local Variables:
803 # mode: shell-script
804 # sh-indentation: 2
805 # eval: (add-hook 'write-file-hooks 'time-stamp)
806 # time-stamp-start: "scriptversion="
807 # time-stamp-format: "%:y-%02m-%02d.%02H"
808 # time-stamp-time-zone: "UTC"
809 # time-stamp-end: "; # UTC"
810 # End: