depcomp revision b73be646
1659607e0Smrg#! /bin/sh
2659607e0Smrg# depcomp - compile a program generating dependencies as side-effects
3659607e0Smrg
4b73be646Smrgscriptversion=2009-04-28.21; # UTC
5659607e0Smrg
6b73be646Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
7b73be646Smrg# Software Foundation, Inc.
8659607e0Smrg
9659607e0Smrg# This program is free software; you can redistribute it and/or modify
10659607e0Smrg# it under the terms of the GNU General Public License as published by
11659607e0Smrg# the Free Software Foundation; either version 2, or (at your option)
12659607e0Smrg# any later version.
13659607e0Smrg
14659607e0Smrg# This program is distributed in the hope that it will be useful,
15659607e0Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
16659607e0Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17659607e0Smrg# GNU General Public License for more details.
18659607e0Smrg
19659607e0Smrg# You should have received a copy of the GNU General Public License
20b73be646Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21659607e0Smrg
22659607e0Smrg# As a special exception to the GNU General Public License, if you
23659607e0Smrg# distribute this file as part of a program that contains a
24659607e0Smrg# configuration script generated by Autoconf, you may include it under
25659607e0Smrg# the same distribution terms that you use for the rest of that program.
26659607e0Smrg
27659607e0Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
28659607e0Smrg
29659607e0Smrgcase $1 in
30659607e0Smrg  '')
31659607e0Smrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
32659607e0Smrg     exit 1;
33659607e0Smrg     ;;
34659607e0Smrg  -h | --h*)
35659607e0Smrg    cat <<\EOF
36659607e0SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
37659607e0Smrg
38659607e0SmrgRun PROGRAMS ARGS to compile a file, generating dependencies
39659607e0Smrgas side-effects.
40659607e0Smrg
41659607e0SmrgEnvironment variables:
42659607e0Smrg  depmode     Dependency tracking mode.
43659607e0Smrg  source      Source file read by `PROGRAMS ARGS'.
44659607e0Smrg  object      Object file output by `PROGRAMS ARGS'.
45659607e0Smrg  DEPDIR      directory where to store dependencies.
46659607e0Smrg  depfile     Dependency file to output.
47659607e0Smrg  tmpdepfile  Temporary file to use when outputing dependencies.
48659607e0Smrg  libtool     Whether libtool is used (yes/no).
49659607e0Smrg
50659607e0SmrgReport bugs to <bug-automake@gnu.org>.
51659607e0SmrgEOF
52659607e0Smrg    exit $?
53659607e0Smrg    ;;
54659607e0Smrg  -v | --v*)
55659607e0Smrg    echo "depcomp $scriptversion"
56659607e0Smrg    exit $?
57659607e0Smrg    ;;
58659607e0Smrgesac
59659607e0Smrg
60659607e0Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
61659607e0Smrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
62659607e0Smrg  exit 1
63659607e0Smrgfi
64659607e0Smrg
65659607e0Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
66659607e0Smrgdepfile=${depfile-`echo "$object" |
67659607e0Smrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
68659607e0Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
69659607e0Smrg
70659607e0Smrgrm -f "$tmpdepfile"
71659607e0Smrg
72659607e0Smrg# Some modes work just like other modes, but use different flags.  We
73659607e0Smrg# parameterize here, but still list the modes in the big case below,
74659607e0Smrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
75659607e0Smrg# here, because this file can only contain one case statement.
76659607e0Smrgif test "$depmode" = hp; then
77659607e0Smrg  # HP compiler uses -M and no extra arg.
78659607e0Smrg  gccflag=-M
79659607e0Smrg  depmode=gcc
80659607e0Smrgfi
81659607e0Smrg
82659607e0Smrgif test "$depmode" = dashXmstdout; then
83659607e0Smrg   # This is just like dashmstdout with a different argument.
84659607e0Smrg   dashmflag=-xM
85659607e0Smrg   depmode=dashmstdout
86659607e0Smrgfi
87659607e0Smrg
88b73be646Smrgcygpath_u="cygpath -u -f -"
89b73be646Smrgif test "$depmode" = msvcmsys; then
90b73be646Smrg   # This is just like msvisualcpp but w/o cygpath translation.
91b73be646Smrg   # Just convert the backslash-escaped backslashes to single forward
92b73be646Smrg   # slashes to satisfy depend.m4
93b73be646Smrg   cygpath_u="sed s,\\\\\\\\,/,g"
94b73be646Smrg   depmode=msvisualcpp
95b73be646Smrgfi
96b73be646Smrg
97659607e0Smrgcase "$depmode" in
98659607e0Smrggcc3)
99659607e0Smrg## gcc 3 implements dependency tracking that does exactly what
100659607e0Smrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
101659607e0Smrg## it if -MD -MP comes after the -MF stuff.  Hmm.
102659607e0Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
103659607e0Smrg## the command line argument order; so add the flags where they
104659607e0Smrg## appear in depend2.am.  Note that the slowdown incurred here
105659607e0Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
106659607e0Smrg  for arg
107659607e0Smrg  do
108659607e0Smrg    case $arg in
109659607e0Smrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
110659607e0Smrg    *)  set fnord "$@" "$arg" ;;
111659607e0Smrg    esac
112659607e0Smrg    shift # fnord
113659607e0Smrg    shift # $arg
114659607e0Smrg  done
115659607e0Smrg  "$@"
116659607e0Smrg  stat=$?
117659607e0Smrg  if test $stat -eq 0; then :
118659607e0Smrg  else
119659607e0Smrg    rm -f "$tmpdepfile"
120659607e0Smrg    exit $stat
121659607e0Smrg  fi
122659607e0Smrg  mv "$tmpdepfile" "$depfile"
123659607e0Smrg  ;;
124659607e0Smrg
125659607e0Smrggcc)
126659607e0Smrg## There are various ways to get dependency output from gcc.  Here's
127659607e0Smrg## why we pick this rather obscure method:
128659607e0Smrg## - Don't want to use -MD because we'd like the dependencies to end
129659607e0Smrg##   up in a subdir.  Having to rename by hand is ugly.
130659607e0Smrg##   (We might end up doing this anyway to support other compilers.)
131659607e0Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
132659607e0Smrg##   -MM, not -M (despite what the docs say).
133659607e0Smrg## - Using -M directly means running the compiler twice (even worse
134659607e0Smrg##   than renaming).
135659607e0Smrg  if test -z "$gccflag"; then
136659607e0Smrg    gccflag=-MD,
137659607e0Smrg  fi
138659607e0Smrg  "$@" -Wp,"$gccflag$tmpdepfile"
139659607e0Smrg  stat=$?
140659607e0Smrg  if test $stat -eq 0; then :
141659607e0Smrg  else
142659607e0Smrg    rm -f "$tmpdepfile"
143659607e0Smrg    exit $stat
144659607e0Smrg  fi
145659607e0Smrg  rm -f "$depfile"
146659607e0Smrg  echo "$object : \\" > "$depfile"
147659607e0Smrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
148659607e0Smrg## The second -e expression handles DOS-style file names with drive letters.
149659607e0Smrg  sed -e 's/^[^:]*: / /' \
150659607e0Smrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
151659607e0Smrg## This next piece of magic avoids the `deleted header file' problem.
152659607e0Smrg## The problem is that when a header file which appears in a .P file
153659607e0Smrg## is deleted, the dependency causes make to die (because there is
154659607e0Smrg## typically no way to rebuild the header).  We avoid this by adding
155659607e0Smrg## dummy dependencies for each header file.  Too bad gcc doesn't do
156659607e0Smrg## this for us directly.
157659607e0Smrg  tr ' ' '
158659607e0Smrg' < "$tmpdepfile" |
159659607e0Smrg## Some versions of gcc put a space before the `:'.  On the theory
160659607e0Smrg## that the space means something, we add a space to the output as
161659607e0Smrg## well.
162659607e0Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
163659607e0Smrg## correctly.  Breaking it into two sed invocations is a workaround.
164659607e0Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
165659607e0Smrg  rm -f "$tmpdepfile"
166659607e0Smrg  ;;
167659607e0Smrg
168659607e0Smrghp)
169659607e0Smrg  # This case exists only to let depend.m4 do its work.  It works by
170659607e0Smrg  # looking at the text of this script.  This case will never be run,
171659607e0Smrg  # since it is checked for above.
172659607e0Smrg  exit 1
173659607e0Smrg  ;;
174659607e0Smrg
175659607e0Smrgsgi)
176659607e0Smrg  if test "$libtool" = yes; then
177659607e0Smrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
178659607e0Smrg  else
179659607e0Smrg    "$@" -MDupdate "$tmpdepfile"
180659607e0Smrg  fi
181659607e0Smrg  stat=$?
182659607e0Smrg  if test $stat -eq 0; then :
183659607e0Smrg  else
184659607e0Smrg    rm -f "$tmpdepfile"
185659607e0Smrg    exit $stat
186659607e0Smrg  fi
187659607e0Smrg  rm -f "$depfile"
188659607e0Smrg
189659607e0Smrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
190659607e0Smrg    echo "$object : \\" > "$depfile"
191659607e0Smrg
192659607e0Smrg    # Clip off the initial element (the dependent).  Don't try to be
193659607e0Smrg    # clever and replace this with sed code, as IRIX sed won't handle
194659607e0Smrg    # lines with more than a fixed number of characters (4096 in
195659607e0Smrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
196659607e0Smrg    # the IRIX cc adds comments like `#:fec' to the end of the
197659607e0Smrg    # dependency line.
198659607e0Smrg    tr ' ' '
199659607e0Smrg' < "$tmpdepfile" \
200659607e0Smrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
201659607e0Smrg    tr '
202b73be646Smrg' ' ' >> "$depfile"
203b73be646Smrg    echo >> "$depfile"
204659607e0Smrg
205659607e0Smrg    # The second pass generates a dummy entry for each header file.
206659607e0Smrg    tr ' ' '
207659607e0Smrg' < "$tmpdepfile" \
208659607e0Smrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
209b73be646Smrg   >> "$depfile"
210659607e0Smrg  else
211659607e0Smrg    # The sourcefile does not contain any dependencies, so just
212659607e0Smrg    # store a dummy comment line, to avoid errors with the Makefile
213659607e0Smrg    # "include basename.Plo" scheme.
214659607e0Smrg    echo "#dummy" > "$depfile"
215659607e0Smrg  fi
216659607e0Smrg  rm -f "$tmpdepfile"
217659607e0Smrg  ;;
218659607e0Smrg
219659607e0Smrgaix)
220659607e0Smrg  # The C for AIX Compiler uses -M and outputs the dependencies
221659607e0Smrg  # in a .u file.  In older versions, this file always lives in the
222659607e0Smrg  # current directory.  Also, the AIX compiler puts `$object:' at the
223659607e0Smrg  # start of each line; $object doesn't have directory information.
224659607e0Smrg  # Version 6 uses the directory in both cases.
225fc27e79cSmrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
226fc27e79cSmrg  test "x$dir" = "x$object" && dir=
227fc27e79cSmrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
228659607e0Smrg  if test "$libtool" = yes; then
229fc27e79cSmrg    tmpdepfile1=$dir$base.u
230fc27e79cSmrg    tmpdepfile2=$base.u
231fc27e79cSmrg    tmpdepfile3=$dir.libs/$base.u
232659607e0Smrg    "$@" -Wc,-M
233659607e0Smrg  else
234fc27e79cSmrg    tmpdepfile1=$dir$base.u
235fc27e79cSmrg    tmpdepfile2=$dir$base.u
236fc27e79cSmrg    tmpdepfile3=$dir$base.u
237659607e0Smrg    "$@" -M
238659607e0Smrg  fi
239659607e0Smrg  stat=$?
240659607e0Smrg
241659607e0Smrg  if test $stat -eq 0; then :
242659607e0Smrg  else
243fc27e79cSmrg    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
244659607e0Smrg    exit $stat
245659607e0Smrg  fi
246659607e0Smrg
247fc27e79cSmrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
248fc27e79cSmrg  do
249fc27e79cSmrg    test -f "$tmpdepfile" && break
250fc27e79cSmrg  done
251659607e0Smrg  if test -f "$tmpdepfile"; then
252659607e0Smrg    # Each line is of the form `foo.o: dependent.h'.
253659607e0Smrg    # Do two passes, one to just change these to
254659607e0Smrg    # `$object: dependent.h' and one to simply `dependent.h:'.
255fc27e79cSmrg    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
256fc27e79cSmrg    # That's a tab and a space in the [].
257fc27e79cSmrg    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
258659607e0Smrg  else
259659607e0Smrg    # The sourcefile does not contain any dependencies, so just
260659607e0Smrg    # store a dummy comment line, to avoid errors with the Makefile
261659607e0Smrg    # "include basename.Plo" scheme.
262659607e0Smrg    echo "#dummy" > "$depfile"
263659607e0Smrg  fi
264659607e0Smrg  rm -f "$tmpdepfile"
265659607e0Smrg  ;;
266659607e0Smrg
267659607e0Smrgicc)
268659607e0Smrg  # Intel's C compiler understands `-MD -MF file'.  However on
269659607e0Smrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
270659607e0Smrg  # ICC 7.0 will fill foo.d with something like
271659607e0Smrg  #    foo.o: sub/foo.c
272659607e0Smrg  #    foo.o: sub/foo.h
273659607e0Smrg  # which is wrong.  We want:
274659607e0Smrg  #    sub/foo.o: sub/foo.c
275659607e0Smrg  #    sub/foo.o: sub/foo.h
276659607e0Smrg  #    sub/foo.c:
277659607e0Smrg  #    sub/foo.h:
278659607e0Smrg  # ICC 7.1 will output
279659607e0Smrg  #    foo.o: sub/foo.c sub/foo.h
280659607e0Smrg  # and will wrap long lines using \ :
281659607e0Smrg  #    foo.o: sub/foo.c ... \
282659607e0Smrg  #     sub/foo.h ... \
283659607e0Smrg  #     ...
284659607e0Smrg
285659607e0Smrg  "$@" -MD -MF "$tmpdepfile"
286659607e0Smrg  stat=$?
287659607e0Smrg  if test $stat -eq 0; then :
288659607e0Smrg  else
289659607e0Smrg    rm -f "$tmpdepfile"
290659607e0Smrg    exit $stat
291659607e0Smrg  fi
292659607e0Smrg  rm -f "$depfile"
293659607e0Smrg  # Each line is of the form `foo.o: dependent.h',
294659607e0Smrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
295659607e0Smrg  # Do two passes, one to just change these to
296659607e0Smrg  # `$object: dependent.h' and one to simply `dependent.h:'.
297659607e0Smrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
298659607e0Smrg  # Some versions of the HPUX 10.20 sed can't process this invocation
299659607e0Smrg  # correctly.  Breaking it into two sed invocations is a workaround.
300659607e0Smrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
301659607e0Smrg    sed -e 's/$/ :/' >> "$depfile"
302659607e0Smrg  rm -f "$tmpdepfile"
303659607e0Smrg  ;;
304659607e0Smrg
305659607e0Smrghp2)
306659607e0Smrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
307659607e0Smrg  # compilers, which have integrated preprocessors.  The correct option
308659607e0Smrg  # to use with these is +Maked; it writes dependencies to a file named
309659607e0Smrg  # 'foo.d', which lands next to the object file, wherever that
310659607e0Smrg  # happens to be.
311659607e0Smrg  # Much of this is similar to the tru64 case; see comments there.
312659607e0Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
313659607e0Smrg  test "x$dir" = "x$object" && dir=
314659607e0Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
315659607e0Smrg  if test "$libtool" = yes; then
316659607e0Smrg    tmpdepfile1=$dir$base.d
317659607e0Smrg    tmpdepfile2=$dir.libs/$base.d
318659607e0Smrg    "$@" -Wc,+Maked
319659607e0Smrg  else
320659607e0Smrg    tmpdepfile1=$dir$base.d
321659607e0Smrg    tmpdepfile2=$dir$base.d
322659607e0Smrg    "$@" +Maked
323659607e0Smrg  fi
324659607e0Smrg  stat=$?
325659607e0Smrg  if test $stat -eq 0; then :
326659607e0Smrg  else
327659607e0Smrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
328659607e0Smrg     exit $stat
329659607e0Smrg  fi
330659607e0Smrg
331659607e0Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
332659607e0Smrg  do
333659607e0Smrg    test -f "$tmpdepfile" && break
334659607e0Smrg  done
335659607e0Smrg  if test -f "$tmpdepfile"; then
336659607e0Smrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
337659607e0Smrg    # Add `dependent.h:' lines.
338b73be646Smrg    sed -ne '2,${
339b73be646Smrg	       s/^ *//
340b73be646Smrg	       s/ \\*$//
341b73be646Smrg	       s/$/:/
342b73be646Smrg	       p
343b73be646Smrg	     }' "$tmpdepfile" >> "$depfile"
344659607e0Smrg  else
345659607e0Smrg    echo "#dummy" > "$depfile"
346659607e0Smrg  fi
347659607e0Smrg  rm -f "$tmpdepfile" "$tmpdepfile2"
348659607e0Smrg  ;;
349659607e0Smrg
350659607e0Smrgtru64)
351659607e0Smrg   # The Tru64 compiler uses -MD to generate dependencies as a side
352659607e0Smrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
353659607e0Smrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
354659607e0Smrg   # dependencies in `foo.d' instead, so we check for that too.
355659607e0Smrg   # Subdirectories are respected.
356659607e0Smrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
357659607e0Smrg   test "x$dir" = "x$object" && dir=
358659607e0Smrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
359659607e0Smrg
360659607e0Smrg   if test "$libtool" = yes; then
361659607e0Smrg      # With Tru64 cc, shared objects can also be used to make a
362659607e0Smrg      # static library.  This mechanism is used in libtool 1.4 series to
363659607e0Smrg      # handle both shared and static libraries in a single compilation.
364659607e0Smrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
365659607e0Smrg      #
366659607e0Smrg      # With libtool 1.5 this exception was removed, and libtool now
367659607e0Smrg      # generates 2 separate objects for the 2 libraries.  These two
368659607e0Smrg      # compilations output dependencies in $dir.libs/$base.o.d and
369659607e0Smrg      # in $dir$base.o.d.  We have to check for both files, because
370659607e0Smrg      # one of the two compilations can be disabled.  We should prefer
371659607e0Smrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
372659607e0Smrg      # automatically cleaned when .libs/ is deleted, while ignoring
373659607e0Smrg      # the former would cause a distcleancheck panic.
374659607e0Smrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
375659607e0Smrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
376659607e0Smrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
377659607e0Smrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
378659607e0Smrg      "$@" -Wc,-MD
379659607e0Smrg   else
380659607e0Smrg      tmpdepfile1=$dir$base.o.d
381659607e0Smrg      tmpdepfile2=$dir$base.d
382659607e0Smrg      tmpdepfile3=$dir$base.d
383659607e0Smrg      tmpdepfile4=$dir$base.d
384659607e0Smrg      "$@" -MD
385659607e0Smrg   fi
386659607e0Smrg
387659607e0Smrg   stat=$?
388659607e0Smrg   if test $stat -eq 0; then :
389659607e0Smrg   else
390659607e0Smrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
391659607e0Smrg      exit $stat
392659607e0Smrg   fi
393659607e0Smrg
394659607e0Smrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
395659607e0Smrg   do
396659607e0Smrg     test -f "$tmpdepfile" && break
397659607e0Smrg   done
398659607e0Smrg   if test -f "$tmpdepfile"; then
399659607e0Smrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
400659607e0Smrg      # That's a tab and a space in the [].
401659607e0Smrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
402659607e0Smrg   else
403659607e0Smrg      echo "#dummy" > "$depfile"
404659607e0Smrg   fi
405659607e0Smrg   rm -f "$tmpdepfile"
406659607e0Smrg   ;;
407659607e0Smrg
408659607e0Smrg#nosideeffect)
409659607e0Smrg  # This comment above is used by automake to tell side-effect
410659607e0Smrg  # dependency tracking mechanisms from slower ones.
411659607e0Smrg
412659607e0Smrgdashmstdout)
413659607e0Smrg  # Important note: in order to support this mode, a compiler *must*
414659607e0Smrg  # always write the preprocessed file to stdout, regardless of -o.
415659607e0Smrg  "$@" || exit $?
416659607e0Smrg
417659607e0Smrg  # Remove the call to Libtool.
418659607e0Smrg  if test "$libtool" = yes; then
419b73be646Smrg    while test "X$1" != 'X--mode=compile'; do
420659607e0Smrg      shift
421659607e0Smrg    done
422659607e0Smrg    shift
423659607e0Smrg  fi
424659607e0Smrg
425659607e0Smrg  # Remove `-o $object'.
426659607e0Smrg  IFS=" "
427659607e0Smrg  for arg
428659607e0Smrg  do
429659607e0Smrg    case $arg in
430659607e0Smrg    -o)
431659607e0Smrg      shift
432659607e0Smrg      ;;
433659607e0Smrg    $object)
434659607e0Smrg      shift
435659607e0Smrg      ;;
436659607e0Smrg    *)
437659607e0Smrg      set fnord "$@" "$arg"
438659607e0Smrg      shift # fnord
439659607e0Smrg      shift # $arg
440659607e0Smrg      ;;
441659607e0Smrg    esac
442659607e0Smrg  done
443659607e0Smrg
444659607e0Smrg  test -z "$dashmflag" && dashmflag=-M
445659607e0Smrg  # Require at least two characters before searching for `:'
446659607e0Smrg  # in the target name.  This is to cope with DOS-style filenames:
447659607e0Smrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
448659607e0Smrg  "$@" $dashmflag |
449659607e0Smrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
450659607e0Smrg  rm -f "$depfile"
451659607e0Smrg  cat < "$tmpdepfile" > "$depfile"
452659607e0Smrg  tr ' ' '
453659607e0Smrg' < "$tmpdepfile" | \
454659607e0Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
455659607e0Smrg## correctly.  Breaking it into two sed invocations is a workaround.
456659607e0Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
457659607e0Smrg  rm -f "$tmpdepfile"
458659607e0Smrg  ;;
459659607e0Smrg
460659607e0SmrgdashXmstdout)
461659607e0Smrg  # This case only exists to satisfy depend.m4.  It is never actually
462659607e0Smrg  # run, as this mode is specially recognized in the preamble.
463659607e0Smrg  exit 1
464659607e0Smrg  ;;
465659607e0Smrg
466659607e0Smrgmakedepend)
467659607e0Smrg  "$@" || exit $?
468659607e0Smrg  # Remove any Libtool call
469659607e0Smrg  if test "$libtool" = yes; then
470b73be646Smrg    while test "X$1" != 'X--mode=compile'; do
471659607e0Smrg      shift
472659607e0Smrg    done
473659607e0Smrg    shift
474659607e0Smrg  fi
475659607e0Smrg  # X makedepend
476659607e0Smrg  shift
477b73be646Smrg  cleared=no eat=no
478b73be646Smrg  for arg
479b73be646Smrg  do
480659607e0Smrg    case $cleared in
481659607e0Smrg    no)
482659607e0Smrg      set ""; shift
483659607e0Smrg      cleared=yes ;;
484659607e0Smrg    esac
485b73be646Smrg    if test $eat = yes; then
486b73be646Smrg      eat=no
487b73be646Smrg      continue
488b73be646Smrg    fi
489659607e0Smrg    case "$arg" in
490659607e0Smrg    -D*|-I*)
491659607e0Smrg      set fnord "$@" "$arg"; shift ;;
492659607e0Smrg    # Strip any option that makedepend may not understand.  Remove
493659607e0Smrg    # the object too, otherwise makedepend will parse it as a source file.
494b73be646Smrg    -arch)
495b73be646Smrg      eat=yes ;;
496659607e0Smrg    -*|$object)
497659607e0Smrg      ;;
498659607e0Smrg    *)
499659607e0Smrg      set fnord "$@" "$arg"; shift ;;
500659607e0Smrg    esac
501659607e0Smrg  done
502b73be646Smrg  obj_suffix=`echo "$object" | sed 's/^.*\././'`
503659607e0Smrg  touch "$tmpdepfile"
504659607e0Smrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
505659607e0Smrg  rm -f "$depfile"
506659607e0Smrg  cat < "$tmpdepfile" > "$depfile"
507659607e0Smrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
508659607e0Smrg' | \
509659607e0Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
510659607e0Smrg## correctly.  Breaking it into two sed invocations is a workaround.
511659607e0Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
512659607e0Smrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
513659607e0Smrg  ;;
514659607e0Smrg
515659607e0Smrgcpp)
516659607e0Smrg  # Important note: in order to support this mode, a compiler *must*
517659607e0Smrg  # always write the preprocessed file to stdout.
518659607e0Smrg  "$@" || exit $?
519659607e0Smrg
520659607e0Smrg  # Remove the call to Libtool.
521659607e0Smrg  if test "$libtool" = yes; then
522b73be646Smrg    while test "X$1" != 'X--mode=compile'; do
523659607e0Smrg      shift
524659607e0Smrg    done
525659607e0Smrg    shift
526659607e0Smrg  fi
527659607e0Smrg
528659607e0Smrg  # Remove `-o $object'.
529659607e0Smrg  IFS=" "
530659607e0Smrg  for arg
531659607e0Smrg  do
532659607e0Smrg    case $arg in
533659607e0Smrg    -o)
534659607e0Smrg      shift
535659607e0Smrg      ;;
536659607e0Smrg    $object)
537659607e0Smrg      shift
538659607e0Smrg      ;;
539659607e0Smrg    *)
540659607e0Smrg      set fnord "$@" "$arg"
541659607e0Smrg      shift # fnord
542659607e0Smrg      shift # $arg
543659607e0Smrg      ;;
544659607e0Smrg    esac
545659607e0Smrg  done
546659607e0Smrg
547659607e0Smrg  "$@" -E |
548659607e0Smrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
549659607e0Smrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
550659607e0Smrg    sed '$ s: \\$::' > "$tmpdepfile"
551659607e0Smrg  rm -f "$depfile"
552659607e0Smrg  echo "$object : \\" > "$depfile"
553659607e0Smrg  cat < "$tmpdepfile" >> "$depfile"
554659607e0Smrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
555659607e0Smrg  rm -f "$tmpdepfile"
556659607e0Smrg  ;;
557659607e0Smrg
558659607e0Smrgmsvisualcpp)
559659607e0Smrg  # Important note: in order to support this mode, a compiler *must*
560b73be646Smrg  # always write the preprocessed file to stdout.
561659607e0Smrg  "$@" || exit $?
562b73be646Smrg
563b73be646Smrg  # Remove the call to Libtool.
564b73be646Smrg  if test "$libtool" = yes; then
565b73be646Smrg    while test "X$1" != 'X--mode=compile'; do
566b73be646Smrg      shift
567b73be646Smrg    done
568b73be646Smrg    shift
569b73be646Smrg  fi
570b73be646Smrg
571659607e0Smrg  IFS=" "
572659607e0Smrg  for arg
573659607e0Smrg  do
574659607e0Smrg    case "$arg" in
575b73be646Smrg    -o)
576b73be646Smrg      shift
577b73be646Smrg      ;;
578b73be646Smrg    $object)
579b73be646Smrg      shift
580b73be646Smrg      ;;
581659607e0Smrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
582659607e0Smrg	set fnord "$@"
583659607e0Smrg	shift
584659607e0Smrg	shift
585659607e0Smrg	;;
586659607e0Smrg    *)
587659607e0Smrg	set fnord "$@" "$arg"
588659607e0Smrg	shift
589659607e0Smrg	shift
590659607e0Smrg	;;
591659607e0Smrg    esac
592659607e0Smrg  done
593b73be646Smrg  "$@" -E 2>/dev/null |
594b73be646Smrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
595659607e0Smrg  rm -f "$depfile"
596659607e0Smrg  echo "$object : \\" > "$depfile"
597b73be646Smrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
598659607e0Smrg  echo "	" >> "$depfile"
599b73be646Smrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
600659607e0Smrg  rm -f "$tmpdepfile"
601659607e0Smrg  ;;
602659607e0Smrg
603b73be646Smrgmsvcmsys)
604b73be646Smrg  # This case exists only to let depend.m4 do its work.  It works by
605b73be646Smrg  # looking at the text of this script.  This case will never be run,
606b73be646Smrg  # since it is checked for above.
607b73be646Smrg  exit 1
608b73be646Smrg  ;;
609b73be646Smrg
610659607e0Smrgnone)
611659607e0Smrg  exec "$@"
612659607e0Smrg  ;;
613659607e0Smrg
614659607e0Smrg*)
615659607e0Smrg  echo "Unknown depmode $depmode" 1>&2
616659607e0Smrg  exit 1
617659607e0Smrg  ;;
618659607e0Smrgesac
619659607e0Smrg
620659607e0Smrgexit 0
621659607e0Smrg
622659607e0Smrg# Local Variables:
623659607e0Smrg# mode: shell-script
624659607e0Smrg# sh-indentation: 2
625659607e0Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
626659607e0Smrg# time-stamp-start: "scriptversion="
627659607e0Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
628b73be646Smrg# time-stamp-time-zone: "UTC"
629b73be646Smrg# time-stamp-end: "; # UTC"
630659607e0Smrg# End:
631