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