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