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