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