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