depcomp revision 19019ffe
1c582b7e3Smrg#! /bin/sh
2c582b7e3Smrg# depcomp - compile a program generating dependencies as side-effects
3c582b7e3Smrg
419019ffeSmrgscriptversion=2009-04-28.21; # UTC
5c582b7e3Smrg
619019ffeSmrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
719019ffeSmrg# Software Foundation, Inc.
8c582b7e3Smrg
9c582b7e3Smrg# This program is free software; you can redistribute it and/or modify
10c582b7e3Smrg# it under the terms of the GNU General Public License as published by
11c582b7e3Smrg# the Free Software Foundation; either version 2, or (at your option)
12c582b7e3Smrg# any later version.
13c582b7e3Smrg
14c582b7e3Smrg# This program is distributed in the hope that it will be useful,
15c582b7e3Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
16c582b7e3Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17c582b7e3Smrg# GNU General Public License for more details.
18c582b7e3Smrg
19c582b7e3Smrg# You should have received a copy of the GNU General Public License
2019019ffeSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21c582b7e3Smrg
22c582b7e3Smrg# As a special exception to the GNU General Public License, if you
23c582b7e3Smrg# distribute this file as part of a program that contains a
24c582b7e3Smrg# configuration script generated by Autoconf, you may include it under
25c582b7e3Smrg# the same distribution terms that you use for the rest of that program.
26c582b7e3Smrg
27c582b7e3Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
28c582b7e3Smrg
29c582b7e3Smrgcase $1 in
30c582b7e3Smrg  '')
31c582b7e3Smrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
32c582b7e3Smrg     exit 1;
33c582b7e3Smrg     ;;
34c582b7e3Smrg  -h | --h*)
35c582b7e3Smrg    cat <<\EOF
36c582b7e3SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
37c582b7e3Smrg
38c582b7e3SmrgRun PROGRAMS ARGS to compile a file, generating dependencies
39c582b7e3Smrgas side-effects.
40c582b7e3Smrg
41c582b7e3SmrgEnvironment variables:
42c582b7e3Smrg  depmode     Dependency tracking mode.
43c582b7e3Smrg  source      Source file read by `PROGRAMS ARGS'.
44c582b7e3Smrg  object      Object file output by `PROGRAMS ARGS'.
45c582b7e3Smrg  DEPDIR      directory where to store dependencies.
46c582b7e3Smrg  depfile     Dependency file to output.
47c582b7e3Smrg  tmpdepfile  Temporary file to use when outputing dependencies.
48c582b7e3Smrg  libtool     Whether libtool is used (yes/no).
49c582b7e3Smrg
50c582b7e3SmrgReport bugs to <bug-automake@gnu.org>.
51c582b7e3SmrgEOF
52c582b7e3Smrg    exit $?
53c582b7e3Smrg    ;;
54c582b7e3Smrg  -v | --v*)
55c582b7e3Smrg    echo "depcomp $scriptversion"
56c582b7e3Smrg    exit $?
57c582b7e3Smrg    ;;
58c582b7e3Smrgesac
59c582b7e3Smrg
60c582b7e3Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
61c582b7e3Smrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
62c582b7e3Smrg  exit 1
63c582b7e3Smrgfi
64c582b7e3Smrg
65c582b7e3Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
66c582b7e3Smrgdepfile=${depfile-`echo "$object" |
67c582b7e3Smrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
68c582b7e3Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
69c582b7e3Smrg
70c582b7e3Smrgrm -f "$tmpdepfile"
71c582b7e3Smrg
72c582b7e3Smrg# Some modes work just like other modes, but use different flags.  We
73c582b7e3Smrg# parameterize here, but still list the modes in the big case below,
74c582b7e3Smrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
75c582b7e3Smrg# here, because this file can only contain one case statement.
76c582b7e3Smrgif test "$depmode" = hp; then
77c582b7e3Smrg  # HP compiler uses -M and no extra arg.
78c582b7e3Smrg  gccflag=-M
79c582b7e3Smrg  depmode=gcc
80c582b7e3Smrgfi
81c582b7e3Smrg
82c582b7e3Smrgif test "$depmode" = dashXmstdout; then
83c582b7e3Smrg   # This is just like dashmstdout with a different argument.
84c582b7e3Smrg   dashmflag=-xM
85c582b7e3Smrg   depmode=dashmstdout
86c582b7e3Smrgfi
87c582b7e3Smrg
8819019ffeSmrgcygpath_u="cygpath -u -f -"
8919019ffeSmrgif test "$depmode" = msvcmsys; then
9019019ffeSmrg   # This is just like msvisualcpp but w/o cygpath translation.
9119019ffeSmrg   # Just convert the backslash-escaped backslashes to single forward
9219019ffeSmrg   # slashes to satisfy depend.m4
9319019ffeSmrg   cygpath_u="sed s,\\\\\\\\,/,g"
9419019ffeSmrg   depmode=msvisualcpp
9519019ffeSmrgfi
9619019ffeSmrg
97c582b7e3Smrgcase "$depmode" in
98c582b7e3Smrggcc3)
99c582b7e3Smrg## gcc 3 implements dependency tracking that does exactly what
100c582b7e3Smrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
101c582b7e3Smrg## it if -MD -MP comes after the -MF stuff.  Hmm.
102c582b7e3Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
103c582b7e3Smrg## the command line argument order; so add the flags where they
104c582b7e3Smrg## appear in depend2.am.  Note that the slowdown incurred here
105c582b7e3Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
106c582b7e3Smrg  for arg
107c582b7e3Smrg  do
108c582b7e3Smrg    case $arg in
109c582b7e3Smrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
110c582b7e3Smrg    *)  set fnord "$@" "$arg" ;;
111c582b7e3Smrg    esac
112c582b7e3Smrg    shift # fnord
113c582b7e3Smrg    shift # $arg
114c582b7e3Smrg  done
115c582b7e3Smrg  "$@"
116c582b7e3Smrg  stat=$?
117c582b7e3Smrg  if test $stat -eq 0; then :
118c582b7e3Smrg  else
119c582b7e3Smrg    rm -f "$tmpdepfile"
120c582b7e3Smrg    exit $stat
121c582b7e3Smrg  fi
122c582b7e3Smrg  mv "$tmpdepfile" "$depfile"
123c582b7e3Smrg  ;;
124c582b7e3Smrg
125c582b7e3Smrggcc)
126c582b7e3Smrg## There are various ways to get dependency output from gcc.  Here's
127c582b7e3Smrg## why we pick this rather obscure method:
128c582b7e3Smrg## - Don't want to use -MD because we'd like the dependencies to end
129c582b7e3Smrg##   up in a subdir.  Having to rename by hand is ugly.
130c582b7e3Smrg##   (We might end up doing this anyway to support other compilers.)
131c582b7e3Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
132c582b7e3Smrg##   -MM, not -M (despite what the docs say).
133c582b7e3Smrg## - Using -M directly means running the compiler twice (even worse
134c582b7e3Smrg##   than renaming).
135c582b7e3Smrg  if test -z "$gccflag"; then
136c582b7e3Smrg    gccflag=-MD,
137c582b7e3Smrg  fi
138c582b7e3Smrg  "$@" -Wp,"$gccflag$tmpdepfile"
139c582b7e3Smrg  stat=$?
140c582b7e3Smrg  if test $stat -eq 0; then :
141c582b7e3Smrg  else
142c582b7e3Smrg    rm -f "$tmpdepfile"
143c582b7e3Smrg    exit $stat
144c582b7e3Smrg  fi
145c582b7e3Smrg  rm -f "$depfile"
146c582b7e3Smrg  echo "$object : \\" > "$depfile"
147c582b7e3Smrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
148c582b7e3Smrg## The second -e expression handles DOS-style file names with drive letters.
149c582b7e3Smrg  sed -e 's/^[^:]*: / /' \
150c582b7e3Smrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
151c582b7e3Smrg## This next piece of magic avoids the `deleted header file' problem.
152c582b7e3Smrg## The problem is that when a header file which appears in a .P file
153c582b7e3Smrg## is deleted, the dependency causes make to die (because there is
154c582b7e3Smrg## typically no way to rebuild the header).  We avoid this by adding
155c582b7e3Smrg## dummy dependencies for each header file.  Too bad gcc doesn't do
156c582b7e3Smrg## this for us directly.
157c582b7e3Smrg  tr ' ' '
158c582b7e3Smrg' < "$tmpdepfile" |
159c582b7e3Smrg## Some versions of gcc put a space before the `:'.  On the theory
160c582b7e3Smrg## that the space means something, we add a space to the output as
161c582b7e3Smrg## well.
162c582b7e3Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
163c582b7e3Smrg## correctly.  Breaking it into two sed invocations is a workaround.
164c582b7e3Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
165c582b7e3Smrg  rm -f "$tmpdepfile"
166c582b7e3Smrg  ;;
167c582b7e3Smrg
168c582b7e3Smrghp)
169c582b7e3Smrg  # This case exists only to let depend.m4 do its work.  It works by
170c582b7e3Smrg  # looking at the text of this script.  This case will never be run,
171c582b7e3Smrg  # since it is checked for above.
172c582b7e3Smrg  exit 1
173c582b7e3Smrg  ;;
174c582b7e3Smrg
175c582b7e3Smrgsgi)
176c582b7e3Smrg  if test "$libtool" = yes; then
177c582b7e3Smrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
178c582b7e3Smrg  else
179c582b7e3Smrg    "$@" -MDupdate "$tmpdepfile"
180c582b7e3Smrg  fi
181c582b7e3Smrg  stat=$?
182c582b7e3Smrg  if test $stat -eq 0; then :
183c582b7e3Smrg  else
184c582b7e3Smrg    rm -f "$tmpdepfile"
185c582b7e3Smrg    exit $stat
186c582b7e3Smrg  fi
187c582b7e3Smrg  rm -f "$depfile"
188c582b7e3Smrg
189c582b7e3Smrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
190c582b7e3Smrg    echo "$object : \\" > "$depfile"
191c582b7e3Smrg
192c582b7e3Smrg    # Clip off the initial element (the dependent).  Don't try to be
193c582b7e3Smrg    # clever and replace this with sed code, as IRIX sed won't handle
194c582b7e3Smrg    # lines with more than a fixed number of characters (4096 in
195c582b7e3Smrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
196c582b7e3Smrg    # the IRIX cc adds comments like `#:fec' to the end of the
197c582b7e3Smrg    # dependency line.
198c582b7e3Smrg    tr ' ' '
199c582b7e3Smrg' < "$tmpdepfile" \
200c582b7e3Smrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
201c582b7e3Smrg    tr '
20219019ffeSmrg' ' ' >> "$depfile"
20319019ffeSmrg    echo >> "$depfile"
204c582b7e3Smrg
205c582b7e3Smrg    # The second pass generates a dummy entry for each header file.
206c582b7e3Smrg    tr ' ' '
207c582b7e3Smrg' < "$tmpdepfile" \
208c582b7e3Smrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
20919019ffeSmrg   >> "$depfile"
210c582b7e3Smrg  else
211c582b7e3Smrg    # The sourcefile does not contain any dependencies, so just
212c582b7e3Smrg    # store a dummy comment line, to avoid errors with the Makefile
213c582b7e3Smrg    # "include basename.Plo" scheme.
214c582b7e3Smrg    echo "#dummy" > "$depfile"
215c582b7e3Smrg  fi
216c582b7e3Smrg  rm -f "$tmpdepfile"
217c582b7e3Smrg  ;;
218c582b7e3Smrg
219c582b7e3Smrgaix)
220c582b7e3Smrg  # The C for AIX Compiler uses -M and outputs the dependencies
221c582b7e3Smrg  # in a .u file.  In older versions, this file always lives in the
222c582b7e3Smrg  # current directory.  Also, the AIX compiler puts `$object:' at the
223c582b7e3Smrg  # start of each line; $object doesn't have directory information.
224c582b7e3Smrg  # Version 6 uses the directory in both cases.
225c582b7e3Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
226c582b7e3Smrg  test "x$dir" = "x$object" && dir=
227c582b7e3Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
228c582b7e3Smrg  if test "$libtool" = yes; then
229c582b7e3Smrg    tmpdepfile1=$dir$base.u
230c582b7e3Smrg    tmpdepfile2=$base.u
231c582b7e3Smrg    tmpdepfile3=$dir.libs/$base.u
232c582b7e3Smrg    "$@" -Wc,-M
233c582b7e3Smrg  else
234c582b7e3Smrg    tmpdepfile1=$dir$base.u
235c582b7e3Smrg    tmpdepfile2=$dir$base.u
236c582b7e3Smrg    tmpdepfile3=$dir$base.u
237c582b7e3Smrg    "$@" -M
238c582b7e3Smrg  fi
239c582b7e3Smrg  stat=$?
240c582b7e3Smrg
241c582b7e3Smrg  if test $stat -eq 0; then :
242c582b7e3Smrg  else
243c582b7e3Smrg    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
244c582b7e3Smrg    exit $stat
245c582b7e3Smrg  fi
246c582b7e3Smrg
247c582b7e3Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
248c582b7e3Smrg  do
249c582b7e3Smrg    test -f "$tmpdepfile" && break
250c582b7e3Smrg  done
251c582b7e3Smrg  if test -f "$tmpdepfile"; then
252c582b7e3Smrg    # Each line is of the form `foo.o: dependent.h'.
253c582b7e3Smrg    # Do two passes, one to just change these to
254c582b7e3Smrg    # `$object: dependent.h' and one to simply `dependent.h:'.
255c582b7e3Smrg    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
256c582b7e3Smrg    # That's a tab and a space in the [].
257c582b7e3Smrg    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
258c582b7e3Smrg  else
259c582b7e3Smrg    # The sourcefile does not contain any dependencies, so just
260c582b7e3Smrg    # store a dummy comment line, to avoid errors with the Makefile
261c582b7e3Smrg    # "include basename.Plo" scheme.
262c582b7e3Smrg    echo "#dummy" > "$depfile"
263c582b7e3Smrg  fi
264c582b7e3Smrg  rm -f "$tmpdepfile"
265c582b7e3Smrg  ;;
266c582b7e3Smrg
267c582b7e3Smrgicc)
268c582b7e3Smrg  # Intel's C compiler understands `-MD -MF file'.  However on
269c582b7e3Smrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
270c582b7e3Smrg  # ICC 7.0 will fill foo.d with something like
271c582b7e3Smrg  #    foo.o: sub/foo.c
272c582b7e3Smrg  #    foo.o: sub/foo.h
273c582b7e3Smrg  # which is wrong.  We want:
274c582b7e3Smrg  #    sub/foo.o: sub/foo.c
275c582b7e3Smrg  #    sub/foo.o: sub/foo.h
276c582b7e3Smrg  #    sub/foo.c:
277c582b7e3Smrg  #    sub/foo.h:
278c582b7e3Smrg  # ICC 7.1 will output
279c582b7e3Smrg  #    foo.o: sub/foo.c sub/foo.h
280c582b7e3Smrg  # and will wrap long lines using \ :
281c582b7e3Smrg  #    foo.o: sub/foo.c ... \
282c582b7e3Smrg  #     sub/foo.h ... \
283c582b7e3Smrg  #     ...
284c582b7e3Smrg
285c582b7e3Smrg  "$@" -MD -MF "$tmpdepfile"
286c582b7e3Smrg  stat=$?
287c582b7e3Smrg  if test $stat -eq 0; then :
288c582b7e3Smrg  else
289c582b7e3Smrg    rm -f "$tmpdepfile"
290c582b7e3Smrg    exit $stat
291c582b7e3Smrg  fi
292c582b7e3Smrg  rm -f "$depfile"
293c582b7e3Smrg  # Each line is of the form `foo.o: dependent.h',
294c582b7e3Smrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
295c582b7e3Smrg  # Do two passes, one to just change these to
296c582b7e3Smrg  # `$object: dependent.h' and one to simply `dependent.h:'.
297c582b7e3Smrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
298c582b7e3Smrg  # Some versions of the HPUX 10.20 sed can't process this invocation
299c582b7e3Smrg  # correctly.  Breaking it into two sed invocations is a workaround.
300c582b7e3Smrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
301c582b7e3Smrg    sed -e 's/$/ :/' >> "$depfile"
302c582b7e3Smrg  rm -f "$tmpdepfile"
303c582b7e3Smrg  ;;
304c582b7e3Smrg
305c582b7e3Smrghp2)
306c582b7e3Smrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
307c582b7e3Smrg  # compilers, which have integrated preprocessors.  The correct option
308c582b7e3Smrg  # to use with these is +Maked; it writes dependencies to a file named
309c582b7e3Smrg  # 'foo.d', which lands next to the object file, wherever that
310c582b7e3Smrg  # happens to be.
311c582b7e3Smrg  # Much of this is similar to the tru64 case; see comments there.
312c582b7e3Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
313c582b7e3Smrg  test "x$dir" = "x$object" && dir=
314c582b7e3Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
315c582b7e3Smrg  if test "$libtool" = yes; then
316c582b7e3Smrg    tmpdepfile1=$dir$base.d
317c582b7e3Smrg    tmpdepfile2=$dir.libs/$base.d
318c582b7e3Smrg    "$@" -Wc,+Maked
319c582b7e3Smrg  else
320c582b7e3Smrg    tmpdepfile1=$dir$base.d
321c582b7e3Smrg    tmpdepfile2=$dir$base.d
322c582b7e3Smrg    "$@" +Maked
323c582b7e3Smrg  fi
324c582b7e3Smrg  stat=$?
325c582b7e3Smrg  if test $stat -eq 0; then :
326c582b7e3Smrg  else
327c582b7e3Smrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
328c582b7e3Smrg     exit $stat
329c582b7e3Smrg  fi
330c582b7e3Smrg
331c582b7e3Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
332c582b7e3Smrg  do
333c582b7e3Smrg    test -f "$tmpdepfile" && break
334c582b7e3Smrg  done
335c582b7e3Smrg  if test -f "$tmpdepfile"; then
336c582b7e3Smrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
337c582b7e3Smrg    # Add `dependent.h:' lines.
33819019ffeSmrg    sed -ne '2,${
33919019ffeSmrg	       s/^ *//
34019019ffeSmrg	       s/ \\*$//
34119019ffeSmrg	       s/$/:/
34219019ffeSmrg	       p
34319019ffeSmrg	     }' "$tmpdepfile" >> "$depfile"
344c582b7e3Smrg  else
345c582b7e3Smrg    echo "#dummy" > "$depfile"
346c582b7e3Smrg  fi
347c582b7e3Smrg  rm -f "$tmpdepfile" "$tmpdepfile2"
348c582b7e3Smrg  ;;
349c582b7e3Smrg
350c582b7e3Smrgtru64)
351c582b7e3Smrg   # The Tru64 compiler uses -MD to generate dependencies as a side
352c582b7e3Smrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
353c582b7e3Smrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
354c582b7e3Smrg   # dependencies in `foo.d' instead, so we check for that too.
355c582b7e3Smrg   # Subdirectories are respected.
356c582b7e3Smrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
357c582b7e3Smrg   test "x$dir" = "x$object" && dir=
358c582b7e3Smrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
359c582b7e3Smrg
360c582b7e3Smrg   if test "$libtool" = yes; then
361c582b7e3Smrg      # With Tru64 cc, shared objects can also be used to make a
362c582b7e3Smrg      # static library.  This mechanism is used in libtool 1.4 series to
363c582b7e3Smrg      # handle both shared and static libraries in a single compilation.
364c582b7e3Smrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
365c582b7e3Smrg      #
366c582b7e3Smrg      # With libtool 1.5 this exception was removed, and libtool now
367c582b7e3Smrg      # generates 2 separate objects for the 2 libraries.  These two
368c582b7e3Smrg      # compilations output dependencies in $dir.libs/$base.o.d and
369c582b7e3Smrg      # in $dir$base.o.d.  We have to check for both files, because
370c582b7e3Smrg      # one of the two compilations can be disabled.  We should prefer
371c582b7e3Smrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
372c582b7e3Smrg      # automatically cleaned when .libs/ is deleted, while ignoring
373c582b7e3Smrg      # the former would cause a distcleancheck panic.
374c582b7e3Smrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
375c582b7e3Smrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
376c582b7e3Smrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
377c582b7e3Smrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
378c582b7e3Smrg      "$@" -Wc,-MD
379c582b7e3Smrg   else
380c582b7e3Smrg      tmpdepfile1=$dir$base.o.d
381c582b7e3Smrg      tmpdepfile2=$dir$base.d
382c582b7e3Smrg      tmpdepfile3=$dir$base.d
383c582b7e3Smrg      tmpdepfile4=$dir$base.d
384c582b7e3Smrg      "$@" -MD
385c582b7e3Smrg   fi
386c582b7e3Smrg
387c582b7e3Smrg   stat=$?
388c582b7e3Smrg   if test $stat -eq 0; then :
389c582b7e3Smrg   else
390c582b7e3Smrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
391c582b7e3Smrg      exit $stat
392c582b7e3Smrg   fi
393c582b7e3Smrg
394c582b7e3Smrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
395c582b7e3Smrg   do
396c582b7e3Smrg     test -f "$tmpdepfile" && break
397c582b7e3Smrg   done
398c582b7e3Smrg   if test -f "$tmpdepfile"; then
399c582b7e3Smrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
400c582b7e3Smrg      # That's a tab and a space in the [].
401c582b7e3Smrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
402c582b7e3Smrg   else
403c582b7e3Smrg      echo "#dummy" > "$depfile"
404c582b7e3Smrg   fi
405c582b7e3Smrg   rm -f "$tmpdepfile"
406c582b7e3Smrg   ;;
407c582b7e3Smrg
408c582b7e3Smrg#nosideeffect)
409c582b7e3Smrg  # This comment above is used by automake to tell side-effect
410c582b7e3Smrg  # dependency tracking mechanisms from slower ones.
411c582b7e3Smrg
412c582b7e3Smrgdashmstdout)
413c582b7e3Smrg  # Important note: in order to support this mode, a compiler *must*
414c582b7e3Smrg  # always write the preprocessed file to stdout, regardless of -o.
415c582b7e3Smrg  "$@" || exit $?
416c582b7e3Smrg
417c582b7e3Smrg  # Remove the call to Libtool.
418c582b7e3Smrg  if test "$libtool" = yes; then
41919019ffeSmrg    while test "X$1" != 'X--mode=compile'; do
420c582b7e3Smrg      shift
421c582b7e3Smrg    done
422c582b7e3Smrg    shift
423c582b7e3Smrg  fi
424c582b7e3Smrg
425c582b7e3Smrg  # Remove `-o $object'.
426c582b7e3Smrg  IFS=" "
427c582b7e3Smrg  for arg
428c582b7e3Smrg  do
429c582b7e3Smrg    case $arg in
430c582b7e3Smrg    -o)
431c582b7e3Smrg      shift
432c582b7e3Smrg      ;;
433c582b7e3Smrg    $object)
434c582b7e3Smrg      shift
435c582b7e3Smrg      ;;
436c582b7e3Smrg    *)
437c582b7e3Smrg      set fnord "$@" "$arg"
438c582b7e3Smrg      shift # fnord
439c582b7e3Smrg      shift # $arg
440c582b7e3Smrg      ;;
441c582b7e3Smrg    esac
442c582b7e3Smrg  done
443c582b7e3Smrg
444c582b7e3Smrg  test -z "$dashmflag" && dashmflag=-M
445c582b7e3Smrg  # Require at least two characters before searching for `:'
446c582b7e3Smrg  # in the target name.  This is to cope with DOS-style filenames:
447c582b7e3Smrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
448c582b7e3Smrg  "$@" $dashmflag |
449c582b7e3Smrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
450c582b7e3Smrg  rm -f "$depfile"
451c582b7e3Smrg  cat < "$tmpdepfile" > "$depfile"
452c582b7e3Smrg  tr ' ' '
453c582b7e3Smrg' < "$tmpdepfile" | \
454c582b7e3Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
455c582b7e3Smrg## correctly.  Breaking it into two sed invocations is a workaround.
456c582b7e3Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
457c582b7e3Smrg  rm -f "$tmpdepfile"
458c582b7e3Smrg  ;;
459c582b7e3Smrg
460c582b7e3SmrgdashXmstdout)
461c582b7e3Smrg  # This case only exists to satisfy depend.m4.  It is never actually
462c582b7e3Smrg  # run, as this mode is specially recognized in the preamble.
463c582b7e3Smrg  exit 1
464c582b7e3Smrg  ;;
465c582b7e3Smrg
466c582b7e3Smrgmakedepend)
467c582b7e3Smrg  "$@" || exit $?
468c582b7e3Smrg  # Remove any Libtool call
469c582b7e3Smrg  if test "$libtool" = yes; then
47019019ffeSmrg    while test "X$1" != 'X--mode=compile'; do
471c582b7e3Smrg      shift
472c582b7e3Smrg    done
473c582b7e3Smrg    shift
474c582b7e3Smrg  fi
475c582b7e3Smrg  # X makedepend
476c582b7e3Smrg  shift
47719019ffeSmrg  cleared=no eat=no
47819019ffeSmrg  for arg
47919019ffeSmrg  do
480c582b7e3Smrg    case $cleared in
481c582b7e3Smrg    no)
482c582b7e3Smrg      set ""; shift
483c582b7e3Smrg      cleared=yes ;;
484c582b7e3Smrg    esac
48519019ffeSmrg    if test $eat = yes; then
48619019ffeSmrg      eat=no
48719019ffeSmrg      continue
48819019ffeSmrg    fi
489c582b7e3Smrg    case "$arg" in
490c582b7e3Smrg    -D*|-I*)
491c582b7e3Smrg      set fnord "$@" "$arg"; shift ;;
492c582b7e3Smrg    # Strip any option that makedepend may not understand.  Remove
493c582b7e3Smrg    # the object too, otherwise makedepend will parse it as a source file.
49419019ffeSmrg    -arch)
49519019ffeSmrg      eat=yes ;;
496c582b7e3Smrg    -*|$object)
497c582b7e3Smrg      ;;
498c582b7e3Smrg    *)
499c582b7e3Smrg      set fnord "$@" "$arg"; shift ;;
500c582b7e3Smrg    esac
501c582b7e3Smrg  done
50219019ffeSmrg  obj_suffix=`echo "$object" | sed 's/^.*\././'`
503c582b7e3Smrg  touch "$tmpdepfile"
504c582b7e3Smrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
505c582b7e3Smrg  rm -f "$depfile"
506c582b7e3Smrg  cat < "$tmpdepfile" > "$depfile"
507c582b7e3Smrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
508c582b7e3Smrg' | \
509c582b7e3Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
510c582b7e3Smrg## correctly.  Breaking it into two sed invocations is a workaround.
511c582b7e3Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
512c582b7e3Smrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
513c582b7e3Smrg  ;;
514c582b7e3Smrg
515c582b7e3Smrgcpp)
516c582b7e3Smrg  # Important note: in order to support this mode, a compiler *must*
517c582b7e3Smrg  # always write the preprocessed file to stdout.
518c582b7e3Smrg  "$@" || exit $?
519c582b7e3Smrg
520c582b7e3Smrg  # Remove the call to Libtool.
521c582b7e3Smrg  if test "$libtool" = yes; then
52219019ffeSmrg    while test "X$1" != 'X--mode=compile'; do
523c582b7e3Smrg      shift
524c582b7e3Smrg    done
525c582b7e3Smrg    shift
526c582b7e3Smrg  fi
527c582b7e3Smrg
528c582b7e3Smrg  # Remove `-o $object'.
529c582b7e3Smrg  IFS=" "
530c582b7e3Smrg  for arg
531c582b7e3Smrg  do
532c582b7e3Smrg    case $arg in
533c582b7e3Smrg    -o)
534c582b7e3Smrg      shift
535c582b7e3Smrg      ;;
536c582b7e3Smrg    $object)
537c582b7e3Smrg      shift
538c582b7e3Smrg      ;;
539c582b7e3Smrg    *)
540c582b7e3Smrg      set fnord "$@" "$arg"
541c582b7e3Smrg      shift # fnord
542c582b7e3Smrg      shift # $arg
543c582b7e3Smrg      ;;
544c582b7e3Smrg    esac
545c582b7e3Smrg  done
546c582b7e3Smrg
547c582b7e3Smrg  "$@" -E |
548c582b7e3Smrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
549c582b7e3Smrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
550c582b7e3Smrg    sed '$ s: \\$::' > "$tmpdepfile"
551c582b7e3Smrg  rm -f "$depfile"
552c582b7e3Smrg  echo "$object : \\" > "$depfile"
553c582b7e3Smrg  cat < "$tmpdepfile" >> "$depfile"
554c582b7e3Smrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
555c582b7e3Smrg  rm -f "$tmpdepfile"
556c582b7e3Smrg  ;;
557c582b7e3Smrg
558c582b7e3Smrgmsvisualcpp)
559c582b7e3Smrg  # Important note: in order to support this mode, a compiler *must*
56019019ffeSmrg  # always write the preprocessed file to stdout.
561c582b7e3Smrg  "$@" || exit $?
56219019ffeSmrg
56319019ffeSmrg  # Remove the call to Libtool.
56419019ffeSmrg  if test "$libtool" = yes; then
56519019ffeSmrg    while test "X$1" != 'X--mode=compile'; do
56619019ffeSmrg      shift
56719019ffeSmrg    done
56819019ffeSmrg    shift
56919019ffeSmrg  fi
57019019ffeSmrg
571c582b7e3Smrg  IFS=" "
572c582b7e3Smrg  for arg
573c582b7e3Smrg  do
574c582b7e3Smrg    case "$arg" in
57519019ffeSmrg    -o)
57619019ffeSmrg      shift
57719019ffeSmrg      ;;
57819019ffeSmrg    $object)
57919019ffeSmrg      shift
58019019ffeSmrg      ;;
581c582b7e3Smrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
582c582b7e3Smrg	set fnord "$@"
583c582b7e3Smrg	shift
584c582b7e3Smrg	shift
585c582b7e3Smrg	;;
586c582b7e3Smrg    *)
587c582b7e3Smrg	set fnord "$@" "$arg"
588c582b7e3Smrg	shift
589c582b7e3Smrg	shift
590c582b7e3Smrg	;;
591c582b7e3Smrg    esac
592c582b7e3Smrg  done
59319019ffeSmrg  "$@" -E 2>/dev/null |
59419019ffeSmrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
595c582b7e3Smrg  rm -f "$depfile"
596c582b7e3Smrg  echo "$object : \\" > "$depfile"
59719019ffeSmrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
598c582b7e3Smrg  echo "	" >> "$depfile"
59919019ffeSmrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
600c582b7e3Smrg  rm -f "$tmpdepfile"
601c582b7e3Smrg  ;;
602c582b7e3Smrg
60319019ffeSmrgmsvcmsys)
60419019ffeSmrg  # This case exists only to let depend.m4 do its work.  It works by
60519019ffeSmrg  # looking at the text of this script.  This case will never be run,
60619019ffeSmrg  # since it is checked for above.
60719019ffeSmrg  exit 1
60819019ffeSmrg  ;;
60919019ffeSmrg
610c582b7e3Smrgnone)
611c582b7e3Smrg  exec "$@"
612c582b7e3Smrg  ;;
613c582b7e3Smrg
614c582b7e3Smrg*)
615c582b7e3Smrg  echo "Unknown depmode $depmode" 1>&2
616c582b7e3Smrg  exit 1
617c582b7e3Smrg  ;;
618c582b7e3Smrgesac
619c582b7e3Smrg
620c582b7e3Smrgexit 0
621c582b7e3Smrg
622c582b7e3Smrg# Local Variables:
623c582b7e3Smrg# mode: shell-script
624c582b7e3Smrg# sh-indentation: 2
625c582b7e3Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
626c582b7e3Smrg# time-stamp-start: "scriptversion="
627c582b7e3Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
62819019ffeSmrg# time-stamp-time-zone: "UTC"
62919019ffeSmrg# time-stamp-end: "; # UTC"
630c582b7e3Smrg# End:
631