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