depcomp revision 48e69166
1fd0c672fSmrg#! /bin/sh
2fd0c672fSmrg# depcomp - compile a program generating dependencies as side-effects
3fd0c672fSmrg
448e69166Smrgscriptversion=2009-04-28.21; # UTC
5fd0c672fSmrg
648e69166Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
748e69166Smrg# Software Foundation, Inc.
8fd0c672fSmrg
9fd0c672fSmrg# This program is free software; you can redistribute it and/or modify
10fd0c672fSmrg# it under the terms of the GNU General Public License as published by
11fd0c672fSmrg# the Free Software Foundation; either version 2, or (at your option)
12fd0c672fSmrg# any later version.
13fd0c672fSmrg
14fd0c672fSmrg# This program is distributed in the hope that it will be useful,
15fd0c672fSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
16fd0c672fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17fd0c672fSmrg# GNU General Public License for more details.
18fd0c672fSmrg
19fd0c672fSmrg# You should have received a copy of the GNU General Public License
2048e69166Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21fd0c672fSmrg
22fd0c672fSmrg# As a special exception to the GNU General Public License, if you
23fd0c672fSmrg# distribute this file as part of a program that contains a
24fd0c672fSmrg# configuration script generated by Autoconf, you may include it under
25fd0c672fSmrg# the same distribution terms that you use for the rest of that program.
26fd0c672fSmrg
27fd0c672fSmrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
28fd0c672fSmrg
29fd0c672fSmrgcase $1 in
30fd0c672fSmrg  '')
31fd0c672fSmrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
32fd0c672fSmrg     exit 1;
33fd0c672fSmrg     ;;
34fd0c672fSmrg  -h | --h*)
35fd0c672fSmrg    cat <<\EOF
36fd0c672fSmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
37fd0c672fSmrg
38fd0c672fSmrgRun PROGRAMS ARGS to compile a file, generating dependencies
39fd0c672fSmrgas side-effects.
40fd0c672fSmrg
41fd0c672fSmrgEnvironment variables:
42fd0c672fSmrg  depmode     Dependency tracking mode.
43fd0c672fSmrg  source      Source file read by `PROGRAMS ARGS'.
44fd0c672fSmrg  object      Object file output by `PROGRAMS ARGS'.
45fd0c672fSmrg  DEPDIR      directory where to store dependencies.
46fd0c672fSmrg  depfile     Dependency file to output.
47fd0c672fSmrg  tmpdepfile  Temporary file to use when outputing dependencies.
48fd0c672fSmrg  libtool     Whether libtool is used (yes/no).
49fd0c672fSmrg
50fd0c672fSmrgReport bugs to <bug-automake@gnu.org>.
51fd0c672fSmrgEOF
52fd0c672fSmrg    exit $?
53fd0c672fSmrg    ;;
54fd0c672fSmrg  -v | --v*)
55fd0c672fSmrg    echo "depcomp $scriptversion"
56fd0c672fSmrg    exit $?
57fd0c672fSmrg    ;;
58fd0c672fSmrgesac
59fd0c672fSmrg
60fd0c672fSmrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
61fd0c672fSmrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
62fd0c672fSmrg  exit 1
63fd0c672fSmrgfi
64fd0c672fSmrg
65fd0c672fSmrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
66fd0c672fSmrgdepfile=${depfile-`echo "$object" |
67fd0c672fSmrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
68fd0c672fSmrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
69fd0c672fSmrg
70fd0c672fSmrgrm -f "$tmpdepfile"
71fd0c672fSmrg
72fd0c672fSmrg# Some modes work just like other modes, but use different flags.  We
73fd0c672fSmrg# parameterize here, but still list the modes in the big case below,
74fd0c672fSmrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
75fd0c672fSmrg# here, because this file can only contain one case statement.
76fd0c672fSmrgif test "$depmode" = hp; then
77fd0c672fSmrg  # HP compiler uses -M and no extra arg.
78fd0c672fSmrg  gccflag=-M
79fd0c672fSmrg  depmode=gcc
80fd0c672fSmrgfi
81fd0c672fSmrg
82fd0c672fSmrgif test "$depmode" = dashXmstdout; then
83fd0c672fSmrg   # This is just like dashmstdout with a different argument.
84fd0c672fSmrg   dashmflag=-xM
85fd0c672fSmrg   depmode=dashmstdout
86fd0c672fSmrgfi
87fd0c672fSmrg
8848e69166Smrgcygpath_u="cygpath -u -f -"
8948e69166Smrgif test "$depmode" = msvcmsys; then
9048e69166Smrg   # This is just like msvisualcpp but w/o cygpath translation.
9148e69166Smrg   # Just convert the backslash-escaped backslashes to single forward
9248e69166Smrg   # slashes to satisfy depend.m4
9348e69166Smrg   cygpath_u="sed s,\\\\\\\\,/,g"
9448e69166Smrg   depmode=msvisualcpp
9548e69166Smrgfi
9648e69166Smrg
97fd0c672fSmrgcase "$depmode" in
98fd0c672fSmrggcc3)
99fd0c672fSmrg## gcc 3 implements dependency tracking that does exactly what
100fd0c672fSmrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
101fd0c672fSmrg## it if -MD -MP comes after the -MF stuff.  Hmm.
10248e69166Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
10348e69166Smrg## the command line argument order; so add the flags where they
10448e69166Smrg## appear in depend2.am.  Note that the slowdown incurred here
10548e69166Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
10648e69166Smrg  for arg
10748e69166Smrg  do
10848e69166Smrg    case $arg in
10948e69166Smrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
11048e69166Smrg    *)  set fnord "$@" "$arg" ;;
11148e69166Smrg    esac
11248e69166Smrg    shift # fnord
11348e69166Smrg    shift # $arg
11448e69166Smrg  done
11548e69166Smrg  "$@"
116fd0c672fSmrg  stat=$?
117fd0c672fSmrg  if test $stat -eq 0; then :
118fd0c672fSmrg  else
119fd0c672fSmrg    rm -f "$tmpdepfile"
120fd0c672fSmrg    exit $stat
121fd0c672fSmrg  fi
122fd0c672fSmrg  mv "$tmpdepfile" "$depfile"
123fd0c672fSmrg  ;;
124fd0c672fSmrg
125fd0c672fSmrggcc)
126fd0c672fSmrg## There are various ways to get dependency output from gcc.  Here's
127fd0c672fSmrg## why we pick this rather obscure method:
128fd0c672fSmrg## - Don't want to use -MD because we'd like the dependencies to end
129fd0c672fSmrg##   up in a subdir.  Having to rename by hand is ugly.
130fd0c672fSmrg##   (We might end up doing this anyway to support other compilers.)
131fd0c672fSmrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
132fd0c672fSmrg##   -MM, not -M (despite what the docs say).
133fd0c672fSmrg## - Using -M directly means running the compiler twice (even worse
134fd0c672fSmrg##   than renaming).
135fd0c672fSmrg  if test -z "$gccflag"; then
136fd0c672fSmrg    gccflag=-MD,
137fd0c672fSmrg  fi
138fd0c672fSmrg  "$@" -Wp,"$gccflag$tmpdepfile"
139fd0c672fSmrg  stat=$?
140fd0c672fSmrg  if test $stat -eq 0; then :
141fd0c672fSmrg  else
142fd0c672fSmrg    rm -f "$tmpdepfile"
143fd0c672fSmrg    exit $stat
144fd0c672fSmrg  fi
145fd0c672fSmrg  rm -f "$depfile"
146fd0c672fSmrg  echo "$object : \\" > "$depfile"
147fd0c672fSmrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
148fd0c672fSmrg## The second -e expression handles DOS-style file names with drive letters.
149fd0c672fSmrg  sed -e 's/^[^:]*: / /' \
150fd0c672fSmrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
151fd0c672fSmrg## This next piece of magic avoids the `deleted header file' problem.
152fd0c672fSmrg## The problem is that when a header file which appears in a .P file
153fd0c672fSmrg## is deleted, the dependency causes make to die (because there is
154fd0c672fSmrg## typically no way to rebuild the header).  We avoid this by adding
155fd0c672fSmrg## dummy dependencies for each header file.  Too bad gcc doesn't do
156fd0c672fSmrg## this for us directly.
157fd0c672fSmrg  tr ' ' '
158fd0c672fSmrg' < "$tmpdepfile" |
159fd0c672fSmrg## Some versions of gcc put a space before the `:'.  On the theory
160fd0c672fSmrg## that the space means something, we add a space to the output as
161fd0c672fSmrg## well.
162fd0c672fSmrg## Some versions of the HPUX 10.20 sed can't process this invocation
163fd0c672fSmrg## correctly.  Breaking it into two sed invocations is a workaround.
164fd0c672fSmrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
165fd0c672fSmrg  rm -f "$tmpdepfile"
166fd0c672fSmrg  ;;
167fd0c672fSmrg
168fd0c672fSmrghp)
169fd0c672fSmrg  # This case exists only to let depend.m4 do its work.  It works by
170fd0c672fSmrg  # looking at the text of this script.  This case will never be run,
171fd0c672fSmrg  # since it is checked for above.
172fd0c672fSmrg  exit 1
173fd0c672fSmrg  ;;
174fd0c672fSmrg
175fd0c672fSmrgsgi)
176fd0c672fSmrg  if test "$libtool" = yes; then
177fd0c672fSmrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
178fd0c672fSmrg  else
179fd0c672fSmrg    "$@" -MDupdate "$tmpdepfile"
180fd0c672fSmrg  fi
181fd0c672fSmrg  stat=$?
182fd0c672fSmrg  if test $stat -eq 0; then :
183fd0c672fSmrg  else
184fd0c672fSmrg    rm -f "$tmpdepfile"
185fd0c672fSmrg    exit $stat
186fd0c672fSmrg  fi
187fd0c672fSmrg  rm -f "$depfile"
188fd0c672fSmrg
189fd0c672fSmrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
190fd0c672fSmrg    echo "$object : \\" > "$depfile"
191fd0c672fSmrg
192fd0c672fSmrg    # Clip off the initial element (the dependent).  Don't try to be
193fd0c672fSmrg    # clever and replace this with sed code, as IRIX sed won't handle
194fd0c672fSmrg    # lines with more than a fixed number of characters (4096 in
195fd0c672fSmrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
196fd0c672fSmrg    # the IRIX cc adds comments like `#:fec' to the end of the
197fd0c672fSmrg    # dependency line.
198fd0c672fSmrg    tr ' ' '
199fd0c672fSmrg' < "$tmpdepfile" \
200fd0c672fSmrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
201fd0c672fSmrg    tr '
20248e69166Smrg' ' ' >> "$depfile"
20348e69166Smrg    echo >> "$depfile"
204fd0c672fSmrg
205fd0c672fSmrg    # The second pass generates a dummy entry for each header file.
206fd0c672fSmrg    tr ' ' '
207fd0c672fSmrg' < "$tmpdepfile" \
208fd0c672fSmrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
20948e69166Smrg   >> "$depfile"
210fd0c672fSmrg  else
211fd0c672fSmrg    # The sourcefile does not contain any dependencies, so just
212fd0c672fSmrg    # store a dummy comment line, to avoid errors with the Makefile
213fd0c672fSmrg    # "include basename.Plo" scheme.
214fd0c672fSmrg    echo "#dummy" > "$depfile"
215fd0c672fSmrg  fi
216fd0c672fSmrg  rm -f "$tmpdepfile"
217fd0c672fSmrg  ;;
218fd0c672fSmrg
219fd0c672fSmrgaix)
220fd0c672fSmrg  # The C for AIX Compiler uses -M and outputs the dependencies
221fd0c672fSmrg  # in a .u file.  In older versions, this file always lives in the
222fd0c672fSmrg  # current directory.  Also, the AIX compiler puts `$object:' at the
223fd0c672fSmrg  # start of each line; $object doesn't have directory information.
224fd0c672fSmrg  # Version 6 uses the directory in both cases.
22548e69166Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
22648e69166Smrg  test "x$dir" = "x$object" && dir=
22748e69166Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
228fd0c672fSmrg  if test "$libtool" = yes; then
22948e69166Smrg    tmpdepfile1=$dir$base.u
23048e69166Smrg    tmpdepfile2=$base.u
23148e69166Smrg    tmpdepfile3=$dir.libs/$base.u
232fd0c672fSmrg    "$@" -Wc,-M
233fd0c672fSmrg  else
23448e69166Smrg    tmpdepfile1=$dir$base.u
23548e69166Smrg    tmpdepfile2=$dir$base.u
23648e69166Smrg    tmpdepfile3=$dir$base.u
237fd0c672fSmrg    "$@" -M
238fd0c672fSmrg  fi
239fd0c672fSmrg  stat=$?
240fd0c672fSmrg
241fd0c672fSmrg  if test $stat -eq 0; then :
242fd0c672fSmrg  else
24348e69166Smrg    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
244fd0c672fSmrg    exit $stat
245fd0c672fSmrg  fi
246fd0c672fSmrg
24748e69166Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
24848e69166Smrg  do
24948e69166Smrg    test -f "$tmpdepfile" && break
25048e69166Smrg  done
251fd0c672fSmrg  if test -f "$tmpdepfile"; then
252fd0c672fSmrg    # Each line is of the form `foo.o: dependent.h'.
253fd0c672fSmrg    # Do two passes, one to just change these to
254fd0c672fSmrg    # `$object: dependent.h' and one to simply `dependent.h:'.
25548e69166Smrg    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
25648e69166Smrg    # That's a tab and a space in the [].
25748e69166Smrg    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
258fd0c672fSmrg  else
259fd0c672fSmrg    # The sourcefile does not contain any dependencies, so just
260fd0c672fSmrg    # store a dummy comment line, to avoid errors with the Makefile
261fd0c672fSmrg    # "include basename.Plo" scheme.
262fd0c672fSmrg    echo "#dummy" > "$depfile"
263fd0c672fSmrg  fi
264fd0c672fSmrg  rm -f "$tmpdepfile"
265fd0c672fSmrg  ;;
266fd0c672fSmrg
267fd0c672fSmrgicc)
268fd0c672fSmrg  # Intel's C compiler understands `-MD -MF file'.  However on
269fd0c672fSmrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
270fd0c672fSmrg  # ICC 7.0 will fill foo.d with something like
271fd0c672fSmrg  #    foo.o: sub/foo.c
272fd0c672fSmrg  #    foo.o: sub/foo.h
273fd0c672fSmrg  # which is wrong.  We want:
274fd0c672fSmrg  #    sub/foo.o: sub/foo.c
275fd0c672fSmrg  #    sub/foo.o: sub/foo.h
276fd0c672fSmrg  #    sub/foo.c:
277fd0c672fSmrg  #    sub/foo.h:
278fd0c672fSmrg  # ICC 7.1 will output
279fd0c672fSmrg  #    foo.o: sub/foo.c sub/foo.h
280fd0c672fSmrg  # and will wrap long lines using \ :
281fd0c672fSmrg  #    foo.o: sub/foo.c ... \
282fd0c672fSmrg  #     sub/foo.h ... \
283fd0c672fSmrg  #     ...
284fd0c672fSmrg
285fd0c672fSmrg  "$@" -MD -MF "$tmpdepfile"
286fd0c672fSmrg  stat=$?
287fd0c672fSmrg  if test $stat -eq 0; then :
288fd0c672fSmrg  else
289fd0c672fSmrg    rm -f "$tmpdepfile"
290fd0c672fSmrg    exit $stat
291fd0c672fSmrg  fi
292fd0c672fSmrg  rm -f "$depfile"
293fd0c672fSmrg  # Each line is of the form `foo.o: dependent.h',
294fd0c672fSmrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
295fd0c672fSmrg  # Do two passes, one to just change these to
296fd0c672fSmrg  # `$object: dependent.h' and one to simply `dependent.h:'.
297fd0c672fSmrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
298fd0c672fSmrg  # Some versions of the HPUX 10.20 sed can't process this invocation
299fd0c672fSmrg  # correctly.  Breaking it into two sed invocations is a workaround.
300fd0c672fSmrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
301fd0c672fSmrg    sed -e 's/$/ :/' >> "$depfile"
302fd0c672fSmrg  rm -f "$tmpdepfile"
303fd0c672fSmrg  ;;
304fd0c672fSmrg
30548e69166Smrghp2)
30648e69166Smrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
30748e69166Smrg  # compilers, which have integrated preprocessors.  The correct option
30848e69166Smrg  # to use with these is +Maked; it writes dependencies to a file named
30948e69166Smrg  # 'foo.d', which lands next to the object file, wherever that
31048e69166Smrg  # happens to be.
31148e69166Smrg  # Much of this is similar to the tru64 case; see comments there.
31248e69166Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
31348e69166Smrg  test "x$dir" = "x$object" && dir=
31448e69166Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
31548e69166Smrg  if test "$libtool" = yes; then
31648e69166Smrg    tmpdepfile1=$dir$base.d
31748e69166Smrg    tmpdepfile2=$dir.libs/$base.d
31848e69166Smrg    "$@" -Wc,+Maked
31948e69166Smrg  else
32048e69166Smrg    tmpdepfile1=$dir$base.d
32148e69166Smrg    tmpdepfile2=$dir$base.d
32248e69166Smrg    "$@" +Maked
32348e69166Smrg  fi
32448e69166Smrg  stat=$?
32548e69166Smrg  if test $stat -eq 0; then :
32648e69166Smrg  else
32748e69166Smrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
32848e69166Smrg     exit $stat
32948e69166Smrg  fi
33048e69166Smrg
33148e69166Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
33248e69166Smrg  do
33348e69166Smrg    test -f "$tmpdepfile" && break
33448e69166Smrg  done
33548e69166Smrg  if test -f "$tmpdepfile"; then
33648e69166Smrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
33748e69166Smrg    # Add `dependent.h:' lines.
33848e69166Smrg    sed -ne '2,${
33948e69166Smrg	       s/^ *//
34048e69166Smrg	       s/ \\*$//
34148e69166Smrg	       s/$/:/
34248e69166Smrg	       p
34348e69166Smrg	     }' "$tmpdepfile" >> "$depfile"
34448e69166Smrg  else
34548e69166Smrg    echo "#dummy" > "$depfile"
34648e69166Smrg  fi
34748e69166Smrg  rm -f "$tmpdepfile" "$tmpdepfile2"
34848e69166Smrg  ;;
34948e69166Smrg
350fd0c672fSmrgtru64)
351fd0c672fSmrg   # The Tru64 compiler uses -MD to generate dependencies as a side
352fd0c672fSmrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
353fd0c672fSmrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
354fd0c672fSmrg   # dependencies in `foo.d' instead, so we check for that too.
355fd0c672fSmrg   # Subdirectories are respected.
356fd0c672fSmrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
357fd0c672fSmrg   test "x$dir" = "x$object" && dir=
358fd0c672fSmrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
359fd0c672fSmrg
360fd0c672fSmrg   if test "$libtool" = yes; then
361fd0c672fSmrg      # With Tru64 cc, shared objects can also be used to make a
36248e69166Smrg      # static library.  This mechanism is used in libtool 1.4 series to
363fd0c672fSmrg      # handle both shared and static libraries in a single compilation.
364fd0c672fSmrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
365fd0c672fSmrg      #
366fd0c672fSmrg      # With libtool 1.5 this exception was removed, and libtool now
367fd0c672fSmrg      # generates 2 separate objects for the 2 libraries.  These two
36848e69166Smrg      # compilations output dependencies in $dir.libs/$base.o.d and
369fd0c672fSmrg      # in $dir$base.o.d.  We have to check for both files, because
370fd0c672fSmrg      # one of the two compilations can be disabled.  We should prefer
371fd0c672fSmrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
372fd0c672fSmrg      # automatically cleaned when .libs/ is deleted, while ignoring
373fd0c672fSmrg      # the former would cause a distcleancheck panic.
374fd0c672fSmrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
375fd0c672fSmrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
376fd0c672fSmrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
377fd0c672fSmrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
378fd0c672fSmrg      "$@" -Wc,-MD
379fd0c672fSmrg   else
380fd0c672fSmrg      tmpdepfile1=$dir$base.o.d
381fd0c672fSmrg      tmpdepfile2=$dir$base.d
382fd0c672fSmrg      tmpdepfile3=$dir$base.d
383fd0c672fSmrg      tmpdepfile4=$dir$base.d
384fd0c672fSmrg      "$@" -MD
385fd0c672fSmrg   fi
386fd0c672fSmrg
387fd0c672fSmrg   stat=$?
388fd0c672fSmrg   if test $stat -eq 0; then :
389fd0c672fSmrg   else
390fd0c672fSmrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
391fd0c672fSmrg      exit $stat
392fd0c672fSmrg   fi
393fd0c672fSmrg
394fd0c672fSmrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
395fd0c672fSmrg   do
396fd0c672fSmrg     test -f "$tmpdepfile" && break
397fd0c672fSmrg   done
398fd0c672fSmrg   if test -f "$tmpdepfile"; then
399fd0c672fSmrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
400fd0c672fSmrg      # That's a tab and a space in the [].
401fd0c672fSmrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
402fd0c672fSmrg   else
403fd0c672fSmrg      echo "#dummy" > "$depfile"
404fd0c672fSmrg   fi
405fd0c672fSmrg   rm -f "$tmpdepfile"
406fd0c672fSmrg   ;;
407fd0c672fSmrg
408fd0c672fSmrg#nosideeffect)
409fd0c672fSmrg  # This comment above is used by automake to tell side-effect
410fd0c672fSmrg  # dependency tracking mechanisms from slower ones.
411fd0c672fSmrg
412fd0c672fSmrgdashmstdout)
413fd0c672fSmrg  # Important note: in order to support this mode, a compiler *must*
414fd0c672fSmrg  # always write the preprocessed file to stdout, regardless of -o.
415fd0c672fSmrg  "$@" || exit $?
416fd0c672fSmrg
417fd0c672fSmrg  # Remove the call to Libtool.
418fd0c672fSmrg  if test "$libtool" = yes; then
41948e69166Smrg    while test "X$1" != 'X--mode=compile'; do
420fd0c672fSmrg      shift
421fd0c672fSmrg    done
422fd0c672fSmrg    shift
423fd0c672fSmrg  fi
424fd0c672fSmrg
425fd0c672fSmrg  # Remove `-o $object'.
426fd0c672fSmrg  IFS=" "
427fd0c672fSmrg  for arg
428fd0c672fSmrg  do
429fd0c672fSmrg    case $arg in
430fd0c672fSmrg    -o)
431fd0c672fSmrg      shift
432fd0c672fSmrg      ;;
433fd0c672fSmrg    $object)
434fd0c672fSmrg      shift
435fd0c672fSmrg      ;;
436fd0c672fSmrg    *)
437fd0c672fSmrg      set fnord "$@" "$arg"
438fd0c672fSmrg      shift # fnord
439fd0c672fSmrg      shift # $arg
440fd0c672fSmrg      ;;
441fd0c672fSmrg    esac
442fd0c672fSmrg  done
443fd0c672fSmrg
444fd0c672fSmrg  test -z "$dashmflag" && dashmflag=-M
445fd0c672fSmrg  # Require at least two characters before searching for `:'
446fd0c672fSmrg  # in the target name.  This is to cope with DOS-style filenames:
447fd0c672fSmrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
448fd0c672fSmrg  "$@" $dashmflag |
449fd0c672fSmrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
450fd0c672fSmrg  rm -f "$depfile"
451fd0c672fSmrg  cat < "$tmpdepfile" > "$depfile"
452fd0c672fSmrg  tr ' ' '
453fd0c672fSmrg' < "$tmpdepfile" | \
454fd0c672fSmrg## Some versions of the HPUX 10.20 sed can't process this invocation
455fd0c672fSmrg## correctly.  Breaking it into two sed invocations is a workaround.
456fd0c672fSmrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
457fd0c672fSmrg  rm -f "$tmpdepfile"
458fd0c672fSmrg  ;;
459fd0c672fSmrg
460fd0c672fSmrgdashXmstdout)
461fd0c672fSmrg  # This case only exists to satisfy depend.m4.  It is never actually
462fd0c672fSmrg  # run, as this mode is specially recognized in the preamble.
463fd0c672fSmrg  exit 1
464fd0c672fSmrg  ;;
465fd0c672fSmrg
466fd0c672fSmrgmakedepend)
467fd0c672fSmrg  "$@" || exit $?
468fd0c672fSmrg  # Remove any Libtool call
469fd0c672fSmrg  if test "$libtool" = yes; then
47048e69166Smrg    while test "X$1" != 'X--mode=compile'; do
471fd0c672fSmrg      shift
472fd0c672fSmrg    done
473fd0c672fSmrg    shift
474fd0c672fSmrg  fi
475fd0c672fSmrg  # X makedepend
476fd0c672fSmrg  shift
47748e69166Smrg  cleared=no eat=no
47848e69166Smrg  for arg
47948e69166Smrg  do
480fd0c672fSmrg    case $cleared in
481fd0c672fSmrg    no)
482fd0c672fSmrg      set ""; shift
483fd0c672fSmrg      cleared=yes ;;
484fd0c672fSmrg    esac
48548e69166Smrg    if test $eat = yes; then
48648e69166Smrg      eat=no
48748e69166Smrg      continue
48848e69166Smrg    fi
489fd0c672fSmrg    case "$arg" in
490fd0c672fSmrg    -D*|-I*)
491fd0c672fSmrg      set fnord "$@" "$arg"; shift ;;
492fd0c672fSmrg    # Strip any option that makedepend may not understand.  Remove
493fd0c672fSmrg    # the object too, otherwise makedepend will parse it as a source file.
49448e69166Smrg    -arch)
49548e69166Smrg      eat=yes ;;
496fd0c672fSmrg    -*|$object)
497fd0c672fSmrg      ;;
498fd0c672fSmrg    *)
499fd0c672fSmrg      set fnord "$@" "$arg"; shift ;;
500fd0c672fSmrg    esac
501fd0c672fSmrg  done
50248e69166Smrg  obj_suffix=`echo "$object" | sed 's/^.*\././'`
503fd0c672fSmrg  touch "$tmpdepfile"
504fd0c672fSmrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
505fd0c672fSmrg  rm -f "$depfile"
506fd0c672fSmrg  cat < "$tmpdepfile" > "$depfile"
507fd0c672fSmrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
508fd0c672fSmrg' | \
509fd0c672fSmrg## Some versions of the HPUX 10.20 sed can't process this invocation
510fd0c672fSmrg## correctly.  Breaking it into two sed invocations is a workaround.
511fd0c672fSmrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
512fd0c672fSmrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
513fd0c672fSmrg  ;;
514fd0c672fSmrg
515fd0c672fSmrgcpp)
516fd0c672fSmrg  # Important note: in order to support this mode, a compiler *must*
517fd0c672fSmrg  # always write the preprocessed file to stdout.
518fd0c672fSmrg  "$@" || exit $?
519fd0c672fSmrg
520fd0c672fSmrg  # Remove the call to Libtool.
521fd0c672fSmrg  if test "$libtool" = yes; then
52248e69166Smrg    while test "X$1" != 'X--mode=compile'; do
523fd0c672fSmrg      shift
524fd0c672fSmrg    done
525fd0c672fSmrg    shift
526fd0c672fSmrg  fi
527fd0c672fSmrg
528fd0c672fSmrg  # Remove `-o $object'.
529fd0c672fSmrg  IFS=" "
530fd0c672fSmrg  for arg
531fd0c672fSmrg  do
532fd0c672fSmrg    case $arg in
533fd0c672fSmrg    -o)
534fd0c672fSmrg      shift
535fd0c672fSmrg      ;;
536fd0c672fSmrg    $object)
537fd0c672fSmrg      shift
538fd0c672fSmrg      ;;
539fd0c672fSmrg    *)
540fd0c672fSmrg      set fnord "$@" "$arg"
541fd0c672fSmrg      shift # fnord
542fd0c672fSmrg      shift # $arg
543fd0c672fSmrg      ;;
544fd0c672fSmrg    esac
545fd0c672fSmrg  done
546fd0c672fSmrg
547fd0c672fSmrg  "$@" -E |
548fd0c672fSmrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
549fd0c672fSmrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
550fd0c672fSmrg    sed '$ s: \\$::' > "$tmpdepfile"
551fd0c672fSmrg  rm -f "$depfile"
552fd0c672fSmrg  echo "$object : \\" > "$depfile"
553fd0c672fSmrg  cat < "$tmpdepfile" >> "$depfile"
554fd0c672fSmrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
555fd0c672fSmrg  rm -f "$tmpdepfile"
556fd0c672fSmrg  ;;
557fd0c672fSmrg
558fd0c672fSmrgmsvisualcpp)
559fd0c672fSmrg  # Important note: in order to support this mode, a compiler *must*
56048e69166Smrg  # always write the preprocessed file to stdout.
561fd0c672fSmrg  "$@" || exit $?
56248e69166Smrg
56348e69166Smrg  # Remove the call to Libtool.
56448e69166Smrg  if test "$libtool" = yes; then
56548e69166Smrg    while test "X$1" != 'X--mode=compile'; do
56648e69166Smrg      shift
56748e69166Smrg    done
56848e69166Smrg    shift
56948e69166Smrg  fi
57048e69166Smrg
571fd0c672fSmrg  IFS=" "
572fd0c672fSmrg  for arg
573fd0c672fSmrg  do
574fd0c672fSmrg    case "$arg" in
57548e69166Smrg    -o)
57648e69166Smrg      shift
57748e69166Smrg      ;;
57848e69166Smrg    $object)
57948e69166Smrg      shift
58048e69166Smrg      ;;
581fd0c672fSmrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
582fd0c672fSmrg	set fnord "$@"
583fd0c672fSmrg	shift
584fd0c672fSmrg	shift
585fd0c672fSmrg	;;
586fd0c672fSmrg    *)
587fd0c672fSmrg	set fnord "$@" "$arg"
588fd0c672fSmrg	shift
589fd0c672fSmrg	shift
590fd0c672fSmrg	;;
591fd0c672fSmrg    esac
592fd0c672fSmrg  done
59348e69166Smrg  "$@" -E 2>/dev/null |
59448e69166Smrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
595fd0c672fSmrg  rm -f "$depfile"
596fd0c672fSmrg  echo "$object : \\" > "$depfile"
59748e69166Smrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
598fd0c672fSmrg  echo "	" >> "$depfile"
59948e69166Smrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
600fd0c672fSmrg  rm -f "$tmpdepfile"
601fd0c672fSmrg  ;;
602fd0c672fSmrg
60348e69166Smrgmsvcmsys)
60448e69166Smrg  # This case exists only to let depend.m4 do its work.  It works by
60548e69166Smrg  # looking at the text of this script.  This case will never be run,
60648e69166Smrg  # since it is checked for above.
60748e69166Smrg  exit 1
60848e69166Smrg  ;;
60948e69166Smrg
610fd0c672fSmrgnone)
611fd0c672fSmrg  exec "$@"
612fd0c672fSmrg  ;;
613fd0c672fSmrg
614fd0c672fSmrg*)
615fd0c672fSmrg  echo "Unknown depmode $depmode" 1>&2
616fd0c672fSmrg  exit 1
617fd0c672fSmrg  ;;
618fd0c672fSmrgesac
619fd0c672fSmrg
620fd0c672fSmrgexit 0
621fd0c672fSmrg
622fd0c672fSmrg# Local Variables:
623fd0c672fSmrg# mode: shell-script
624fd0c672fSmrg# sh-indentation: 2
625fd0c672fSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
626fd0c672fSmrg# time-stamp-start: "scriptversion="
627fd0c672fSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
62848e69166Smrg# time-stamp-time-zone: "UTC"
62948e69166Smrg# time-stamp-end: "; # UTC"
630fd0c672fSmrg# End:
631