depcomp revision e96acad6
1dbbd9e4bSmacallan#! /bin/sh
2dbbd9e4bSmacallan# depcomp - compile a program generating dependencies as side-effects
3dbbd9e4bSmacallan
4e96acad6Smrgscriptversion=2012-07-12.20; # UTC
5dbbd9e4bSmacallan
6e96acad6Smrg# Copyright (C) 1999-2012 Free Software Foundation, Inc.
7dbbd9e4bSmacallan
8dbbd9e4bSmacallan# This program is free software; you can redistribute it and/or modify
9dbbd9e4bSmacallan# it under the terms of the GNU General Public License as published by
10dbbd9e4bSmacallan# the Free Software Foundation; either version 2, or (at your option)
11dbbd9e4bSmacallan# any later version.
12dbbd9e4bSmacallan
13dbbd9e4bSmacallan# This program is distributed in the hope that it will be useful,
14dbbd9e4bSmacallan# but WITHOUT ANY WARRANTY; without even the implied warranty of
15dbbd9e4bSmacallan# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16dbbd9e4bSmacallan# GNU General Public License for more details.
17dbbd9e4bSmacallan
18dbbd9e4bSmacallan# You should have received a copy of the GNU General Public License
191c397cbaSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
20dbbd9e4bSmacallan
21dbbd9e4bSmacallan# As a special exception to the GNU General Public License, if you
22dbbd9e4bSmacallan# distribute this file as part of a program that contains a
23dbbd9e4bSmacallan# configuration script generated by Autoconf, you may include it under
24dbbd9e4bSmacallan# the same distribution terms that you use for the rest of that program.
25dbbd9e4bSmacallan
26dbbd9e4bSmacallan# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
27dbbd9e4bSmacallan
28dbbd9e4bSmacallancase $1 in
29dbbd9e4bSmacallan  '')
30e96acad6Smrg     echo "$0: No command.  Try '$0 --help' for more information." 1>&2
31dbbd9e4bSmacallan     exit 1;
32dbbd9e4bSmacallan     ;;
33dbbd9e4bSmacallan  -h | --h*)
34dbbd9e4bSmacallan    cat <<\EOF
35dbbd9e4bSmacallanUsage: depcomp [--help] [--version] PROGRAM [ARGS]
36dbbd9e4bSmacallan
37dbbd9e4bSmacallanRun PROGRAMS ARGS to compile a file, generating dependencies
38dbbd9e4bSmacallanas side-effects.
39dbbd9e4bSmacallan
40dbbd9e4bSmacallanEnvironment variables:
41dbbd9e4bSmacallan  depmode     Dependency tracking mode.
42e96acad6Smrg  source      Source file read by 'PROGRAMS ARGS'.
43e96acad6Smrg  object      Object file output by 'PROGRAMS ARGS'.
44dbbd9e4bSmacallan  DEPDIR      directory where to store dependencies.
45dbbd9e4bSmacallan  depfile     Dependency file to output.
46e96acad6Smrg  tmpdepfile  Temporary file to use when outputting dependencies.
47dbbd9e4bSmacallan  libtool     Whether libtool is used (yes/no).
48dbbd9e4bSmacallan
49dbbd9e4bSmacallanReport bugs to <bug-automake@gnu.org>.
50dbbd9e4bSmacallanEOF
51dbbd9e4bSmacallan    exit $?
52dbbd9e4bSmacallan    ;;
53dbbd9e4bSmacallan  -v | --v*)
54dbbd9e4bSmacallan    echo "depcomp $scriptversion"
55dbbd9e4bSmacallan    exit $?
56dbbd9e4bSmacallan    ;;
57dbbd9e4bSmacallanesac
58dbbd9e4bSmacallan
59e96acad6Smrg# A tabulation character.
60e96acad6Smrgtab='	'
61e96acad6Smrg# A newline character.
62e96acad6Smrgnl='
63e96acad6Smrg'
64e96acad6Smrg
65dbbd9e4bSmacallanif test -z "$depmode" || test -z "$source" || test -z "$object"; then
66dbbd9e4bSmacallan  echo "depcomp: Variables source, object and depmode must be set" 1>&2
67dbbd9e4bSmacallan  exit 1
68dbbd9e4bSmacallanfi
69dbbd9e4bSmacallan
70dbbd9e4bSmacallan# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
71dbbd9e4bSmacallandepfile=${depfile-`echo "$object" |
72dbbd9e4bSmacallan  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
73dbbd9e4bSmacallantmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
74dbbd9e4bSmacallan
75dbbd9e4bSmacallanrm -f "$tmpdepfile"
76dbbd9e4bSmacallan
77e96acad6Smrg# Avoid interferences from the environment.
78e96acad6Smrggccflag= dashmflag=
79e96acad6Smrg
80dbbd9e4bSmacallan# Some modes work just like other modes, but use different flags.  We
81dbbd9e4bSmacallan# parameterize here, but still list the modes in the big case below,
82dbbd9e4bSmacallan# to make depend.m4 easier to write.  Note that we *cannot* use a case
83dbbd9e4bSmacallan# here, because this file can only contain one case statement.
84dbbd9e4bSmacallanif test "$depmode" = hp; then
85dbbd9e4bSmacallan  # HP compiler uses -M and no extra arg.
86dbbd9e4bSmacallan  gccflag=-M
87dbbd9e4bSmacallan  depmode=gcc
88dbbd9e4bSmacallanfi
89dbbd9e4bSmacallan
90dbbd9e4bSmacallanif test "$depmode" = dashXmstdout; then
91dbbd9e4bSmacallan   # This is just like dashmstdout with a different argument.
92dbbd9e4bSmacallan   dashmflag=-xM
93dbbd9e4bSmacallan   depmode=dashmstdout
94dbbd9e4bSmacallanfi
95dbbd9e4bSmacallan
961c397cbaSmrgcygpath_u="cygpath -u -f -"
971c397cbaSmrgif test "$depmode" = msvcmsys; then
981c397cbaSmrg   # This is just like msvisualcpp but w/o cygpath translation.
991c397cbaSmrg   # Just convert the backslash-escaped backslashes to single forward
1001c397cbaSmrg   # slashes to satisfy depend.m4
101e96acad6Smrg   cygpath_u='sed s,\\\\,/,g'
1021c397cbaSmrg   depmode=msvisualcpp
1031c397cbaSmrgfi
1041c397cbaSmrg
105e96acad6Smrgif test "$depmode" = msvc7msys; then
106e96acad6Smrg   # This is just like msvc7 but w/o cygpath translation.
107e96acad6Smrg   # Just convert the backslash-escaped backslashes to single forward
108e96acad6Smrg   # slashes to satisfy depend.m4
109e96acad6Smrg   cygpath_u='sed s,\\\\,/,g'
110e96acad6Smrg   depmode=msvc7
111e96acad6Smrgfi
112e96acad6Smrg
113e96acad6Smrgif test "$depmode" = xlc; then
114e96acad6Smrg   # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
115e96acad6Smrg   gccflag=-qmakedep=gcc,-MF
116e96acad6Smrg   depmode=gcc
117e96acad6Smrgfi
118e96acad6Smrg
119dbbd9e4bSmacallancase "$depmode" in
120dbbd9e4bSmacallangcc3)
121dbbd9e4bSmacallan## gcc 3 implements dependency tracking that does exactly what
122dbbd9e4bSmacallan## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
123dbbd9e4bSmacallan## it if -MD -MP comes after the -MF stuff.  Hmm.
124dbbd9e4bSmacallan## Unfortunately, FreeBSD c89 acceptance of flags depends upon
125dbbd9e4bSmacallan## the command line argument order; so add the flags where they
126dbbd9e4bSmacallan## appear in depend2.am.  Note that the slowdown incurred here
127dbbd9e4bSmacallan## affects only configure: in makefiles, %FASTDEP% shortcuts this.
128dbbd9e4bSmacallan  for arg
129dbbd9e4bSmacallan  do
130dbbd9e4bSmacallan    case $arg in
131dbbd9e4bSmacallan    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
132dbbd9e4bSmacallan    *)  set fnord "$@" "$arg" ;;
133dbbd9e4bSmacallan    esac
134dbbd9e4bSmacallan    shift # fnord
135dbbd9e4bSmacallan    shift # $arg
136dbbd9e4bSmacallan  done
137dbbd9e4bSmacallan  "$@"
138dbbd9e4bSmacallan  stat=$?
139dbbd9e4bSmacallan  if test $stat -eq 0; then :
140dbbd9e4bSmacallan  else
141dbbd9e4bSmacallan    rm -f "$tmpdepfile"
142dbbd9e4bSmacallan    exit $stat
143dbbd9e4bSmacallan  fi
144dbbd9e4bSmacallan  mv "$tmpdepfile" "$depfile"
145dbbd9e4bSmacallan  ;;
146dbbd9e4bSmacallan
147dbbd9e4bSmacallangcc)
148e96acad6Smrg## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
149e96acad6Smrg## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
150e96acad6Smrg## (see the conditional assignment to $gccflag above).
151dbbd9e4bSmacallan## There are various ways to get dependency output from gcc.  Here's
152dbbd9e4bSmacallan## why we pick this rather obscure method:
153dbbd9e4bSmacallan## - Don't want to use -MD because we'd like the dependencies to end
154dbbd9e4bSmacallan##   up in a subdir.  Having to rename by hand is ugly.
155dbbd9e4bSmacallan##   (We might end up doing this anyway to support other compilers.)
156dbbd9e4bSmacallan## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
157e96acad6Smrg##   -MM, not -M (despite what the docs say).  Also, it might not be
158e96acad6Smrg##   supported by the other compilers which use the 'gcc' depmode.
159dbbd9e4bSmacallan## - Using -M directly means running the compiler twice (even worse
160dbbd9e4bSmacallan##   than renaming).
161dbbd9e4bSmacallan  if test -z "$gccflag"; then
162dbbd9e4bSmacallan    gccflag=-MD,
163dbbd9e4bSmacallan  fi
164dbbd9e4bSmacallan  "$@" -Wp,"$gccflag$tmpdepfile"
165dbbd9e4bSmacallan  stat=$?
166dbbd9e4bSmacallan  if test $stat -eq 0; then :
167dbbd9e4bSmacallan  else
168dbbd9e4bSmacallan    rm -f "$tmpdepfile"
169dbbd9e4bSmacallan    exit $stat
170dbbd9e4bSmacallan  fi
171dbbd9e4bSmacallan  rm -f "$depfile"
172dbbd9e4bSmacallan  echo "$object : \\" > "$depfile"
173dbbd9e4bSmacallan  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
174dbbd9e4bSmacallan## The second -e expression handles DOS-style file names with drive letters.
175dbbd9e4bSmacallan  sed -e 's/^[^:]*: / /' \
176dbbd9e4bSmacallan      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
177e96acad6Smrg## This next piece of magic avoids the "deleted header file" problem.
178dbbd9e4bSmacallan## The problem is that when a header file which appears in a .P file
179dbbd9e4bSmacallan## is deleted, the dependency causes make to die (because there is
180dbbd9e4bSmacallan## typically no way to rebuild the header).  We avoid this by adding
181dbbd9e4bSmacallan## dummy dependencies for each header file.  Too bad gcc doesn't do
182dbbd9e4bSmacallan## this for us directly.
183e96acad6Smrg  tr ' ' "$nl" < "$tmpdepfile" |
184e96acad6Smrg## Some versions of gcc put a space before the ':'.  On the theory
185dbbd9e4bSmacallan## that the space means something, we add a space to the output as
186e96acad6Smrg## well.  hp depmode also adds that space, but also prefixes the VPATH
187e96acad6Smrg## to the object.  Take care to not repeat it in the output.
188dbbd9e4bSmacallan## Some versions of the HPUX 10.20 sed can't process this invocation
189dbbd9e4bSmacallan## correctly.  Breaking it into two sed invocations is a workaround.
190e96acad6Smrg    sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
191e96acad6Smrg      | sed -e 's/$/ :/' >> "$depfile"
192dbbd9e4bSmacallan  rm -f "$tmpdepfile"
193dbbd9e4bSmacallan  ;;
194dbbd9e4bSmacallan
195dbbd9e4bSmacallanhp)
196dbbd9e4bSmacallan  # This case exists only to let depend.m4 do its work.  It works by
197dbbd9e4bSmacallan  # looking at the text of this script.  This case will never be run,
198dbbd9e4bSmacallan  # since it is checked for above.
199dbbd9e4bSmacallan  exit 1
200dbbd9e4bSmacallan  ;;
201dbbd9e4bSmacallan
202dbbd9e4bSmacallansgi)
203dbbd9e4bSmacallan  if test "$libtool" = yes; then
204dbbd9e4bSmacallan    "$@" "-Wp,-MDupdate,$tmpdepfile"
205dbbd9e4bSmacallan  else
206dbbd9e4bSmacallan    "$@" -MDupdate "$tmpdepfile"
207dbbd9e4bSmacallan  fi
208dbbd9e4bSmacallan  stat=$?
209dbbd9e4bSmacallan  if test $stat -eq 0; then :
210dbbd9e4bSmacallan  else
211dbbd9e4bSmacallan    rm -f "$tmpdepfile"
212dbbd9e4bSmacallan    exit $stat
213dbbd9e4bSmacallan  fi
214dbbd9e4bSmacallan  rm -f "$depfile"
215dbbd9e4bSmacallan
216dbbd9e4bSmacallan  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
217dbbd9e4bSmacallan    echo "$object : \\" > "$depfile"
218dbbd9e4bSmacallan
219dbbd9e4bSmacallan    # Clip off the initial element (the dependent).  Don't try to be
220dbbd9e4bSmacallan    # clever and replace this with sed code, as IRIX sed won't handle
221dbbd9e4bSmacallan    # lines with more than a fixed number of characters (4096 in
222dbbd9e4bSmacallan    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
223e96acad6Smrg    # the IRIX cc adds comments like '#:fec' to the end of the
224dbbd9e4bSmacallan    # dependency line.
225e96acad6Smrg    tr ' ' "$nl" < "$tmpdepfile" \
226dbbd9e4bSmacallan    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
227e96acad6Smrg    tr "$nl" ' ' >> "$depfile"
2281c397cbaSmrg    echo >> "$depfile"
229dbbd9e4bSmacallan
230dbbd9e4bSmacallan    # The second pass generates a dummy entry for each header file.
231e96acad6Smrg    tr ' ' "$nl" < "$tmpdepfile" \
232dbbd9e4bSmacallan   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
2331c397cbaSmrg   >> "$depfile"
234dbbd9e4bSmacallan  else
235dbbd9e4bSmacallan    # The sourcefile does not contain any dependencies, so just
236dbbd9e4bSmacallan    # store a dummy comment line, to avoid errors with the Makefile
237dbbd9e4bSmacallan    # "include basename.Plo" scheme.
238dbbd9e4bSmacallan    echo "#dummy" > "$depfile"
239dbbd9e4bSmacallan  fi
240dbbd9e4bSmacallan  rm -f "$tmpdepfile"
241dbbd9e4bSmacallan  ;;
242dbbd9e4bSmacallan
243e96acad6Smrgxlc)
244e96acad6Smrg  # This case exists only to let depend.m4 do its work.  It works by
245e96acad6Smrg  # looking at the text of this script.  This case will never be run,
246e96acad6Smrg  # since it is checked for above.
247e96acad6Smrg  exit 1
248e96acad6Smrg  ;;
249e96acad6Smrg
250dbbd9e4bSmacallanaix)
251dbbd9e4bSmacallan  # The C for AIX Compiler uses -M and outputs the dependencies
252dbbd9e4bSmacallan  # in a .u file.  In older versions, this file always lives in the
253e96acad6Smrg  # current directory.  Also, the AIX compiler puts '$object:' at the
254dbbd9e4bSmacallan  # start of each line; $object doesn't have directory information.
255dbbd9e4bSmacallan  # Version 6 uses the directory in both cases.
256dbbd9e4bSmacallan  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
257dbbd9e4bSmacallan  test "x$dir" = "x$object" && dir=
258dbbd9e4bSmacallan  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
259dbbd9e4bSmacallan  if test "$libtool" = yes; then
260dbbd9e4bSmacallan    tmpdepfile1=$dir$base.u
261dbbd9e4bSmacallan    tmpdepfile2=$base.u
262dbbd9e4bSmacallan    tmpdepfile3=$dir.libs/$base.u
263dbbd9e4bSmacallan    "$@" -Wc,-M
264dbbd9e4bSmacallan  else
265dbbd9e4bSmacallan    tmpdepfile1=$dir$base.u
266dbbd9e4bSmacallan    tmpdepfile2=$dir$base.u
267dbbd9e4bSmacallan    tmpdepfile3=$dir$base.u
268dbbd9e4bSmacallan    "$@" -M
269dbbd9e4bSmacallan  fi
270dbbd9e4bSmacallan  stat=$?
271dbbd9e4bSmacallan
272dbbd9e4bSmacallan  if test $stat -eq 0; then :
273dbbd9e4bSmacallan  else
274dbbd9e4bSmacallan    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
275dbbd9e4bSmacallan    exit $stat
276dbbd9e4bSmacallan  fi
277dbbd9e4bSmacallan
278dbbd9e4bSmacallan  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
279dbbd9e4bSmacallan  do
280dbbd9e4bSmacallan    test -f "$tmpdepfile" && break
281dbbd9e4bSmacallan  done
282dbbd9e4bSmacallan  if test -f "$tmpdepfile"; then
283e96acad6Smrg    # Each line is of the form 'foo.o: dependent.h'.
284dbbd9e4bSmacallan    # Do two passes, one to just change these to
285e96acad6Smrg    # '$object: dependent.h' and one to simply 'dependent.h:'.
286dbbd9e4bSmacallan    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
287e96acad6Smrg    sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
288dbbd9e4bSmacallan  else
289dbbd9e4bSmacallan    # The sourcefile does not contain any dependencies, so just
290dbbd9e4bSmacallan    # store a dummy comment line, to avoid errors with the Makefile
291dbbd9e4bSmacallan    # "include basename.Plo" scheme.
292dbbd9e4bSmacallan    echo "#dummy" > "$depfile"
293dbbd9e4bSmacallan  fi
294dbbd9e4bSmacallan  rm -f "$tmpdepfile"
295dbbd9e4bSmacallan  ;;
296dbbd9e4bSmacallan
297dbbd9e4bSmacallanicc)
298e96acad6Smrg  # Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'.
299e96acad6Smrg  # However on
300e96acad6Smrg  #    $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c
301dbbd9e4bSmacallan  # ICC 7.0 will fill foo.d with something like
302dbbd9e4bSmacallan  #    foo.o: sub/foo.c
303dbbd9e4bSmacallan  #    foo.o: sub/foo.h
304e96acad6Smrg  # which is wrong.  We want
305dbbd9e4bSmacallan  #    sub/foo.o: sub/foo.c
306dbbd9e4bSmacallan  #    sub/foo.o: sub/foo.h
307dbbd9e4bSmacallan  #    sub/foo.c:
308dbbd9e4bSmacallan  #    sub/foo.h:
309dbbd9e4bSmacallan  # ICC 7.1 will output
310dbbd9e4bSmacallan  #    foo.o: sub/foo.c sub/foo.h
311e96acad6Smrg  # and will wrap long lines using '\':
312dbbd9e4bSmacallan  #    foo.o: sub/foo.c ... \
313dbbd9e4bSmacallan  #     sub/foo.h ... \
314dbbd9e4bSmacallan  #     ...
315e96acad6Smrg  # tcc 0.9.26 (FIXME still under development at the moment of writing)
316e96acad6Smrg  # will emit a similar output, but also prepend the continuation lines
317e96acad6Smrg  # with horizontal tabulation characters.
318dbbd9e4bSmacallan  "$@" -MD -MF "$tmpdepfile"
319dbbd9e4bSmacallan  stat=$?
320dbbd9e4bSmacallan  if test $stat -eq 0; then :
321dbbd9e4bSmacallan  else
322dbbd9e4bSmacallan    rm -f "$tmpdepfile"
323dbbd9e4bSmacallan    exit $stat
324dbbd9e4bSmacallan  fi
325dbbd9e4bSmacallan  rm -f "$depfile"
326e96acad6Smrg  # Each line is of the form 'foo.o: dependent.h',
327e96acad6Smrg  # or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'.
328e96acad6Smrg  # Do two passes, one to just change these to
329e96acad6Smrg  # '$object: dependent.h' and one to simply 'dependent.h:'.
330e96acad6Smrg  sed -e "s/^[ $tab][ $tab]*/  /" -e "s,^[^:]*:,$object :," \
331e96acad6Smrg    < "$tmpdepfile" > "$depfile"
332e96acad6Smrg  sed '
333e96acad6Smrg    s/[ '"$tab"'][ '"$tab"']*/ /g
334e96acad6Smrg    s/^ *//
335e96acad6Smrg    s/ *\\*$//
336e96acad6Smrg    s/^[^:]*: *//
337e96acad6Smrg    /^$/d
338e96acad6Smrg    /:$/d
339e96acad6Smrg    s/$/ :/
340e96acad6Smrg  ' < "$tmpdepfile" >> "$depfile"
341e96acad6Smrg  rm -f "$tmpdepfile"
342e96acad6Smrg  ;;
343e96acad6Smrg
344e96acad6Smrg## The order of this option in the case statement is important, since the
345e96acad6Smrg## shell code in configure will try each of these formats in the order
346e96acad6Smrg## listed in this file.  A plain '-MD' option would be understood by many
347e96acad6Smrg## compilers, so we must ensure this comes after the gcc and icc options.
348e96acad6Smrgpgcc)
349e96acad6Smrg  # Portland's C compiler understands '-MD'.
350e96acad6Smrg  # Will always output deps to 'file.d' where file is the root name of the
351e96acad6Smrg  # source file under compilation, even if file resides in a subdirectory.
352e96acad6Smrg  # The object file name does not affect the name of the '.d' file.
353e96acad6Smrg  # pgcc 10.2 will output
354e96acad6Smrg  #    foo.o: sub/foo.c sub/foo.h
355e96acad6Smrg  # and will wrap long lines using '\' :
356e96acad6Smrg  #    foo.o: sub/foo.c ... \
357e96acad6Smrg  #     sub/foo.h ... \
358e96acad6Smrg  #     ...
359e96acad6Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
360e96acad6Smrg  test "x$dir" = "x$object" && dir=
361e96acad6Smrg  # Use the source, not the object, to determine the base name, since
362e96acad6Smrg  # that's sadly what pgcc will do too.
363e96acad6Smrg  base=`echo "$source" | sed -e 's|^.*/||' -e 's/\.[-_a-zA-Z0-9]*$//'`
364e96acad6Smrg  tmpdepfile="$base.d"
365e96acad6Smrg
366e96acad6Smrg  # For projects that build the same source file twice into different object
367e96acad6Smrg  # files, the pgcc approach of using the *source* file root name can cause
368e96acad6Smrg  # problems in parallel builds.  Use a locking strategy to avoid stomping on
369e96acad6Smrg  # the same $tmpdepfile.
370e96acad6Smrg  lockdir="$base.d-lock"
371e96acad6Smrg  trap "echo '$0: caught signal, cleaning up...' >&2; rm -rf $lockdir" 1 2 13 15
372e96acad6Smrg  numtries=100
373e96acad6Smrg  i=$numtries
374e96acad6Smrg  while test $i -gt 0 ; do
375e96acad6Smrg    # mkdir is a portable test-and-set.
376e96acad6Smrg    if mkdir $lockdir 2>/dev/null; then
377e96acad6Smrg      # This process acquired the lock.
378e96acad6Smrg      "$@" -MD
379e96acad6Smrg      stat=$?
380e96acad6Smrg      # Release the lock.
381e96acad6Smrg      rm -rf $lockdir
382e96acad6Smrg      break
383e96acad6Smrg    else
384e96acad6Smrg      ## the lock is being held by a different process,
385e96acad6Smrg      ## wait until the winning process is done or we timeout
386e96acad6Smrg      while test -d $lockdir && test $i -gt 0; do
387e96acad6Smrg        sleep 1
388e96acad6Smrg        i=`expr $i - 1`
389e96acad6Smrg      done
390e96acad6Smrg    fi
391e96acad6Smrg    i=`expr $i - 1`
392e96acad6Smrg  done
393e96acad6Smrg  trap - 1 2 13 15
394e96acad6Smrg  if test $i -le 0; then
395e96acad6Smrg    echo "$0: failed to acquire lock after $numtries attempts" >&2
396e96acad6Smrg    echo "$0: check lockdir '$lockdir'" >&2
397e96acad6Smrg    exit 1
398e96acad6Smrg  fi
399e96acad6Smrg
400e96acad6Smrg  if test $stat -ne 0; then
401e96acad6Smrg    rm -f "$tmpdepfile"
402e96acad6Smrg    exit $stat
403e96acad6Smrg  fi
404e96acad6Smrg  rm -f "$depfile"
405dbbd9e4bSmacallan  # Each line is of the form `foo.o: dependent.h',
406dbbd9e4bSmacallan  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
407dbbd9e4bSmacallan  # Do two passes, one to just change these to
408dbbd9e4bSmacallan  # `$object: dependent.h' and one to simply `dependent.h:'.
409dbbd9e4bSmacallan  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
410dbbd9e4bSmacallan  # Some versions of the HPUX 10.20 sed can't process this invocation
411dbbd9e4bSmacallan  # correctly.  Breaking it into two sed invocations is a workaround.
412dbbd9e4bSmacallan  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
413dbbd9e4bSmacallan    sed -e 's/$/ :/' >> "$depfile"
414dbbd9e4bSmacallan  rm -f "$tmpdepfile"
415dbbd9e4bSmacallan  ;;
416dbbd9e4bSmacallan
417dbbd9e4bSmacallanhp2)
418dbbd9e4bSmacallan  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
419dbbd9e4bSmacallan  # compilers, which have integrated preprocessors.  The correct option
420dbbd9e4bSmacallan  # to use with these is +Maked; it writes dependencies to a file named
421dbbd9e4bSmacallan  # 'foo.d', which lands next to the object file, wherever that
422dbbd9e4bSmacallan  # happens to be.
423dbbd9e4bSmacallan  # Much of this is similar to the tru64 case; see comments there.
424dbbd9e4bSmacallan  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
425dbbd9e4bSmacallan  test "x$dir" = "x$object" && dir=
426dbbd9e4bSmacallan  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
427dbbd9e4bSmacallan  if test "$libtool" = yes; then
428dbbd9e4bSmacallan    tmpdepfile1=$dir$base.d
429dbbd9e4bSmacallan    tmpdepfile2=$dir.libs/$base.d
430dbbd9e4bSmacallan    "$@" -Wc,+Maked
431dbbd9e4bSmacallan  else
432dbbd9e4bSmacallan    tmpdepfile1=$dir$base.d
433dbbd9e4bSmacallan    tmpdepfile2=$dir$base.d
434dbbd9e4bSmacallan    "$@" +Maked
435dbbd9e4bSmacallan  fi
436dbbd9e4bSmacallan  stat=$?
437dbbd9e4bSmacallan  if test $stat -eq 0; then :
438dbbd9e4bSmacallan  else
439dbbd9e4bSmacallan     rm -f "$tmpdepfile1" "$tmpdepfile2"
440dbbd9e4bSmacallan     exit $stat
441dbbd9e4bSmacallan  fi
442dbbd9e4bSmacallan
443dbbd9e4bSmacallan  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
444dbbd9e4bSmacallan  do
445dbbd9e4bSmacallan    test -f "$tmpdepfile" && break
446dbbd9e4bSmacallan  done
447dbbd9e4bSmacallan  if test -f "$tmpdepfile"; then
448dbbd9e4bSmacallan    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
449e96acad6Smrg    # Add 'dependent.h:' lines.
4501c397cbaSmrg    sed -ne '2,${
4511c397cbaSmrg	       s/^ *//
4521c397cbaSmrg	       s/ \\*$//
4531c397cbaSmrg	       s/$/:/
4541c397cbaSmrg	       p
4551c397cbaSmrg	     }' "$tmpdepfile" >> "$depfile"
456dbbd9e4bSmacallan  else
457dbbd9e4bSmacallan    echo "#dummy" > "$depfile"
458dbbd9e4bSmacallan  fi
459dbbd9e4bSmacallan  rm -f "$tmpdepfile" "$tmpdepfile2"
460dbbd9e4bSmacallan  ;;
461dbbd9e4bSmacallan
462dbbd9e4bSmacallantru64)
463dbbd9e4bSmacallan   # The Tru64 compiler uses -MD to generate dependencies as a side
464e96acad6Smrg   # effect.  'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
465dbbd9e4bSmacallan   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
466e96acad6Smrg   # dependencies in 'foo.d' instead, so we check for that too.
467dbbd9e4bSmacallan   # Subdirectories are respected.
468dbbd9e4bSmacallan   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
469dbbd9e4bSmacallan   test "x$dir" = "x$object" && dir=
470dbbd9e4bSmacallan   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
471dbbd9e4bSmacallan
472dbbd9e4bSmacallan   if test "$libtool" = yes; then
473dbbd9e4bSmacallan      # With Tru64 cc, shared objects can also be used to make a
474dbbd9e4bSmacallan      # static library.  This mechanism is used in libtool 1.4 series to
475dbbd9e4bSmacallan      # handle both shared and static libraries in a single compilation.
476dbbd9e4bSmacallan      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
477dbbd9e4bSmacallan      #
478dbbd9e4bSmacallan      # With libtool 1.5 this exception was removed, and libtool now
479dbbd9e4bSmacallan      # generates 2 separate objects for the 2 libraries.  These two
480dbbd9e4bSmacallan      # compilations output dependencies in $dir.libs/$base.o.d and
481dbbd9e4bSmacallan      # in $dir$base.o.d.  We have to check for both files, because
482dbbd9e4bSmacallan      # one of the two compilations can be disabled.  We should prefer
483dbbd9e4bSmacallan      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
484dbbd9e4bSmacallan      # automatically cleaned when .libs/ is deleted, while ignoring
485dbbd9e4bSmacallan      # the former would cause a distcleancheck panic.
486dbbd9e4bSmacallan      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
487dbbd9e4bSmacallan      tmpdepfile2=$dir$base.o.d          # libtool 1.5
488dbbd9e4bSmacallan      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
489dbbd9e4bSmacallan      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
490dbbd9e4bSmacallan      "$@" -Wc,-MD
491dbbd9e4bSmacallan   else
492dbbd9e4bSmacallan      tmpdepfile1=$dir$base.o.d
493dbbd9e4bSmacallan      tmpdepfile2=$dir$base.d
494dbbd9e4bSmacallan      tmpdepfile3=$dir$base.d
495dbbd9e4bSmacallan      tmpdepfile4=$dir$base.d
496dbbd9e4bSmacallan      "$@" -MD
497dbbd9e4bSmacallan   fi
498dbbd9e4bSmacallan
499dbbd9e4bSmacallan   stat=$?
500dbbd9e4bSmacallan   if test $stat -eq 0; then :
501dbbd9e4bSmacallan   else
502dbbd9e4bSmacallan      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
503dbbd9e4bSmacallan      exit $stat
504dbbd9e4bSmacallan   fi
505dbbd9e4bSmacallan
506dbbd9e4bSmacallan   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
507dbbd9e4bSmacallan   do
508dbbd9e4bSmacallan     test -f "$tmpdepfile" && break
509dbbd9e4bSmacallan   done
510dbbd9e4bSmacallan   if test -f "$tmpdepfile"; then
511dbbd9e4bSmacallan      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
512e96acad6Smrg      sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
513dbbd9e4bSmacallan   else
514dbbd9e4bSmacallan      echo "#dummy" > "$depfile"
515dbbd9e4bSmacallan   fi
516dbbd9e4bSmacallan   rm -f "$tmpdepfile"
517dbbd9e4bSmacallan   ;;
518dbbd9e4bSmacallan
519e96acad6Smrgmsvc7)
520e96acad6Smrg  if test "$libtool" = yes; then
521e96acad6Smrg    showIncludes=-Wc,-showIncludes
522e96acad6Smrg  else
523e96acad6Smrg    showIncludes=-showIncludes
524e96acad6Smrg  fi
525e96acad6Smrg  "$@" $showIncludes > "$tmpdepfile"
526e96acad6Smrg  stat=$?
527e96acad6Smrg  grep -v '^Note: including file: ' "$tmpdepfile"
528e96acad6Smrg  if test "$stat" = 0; then :
529e96acad6Smrg  else
530e96acad6Smrg    rm -f "$tmpdepfile"
531e96acad6Smrg    exit $stat
532e96acad6Smrg  fi
533e96acad6Smrg  rm -f "$depfile"
534e96acad6Smrg  echo "$object : \\" > "$depfile"
535e96acad6Smrg  # The first sed program below extracts the file names and escapes
536e96acad6Smrg  # backslashes for cygpath.  The second sed program outputs the file
537e96acad6Smrg  # name when reading, but also accumulates all include files in the
538e96acad6Smrg  # hold buffer in order to output them again at the end.  This only
539e96acad6Smrg  # works with sed implementations that can handle large buffers.
540e96acad6Smrg  sed < "$tmpdepfile" -n '
541e96acad6Smrg/^Note: including file:  *\(.*\)/ {
542e96acad6Smrg  s//\1/
543e96acad6Smrg  s/\\/\\\\/g
544e96acad6Smrg  p
545e96acad6Smrg}' | $cygpath_u | sort -u | sed -n '
546e96acad6Smrgs/ /\\ /g
547e96acad6Smrgs/\(.*\)/'"$tab"'\1 \\/p
548e96acad6Smrgs/.\(.*\) \\/\1:/
549e96acad6SmrgH
550e96acad6Smrg$ {
551e96acad6Smrg  s/.*/'"$tab"'/
552e96acad6Smrg  G
553e96acad6Smrg  p
554e96acad6Smrg}' >> "$depfile"
555e96acad6Smrg  rm -f "$tmpdepfile"
556e96acad6Smrg  ;;
557e96acad6Smrg
558e96acad6Smrgmsvc7msys)
559e96acad6Smrg  # This case exists only to let depend.m4 do its work.  It works by
560e96acad6Smrg  # looking at the text of this script.  This case will never be run,
561e96acad6Smrg  # since it is checked for above.
562e96acad6Smrg  exit 1
563e96acad6Smrg  ;;
564e96acad6Smrg
565dbbd9e4bSmacallan#nosideeffect)
566dbbd9e4bSmacallan  # This comment above is used by automake to tell side-effect
567dbbd9e4bSmacallan  # dependency tracking mechanisms from slower ones.
568dbbd9e4bSmacallan
569dbbd9e4bSmacallandashmstdout)
570dbbd9e4bSmacallan  # Important note: in order to support this mode, a compiler *must*
571dbbd9e4bSmacallan  # always write the preprocessed file to stdout, regardless of -o.
572dbbd9e4bSmacallan  "$@" || exit $?
573dbbd9e4bSmacallan
574dbbd9e4bSmacallan  # Remove the call to Libtool.
575dbbd9e4bSmacallan  if test "$libtool" = yes; then
5761c397cbaSmrg    while test "X$1" != 'X--mode=compile'; do
577dbbd9e4bSmacallan      shift
578dbbd9e4bSmacallan    done
579dbbd9e4bSmacallan    shift
580dbbd9e4bSmacallan  fi
581dbbd9e4bSmacallan
582e96acad6Smrg  # Remove '-o $object'.
583dbbd9e4bSmacallan  IFS=" "
584dbbd9e4bSmacallan  for arg
585dbbd9e4bSmacallan  do
586dbbd9e4bSmacallan    case $arg in
587dbbd9e4bSmacallan    -o)
588dbbd9e4bSmacallan      shift
589dbbd9e4bSmacallan      ;;
590dbbd9e4bSmacallan    $object)
591dbbd9e4bSmacallan      shift
592dbbd9e4bSmacallan      ;;
593dbbd9e4bSmacallan    *)
594dbbd9e4bSmacallan      set fnord "$@" "$arg"
595dbbd9e4bSmacallan      shift # fnord
596dbbd9e4bSmacallan      shift # $arg
597dbbd9e4bSmacallan      ;;
598dbbd9e4bSmacallan    esac
599dbbd9e4bSmacallan  done
600dbbd9e4bSmacallan
601dbbd9e4bSmacallan  test -z "$dashmflag" && dashmflag=-M
602e96acad6Smrg  # Require at least two characters before searching for ':'
603dbbd9e4bSmacallan  # in the target name.  This is to cope with DOS-style filenames:
604e96acad6Smrg  # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
605dbbd9e4bSmacallan  "$@" $dashmflag |
606e96acad6Smrg    sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile"
607dbbd9e4bSmacallan  rm -f "$depfile"
608dbbd9e4bSmacallan  cat < "$tmpdepfile" > "$depfile"
609e96acad6Smrg  tr ' ' "$nl" < "$tmpdepfile" | \
610dbbd9e4bSmacallan## Some versions of the HPUX 10.20 sed can't process this invocation
611dbbd9e4bSmacallan## correctly.  Breaking it into two sed invocations is a workaround.
612dbbd9e4bSmacallan    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
613dbbd9e4bSmacallan  rm -f "$tmpdepfile"
614dbbd9e4bSmacallan  ;;
615dbbd9e4bSmacallan
616dbbd9e4bSmacallandashXmstdout)
617dbbd9e4bSmacallan  # This case only exists to satisfy depend.m4.  It is never actually
618dbbd9e4bSmacallan  # run, as this mode is specially recognized in the preamble.
619dbbd9e4bSmacallan  exit 1
620dbbd9e4bSmacallan  ;;
621dbbd9e4bSmacallan
622dbbd9e4bSmacallanmakedepend)
623dbbd9e4bSmacallan  "$@" || exit $?
624dbbd9e4bSmacallan  # Remove any Libtool call
625dbbd9e4bSmacallan  if test "$libtool" = yes; then
6261c397cbaSmrg    while test "X$1" != 'X--mode=compile'; do
627dbbd9e4bSmacallan      shift
628dbbd9e4bSmacallan    done
629dbbd9e4bSmacallan    shift
630dbbd9e4bSmacallan  fi
631dbbd9e4bSmacallan  # X makedepend
632dbbd9e4bSmacallan  shift
6331c397cbaSmrg  cleared=no eat=no
6341c397cbaSmrg  for arg
6351c397cbaSmrg  do
636dbbd9e4bSmacallan    case $cleared in
637dbbd9e4bSmacallan    no)
638dbbd9e4bSmacallan      set ""; shift
639dbbd9e4bSmacallan      cleared=yes ;;
640dbbd9e4bSmacallan    esac
6411c397cbaSmrg    if test $eat = yes; then
6421c397cbaSmrg      eat=no
6431c397cbaSmrg      continue
6441c397cbaSmrg    fi
645dbbd9e4bSmacallan    case "$arg" in
646dbbd9e4bSmacallan    -D*|-I*)
647dbbd9e4bSmacallan      set fnord "$@" "$arg"; shift ;;
648dbbd9e4bSmacallan    # Strip any option that makedepend may not understand.  Remove
649dbbd9e4bSmacallan    # the object too, otherwise makedepend will parse it as a source file.
6501c397cbaSmrg    -arch)
6511c397cbaSmrg      eat=yes ;;
652dbbd9e4bSmacallan    -*|$object)
653dbbd9e4bSmacallan      ;;
654dbbd9e4bSmacallan    *)
655dbbd9e4bSmacallan      set fnord "$@" "$arg"; shift ;;
656dbbd9e4bSmacallan    esac
657dbbd9e4bSmacallan  done
6581c397cbaSmrg  obj_suffix=`echo "$object" | sed 's/^.*\././'`
659dbbd9e4bSmacallan  touch "$tmpdepfile"
660dbbd9e4bSmacallan  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
661dbbd9e4bSmacallan  rm -f "$depfile"
662e96acad6Smrg  # makedepend may prepend the VPATH from the source file name to the object.
663e96acad6Smrg  # No need to regex-escape $object, excess matching of '.' is harmless.
664e96acad6Smrg  sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
665e96acad6Smrg  sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \
666dbbd9e4bSmacallan## Some versions of the HPUX 10.20 sed can't process this invocation
667dbbd9e4bSmacallan## correctly.  Breaking it into two sed invocations is a workaround.
668dbbd9e4bSmacallan    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
669dbbd9e4bSmacallan  rm -f "$tmpdepfile" "$tmpdepfile".bak
670dbbd9e4bSmacallan  ;;
671dbbd9e4bSmacallan
672dbbd9e4bSmacallancpp)
673dbbd9e4bSmacallan  # Important note: in order to support this mode, a compiler *must*
674dbbd9e4bSmacallan  # always write the preprocessed file to stdout.
675dbbd9e4bSmacallan  "$@" || exit $?
676dbbd9e4bSmacallan
677dbbd9e4bSmacallan  # Remove the call to Libtool.
678dbbd9e4bSmacallan  if test "$libtool" = yes; then
6791c397cbaSmrg    while test "X$1" != 'X--mode=compile'; do
680dbbd9e4bSmacallan      shift
681dbbd9e4bSmacallan    done
682dbbd9e4bSmacallan    shift
683dbbd9e4bSmacallan  fi
684dbbd9e4bSmacallan
685e96acad6Smrg  # Remove '-o $object'.
686dbbd9e4bSmacallan  IFS=" "
687dbbd9e4bSmacallan  for arg
688dbbd9e4bSmacallan  do
689dbbd9e4bSmacallan    case $arg in
690dbbd9e4bSmacallan    -o)
691dbbd9e4bSmacallan      shift
692dbbd9e4bSmacallan      ;;
693dbbd9e4bSmacallan    $object)
694dbbd9e4bSmacallan      shift
695dbbd9e4bSmacallan      ;;
696dbbd9e4bSmacallan    *)
697dbbd9e4bSmacallan      set fnord "$@" "$arg"
698dbbd9e4bSmacallan      shift # fnord
699dbbd9e4bSmacallan      shift # $arg
700dbbd9e4bSmacallan      ;;
701dbbd9e4bSmacallan    esac
702dbbd9e4bSmacallan  done
703dbbd9e4bSmacallan
704dbbd9e4bSmacallan  "$@" -E |
705dbbd9e4bSmacallan    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
706dbbd9e4bSmacallan       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
707dbbd9e4bSmacallan    sed '$ s: \\$::' > "$tmpdepfile"
708dbbd9e4bSmacallan  rm -f "$depfile"
709dbbd9e4bSmacallan  echo "$object : \\" > "$depfile"
710dbbd9e4bSmacallan  cat < "$tmpdepfile" >> "$depfile"
711dbbd9e4bSmacallan  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
712dbbd9e4bSmacallan  rm -f "$tmpdepfile"
713dbbd9e4bSmacallan  ;;
714dbbd9e4bSmacallan
715dbbd9e4bSmacallanmsvisualcpp)
716dbbd9e4bSmacallan  # Important note: in order to support this mode, a compiler *must*
7171c397cbaSmrg  # always write the preprocessed file to stdout.
718dbbd9e4bSmacallan  "$@" || exit $?
7191c397cbaSmrg
7201c397cbaSmrg  # Remove the call to Libtool.
7211c397cbaSmrg  if test "$libtool" = yes; then
7221c397cbaSmrg    while test "X$1" != 'X--mode=compile'; do
7231c397cbaSmrg      shift
7241c397cbaSmrg    done
7251c397cbaSmrg    shift
7261c397cbaSmrg  fi
7271c397cbaSmrg
728dbbd9e4bSmacallan  IFS=" "
729dbbd9e4bSmacallan  for arg
730dbbd9e4bSmacallan  do
731dbbd9e4bSmacallan    case "$arg" in
7321c397cbaSmrg    -o)
7331c397cbaSmrg      shift
7341c397cbaSmrg      ;;
7351c397cbaSmrg    $object)
7361c397cbaSmrg      shift
7371c397cbaSmrg      ;;
738dbbd9e4bSmacallan    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
739dbbd9e4bSmacallan	set fnord "$@"
740dbbd9e4bSmacallan	shift
741dbbd9e4bSmacallan	shift
742dbbd9e4bSmacallan	;;
743dbbd9e4bSmacallan    *)
744dbbd9e4bSmacallan	set fnord "$@" "$arg"
745dbbd9e4bSmacallan	shift
746dbbd9e4bSmacallan	shift
747dbbd9e4bSmacallan	;;
748dbbd9e4bSmacallan    esac
749dbbd9e4bSmacallan  done
7501c397cbaSmrg  "$@" -E 2>/dev/null |
7511c397cbaSmrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
752dbbd9e4bSmacallan  rm -f "$depfile"
753dbbd9e4bSmacallan  echo "$object : \\" > "$depfile"
754e96acad6Smrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
755e96acad6Smrg  echo "$tab" >> "$depfile"
7561c397cbaSmrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
757dbbd9e4bSmacallan  rm -f "$tmpdepfile"
758dbbd9e4bSmacallan  ;;
759dbbd9e4bSmacallan
7601c397cbaSmrgmsvcmsys)
7611c397cbaSmrg  # This case exists only to let depend.m4 do its work.  It works by
7621c397cbaSmrg  # looking at the text of this script.  This case will never be run,
7631c397cbaSmrg  # since it is checked for above.
7641c397cbaSmrg  exit 1
7651c397cbaSmrg  ;;
7661c397cbaSmrg
767dbbd9e4bSmacallannone)
768dbbd9e4bSmacallan  exec "$@"
769dbbd9e4bSmacallan  ;;
770dbbd9e4bSmacallan
771dbbd9e4bSmacallan*)
772dbbd9e4bSmacallan  echo "Unknown depmode $depmode" 1>&2
773dbbd9e4bSmacallan  exit 1
774dbbd9e4bSmacallan  ;;
775dbbd9e4bSmacallanesac
776dbbd9e4bSmacallan
777dbbd9e4bSmacallanexit 0
778dbbd9e4bSmacallan
779dbbd9e4bSmacallan# Local Variables:
780dbbd9e4bSmacallan# mode: shell-script
781dbbd9e4bSmacallan# sh-indentation: 2
782dbbd9e4bSmacallan# eval: (add-hook 'write-file-hooks 'time-stamp)
783dbbd9e4bSmacallan# time-stamp-start: "scriptversion="
784dbbd9e4bSmacallan# time-stamp-format: "%:y-%02m-%02d.%02H"
7851c397cbaSmrg# time-stamp-time-zone: "UTC"
7861c397cbaSmrg# time-stamp-end: "; # UTC"
787dbbd9e4bSmacallan# End:
788