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