depcomp revision 1fb744b4
1c35d236eSmrg#! /bin/sh
2c35d236eSmrg# depcomp - compile a program generating dependencies as side-effects
3c35d236eSmrg
41fb744b4Smrgscriptversion=2011-12-04.11; # UTC
5c35d236eSmrg
61fb744b4Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
71fb744b4Smrg# 2011 Free Software Foundation, Inc.
8c35d236eSmrg
9c35d236eSmrg# This program is free software; you can redistribute it and/or modify
10c35d236eSmrg# it under the terms of the GNU General Public License as published by
11c35d236eSmrg# the Free Software Foundation; either version 2, or (at your option)
12c35d236eSmrg# any later version.
13c35d236eSmrg
14c35d236eSmrg# This program is distributed in the hope that it will be useful,
15c35d236eSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
16c35d236eSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17c35d236eSmrg# GNU General Public License for more details.
18c35d236eSmrg
19c35d236eSmrg# You should have received a copy of the GNU General Public License
20518bcf38Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21c35d236eSmrg
22c35d236eSmrg# As a special exception to the GNU General Public License, if you
23c35d236eSmrg# distribute this file as part of a program that contains a
24c35d236eSmrg# configuration script generated by Autoconf, you may include it under
25c35d236eSmrg# the same distribution terms that you use for the rest of that program.
26c35d236eSmrg
27c35d236eSmrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
28c35d236eSmrg
29c35d236eSmrgcase $1 in
30c35d236eSmrg  '')
31c35d236eSmrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
32c35d236eSmrg     exit 1;
33c35d236eSmrg     ;;
34c35d236eSmrg  -h | --h*)
35c35d236eSmrg    cat <<\EOF
36c35d236eSmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
37c35d236eSmrg
38c35d236eSmrgRun PROGRAMS ARGS to compile a file, generating dependencies
39c35d236eSmrgas side-effects.
40c35d236eSmrg
41c35d236eSmrgEnvironment variables:
42c35d236eSmrg  depmode     Dependency tracking mode.
43c35d236eSmrg  source      Source file read by `PROGRAMS ARGS'.
44c35d236eSmrg  object      Object file output by `PROGRAMS ARGS'.
45c35d236eSmrg  DEPDIR      directory where to store dependencies.
46c35d236eSmrg  depfile     Dependency file to output.
471fb744b4Smrg  tmpdepfile  Temporary file to use when outputting dependencies.
48c35d236eSmrg  libtool     Whether libtool is used (yes/no).
49c35d236eSmrg
50c35d236eSmrgReport bugs to <bug-automake@gnu.org>.
51c35d236eSmrgEOF
52c35d236eSmrg    exit $?
53c35d236eSmrg    ;;
54c35d236eSmrg  -v | --v*)
55c35d236eSmrg    echo "depcomp $scriptversion"
56c35d236eSmrg    exit $?
57c35d236eSmrg    ;;
58c35d236eSmrgesac
59c35d236eSmrg
60c35d236eSmrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
61c35d236eSmrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
62c35d236eSmrg  exit 1
63c35d236eSmrgfi
64c35d236eSmrg
65c35d236eSmrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
66c35d236eSmrgdepfile=${depfile-`echo "$object" |
67c35d236eSmrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
68c35d236eSmrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
69c35d236eSmrg
70c35d236eSmrgrm -f "$tmpdepfile"
71c35d236eSmrg
72c35d236eSmrg# Some modes work just like other modes, but use different flags.  We
73c35d236eSmrg# parameterize here, but still list the modes in the big case below,
74c35d236eSmrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
75c35d236eSmrg# here, because this file can only contain one case statement.
76c35d236eSmrgif test "$depmode" = hp; then
77c35d236eSmrg  # HP compiler uses -M and no extra arg.
78c35d236eSmrg  gccflag=-M
79c35d236eSmrg  depmode=gcc
80c35d236eSmrgfi
81c35d236eSmrg
82c35d236eSmrgif test "$depmode" = dashXmstdout; then
83c35d236eSmrg   # This is just like dashmstdout with a different argument.
84c35d236eSmrg   dashmflag=-xM
85c35d236eSmrg   depmode=dashmstdout
86c35d236eSmrgfi
87c35d236eSmrg
88518bcf38Smrgcygpath_u="cygpath -u -f -"
89518bcf38Smrgif test "$depmode" = msvcmsys; then
90518bcf38Smrg   # This is just like msvisualcpp but w/o cygpath translation.
91518bcf38Smrg   # Just convert the backslash-escaped backslashes to single forward
92518bcf38Smrg   # slashes to satisfy depend.m4
931fb744b4Smrg   cygpath_u='sed s,\\\\,/,g'
94518bcf38Smrg   depmode=msvisualcpp
95518bcf38Smrgfi
96518bcf38Smrg
971fb744b4Smrgif test "$depmode" = msvc7msys; then
981fb744b4Smrg   # This is just like msvc7 but w/o cygpath translation.
991fb744b4Smrg   # Just convert the backslash-escaped backslashes to single forward
1001fb744b4Smrg   # slashes to satisfy depend.m4
1011fb744b4Smrg   cygpath_u='sed s,\\\\,/,g'
1021fb744b4Smrg   depmode=msvc7
1031fb744b4Smrgfi
1041fb744b4Smrg
105c35d236eSmrgcase "$depmode" in
106c35d236eSmrggcc3)
107c35d236eSmrg## gcc 3 implements dependency tracking that does exactly what
108c35d236eSmrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
109c35d236eSmrg## it if -MD -MP comes after the -MF stuff.  Hmm.
1104f6cd06fSmrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
1114f6cd06fSmrg## the command line argument order; so add the flags where they
1124f6cd06fSmrg## appear in depend2.am.  Note that the slowdown incurred here
1134f6cd06fSmrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
1144f6cd06fSmrg  for arg
1154f6cd06fSmrg  do
1164f6cd06fSmrg    case $arg in
1174f6cd06fSmrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
1184f6cd06fSmrg    *)  set fnord "$@" "$arg" ;;
1194f6cd06fSmrg    esac
1204f6cd06fSmrg    shift # fnord
1214f6cd06fSmrg    shift # $arg
1224f6cd06fSmrg  done
1234f6cd06fSmrg  "$@"
124c35d236eSmrg  stat=$?
125c35d236eSmrg  if test $stat -eq 0; then :
126c35d236eSmrg  else
127c35d236eSmrg    rm -f "$tmpdepfile"
128c35d236eSmrg    exit $stat
129c35d236eSmrg  fi
130c35d236eSmrg  mv "$tmpdepfile" "$depfile"
131c35d236eSmrg  ;;
132c35d236eSmrg
133c35d236eSmrggcc)
134c35d236eSmrg## There are various ways to get dependency output from gcc.  Here's
135c35d236eSmrg## why we pick this rather obscure method:
136c35d236eSmrg## - Don't want to use -MD because we'd like the dependencies to end
137c35d236eSmrg##   up in a subdir.  Having to rename by hand is ugly.
138c35d236eSmrg##   (We might end up doing this anyway to support other compilers.)
139c35d236eSmrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
140c35d236eSmrg##   -MM, not -M (despite what the docs say).
141c35d236eSmrg## - Using -M directly means running the compiler twice (even worse
142c35d236eSmrg##   than renaming).
143c35d236eSmrg  if test -z "$gccflag"; then
144c35d236eSmrg    gccflag=-MD,
145c35d236eSmrg  fi
146c35d236eSmrg  "$@" -Wp,"$gccflag$tmpdepfile"
147c35d236eSmrg  stat=$?
148c35d236eSmrg  if test $stat -eq 0; then :
149c35d236eSmrg  else
150c35d236eSmrg    rm -f "$tmpdepfile"
151c35d236eSmrg    exit $stat
152c35d236eSmrg  fi
153c35d236eSmrg  rm -f "$depfile"
154c35d236eSmrg  echo "$object : \\" > "$depfile"
155c35d236eSmrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
156c35d236eSmrg## The second -e expression handles DOS-style file names with drive letters.
157c35d236eSmrg  sed -e 's/^[^:]*: / /' \
158c35d236eSmrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
159c35d236eSmrg## This next piece of magic avoids the `deleted header file' problem.
160c35d236eSmrg## The problem is that when a header file which appears in a .P file
161c35d236eSmrg## is deleted, the dependency causes make to die (because there is
162c35d236eSmrg## typically no way to rebuild the header).  We avoid this by adding
163c35d236eSmrg## dummy dependencies for each header file.  Too bad gcc doesn't do
164c35d236eSmrg## this for us directly.
165c35d236eSmrg  tr ' ' '
166c35d236eSmrg' < "$tmpdepfile" |
167c35d236eSmrg## Some versions of gcc put a space before the `:'.  On the theory
168c35d236eSmrg## that the space means something, we add a space to the output as
1691fb744b4Smrg## well.  hp depmode also adds that space, but also prefixes the VPATH
1701fb744b4Smrg## to the object.  Take care to not repeat it in the output.
171c35d236eSmrg## Some versions of the HPUX 10.20 sed can't process this invocation
172c35d236eSmrg## correctly.  Breaking it into two sed invocations is a workaround.
1731fb744b4Smrg    sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
1741fb744b4Smrg      | sed -e 's/$/ :/' >> "$depfile"
175c35d236eSmrg  rm -f "$tmpdepfile"
176c35d236eSmrg  ;;
177c35d236eSmrg
178c35d236eSmrghp)
179c35d236eSmrg  # This case exists only to let depend.m4 do its work.  It works by
180c35d236eSmrg  # looking at the text of this script.  This case will never be run,
181c35d236eSmrg  # since it is checked for above.
182c35d236eSmrg  exit 1
183c35d236eSmrg  ;;
184c35d236eSmrg
185c35d236eSmrgsgi)
186c35d236eSmrg  if test "$libtool" = yes; then
187c35d236eSmrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
188c35d236eSmrg  else
189c35d236eSmrg    "$@" -MDupdate "$tmpdepfile"
190c35d236eSmrg  fi
191c35d236eSmrg  stat=$?
192c35d236eSmrg  if test $stat -eq 0; then :
193c35d236eSmrg  else
194c35d236eSmrg    rm -f "$tmpdepfile"
195c35d236eSmrg    exit $stat
196c35d236eSmrg  fi
197c35d236eSmrg  rm -f "$depfile"
198c35d236eSmrg
199c35d236eSmrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
200c35d236eSmrg    echo "$object : \\" > "$depfile"
201c35d236eSmrg
202c35d236eSmrg    # Clip off the initial element (the dependent).  Don't try to be
203c35d236eSmrg    # clever and replace this with sed code, as IRIX sed won't handle
204c35d236eSmrg    # lines with more than a fixed number of characters (4096 in
205c35d236eSmrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
206c35d236eSmrg    # the IRIX cc adds comments like `#:fec' to the end of the
207c35d236eSmrg    # dependency line.
208c35d236eSmrg    tr ' ' '
209c35d236eSmrg' < "$tmpdepfile" \
210c35d236eSmrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
211c35d236eSmrg    tr '
212518bcf38Smrg' ' ' >> "$depfile"
213518bcf38Smrg    echo >> "$depfile"
214c35d236eSmrg
215c35d236eSmrg    # The second pass generates a dummy entry for each header file.
216c35d236eSmrg    tr ' ' '
217c35d236eSmrg' < "$tmpdepfile" \
218c35d236eSmrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
219518bcf38Smrg   >> "$depfile"
220c35d236eSmrg  else
221c35d236eSmrg    # The sourcefile does not contain any dependencies, so just
222c35d236eSmrg    # store a dummy comment line, to avoid errors with the Makefile
223c35d236eSmrg    # "include basename.Plo" scheme.
224c35d236eSmrg    echo "#dummy" > "$depfile"
225c35d236eSmrg  fi
226c35d236eSmrg  rm -f "$tmpdepfile"
227c35d236eSmrg  ;;
228c35d236eSmrg
229c35d236eSmrgaix)
230c35d236eSmrg  # The C for AIX Compiler uses -M and outputs the dependencies
231c35d236eSmrg  # in a .u file.  In older versions, this file always lives in the
232c35d236eSmrg  # current directory.  Also, the AIX compiler puts `$object:' at the
233c35d236eSmrg  # start of each line; $object doesn't have directory information.
234c35d236eSmrg  # Version 6 uses the directory in both cases.
235f55e6a01Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
236f55e6a01Smrg  test "x$dir" = "x$object" && dir=
237f55e6a01Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
238c35d236eSmrg  if test "$libtool" = yes; then
239f55e6a01Smrg    tmpdepfile1=$dir$base.u
240f55e6a01Smrg    tmpdepfile2=$base.u
241f55e6a01Smrg    tmpdepfile3=$dir.libs/$base.u
242c35d236eSmrg    "$@" -Wc,-M
243c35d236eSmrg  else
244f55e6a01Smrg    tmpdepfile1=$dir$base.u
245f55e6a01Smrg    tmpdepfile2=$dir$base.u
246f55e6a01Smrg    tmpdepfile3=$dir$base.u
247c35d236eSmrg    "$@" -M
248c35d236eSmrg  fi
249c35d236eSmrg  stat=$?
250c35d236eSmrg
251c35d236eSmrg  if test $stat -eq 0; then :
252c35d236eSmrg  else
253f55e6a01Smrg    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
254c35d236eSmrg    exit $stat
255c35d236eSmrg  fi
256c35d236eSmrg
257f55e6a01Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
258f55e6a01Smrg  do
259f55e6a01Smrg    test -f "$tmpdepfile" && break
260f55e6a01Smrg  done
261c35d236eSmrg  if test -f "$tmpdepfile"; then
262c35d236eSmrg    # Each line is of the form `foo.o: dependent.h'.
263c35d236eSmrg    # Do two passes, one to just change these to
264c35d236eSmrg    # `$object: dependent.h' and one to simply `dependent.h:'.
265f55e6a01Smrg    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
266f55e6a01Smrg    # That's a tab and a space in the [].
267f55e6a01Smrg    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
268c35d236eSmrg  else
269c35d236eSmrg    # The sourcefile does not contain any dependencies, so just
270c35d236eSmrg    # store a dummy comment line, to avoid errors with the Makefile
271c35d236eSmrg    # "include basename.Plo" scheme.
272c35d236eSmrg    echo "#dummy" > "$depfile"
273c35d236eSmrg  fi
274c35d236eSmrg  rm -f "$tmpdepfile"
275c35d236eSmrg  ;;
276c35d236eSmrg
277c35d236eSmrgicc)
278c35d236eSmrg  # Intel's C compiler understands `-MD -MF file'.  However on
279c35d236eSmrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
280c35d236eSmrg  # ICC 7.0 will fill foo.d with something like
281c35d236eSmrg  #    foo.o: sub/foo.c
282c35d236eSmrg  #    foo.o: sub/foo.h
283c35d236eSmrg  # which is wrong.  We want:
284c35d236eSmrg  #    sub/foo.o: sub/foo.c
285c35d236eSmrg  #    sub/foo.o: sub/foo.h
286c35d236eSmrg  #    sub/foo.c:
287c35d236eSmrg  #    sub/foo.h:
288c35d236eSmrg  # ICC 7.1 will output
289c35d236eSmrg  #    foo.o: sub/foo.c sub/foo.h
290c35d236eSmrg  # and will wrap long lines using \ :
291c35d236eSmrg  #    foo.o: sub/foo.c ... \
292c35d236eSmrg  #     sub/foo.h ... \
293c35d236eSmrg  #     ...
294c35d236eSmrg
295c35d236eSmrg  "$@" -MD -MF "$tmpdepfile"
296c35d236eSmrg  stat=$?
297c35d236eSmrg  if test $stat -eq 0; then :
298c35d236eSmrg  else
299c35d236eSmrg    rm -f "$tmpdepfile"
300c35d236eSmrg    exit $stat
301c35d236eSmrg  fi
302c35d236eSmrg  rm -f "$depfile"
303c35d236eSmrg  # Each line is of the form `foo.o: dependent.h',
304c35d236eSmrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
305c35d236eSmrg  # Do two passes, one to just change these to
306c35d236eSmrg  # `$object: dependent.h' and one to simply `dependent.h:'.
307c35d236eSmrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
308c35d236eSmrg  # Some versions of the HPUX 10.20 sed can't process this invocation
309c35d236eSmrg  # correctly.  Breaking it into two sed invocations is a workaround.
310c35d236eSmrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
311c35d236eSmrg    sed -e 's/$/ :/' >> "$depfile"
312c35d236eSmrg  rm -f "$tmpdepfile"
313c35d236eSmrg  ;;
314c35d236eSmrg
3154f6cd06fSmrghp2)
3164f6cd06fSmrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
3174f6cd06fSmrg  # compilers, which have integrated preprocessors.  The correct option
3184f6cd06fSmrg  # to use with these is +Maked; it writes dependencies to a file named
3194f6cd06fSmrg  # 'foo.d', which lands next to the object file, wherever that
3204f6cd06fSmrg  # happens to be.
3214f6cd06fSmrg  # Much of this is similar to the tru64 case; see comments there.
3224f6cd06fSmrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3234f6cd06fSmrg  test "x$dir" = "x$object" && dir=
3244f6cd06fSmrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3254f6cd06fSmrg  if test "$libtool" = yes; then
3264f6cd06fSmrg    tmpdepfile1=$dir$base.d
3274f6cd06fSmrg    tmpdepfile2=$dir.libs/$base.d
3284f6cd06fSmrg    "$@" -Wc,+Maked
3294f6cd06fSmrg  else
3304f6cd06fSmrg    tmpdepfile1=$dir$base.d
3314f6cd06fSmrg    tmpdepfile2=$dir$base.d
3324f6cd06fSmrg    "$@" +Maked
3334f6cd06fSmrg  fi
3344f6cd06fSmrg  stat=$?
3354f6cd06fSmrg  if test $stat -eq 0; then :
3364f6cd06fSmrg  else
3374f6cd06fSmrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
3384f6cd06fSmrg     exit $stat
3394f6cd06fSmrg  fi
3404f6cd06fSmrg
3414f6cd06fSmrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
3424f6cd06fSmrg  do
3434f6cd06fSmrg    test -f "$tmpdepfile" && break
3444f6cd06fSmrg  done
3454f6cd06fSmrg  if test -f "$tmpdepfile"; then
3464f6cd06fSmrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
3474f6cd06fSmrg    # Add `dependent.h:' lines.
348518bcf38Smrg    sed -ne '2,${
349518bcf38Smrg	       s/^ *//
350518bcf38Smrg	       s/ \\*$//
351518bcf38Smrg	       s/$/:/
352518bcf38Smrg	       p
353518bcf38Smrg	     }' "$tmpdepfile" >> "$depfile"
3544f6cd06fSmrg  else
3554f6cd06fSmrg    echo "#dummy" > "$depfile"
3564f6cd06fSmrg  fi
3574f6cd06fSmrg  rm -f "$tmpdepfile" "$tmpdepfile2"
3584f6cd06fSmrg  ;;
3594f6cd06fSmrg
360c35d236eSmrgtru64)
361c35d236eSmrg   # The Tru64 compiler uses -MD to generate dependencies as a side
362c35d236eSmrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
363c35d236eSmrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
364c35d236eSmrg   # dependencies in `foo.d' instead, so we check for that too.
365c35d236eSmrg   # Subdirectories are respected.
366c35d236eSmrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
367c35d236eSmrg   test "x$dir" = "x$object" && dir=
368c35d236eSmrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
369c35d236eSmrg
370c35d236eSmrg   if test "$libtool" = yes; then
371c35d236eSmrg      # With Tru64 cc, shared objects can also be used to make a
3724f6cd06fSmrg      # static library.  This mechanism is used in libtool 1.4 series to
373c35d236eSmrg      # handle both shared and static libraries in a single compilation.
374c35d236eSmrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
375c35d236eSmrg      #
376c35d236eSmrg      # With libtool 1.5 this exception was removed, and libtool now
377c35d236eSmrg      # generates 2 separate objects for the 2 libraries.  These two
3784f6cd06fSmrg      # compilations output dependencies in $dir.libs/$base.o.d and
379c35d236eSmrg      # in $dir$base.o.d.  We have to check for both files, because
380c35d236eSmrg      # one of the two compilations can be disabled.  We should prefer
381c35d236eSmrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
382c35d236eSmrg      # automatically cleaned when .libs/ is deleted, while ignoring
383c35d236eSmrg      # the former would cause a distcleancheck panic.
384c35d236eSmrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
385c35d236eSmrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
386c35d236eSmrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
387c35d236eSmrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
388c35d236eSmrg      "$@" -Wc,-MD
389c35d236eSmrg   else
390c35d236eSmrg      tmpdepfile1=$dir$base.o.d
391c35d236eSmrg      tmpdepfile2=$dir$base.d
392c35d236eSmrg      tmpdepfile3=$dir$base.d
393c35d236eSmrg      tmpdepfile4=$dir$base.d
394c35d236eSmrg      "$@" -MD
395c35d236eSmrg   fi
396c35d236eSmrg
397c35d236eSmrg   stat=$?
398c35d236eSmrg   if test $stat -eq 0; then :
399c35d236eSmrg   else
400c35d236eSmrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
401c35d236eSmrg      exit $stat
402c35d236eSmrg   fi
403c35d236eSmrg
404c35d236eSmrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
405c35d236eSmrg   do
406c35d236eSmrg     test -f "$tmpdepfile" && break
407c35d236eSmrg   done
408c35d236eSmrg   if test -f "$tmpdepfile"; then
409c35d236eSmrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
410c35d236eSmrg      # That's a tab and a space in the [].
411c35d236eSmrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
412c35d236eSmrg   else
413c35d236eSmrg      echo "#dummy" > "$depfile"
414c35d236eSmrg   fi
415c35d236eSmrg   rm -f "$tmpdepfile"
416c35d236eSmrg   ;;
417c35d236eSmrg
4181fb744b4Smrgmsvc7)
4191fb744b4Smrg  if test "$libtool" = yes; then
4201fb744b4Smrg    showIncludes=-Wc,-showIncludes
4211fb744b4Smrg  else
4221fb744b4Smrg    showIncludes=-showIncludes
4231fb744b4Smrg  fi
4241fb744b4Smrg  "$@" $showIncludes > "$tmpdepfile"
4251fb744b4Smrg  stat=$?
4261fb744b4Smrg  grep -v '^Note: including file: ' "$tmpdepfile"
4271fb744b4Smrg  if test "$stat" = 0; then :
4281fb744b4Smrg  else
4291fb744b4Smrg    rm -f "$tmpdepfile"
4301fb744b4Smrg    exit $stat
4311fb744b4Smrg  fi
4321fb744b4Smrg  rm -f "$depfile"
4331fb744b4Smrg  echo "$object : \\" > "$depfile"
4341fb744b4Smrg  # The first sed program below extracts the file names and escapes
4351fb744b4Smrg  # backslashes for cygpath.  The second sed program outputs the file
4361fb744b4Smrg  # name when reading, but also accumulates all include files in the
4371fb744b4Smrg  # hold buffer in order to output them again at the end.  This only
4381fb744b4Smrg  # works with sed implementations that can handle large buffers.
4391fb744b4Smrg  sed < "$tmpdepfile" -n '
4401fb744b4Smrg/^Note: including file:  *\(.*\)/ {
4411fb744b4Smrg  s//\1/
4421fb744b4Smrg  s/\\/\\\\/g
4431fb744b4Smrg  p
4441fb744b4Smrg}' | $cygpath_u | sort -u | sed -n '
4451fb744b4Smrgs/ /\\ /g
4461fb744b4Smrgs/\(.*\)/	\1 \\/p
4471fb744b4Smrgs/.\(.*\) \\/\1:/
4481fb744b4SmrgH
4491fb744b4Smrg$ {
4501fb744b4Smrg  s/.*/	/
4511fb744b4Smrg  G
4521fb744b4Smrg  p
4531fb744b4Smrg}' >> "$depfile"
4541fb744b4Smrg  rm -f "$tmpdepfile"
4551fb744b4Smrg  ;;
4561fb744b4Smrg
4571fb744b4Smrgmsvc7msys)
4581fb744b4Smrg  # This case exists only to let depend.m4 do its work.  It works by
4591fb744b4Smrg  # looking at the text of this script.  This case will never be run,
4601fb744b4Smrg  # since it is checked for above.
4611fb744b4Smrg  exit 1
4621fb744b4Smrg  ;;
4631fb744b4Smrg
464c35d236eSmrg#nosideeffect)
465c35d236eSmrg  # This comment above is used by automake to tell side-effect
466c35d236eSmrg  # dependency tracking mechanisms from slower ones.
467c35d236eSmrg
468c35d236eSmrgdashmstdout)
469c35d236eSmrg  # Important note: in order to support this mode, a compiler *must*
470c35d236eSmrg  # always write the preprocessed file to stdout, regardless of -o.
471c35d236eSmrg  "$@" || exit $?
472c35d236eSmrg
473c35d236eSmrg  # Remove the call to Libtool.
474c35d236eSmrg  if test "$libtool" = yes; then
475518bcf38Smrg    while test "X$1" != 'X--mode=compile'; do
476c35d236eSmrg      shift
477c35d236eSmrg    done
478c35d236eSmrg    shift
479c35d236eSmrg  fi
480c35d236eSmrg
481c35d236eSmrg  # Remove `-o $object'.
482c35d236eSmrg  IFS=" "
483c35d236eSmrg  for arg
484c35d236eSmrg  do
485c35d236eSmrg    case $arg in
486c35d236eSmrg    -o)
487c35d236eSmrg      shift
488c35d236eSmrg      ;;
489c35d236eSmrg    $object)
490c35d236eSmrg      shift
491c35d236eSmrg      ;;
492c35d236eSmrg    *)
493c35d236eSmrg      set fnord "$@" "$arg"
494c35d236eSmrg      shift # fnord
495c35d236eSmrg      shift # $arg
496c35d236eSmrg      ;;
497c35d236eSmrg    esac
498c35d236eSmrg  done
499c35d236eSmrg
500c35d236eSmrg  test -z "$dashmflag" && dashmflag=-M
501c35d236eSmrg  # Require at least two characters before searching for `:'
502c35d236eSmrg  # in the target name.  This is to cope with DOS-style filenames:
503c35d236eSmrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
504c35d236eSmrg  "$@" $dashmflag |
505c35d236eSmrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
506c35d236eSmrg  rm -f "$depfile"
507c35d236eSmrg  cat < "$tmpdepfile" > "$depfile"
508c35d236eSmrg  tr ' ' '
509c35d236eSmrg' < "$tmpdepfile" | \
510c35d236eSmrg## Some versions of the HPUX 10.20 sed can't process this invocation
511c35d236eSmrg## correctly.  Breaking it into two sed invocations is a workaround.
512c35d236eSmrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
513c35d236eSmrg  rm -f "$tmpdepfile"
514c35d236eSmrg  ;;
515c35d236eSmrg
516c35d236eSmrgdashXmstdout)
517c35d236eSmrg  # This case only exists to satisfy depend.m4.  It is never actually
518c35d236eSmrg  # run, as this mode is specially recognized in the preamble.
519c35d236eSmrg  exit 1
520c35d236eSmrg  ;;
521c35d236eSmrg
522c35d236eSmrgmakedepend)
523c35d236eSmrg  "$@" || exit $?
524c35d236eSmrg  # Remove any Libtool call
525c35d236eSmrg  if test "$libtool" = yes; then
526518bcf38Smrg    while test "X$1" != 'X--mode=compile'; do
527c35d236eSmrg      shift
528c35d236eSmrg    done
529c35d236eSmrg    shift
530c35d236eSmrg  fi
531c35d236eSmrg  # X makedepend
532c35d236eSmrg  shift
533518bcf38Smrg  cleared=no eat=no
534518bcf38Smrg  for arg
535518bcf38Smrg  do
536c35d236eSmrg    case $cleared in
537c35d236eSmrg    no)
538c35d236eSmrg      set ""; shift
539c35d236eSmrg      cleared=yes ;;
540c35d236eSmrg    esac
541518bcf38Smrg    if test $eat = yes; then
542518bcf38Smrg      eat=no
543518bcf38Smrg      continue
544518bcf38Smrg    fi
545c35d236eSmrg    case "$arg" in
546c35d236eSmrg    -D*|-I*)
547c35d236eSmrg      set fnord "$@" "$arg"; shift ;;
548c35d236eSmrg    # Strip any option that makedepend may not understand.  Remove
549c35d236eSmrg    # the object too, otherwise makedepend will parse it as a source file.
550518bcf38Smrg    -arch)
551518bcf38Smrg      eat=yes ;;
552c35d236eSmrg    -*|$object)
553c35d236eSmrg      ;;
554c35d236eSmrg    *)
555c35d236eSmrg      set fnord "$@" "$arg"; shift ;;
556c35d236eSmrg    esac
557c35d236eSmrg  done
558518bcf38Smrg  obj_suffix=`echo "$object" | sed 's/^.*\././'`
559c35d236eSmrg  touch "$tmpdepfile"
560c35d236eSmrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
561c35d236eSmrg  rm -f "$depfile"
5621fb744b4Smrg  # makedepend may prepend the VPATH from the source file name to the object.
5631fb744b4Smrg  # No need to regex-escape $object, excess matching of '.' is harmless.
5641fb744b4Smrg  sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
565c35d236eSmrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
566c35d236eSmrg' | \
567c35d236eSmrg## Some versions of the HPUX 10.20 sed can't process this invocation
568c35d236eSmrg## correctly.  Breaking it into two sed invocations is a workaround.
569c35d236eSmrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
570c35d236eSmrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
571c35d236eSmrg  ;;
572c35d236eSmrg
573c35d236eSmrgcpp)
574c35d236eSmrg  # Important note: in order to support this mode, a compiler *must*
575c35d236eSmrg  # always write the preprocessed file to stdout.
576c35d236eSmrg  "$@" || exit $?
577c35d236eSmrg
578c35d236eSmrg  # Remove the call to Libtool.
579c35d236eSmrg  if test "$libtool" = yes; then
580518bcf38Smrg    while test "X$1" != 'X--mode=compile'; do
581c35d236eSmrg      shift
582c35d236eSmrg    done
583c35d236eSmrg    shift
584c35d236eSmrg  fi
585c35d236eSmrg
586c35d236eSmrg  # Remove `-o $object'.
587c35d236eSmrg  IFS=" "
588c35d236eSmrg  for arg
589c35d236eSmrg  do
590c35d236eSmrg    case $arg in
591c35d236eSmrg    -o)
592c35d236eSmrg      shift
593c35d236eSmrg      ;;
594c35d236eSmrg    $object)
595c35d236eSmrg      shift
596c35d236eSmrg      ;;
597c35d236eSmrg    *)
598c35d236eSmrg      set fnord "$@" "$arg"
599c35d236eSmrg      shift # fnord
600c35d236eSmrg      shift # $arg
601c35d236eSmrg      ;;
602c35d236eSmrg    esac
603c35d236eSmrg  done
604c35d236eSmrg
605c35d236eSmrg  "$@" -E |
606c35d236eSmrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
607c35d236eSmrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
608c35d236eSmrg    sed '$ s: \\$::' > "$tmpdepfile"
609c35d236eSmrg  rm -f "$depfile"
610c35d236eSmrg  echo "$object : \\" > "$depfile"
611c35d236eSmrg  cat < "$tmpdepfile" >> "$depfile"
612c35d236eSmrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
613c35d236eSmrg  rm -f "$tmpdepfile"
614c35d236eSmrg  ;;
615c35d236eSmrg
616c35d236eSmrgmsvisualcpp)
617c35d236eSmrg  # Important note: in order to support this mode, a compiler *must*
618518bcf38Smrg  # always write the preprocessed file to stdout.
619c35d236eSmrg  "$@" || exit $?
620518bcf38Smrg
621518bcf38Smrg  # Remove the call to Libtool.
622518bcf38Smrg  if test "$libtool" = yes; then
623518bcf38Smrg    while test "X$1" != 'X--mode=compile'; do
624518bcf38Smrg      shift
625518bcf38Smrg    done
626518bcf38Smrg    shift
627518bcf38Smrg  fi
628518bcf38Smrg
629c35d236eSmrg  IFS=" "
630c35d236eSmrg  for arg
631c35d236eSmrg  do
632c35d236eSmrg    case "$arg" in
633518bcf38Smrg    -o)
634518bcf38Smrg      shift
635518bcf38Smrg      ;;
636518bcf38Smrg    $object)
637518bcf38Smrg      shift
638518bcf38Smrg      ;;
639c35d236eSmrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
640c35d236eSmrg	set fnord "$@"
641c35d236eSmrg	shift
642c35d236eSmrg	shift
643c35d236eSmrg	;;
644c35d236eSmrg    *)
645c35d236eSmrg	set fnord "$@" "$arg"
646c35d236eSmrg	shift
647c35d236eSmrg	shift
648c35d236eSmrg	;;
649c35d236eSmrg    esac
650c35d236eSmrg  done
651518bcf38Smrg  "$@" -E 2>/dev/null |
652518bcf38Smrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
653c35d236eSmrg  rm -f "$depfile"
654c35d236eSmrg  echo "$object : \\" > "$depfile"
655518bcf38Smrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
656c35d236eSmrg  echo "	" >> "$depfile"
657518bcf38Smrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
658c35d236eSmrg  rm -f "$tmpdepfile"
659c35d236eSmrg  ;;
660c35d236eSmrg
661518bcf38Smrgmsvcmsys)
662518bcf38Smrg  # This case exists only to let depend.m4 do its work.  It works by
663518bcf38Smrg  # looking at the text of this script.  This case will never be run,
664518bcf38Smrg  # since it is checked for above.
665518bcf38Smrg  exit 1
666518bcf38Smrg  ;;
667518bcf38Smrg
668c35d236eSmrgnone)
669c35d236eSmrg  exec "$@"
670c35d236eSmrg  ;;
671c35d236eSmrg
672c35d236eSmrg*)
673c35d236eSmrg  echo "Unknown depmode $depmode" 1>&2
674c35d236eSmrg  exit 1
675c35d236eSmrg  ;;
676c35d236eSmrgesac
677c35d236eSmrg
678c35d236eSmrgexit 0
679c35d236eSmrg
680c35d236eSmrg# Local Variables:
681c35d236eSmrg# mode: shell-script
682c35d236eSmrg# sh-indentation: 2
683c35d236eSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
684c35d236eSmrg# time-stamp-start: "scriptversion="
685c35d236eSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
686518bcf38Smrg# time-stamp-time-zone: "UTC"
687518bcf38Smrg# time-stamp-end: "; # UTC"
688c35d236eSmrg# End:
689