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