depcomp revision 010cdda0
1010cdda0Smrg#! /bin/sh
2010cdda0Smrg
3010cdda0Smrg# depcomp - compile a program generating dependencies as side-effects
4010cdda0Smrg# Copyright 1999, 2000, 2003 Free Software Foundation, Inc.
5010cdda0Smrg
6010cdda0Smrg# This program is free software; you can redistribute it and/or modify
7010cdda0Smrg# it under the terms of the GNU General Public License as published by
8010cdda0Smrg# the Free Software Foundation; either version 2, or (at your option)
9010cdda0Smrg# any later version.
10010cdda0Smrg
11010cdda0Smrg# This program is distributed in the hope that it will be useful,
12010cdda0Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
13010cdda0Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14010cdda0Smrg# GNU General Public License for more details.
15010cdda0Smrg
16010cdda0Smrg# You should have received a copy of the GNU General Public License
17010cdda0Smrg# along with this program; if not, write to the Free Software
18010cdda0Smrg# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19010cdda0Smrg# 02111-1307, USA.
20010cdda0Smrg
21010cdda0Smrg# As a special exception to the GNU General Public License, if you
22010cdda0Smrg# distribute this file as part of a program that contains a
23010cdda0Smrg# configuration script generated by Autoconf, you may include it under
24010cdda0Smrg# the same distribution terms that you use for the rest of that program.
25010cdda0Smrg
26010cdda0Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
27010cdda0Smrg
28010cdda0Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
29010cdda0Smrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
30010cdda0Smrg  exit 1
31010cdda0Smrgfi
32010cdda0Smrg# `libtool' can also be set to `yes' or `no'.
33010cdda0Smrg
34010cdda0Smrgif test -z "$depfile"; then
35010cdda0Smrg   base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'`
36010cdda0Smrg   dir=`echo "$object" | sed 's,/.*$,/,'`
37010cdda0Smrg   if test "$dir" = "$object"; then
38010cdda0Smrg      dir=
39010cdda0Smrg   fi
40010cdda0Smrg   # FIXME: should be _deps on DOS.
41010cdda0Smrg   depfile="$dir.deps/$base"
42010cdda0Smrgfi
43010cdda0Smrg
44010cdda0Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
45010cdda0Smrg
46010cdda0Smrgrm -f "$tmpdepfile"
47010cdda0Smrg
48010cdda0Smrg# Some modes work just like other modes, but use different flags.  We
49010cdda0Smrg# parameterize here, but still list the modes in the big case below,
50010cdda0Smrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
51010cdda0Smrg# here, because this file can only contain one case statement.
52010cdda0Smrgif test "$depmode" = hp; then
53010cdda0Smrg  # HP compiler uses -M and no extra arg.
54010cdda0Smrg  gccflag=-M
55010cdda0Smrg  depmode=gcc
56010cdda0Smrgfi
57010cdda0Smrg
58010cdda0Smrgif test "$depmode" = dashXmstdout; then
59010cdda0Smrg   # This is just like dashmstdout with a different argument.
60010cdda0Smrg   dashmflag=-xM
61010cdda0Smrg   depmode=dashmstdout
62010cdda0Smrgfi
63010cdda0Smrg
64010cdda0Smrgcase "$depmode" in
65010cdda0Smrggcc3)
66010cdda0Smrg## gcc 3 implements dependency tracking that does exactly what
67010cdda0Smrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
68010cdda0Smrg## it if -MD -MP comes after the -MF stuff.  Hmm.
69010cdda0Smrg  "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
70010cdda0Smrg  stat=$?
71010cdda0Smrg  if test $stat -eq 0; then :
72010cdda0Smrg  else
73010cdda0Smrg    rm -f "$tmpdepfile"
74010cdda0Smrg    exit $stat
75010cdda0Smrg  fi
76010cdda0Smrg  mv "$tmpdepfile" "$depfile"
77010cdda0Smrg  ;;
78010cdda0Smrg
79010cdda0Smrggcc)
80010cdda0Smrg## There are various ways to get dependency output from gcc.  Here's
81010cdda0Smrg## why we pick this rather obscure method:
82010cdda0Smrg## - Don't want to use -MD because we'd like the dependencies to end
83010cdda0Smrg##   up in a subdir.  Having to rename by hand is ugly.
84010cdda0Smrg##   (We might end up doing this anyway to support other compilers.)
85010cdda0Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
86010cdda0Smrg##   -MM, not -M (despite what the docs say).
87010cdda0Smrg## - Using -M directly means running the compiler twice (even worse
88010cdda0Smrg##   than renaming).
89010cdda0Smrg  if test -z "$gccflag"; then
90010cdda0Smrg    gccflag=-MD,
91010cdda0Smrg  fi
92010cdda0Smrg  "$@" -Wp,"$gccflag$tmpdepfile"
93010cdda0Smrg  stat=$?
94010cdda0Smrg  if test $stat -eq 0; then :
95010cdda0Smrg  else
96010cdda0Smrg    rm -f "$tmpdepfile"
97010cdda0Smrg    exit $stat
98010cdda0Smrg  fi
99010cdda0Smrg  rm -f "$depfile"
100010cdda0Smrg  echo "$object : \\" > "$depfile"
101010cdda0Smrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
102010cdda0Smrg## The second -e expression handles DOS-style file names with drive letters.
103010cdda0Smrg  sed -e 's/^[^:]*: / /' \
104010cdda0Smrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
105010cdda0Smrg## This next piece of magic avoids the `deleted header file' problem.
106010cdda0Smrg## The problem is that when a header file which appears in a .P file
107010cdda0Smrg## is deleted, the dependency causes make to die (because there is
108010cdda0Smrg## typically no way to rebuild the header).  We avoid this by adding
109010cdda0Smrg## dummy dependencies for each header file.  Too bad gcc doesn't do
110010cdda0Smrg## this for us directly.
111010cdda0Smrg  tr ' ' '
112010cdda0Smrg' < "$tmpdepfile" |
113010cdda0Smrg## Some versions of gcc put a space before the `:'.  On the theory
114010cdda0Smrg## that the space means something, we add a space to the output as
115010cdda0Smrg## well.
116010cdda0Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
117010cdda0Smrg## correctly.  Breaking it into two sed invocations is a workaround.
118010cdda0Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
119010cdda0Smrg  rm -f "$tmpdepfile"
120010cdda0Smrg  ;;
121010cdda0Smrg
122010cdda0Smrghp)
123010cdda0Smrg  # This case exists only to let depend.m4 do its work.  It works by
124010cdda0Smrg  # looking at the text of this script.  This case will never be run,
125010cdda0Smrg  # since it is checked for above.
126010cdda0Smrg  exit 1
127010cdda0Smrg  ;;
128010cdda0Smrg
129010cdda0Smrgsgi)
130010cdda0Smrg  if test "$libtool" = yes; then
131010cdda0Smrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
132010cdda0Smrg  else
133010cdda0Smrg    "$@" -MDupdate "$tmpdepfile"
134010cdda0Smrg  fi
135010cdda0Smrg  stat=$?
136010cdda0Smrg  if test $stat -eq 0; then :
137010cdda0Smrg  else
138010cdda0Smrg    rm -f "$tmpdepfile"
139010cdda0Smrg    exit $stat
140010cdda0Smrg  fi
141010cdda0Smrg  rm -f "$depfile"
142010cdda0Smrg
143010cdda0Smrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
144010cdda0Smrg    echo "$object : \\" > "$depfile"
145010cdda0Smrg
146010cdda0Smrg    # Clip off the initial element (the dependent).  Don't try to be
147010cdda0Smrg    # clever and replace this with sed code, as IRIX sed won't handle
148010cdda0Smrg    # lines with more than a fixed number of characters (4096 in
149010cdda0Smrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
150010cdda0Smrg    # the IRIX cc adds comments like `#:fec' to the end of the
151010cdda0Smrg    # dependency line.
152010cdda0Smrg    tr ' ' '
153010cdda0Smrg' < "$tmpdepfile" \
154010cdda0Smrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
155010cdda0Smrg    tr '
156010cdda0Smrg' ' ' >> $depfile
157010cdda0Smrg    echo >> $depfile
158010cdda0Smrg
159010cdda0Smrg    # The second pass generates a dummy entry for each header file.
160010cdda0Smrg    tr ' ' '
161010cdda0Smrg' < "$tmpdepfile" \
162010cdda0Smrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
163010cdda0Smrg   >> $depfile
164010cdda0Smrg  else
165010cdda0Smrg    # The sourcefile does not contain any dependencies, so just
166010cdda0Smrg    # store a dummy comment line, to avoid errors with the Makefile
167010cdda0Smrg    # "include basename.Plo" scheme.
168010cdda0Smrg    echo "#dummy" > "$depfile"
169010cdda0Smrg  fi
170010cdda0Smrg  rm -f "$tmpdepfile"
171010cdda0Smrg  ;;
172010cdda0Smrg
173010cdda0Smrgaix)
174010cdda0Smrg  # The C for AIX Compiler uses -M and outputs the dependencies
175010cdda0Smrg  # in a .u file.  In older versions, this file always lives in the
176010cdda0Smrg  # current directory.  Also, the AIX compiler puts `$object:' at the
177010cdda0Smrg  # start of each line; $object doesn't have directory information.
178010cdda0Smrg  # Version 6 uses the directory in both cases.
179010cdda0Smrg  stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
180010cdda0Smrg  tmpdepfile="$stripped.u"
181010cdda0Smrg  if test "$libtool" = yes; then
182010cdda0Smrg    "$@" -Wc,-M
183010cdda0Smrg  else
184010cdda0Smrg    "$@" -M
185010cdda0Smrg  fi
186010cdda0Smrg  stat=$?
187010cdda0Smrg
188010cdda0Smrg  if test -f "$tmpdepfile"; then :
189010cdda0Smrg  else
190010cdda0Smrg    stripped=`echo "$stripped" | sed 's,^.*/,,'`
191010cdda0Smrg    tmpdepfile="$stripped.u"
192010cdda0Smrg  fi
193010cdda0Smrg
194010cdda0Smrg  if test $stat -eq 0; then :
195010cdda0Smrg  else
196010cdda0Smrg    rm -f "$tmpdepfile"
197010cdda0Smrg    exit $stat
198010cdda0Smrg  fi
199010cdda0Smrg
200010cdda0Smrg  if test -f "$tmpdepfile"; then
201010cdda0Smrg    outname="$stripped.o"
202010cdda0Smrg    # Each line is of the form `foo.o: dependent.h'.
203010cdda0Smrg    # Do two passes, one to just change these to
204010cdda0Smrg    # `$object: dependent.h' and one to simply `dependent.h:'.
205010cdda0Smrg    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
206010cdda0Smrg    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
207010cdda0Smrg  else
208010cdda0Smrg    # The sourcefile does not contain any dependencies, so just
209010cdda0Smrg    # store a dummy comment line, to avoid errors with the Makefile
210010cdda0Smrg    # "include basename.Plo" scheme.
211010cdda0Smrg    echo "#dummy" > "$depfile"
212010cdda0Smrg  fi
213010cdda0Smrg  rm -f "$tmpdepfile"
214010cdda0Smrg  ;;
215010cdda0Smrg
216010cdda0Smrgicc)
217010cdda0Smrg  # Intel's C compiler understands `-MD -MF file'.  However on
218010cdda0Smrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
219010cdda0Smrg  # ICC 7.0 will fill foo.d with something like
220010cdda0Smrg  #    foo.o: sub/foo.c
221010cdda0Smrg  #    foo.o: sub/foo.h
222010cdda0Smrg  # which is wrong.  We want:
223010cdda0Smrg  #    sub/foo.o: sub/foo.c
224010cdda0Smrg  #    sub/foo.o: sub/foo.h
225010cdda0Smrg  #    sub/foo.c:
226010cdda0Smrg  #    sub/foo.h:
227010cdda0Smrg  # ICC 7.1 will output
228010cdda0Smrg  #    foo.o: sub/foo.c sub/foo.h
229010cdda0Smrg  # and will wrap long lines using \ :
230010cdda0Smrg  #    foo.o: sub/foo.c ... \
231010cdda0Smrg  #     sub/foo.h ... \
232010cdda0Smrg  #     ...
233010cdda0Smrg
234010cdda0Smrg  "$@" -MD -MF "$tmpdepfile"
235010cdda0Smrg  stat=$?
236010cdda0Smrg  if test $stat -eq 0; then :
237010cdda0Smrg  else
238010cdda0Smrg    rm -f "$tmpdepfile"
239010cdda0Smrg    exit $stat
240010cdda0Smrg  fi
241010cdda0Smrg  rm -f "$depfile"
242010cdda0Smrg  # Each line is of the form `foo.o: dependent.h',
243010cdda0Smrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
244010cdda0Smrg  # Do two passes, one to just change these to
245010cdda0Smrg  # `$object: dependent.h' and one to simply `dependent.h:'.
246010cdda0Smrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
247010cdda0Smrg  # Some versions of the HPUX 10.20 sed can't process this invocation
248010cdda0Smrg  # correctly.  Breaking it into two sed invocations is a workaround.
249010cdda0Smrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
250010cdda0Smrg    sed -e 's/$/ :/' >> "$depfile"
251010cdda0Smrg  rm -f "$tmpdepfile"
252010cdda0Smrg  ;;
253010cdda0Smrg
254010cdda0Smrgtru64)
255010cdda0Smrg   # The Tru64 compiler uses -MD to generate dependencies as a side
256010cdda0Smrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
257010cdda0Smrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
258010cdda0Smrg   # dependencies in `foo.d' instead, so we check for that too.
259010cdda0Smrg   # Subdirectories are respected.
260010cdda0Smrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
261010cdda0Smrg   test "x$dir" = "x$object" && dir=
262010cdda0Smrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
263010cdda0Smrg
264010cdda0Smrg   if test "$libtool" = yes; then
265010cdda0Smrg      tmpdepfile1="$dir.libs/$base.lo.d"
266010cdda0Smrg      tmpdepfile2="$dir.libs/$base.d"
267010cdda0Smrg      "$@" -Wc,-MD
268010cdda0Smrg   else
269010cdda0Smrg      tmpdepfile1="$dir$base.o.d"
270010cdda0Smrg      tmpdepfile2="$dir$base.d"
271010cdda0Smrg      "$@" -MD
272010cdda0Smrg   fi
273010cdda0Smrg
274010cdda0Smrg   stat=$?
275010cdda0Smrg   if test $stat -eq 0; then :
276010cdda0Smrg   else
277010cdda0Smrg      rm -f "$tmpdepfile1" "$tmpdepfile2"
278010cdda0Smrg      exit $stat
279010cdda0Smrg   fi
280010cdda0Smrg
281010cdda0Smrg   if test -f "$tmpdepfile1"; then
282010cdda0Smrg      tmpdepfile="$tmpdepfile1"
283010cdda0Smrg   else
284010cdda0Smrg      tmpdepfile="$tmpdepfile2"
285010cdda0Smrg   fi
286010cdda0Smrg   if test -f "$tmpdepfile"; then
287010cdda0Smrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
288010cdda0Smrg      # That's a tab and a space in the [].
289010cdda0Smrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
290010cdda0Smrg   else
291010cdda0Smrg      echo "#dummy" > "$depfile"
292010cdda0Smrg   fi
293010cdda0Smrg   rm -f "$tmpdepfile"
294010cdda0Smrg   ;;
295010cdda0Smrg
296010cdda0Smrg#nosideeffect)
297010cdda0Smrg  # This comment above is used by automake to tell side-effect
298010cdda0Smrg  # dependency tracking mechanisms from slower ones.
299010cdda0Smrg
300010cdda0Smrgdashmstdout)
301010cdda0Smrg  # Important note: in order to support this mode, a compiler *must*
302010cdda0Smrg  # always write the preprocessed file to stdout, regardless of -o.
303010cdda0Smrg  "$@" || exit $?
304010cdda0Smrg
305010cdda0Smrg  # Remove the call to Libtool.
306010cdda0Smrg  if test "$libtool" = yes; then
307010cdda0Smrg    while test $1 != '--mode=compile'; do
308010cdda0Smrg      shift
309010cdda0Smrg    done
310010cdda0Smrg    shift
311010cdda0Smrg  fi
312010cdda0Smrg
313010cdda0Smrg  # Remove `-o $object'.
314010cdda0Smrg  IFS=" "
315010cdda0Smrg  for arg
316010cdda0Smrg  do
317010cdda0Smrg    case $arg in
318010cdda0Smrg    -o)
319010cdda0Smrg      shift
320010cdda0Smrg      ;;
321010cdda0Smrg    $object)
322010cdda0Smrg      shift
323010cdda0Smrg      ;;
324010cdda0Smrg    *)
325010cdda0Smrg      set fnord "$@" "$arg"
326010cdda0Smrg      shift # fnord
327010cdda0Smrg      shift # $arg
328010cdda0Smrg      ;;
329010cdda0Smrg    esac
330010cdda0Smrg  done
331010cdda0Smrg
332010cdda0Smrg  test -z "$dashmflag" && dashmflag=-M
333010cdda0Smrg  # Require at least two characters before searching for `:'
334010cdda0Smrg  # in the target name.  This is to cope with DOS-style filenames:
335010cdda0Smrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
336010cdda0Smrg  "$@" $dashmflag |
337010cdda0Smrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
338010cdda0Smrg  rm -f "$depfile"
339010cdda0Smrg  cat < "$tmpdepfile" > "$depfile"
340010cdda0Smrg  tr ' ' '
341010cdda0Smrg' < "$tmpdepfile" | \
342010cdda0Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
343010cdda0Smrg## correctly.  Breaking it into two sed invocations is a workaround.
344010cdda0Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
345010cdda0Smrg  rm -f "$tmpdepfile"
346010cdda0Smrg  ;;
347010cdda0Smrg
348010cdda0SmrgdashXmstdout)
349010cdda0Smrg  # This case only exists to satisfy depend.m4.  It is never actually
350010cdda0Smrg  # run, as this mode is specially recognized in the preamble.
351010cdda0Smrg  exit 1
352010cdda0Smrg  ;;
353010cdda0Smrg
354010cdda0Smrgmakedepend)
355010cdda0Smrg  "$@" || exit $?
356010cdda0Smrg  # Remove any Libtool call
357010cdda0Smrg  if test "$libtool" = yes; then
358010cdda0Smrg    while test $1 != '--mode=compile'; do
359010cdda0Smrg      shift
360010cdda0Smrg    done
361010cdda0Smrg    shift
362010cdda0Smrg  fi
363010cdda0Smrg  # X makedepend
364010cdda0Smrg  shift
365010cdda0Smrg  cleared=no
366010cdda0Smrg  for arg in "$@"; do
367010cdda0Smrg    case $cleared in
368010cdda0Smrg    no)
369010cdda0Smrg      set ""; shift
370010cdda0Smrg      cleared=yes ;;
371010cdda0Smrg    esac
372010cdda0Smrg    case "$arg" in
373010cdda0Smrg    -D*|-I*)
374010cdda0Smrg      set fnord "$@" "$arg"; shift ;;
375010cdda0Smrg    # Strip any option that makedepend may not understand.  Remove
376010cdda0Smrg    # the object too, otherwise makedepend will parse it as a source file.
377010cdda0Smrg    -*|$object)
378010cdda0Smrg      ;;
379010cdda0Smrg    *)
380010cdda0Smrg      set fnord "$@" "$arg"; shift ;;
381010cdda0Smrg    esac
382010cdda0Smrg  done
383010cdda0Smrg  obj_suffix="`echo $object | sed 's/^.*\././'`"
384010cdda0Smrg  touch "$tmpdepfile"
385010cdda0Smrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
386010cdda0Smrg  rm -f "$depfile"
387010cdda0Smrg  cat < "$tmpdepfile" > "$depfile"
388010cdda0Smrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
389010cdda0Smrg' | \
390010cdda0Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
391010cdda0Smrg## correctly.  Breaking it into two sed invocations is a workaround.
392010cdda0Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
393010cdda0Smrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
394010cdda0Smrg  ;;
395010cdda0Smrg
396010cdda0Smrgcpp)
397010cdda0Smrg  # Important note: in order to support this mode, a compiler *must*
398010cdda0Smrg  # always write the preprocessed file to stdout.
399010cdda0Smrg  "$@" || exit $?
400010cdda0Smrg
401010cdda0Smrg  # Remove the call to Libtool.
402010cdda0Smrg  if test "$libtool" = yes; then
403010cdda0Smrg    while test $1 != '--mode=compile'; do
404010cdda0Smrg      shift
405010cdda0Smrg    done
406010cdda0Smrg    shift
407010cdda0Smrg  fi
408010cdda0Smrg
409010cdda0Smrg  # Remove `-o $object'.
410010cdda0Smrg  IFS=" "
411010cdda0Smrg  for arg
412010cdda0Smrg  do
413010cdda0Smrg    case $arg in
414010cdda0Smrg    -o)
415010cdda0Smrg      shift
416010cdda0Smrg      ;;
417010cdda0Smrg    $object)
418010cdda0Smrg      shift
419010cdda0Smrg      ;;
420010cdda0Smrg    *)
421010cdda0Smrg      set fnord "$@" "$arg"
422010cdda0Smrg      shift # fnord
423010cdda0Smrg      shift # $arg
424010cdda0Smrg      ;;
425010cdda0Smrg    esac
426010cdda0Smrg  done
427010cdda0Smrg
428010cdda0Smrg  "$@" -E |
429010cdda0Smrg    sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
430010cdda0Smrg    sed '$ s: \\$::' > "$tmpdepfile"
431010cdda0Smrg  rm -f "$depfile"
432010cdda0Smrg  echo "$object : \\" > "$depfile"
433010cdda0Smrg  cat < "$tmpdepfile" >> "$depfile"
434010cdda0Smrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
435010cdda0Smrg  rm -f "$tmpdepfile"
436010cdda0Smrg  ;;
437010cdda0Smrg
438010cdda0Smrgmsvisualcpp)
439010cdda0Smrg  # Important note: in order to support this mode, a compiler *must*
440010cdda0Smrg  # always write the preprocessed file to stdout, regardless of -o,
441010cdda0Smrg  # because we must use -o when running libtool.
442010cdda0Smrg  "$@" || exit $?
443010cdda0Smrg  IFS=" "
444010cdda0Smrg  for arg
445010cdda0Smrg  do
446010cdda0Smrg    case "$arg" in
447010cdda0Smrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
448010cdda0Smrg	set fnord "$@"
449010cdda0Smrg	shift
450010cdda0Smrg	shift
451010cdda0Smrg	;;
452010cdda0Smrg    *)
453010cdda0Smrg	set fnord "$@" "$arg"
454010cdda0Smrg	shift
455010cdda0Smrg	shift
456010cdda0Smrg	;;
457010cdda0Smrg    esac
458010cdda0Smrg  done
459010cdda0Smrg  "$@" -E |
460010cdda0Smrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
461010cdda0Smrg  rm -f "$depfile"
462010cdda0Smrg  echo "$object : \\" > "$depfile"
463010cdda0Smrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
464010cdda0Smrg  echo "	" >> "$depfile"
465010cdda0Smrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
466010cdda0Smrg  rm -f "$tmpdepfile"
467010cdda0Smrg  ;;
468010cdda0Smrg
469010cdda0Smrgnone)
470010cdda0Smrg  exec "$@"
471010cdda0Smrg  ;;
472010cdda0Smrg
473010cdda0Smrg*)
474010cdda0Smrg  echo "Unknown depmode $depmode" 1>&2
475010cdda0Smrg  exit 1
476010cdda0Smrg  ;;
477010cdda0Smrgesac
478010cdda0Smrg
479010cdda0Smrgexit 0
480