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