depcomp revision 2b32c8f7
1eaef79e5Smrg#! /bin/sh
2eaef79e5Smrg# depcomp - compile a program generating dependencies as side-effects
3eaef79e5Smrg
42b32c8f7Smrgscriptversion=2009-04-28.21; # UTC
5eaef79e5Smrg
62b32c8f7Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
72b32c8f7Smrg# Software Foundation, Inc.
8eaef79e5Smrg
9eaef79e5Smrg# This program is free software; you can redistribute it and/or modify
10eaef79e5Smrg# it under the terms of the GNU General Public License as published by
11eaef79e5Smrg# the Free Software Foundation; either version 2, or (at your option)
12eaef79e5Smrg# any later version.
13eaef79e5Smrg
14eaef79e5Smrg# This program is distributed in the hope that it will be useful,
15eaef79e5Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
16eaef79e5Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17eaef79e5Smrg# GNU General Public License for more details.
18eaef79e5Smrg
19eaef79e5Smrg# You should have received a copy of the GNU General Public License
202b32c8f7Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21eaef79e5Smrg
22eaef79e5Smrg# As a special exception to the GNU General Public License, if you
23eaef79e5Smrg# distribute this file as part of a program that contains a
24eaef79e5Smrg# configuration script generated by Autoconf, you may include it under
25eaef79e5Smrg# the same distribution terms that you use for the rest of that program.
26eaef79e5Smrg
27eaef79e5Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
28eaef79e5Smrg
29eaef79e5Smrgcase $1 in
30eaef79e5Smrg  '')
31eaef79e5Smrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
32eaef79e5Smrg     exit 1;
33eaef79e5Smrg     ;;
34eaef79e5Smrg  -h | --h*)
35eaef79e5Smrg    cat <<\EOF
36eaef79e5SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
37eaef79e5Smrg
38eaef79e5SmrgRun PROGRAMS ARGS to compile a file, generating dependencies
39eaef79e5Smrgas side-effects.
40eaef79e5Smrg
41eaef79e5SmrgEnvironment variables:
42eaef79e5Smrg  depmode     Dependency tracking mode.
43eaef79e5Smrg  source      Source file read by `PROGRAMS ARGS'.
44eaef79e5Smrg  object      Object file output by `PROGRAMS ARGS'.
45eaef79e5Smrg  DEPDIR      directory where to store dependencies.
46eaef79e5Smrg  depfile     Dependency file to output.
47eaef79e5Smrg  tmpdepfile  Temporary file to use when outputing dependencies.
48eaef79e5Smrg  libtool     Whether libtool is used (yes/no).
49eaef79e5Smrg
50eaef79e5SmrgReport bugs to <bug-automake@gnu.org>.
51eaef79e5SmrgEOF
52eaef79e5Smrg    exit $?
53eaef79e5Smrg    ;;
54eaef79e5Smrg  -v | --v*)
55eaef79e5Smrg    echo "depcomp $scriptversion"
56eaef79e5Smrg    exit $?
57eaef79e5Smrg    ;;
58eaef79e5Smrgesac
59eaef79e5Smrg
60eaef79e5Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
61eaef79e5Smrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
62eaef79e5Smrg  exit 1
63eaef79e5Smrgfi
64eaef79e5Smrg
65eaef79e5Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
66eaef79e5Smrgdepfile=${depfile-`echo "$object" |
67eaef79e5Smrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
68eaef79e5Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
69eaef79e5Smrg
70eaef79e5Smrgrm -f "$tmpdepfile"
71eaef79e5Smrg
72eaef79e5Smrg# Some modes work just like other modes, but use different flags.  We
73eaef79e5Smrg# parameterize here, but still list the modes in the big case below,
74eaef79e5Smrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
75eaef79e5Smrg# here, because this file can only contain one case statement.
76eaef79e5Smrgif test "$depmode" = hp; then
77eaef79e5Smrg  # HP compiler uses -M and no extra arg.
78eaef79e5Smrg  gccflag=-M
79eaef79e5Smrg  depmode=gcc
80eaef79e5Smrgfi
81eaef79e5Smrg
82eaef79e5Smrgif test "$depmode" = dashXmstdout; then
83eaef79e5Smrg   # This is just like dashmstdout with a different argument.
84eaef79e5Smrg   dashmflag=-xM
85eaef79e5Smrg   depmode=dashmstdout
86eaef79e5Smrgfi
87eaef79e5Smrg
882b32c8f7Smrgcygpath_u="cygpath -u -f -"
892b32c8f7Smrgif test "$depmode" = msvcmsys; then
902b32c8f7Smrg   # This is just like msvisualcpp but w/o cygpath translation.
912b32c8f7Smrg   # Just convert the backslash-escaped backslashes to single forward
922b32c8f7Smrg   # slashes to satisfy depend.m4
932b32c8f7Smrg   cygpath_u="sed s,\\\\\\\\,/,g"
942b32c8f7Smrg   depmode=msvisualcpp
952b32c8f7Smrgfi
962b32c8f7Smrg
97eaef79e5Smrgcase "$depmode" in
98eaef79e5Smrggcc3)
99eaef79e5Smrg## gcc 3 implements dependency tracking that does exactly what
100eaef79e5Smrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
101eaef79e5Smrg## it if -MD -MP comes after the -MF stuff.  Hmm.
1022b32c8f7Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
1032b32c8f7Smrg## the command line argument order; so add the flags where they
1042b32c8f7Smrg## appear in depend2.am.  Note that the slowdown incurred here
1052b32c8f7Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
1062b32c8f7Smrg  for arg
1072b32c8f7Smrg  do
1082b32c8f7Smrg    case $arg in
1092b32c8f7Smrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
1102b32c8f7Smrg    *)  set fnord "$@" "$arg" ;;
1112b32c8f7Smrg    esac
1122b32c8f7Smrg    shift # fnord
1132b32c8f7Smrg    shift # $arg
1142b32c8f7Smrg  done
1152b32c8f7Smrg  "$@"
116eaef79e5Smrg  stat=$?
117eaef79e5Smrg  if test $stat -eq 0; then :
118eaef79e5Smrg  else
119eaef79e5Smrg    rm -f "$tmpdepfile"
120eaef79e5Smrg    exit $stat
121eaef79e5Smrg  fi
122eaef79e5Smrg  mv "$tmpdepfile" "$depfile"
123eaef79e5Smrg  ;;
124eaef79e5Smrg
125eaef79e5Smrggcc)
126eaef79e5Smrg## There are various ways to get dependency output from gcc.  Here's
127eaef79e5Smrg## why we pick this rather obscure method:
128eaef79e5Smrg## - Don't want to use -MD because we'd like the dependencies to end
129eaef79e5Smrg##   up in a subdir.  Having to rename by hand is ugly.
130eaef79e5Smrg##   (We might end up doing this anyway to support other compilers.)
131eaef79e5Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
132eaef79e5Smrg##   -MM, not -M (despite what the docs say).
133eaef79e5Smrg## - Using -M directly means running the compiler twice (even worse
134eaef79e5Smrg##   than renaming).
135eaef79e5Smrg  if test -z "$gccflag"; then
136eaef79e5Smrg    gccflag=-MD,
137eaef79e5Smrg  fi
138eaef79e5Smrg  "$@" -Wp,"$gccflag$tmpdepfile"
139eaef79e5Smrg  stat=$?
140eaef79e5Smrg  if test $stat -eq 0; then :
141eaef79e5Smrg  else
142eaef79e5Smrg    rm -f "$tmpdepfile"
143eaef79e5Smrg    exit $stat
144eaef79e5Smrg  fi
145eaef79e5Smrg  rm -f "$depfile"
146eaef79e5Smrg  echo "$object : \\" > "$depfile"
147eaef79e5Smrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
148eaef79e5Smrg## The second -e expression handles DOS-style file names with drive letters.
149eaef79e5Smrg  sed -e 's/^[^:]*: / /' \
150eaef79e5Smrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
151eaef79e5Smrg## This next piece of magic avoids the `deleted header file' problem.
152eaef79e5Smrg## The problem is that when a header file which appears in a .P file
153eaef79e5Smrg## is deleted, the dependency causes make to die (because there is
154eaef79e5Smrg## typically no way to rebuild the header).  We avoid this by adding
155eaef79e5Smrg## dummy dependencies for each header file.  Too bad gcc doesn't do
156eaef79e5Smrg## this for us directly.
157eaef79e5Smrg  tr ' ' '
158eaef79e5Smrg' < "$tmpdepfile" |
159eaef79e5Smrg## Some versions of gcc put a space before the `:'.  On the theory
160eaef79e5Smrg## that the space means something, we add a space to the output as
161eaef79e5Smrg## well.
162eaef79e5Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
163eaef79e5Smrg## correctly.  Breaking it into two sed invocations is a workaround.
164eaef79e5Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
165eaef79e5Smrg  rm -f "$tmpdepfile"
166eaef79e5Smrg  ;;
167eaef79e5Smrg
168eaef79e5Smrghp)
169eaef79e5Smrg  # This case exists only to let depend.m4 do its work.  It works by
170eaef79e5Smrg  # looking at the text of this script.  This case will never be run,
171eaef79e5Smrg  # since it is checked for above.
172eaef79e5Smrg  exit 1
173eaef79e5Smrg  ;;
174eaef79e5Smrg
175eaef79e5Smrgsgi)
176eaef79e5Smrg  if test "$libtool" = yes; then
177eaef79e5Smrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
178eaef79e5Smrg  else
179eaef79e5Smrg    "$@" -MDupdate "$tmpdepfile"
180eaef79e5Smrg  fi
181eaef79e5Smrg  stat=$?
182eaef79e5Smrg  if test $stat -eq 0; then :
183eaef79e5Smrg  else
184eaef79e5Smrg    rm -f "$tmpdepfile"
185eaef79e5Smrg    exit $stat
186eaef79e5Smrg  fi
187eaef79e5Smrg  rm -f "$depfile"
188eaef79e5Smrg
189eaef79e5Smrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
190eaef79e5Smrg    echo "$object : \\" > "$depfile"
191eaef79e5Smrg
192eaef79e5Smrg    # Clip off the initial element (the dependent).  Don't try to be
193eaef79e5Smrg    # clever and replace this with sed code, as IRIX sed won't handle
194eaef79e5Smrg    # lines with more than a fixed number of characters (4096 in
195eaef79e5Smrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
196eaef79e5Smrg    # the IRIX cc adds comments like `#:fec' to the end of the
197eaef79e5Smrg    # dependency line.
198eaef79e5Smrg    tr ' ' '
199eaef79e5Smrg' < "$tmpdepfile" \
200eaef79e5Smrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
201eaef79e5Smrg    tr '
2022b32c8f7Smrg' ' ' >> "$depfile"
2032b32c8f7Smrg    echo >> "$depfile"
204eaef79e5Smrg
205eaef79e5Smrg    # The second pass generates a dummy entry for each header file.
206eaef79e5Smrg    tr ' ' '
207eaef79e5Smrg' < "$tmpdepfile" \
208eaef79e5Smrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
2092b32c8f7Smrg   >> "$depfile"
210eaef79e5Smrg  else
211eaef79e5Smrg    # The sourcefile does not contain any dependencies, so just
212eaef79e5Smrg    # store a dummy comment line, to avoid errors with the Makefile
213eaef79e5Smrg    # "include basename.Plo" scheme.
214eaef79e5Smrg    echo "#dummy" > "$depfile"
215eaef79e5Smrg  fi
216eaef79e5Smrg  rm -f "$tmpdepfile"
217eaef79e5Smrg  ;;
218eaef79e5Smrg
219eaef79e5Smrgaix)
220eaef79e5Smrg  # The C for AIX Compiler uses -M and outputs the dependencies
221eaef79e5Smrg  # in a .u file.  In older versions, this file always lives in the
222eaef79e5Smrg  # current directory.  Also, the AIX compiler puts `$object:' at the
223eaef79e5Smrg  # start of each line; $object doesn't have directory information.
224eaef79e5Smrg  # Version 6 uses the directory in both cases.
2252b32c8f7Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
2262b32c8f7Smrg  test "x$dir" = "x$object" && dir=
2272b32c8f7Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
228eaef79e5Smrg  if test "$libtool" = yes; then
2292b32c8f7Smrg    tmpdepfile1=$dir$base.u
2302b32c8f7Smrg    tmpdepfile2=$base.u
2312b32c8f7Smrg    tmpdepfile3=$dir.libs/$base.u
232eaef79e5Smrg    "$@" -Wc,-M
233eaef79e5Smrg  else
2342b32c8f7Smrg    tmpdepfile1=$dir$base.u
2352b32c8f7Smrg    tmpdepfile2=$dir$base.u
2362b32c8f7Smrg    tmpdepfile3=$dir$base.u
237eaef79e5Smrg    "$@" -M
238eaef79e5Smrg  fi
239eaef79e5Smrg  stat=$?
240eaef79e5Smrg
241eaef79e5Smrg  if test $stat -eq 0; then :
242eaef79e5Smrg  else
2432b32c8f7Smrg    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
244eaef79e5Smrg    exit $stat
245eaef79e5Smrg  fi
246eaef79e5Smrg
2472b32c8f7Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
2482b32c8f7Smrg  do
2492b32c8f7Smrg    test -f "$tmpdepfile" && break
2502b32c8f7Smrg  done
251eaef79e5Smrg  if test -f "$tmpdepfile"; then
252eaef79e5Smrg    # Each line is of the form `foo.o: dependent.h'.
253eaef79e5Smrg    # Do two passes, one to just change these to
254eaef79e5Smrg    # `$object: dependent.h' and one to simply `dependent.h:'.
2552b32c8f7Smrg    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
2562b32c8f7Smrg    # That's a tab and a space in the [].
2572b32c8f7Smrg    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
258eaef79e5Smrg  else
259eaef79e5Smrg    # The sourcefile does not contain any dependencies, so just
260eaef79e5Smrg    # store a dummy comment line, to avoid errors with the Makefile
261eaef79e5Smrg    # "include basename.Plo" scheme.
262eaef79e5Smrg    echo "#dummy" > "$depfile"
263eaef79e5Smrg  fi
264eaef79e5Smrg  rm -f "$tmpdepfile"
265eaef79e5Smrg  ;;
266eaef79e5Smrg
267eaef79e5Smrgicc)
268eaef79e5Smrg  # Intel's C compiler understands `-MD -MF file'.  However on
269eaef79e5Smrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
270eaef79e5Smrg  # ICC 7.0 will fill foo.d with something like
271eaef79e5Smrg  #    foo.o: sub/foo.c
272eaef79e5Smrg  #    foo.o: sub/foo.h
273eaef79e5Smrg  # which is wrong.  We want:
274eaef79e5Smrg  #    sub/foo.o: sub/foo.c
275eaef79e5Smrg  #    sub/foo.o: sub/foo.h
276eaef79e5Smrg  #    sub/foo.c:
277eaef79e5Smrg  #    sub/foo.h:
278eaef79e5Smrg  # ICC 7.1 will output
279eaef79e5Smrg  #    foo.o: sub/foo.c sub/foo.h
280eaef79e5Smrg  # and will wrap long lines using \ :
281eaef79e5Smrg  #    foo.o: sub/foo.c ... \
282eaef79e5Smrg  #     sub/foo.h ... \
283eaef79e5Smrg  #     ...
284eaef79e5Smrg
285eaef79e5Smrg  "$@" -MD -MF "$tmpdepfile"
286eaef79e5Smrg  stat=$?
287eaef79e5Smrg  if test $stat -eq 0; then :
288eaef79e5Smrg  else
289eaef79e5Smrg    rm -f "$tmpdepfile"
290eaef79e5Smrg    exit $stat
291eaef79e5Smrg  fi
292eaef79e5Smrg  rm -f "$depfile"
293eaef79e5Smrg  # Each line is of the form `foo.o: dependent.h',
294eaef79e5Smrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
295eaef79e5Smrg  # Do two passes, one to just change these to
296eaef79e5Smrg  # `$object: dependent.h' and one to simply `dependent.h:'.
297eaef79e5Smrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
298eaef79e5Smrg  # Some versions of the HPUX 10.20 sed can't process this invocation
299eaef79e5Smrg  # correctly.  Breaking it into two sed invocations is a workaround.
300eaef79e5Smrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
301eaef79e5Smrg    sed -e 's/$/ :/' >> "$depfile"
302eaef79e5Smrg  rm -f "$tmpdepfile"
303eaef79e5Smrg  ;;
304eaef79e5Smrg
3052b32c8f7Smrghp2)
3062b32c8f7Smrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
3072b32c8f7Smrg  # compilers, which have integrated preprocessors.  The correct option
3082b32c8f7Smrg  # to use with these is +Maked; it writes dependencies to a file named
3092b32c8f7Smrg  # 'foo.d', which lands next to the object file, wherever that
3102b32c8f7Smrg  # happens to be.
3112b32c8f7Smrg  # Much of this is similar to the tru64 case; see comments there.
3122b32c8f7Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3132b32c8f7Smrg  test "x$dir" = "x$object" && dir=
3142b32c8f7Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3152b32c8f7Smrg  if test "$libtool" = yes; then
3162b32c8f7Smrg    tmpdepfile1=$dir$base.d
3172b32c8f7Smrg    tmpdepfile2=$dir.libs/$base.d
3182b32c8f7Smrg    "$@" -Wc,+Maked
3192b32c8f7Smrg  else
3202b32c8f7Smrg    tmpdepfile1=$dir$base.d
3212b32c8f7Smrg    tmpdepfile2=$dir$base.d
3222b32c8f7Smrg    "$@" +Maked
3232b32c8f7Smrg  fi
3242b32c8f7Smrg  stat=$?
3252b32c8f7Smrg  if test $stat -eq 0; then :
3262b32c8f7Smrg  else
3272b32c8f7Smrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
3282b32c8f7Smrg     exit $stat
3292b32c8f7Smrg  fi
3302b32c8f7Smrg
3312b32c8f7Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
3322b32c8f7Smrg  do
3332b32c8f7Smrg    test -f "$tmpdepfile" && break
3342b32c8f7Smrg  done
3352b32c8f7Smrg  if test -f "$tmpdepfile"; then
3362b32c8f7Smrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
3372b32c8f7Smrg    # Add `dependent.h:' lines.
3382b32c8f7Smrg    sed -ne '2,${
3392b32c8f7Smrg	       s/^ *//
3402b32c8f7Smrg	       s/ \\*$//
3412b32c8f7Smrg	       s/$/:/
3422b32c8f7Smrg	       p
3432b32c8f7Smrg	     }' "$tmpdepfile" >> "$depfile"
3442b32c8f7Smrg  else
3452b32c8f7Smrg    echo "#dummy" > "$depfile"
3462b32c8f7Smrg  fi
3472b32c8f7Smrg  rm -f "$tmpdepfile" "$tmpdepfile2"
3482b32c8f7Smrg  ;;
3492b32c8f7Smrg
350eaef79e5Smrgtru64)
351eaef79e5Smrg   # The Tru64 compiler uses -MD to generate dependencies as a side
352eaef79e5Smrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
353eaef79e5Smrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
354eaef79e5Smrg   # dependencies in `foo.d' instead, so we check for that too.
355eaef79e5Smrg   # Subdirectories are respected.
356eaef79e5Smrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
357eaef79e5Smrg   test "x$dir" = "x$object" && dir=
358eaef79e5Smrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
359eaef79e5Smrg
360eaef79e5Smrg   if test "$libtool" = yes; then
361eaef79e5Smrg      # With Tru64 cc, shared objects can also be used to make a
3622b32c8f7Smrg      # static library.  This mechanism is used in libtool 1.4 series to
363eaef79e5Smrg      # handle both shared and static libraries in a single compilation.
364eaef79e5Smrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
365eaef79e5Smrg      #
366eaef79e5Smrg      # With libtool 1.5 this exception was removed, and libtool now
367eaef79e5Smrg      # generates 2 separate objects for the 2 libraries.  These two
3682b32c8f7Smrg      # compilations output dependencies in $dir.libs/$base.o.d and
369eaef79e5Smrg      # in $dir$base.o.d.  We have to check for both files, because
370eaef79e5Smrg      # one of the two compilations can be disabled.  We should prefer
371eaef79e5Smrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
372eaef79e5Smrg      # automatically cleaned when .libs/ is deleted, while ignoring
373eaef79e5Smrg      # the former would cause a distcleancheck panic.
374eaef79e5Smrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
375eaef79e5Smrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
376eaef79e5Smrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
377eaef79e5Smrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
378eaef79e5Smrg      "$@" -Wc,-MD
379eaef79e5Smrg   else
380eaef79e5Smrg      tmpdepfile1=$dir$base.o.d
381eaef79e5Smrg      tmpdepfile2=$dir$base.d
382eaef79e5Smrg      tmpdepfile3=$dir$base.d
383eaef79e5Smrg      tmpdepfile4=$dir$base.d
384eaef79e5Smrg      "$@" -MD
385eaef79e5Smrg   fi
386eaef79e5Smrg
387eaef79e5Smrg   stat=$?
388eaef79e5Smrg   if test $stat -eq 0; then :
389eaef79e5Smrg   else
390eaef79e5Smrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
391eaef79e5Smrg      exit $stat
392eaef79e5Smrg   fi
393eaef79e5Smrg
394eaef79e5Smrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
395eaef79e5Smrg   do
396eaef79e5Smrg     test -f "$tmpdepfile" && break
397eaef79e5Smrg   done
398eaef79e5Smrg   if test -f "$tmpdepfile"; then
399eaef79e5Smrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
400eaef79e5Smrg      # That's a tab and a space in the [].
401eaef79e5Smrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
402eaef79e5Smrg   else
403eaef79e5Smrg      echo "#dummy" > "$depfile"
404eaef79e5Smrg   fi
405eaef79e5Smrg   rm -f "$tmpdepfile"
406eaef79e5Smrg   ;;
407eaef79e5Smrg
408eaef79e5Smrg#nosideeffect)
409eaef79e5Smrg  # This comment above is used by automake to tell side-effect
410eaef79e5Smrg  # dependency tracking mechanisms from slower ones.
411eaef79e5Smrg
412eaef79e5Smrgdashmstdout)
413eaef79e5Smrg  # Important note: in order to support this mode, a compiler *must*
414eaef79e5Smrg  # always write the preprocessed file to stdout, regardless of -o.
415eaef79e5Smrg  "$@" || exit $?
416eaef79e5Smrg
417eaef79e5Smrg  # Remove the call to Libtool.
418eaef79e5Smrg  if test "$libtool" = yes; then
4192b32c8f7Smrg    while test "X$1" != 'X--mode=compile'; do
420eaef79e5Smrg      shift
421eaef79e5Smrg    done
422eaef79e5Smrg    shift
423eaef79e5Smrg  fi
424eaef79e5Smrg
425eaef79e5Smrg  # Remove `-o $object'.
426eaef79e5Smrg  IFS=" "
427eaef79e5Smrg  for arg
428eaef79e5Smrg  do
429eaef79e5Smrg    case $arg in
430eaef79e5Smrg    -o)
431eaef79e5Smrg      shift
432eaef79e5Smrg      ;;
433eaef79e5Smrg    $object)
434eaef79e5Smrg      shift
435eaef79e5Smrg      ;;
436eaef79e5Smrg    *)
437eaef79e5Smrg      set fnord "$@" "$arg"
438eaef79e5Smrg      shift # fnord
439eaef79e5Smrg      shift # $arg
440eaef79e5Smrg      ;;
441eaef79e5Smrg    esac
442eaef79e5Smrg  done
443eaef79e5Smrg
444eaef79e5Smrg  test -z "$dashmflag" && dashmflag=-M
445eaef79e5Smrg  # Require at least two characters before searching for `:'
446eaef79e5Smrg  # in the target name.  This is to cope with DOS-style filenames:
447eaef79e5Smrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
448eaef79e5Smrg  "$@" $dashmflag |
449eaef79e5Smrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
450eaef79e5Smrg  rm -f "$depfile"
451eaef79e5Smrg  cat < "$tmpdepfile" > "$depfile"
452eaef79e5Smrg  tr ' ' '
453eaef79e5Smrg' < "$tmpdepfile" | \
454eaef79e5Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
455eaef79e5Smrg## correctly.  Breaking it into two sed invocations is a workaround.
456eaef79e5Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
457eaef79e5Smrg  rm -f "$tmpdepfile"
458eaef79e5Smrg  ;;
459eaef79e5Smrg
460eaef79e5SmrgdashXmstdout)
461eaef79e5Smrg  # This case only exists to satisfy depend.m4.  It is never actually
462eaef79e5Smrg  # run, as this mode is specially recognized in the preamble.
463eaef79e5Smrg  exit 1
464eaef79e5Smrg  ;;
465eaef79e5Smrg
466eaef79e5Smrgmakedepend)
467eaef79e5Smrg  "$@" || exit $?
468eaef79e5Smrg  # Remove any Libtool call
469eaef79e5Smrg  if test "$libtool" = yes; then
4702b32c8f7Smrg    while test "X$1" != 'X--mode=compile'; do
471eaef79e5Smrg      shift
472eaef79e5Smrg    done
473eaef79e5Smrg    shift
474eaef79e5Smrg  fi
475eaef79e5Smrg  # X makedepend
476eaef79e5Smrg  shift
4772b32c8f7Smrg  cleared=no eat=no
4782b32c8f7Smrg  for arg
4792b32c8f7Smrg  do
480eaef79e5Smrg    case $cleared in
481eaef79e5Smrg    no)
482eaef79e5Smrg      set ""; shift
483eaef79e5Smrg      cleared=yes ;;
484eaef79e5Smrg    esac
4852b32c8f7Smrg    if test $eat = yes; then
4862b32c8f7Smrg      eat=no
4872b32c8f7Smrg      continue
4882b32c8f7Smrg    fi
489eaef79e5Smrg    case "$arg" in
490eaef79e5Smrg    -D*|-I*)
491eaef79e5Smrg      set fnord "$@" "$arg"; shift ;;
492eaef79e5Smrg    # Strip any option that makedepend may not understand.  Remove
493eaef79e5Smrg    # the object too, otherwise makedepend will parse it as a source file.
4942b32c8f7Smrg    -arch)
4952b32c8f7Smrg      eat=yes ;;
496eaef79e5Smrg    -*|$object)
497eaef79e5Smrg      ;;
498eaef79e5Smrg    *)
499eaef79e5Smrg      set fnord "$@" "$arg"; shift ;;
500eaef79e5Smrg    esac
501eaef79e5Smrg  done
5022b32c8f7Smrg  obj_suffix=`echo "$object" | sed 's/^.*\././'`
503eaef79e5Smrg  touch "$tmpdepfile"
504eaef79e5Smrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
505eaef79e5Smrg  rm -f "$depfile"
506eaef79e5Smrg  cat < "$tmpdepfile" > "$depfile"
507eaef79e5Smrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
508eaef79e5Smrg' | \
509eaef79e5Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
510eaef79e5Smrg## correctly.  Breaking it into two sed invocations is a workaround.
511eaef79e5Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
512eaef79e5Smrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
513eaef79e5Smrg  ;;
514eaef79e5Smrg
515eaef79e5Smrgcpp)
516eaef79e5Smrg  # Important note: in order to support this mode, a compiler *must*
517eaef79e5Smrg  # always write the preprocessed file to stdout.
518eaef79e5Smrg  "$@" || exit $?
519eaef79e5Smrg
520eaef79e5Smrg  # Remove the call to Libtool.
521eaef79e5Smrg  if test "$libtool" = yes; then
5222b32c8f7Smrg    while test "X$1" != 'X--mode=compile'; do
523eaef79e5Smrg      shift
524eaef79e5Smrg    done
525eaef79e5Smrg    shift
526eaef79e5Smrg  fi
527eaef79e5Smrg
528eaef79e5Smrg  # Remove `-o $object'.
529eaef79e5Smrg  IFS=" "
530eaef79e5Smrg  for arg
531eaef79e5Smrg  do
532eaef79e5Smrg    case $arg in
533eaef79e5Smrg    -o)
534eaef79e5Smrg      shift
535eaef79e5Smrg      ;;
536eaef79e5Smrg    $object)
537eaef79e5Smrg      shift
538eaef79e5Smrg      ;;
539eaef79e5Smrg    *)
540eaef79e5Smrg      set fnord "$@" "$arg"
541eaef79e5Smrg      shift # fnord
542eaef79e5Smrg      shift # $arg
543eaef79e5Smrg      ;;
544eaef79e5Smrg    esac
545eaef79e5Smrg  done
546eaef79e5Smrg
547eaef79e5Smrg  "$@" -E |
548eaef79e5Smrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
549eaef79e5Smrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
550eaef79e5Smrg    sed '$ s: \\$::' > "$tmpdepfile"
551eaef79e5Smrg  rm -f "$depfile"
552eaef79e5Smrg  echo "$object : \\" > "$depfile"
553eaef79e5Smrg  cat < "$tmpdepfile" >> "$depfile"
554eaef79e5Smrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
555eaef79e5Smrg  rm -f "$tmpdepfile"
556eaef79e5Smrg  ;;
557eaef79e5Smrg
558eaef79e5Smrgmsvisualcpp)
559eaef79e5Smrg  # Important note: in order to support this mode, a compiler *must*
5602b32c8f7Smrg  # always write the preprocessed file to stdout.
561eaef79e5Smrg  "$@" || exit $?
5622b32c8f7Smrg
5632b32c8f7Smrg  # Remove the call to Libtool.
5642b32c8f7Smrg  if test "$libtool" = yes; then
5652b32c8f7Smrg    while test "X$1" != 'X--mode=compile'; do
5662b32c8f7Smrg      shift
5672b32c8f7Smrg    done
5682b32c8f7Smrg    shift
5692b32c8f7Smrg  fi
5702b32c8f7Smrg
571eaef79e5Smrg  IFS=" "
572eaef79e5Smrg  for arg
573eaef79e5Smrg  do
574eaef79e5Smrg    case "$arg" in
5752b32c8f7Smrg    -o)
5762b32c8f7Smrg      shift
5772b32c8f7Smrg      ;;
5782b32c8f7Smrg    $object)
5792b32c8f7Smrg      shift
5802b32c8f7Smrg      ;;
581eaef79e5Smrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
582eaef79e5Smrg	set fnord "$@"
583eaef79e5Smrg	shift
584eaef79e5Smrg	shift
585eaef79e5Smrg	;;
586eaef79e5Smrg    *)
587eaef79e5Smrg	set fnord "$@" "$arg"
588eaef79e5Smrg	shift
589eaef79e5Smrg	shift
590eaef79e5Smrg	;;
591eaef79e5Smrg    esac
592eaef79e5Smrg  done
5932b32c8f7Smrg  "$@" -E 2>/dev/null |
5942b32c8f7Smrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
595eaef79e5Smrg  rm -f "$depfile"
596eaef79e5Smrg  echo "$object : \\" > "$depfile"
5972b32c8f7Smrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
598eaef79e5Smrg  echo "	" >> "$depfile"
5992b32c8f7Smrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
600eaef79e5Smrg  rm -f "$tmpdepfile"
601eaef79e5Smrg  ;;
602eaef79e5Smrg
6032b32c8f7Smrgmsvcmsys)
6042b32c8f7Smrg  # This case exists only to let depend.m4 do its work.  It works by
6052b32c8f7Smrg  # looking at the text of this script.  This case will never be run,
6062b32c8f7Smrg  # since it is checked for above.
6072b32c8f7Smrg  exit 1
6082b32c8f7Smrg  ;;
6092b32c8f7Smrg
610eaef79e5Smrgnone)
611eaef79e5Smrg  exec "$@"
612eaef79e5Smrg  ;;
613eaef79e5Smrg
614eaef79e5Smrg*)
615eaef79e5Smrg  echo "Unknown depmode $depmode" 1>&2
616eaef79e5Smrg  exit 1
617eaef79e5Smrg  ;;
618eaef79e5Smrgesac
619eaef79e5Smrg
620eaef79e5Smrgexit 0
621eaef79e5Smrg
622eaef79e5Smrg# Local Variables:
623eaef79e5Smrg# mode: shell-script
624eaef79e5Smrg# sh-indentation: 2
625eaef79e5Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
626eaef79e5Smrg# time-stamp-start: "scriptversion="
627eaef79e5Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
6282b32c8f7Smrg# time-stamp-time-zone: "UTC"
6292b32c8f7Smrg# time-stamp-end: "; # UTC"
630eaef79e5Smrg# End:
631