depcomp revision 14330f12
195b296d0Smrg#! /bin/sh
295b296d0Smrg# depcomp - compile a program generating dependencies as side-effects
395b296d0Smrg
414330f12Smrgscriptversion=2009-04-28.21; # UTC
595b296d0Smrg
614330f12Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
714330f12Smrg# Software Foundation, Inc.
895b296d0Smrg
995b296d0Smrg# This program is free software; you can redistribute it and/or modify
1095b296d0Smrg# it under the terms of the GNU General Public License as published by
1195b296d0Smrg# the Free Software Foundation; either version 2, or (at your option)
1295b296d0Smrg# any later version.
1395b296d0Smrg
1495b296d0Smrg# This program is distributed in the hope that it will be useful,
1595b296d0Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1695b296d0Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1795b296d0Smrg# GNU General Public License for more details.
1895b296d0Smrg
1995b296d0Smrg# You should have received a copy of the GNU General Public License
2014330f12Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2195b296d0Smrg
2295b296d0Smrg# As a special exception to the GNU General Public License, if you
2395b296d0Smrg# distribute this file as part of a program that contains a
2495b296d0Smrg# configuration script generated by Autoconf, you may include it under
2595b296d0Smrg# the same distribution terms that you use for the rest of that program.
2695b296d0Smrg
2795b296d0Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
2895b296d0Smrg
2995b296d0Smrgcase $1 in
3095b296d0Smrg  '')
3195b296d0Smrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
3295b296d0Smrg     exit 1;
3395b296d0Smrg     ;;
3495b296d0Smrg  -h | --h*)
3595b296d0Smrg    cat <<\EOF
3695b296d0SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
3795b296d0Smrg
3895b296d0SmrgRun PROGRAMS ARGS to compile a file, generating dependencies
3995b296d0Smrgas side-effects.
4095b296d0Smrg
4195b296d0SmrgEnvironment variables:
4295b296d0Smrg  depmode     Dependency tracking mode.
4395b296d0Smrg  source      Source file read by `PROGRAMS ARGS'.
4495b296d0Smrg  object      Object file output by `PROGRAMS ARGS'.
4595b296d0Smrg  DEPDIR      directory where to store dependencies.
4695b296d0Smrg  depfile     Dependency file to output.
4795b296d0Smrg  tmpdepfile  Temporary file to use when outputing dependencies.
4895b296d0Smrg  libtool     Whether libtool is used (yes/no).
4995b296d0Smrg
5095b296d0SmrgReport bugs to <bug-automake@gnu.org>.
5195b296d0SmrgEOF
5295b296d0Smrg    exit $?
5395b296d0Smrg    ;;
5495b296d0Smrg  -v | --v*)
5595b296d0Smrg    echo "depcomp $scriptversion"
5695b296d0Smrg    exit $?
5795b296d0Smrg    ;;
5895b296d0Smrgesac
5995b296d0Smrg
6095b296d0Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
6195b296d0Smrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
6295b296d0Smrg  exit 1
6395b296d0Smrgfi
6495b296d0Smrg
6595b296d0Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
6695b296d0Smrgdepfile=${depfile-`echo "$object" |
6795b296d0Smrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
6895b296d0Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
6995b296d0Smrg
7095b296d0Smrgrm -f "$tmpdepfile"
7195b296d0Smrg
7295b296d0Smrg# Some modes work just like other modes, but use different flags.  We
7395b296d0Smrg# parameterize here, but still list the modes in the big case below,
7495b296d0Smrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
7595b296d0Smrg# here, because this file can only contain one case statement.
7695b296d0Smrgif test "$depmode" = hp; then
7795b296d0Smrg  # HP compiler uses -M and no extra arg.
7895b296d0Smrg  gccflag=-M
7995b296d0Smrg  depmode=gcc
8095b296d0Smrgfi
8195b296d0Smrg
8295b296d0Smrgif test "$depmode" = dashXmstdout; then
8395b296d0Smrg   # This is just like dashmstdout with a different argument.
8495b296d0Smrg   dashmflag=-xM
8595b296d0Smrg   depmode=dashmstdout
8695b296d0Smrgfi
8795b296d0Smrg
8814330f12Smrgcygpath_u="cygpath -u -f -"
8914330f12Smrgif test "$depmode" = msvcmsys; then
9014330f12Smrg   # This is just like msvisualcpp but w/o cygpath translation.
9114330f12Smrg   # Just convert the backslash-escaped backslashes to single forward
9214330f12Smrg   # slashes to satisfy depend.m4
9314330f12Smrg   cygpath_u="sed s,\\\\\\\\,/,g"
9414330f12Smrg   depmode=msvisualcpp
9514330f12Smrgfi
9614330f12Smrg
9795b296d0Smrgcase "$depmode" in
9895b296d0Smrggcc3)
9995b296d0Smrg## gcc 3 implements dependency tracking that does exactly what
10095b296d0Smrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
10195b296d0Smrg## it if -MD -MP comes after the -MF stuff.  Hmm.
102ff89ac2bSmrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
103ff89ac2bSmrg## the command line argument order; so add the flags where they
104ff89ac2bSmrg## appear in depend2.am.  Note that the slowdown incurred here
105ff89ac2bSmrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
106ff89ac2bSmrg  for arg
107ff89ac2bSmrg  do
108ff89ac2bSmrg    case $arg in
109ff89ac2bSmrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
110ff89ac2bSmrg    *)  set fnord "$@" "$arg" ;;
111ff89ac2bSmrg    esac
112ff89ac2bSmrg    shift # fnord
113ff89ac2bSmrg    shift # $arg
114ff89ac2bSmrg  done
115ff89ac2bSmrg  "$@"
11695b296d0Smrg  stat=$?
11795b296d0Smrg  if test $stat -eq 0; then :
11895b296d0Smrg  else
11995b296d0Smrg    rm -f "$tmpdepfile"
12095b296d0Smrg    exit $stat
12195b296d0Smrg  fi
12295b296d0Smrg  mv "$tmpdepfile" "$depfile"
12395b296d0Smrg  ;;
12495b296d0Smrg
12595b296d0Smrggcc)
12695b296d0Smrg## There are various ways to get dependency output from gcc.  Here's
12795b296d0Smrg## why we pick this rather obscure method:
12895b296d0Smrg## - Don't want to use -MD because we'd like the dependencies to end
12995b296d0Smrg##   up in a subdir.  Having to rename by hand is ugly.
13095b296d0Smrg##   (We might end up doing this anyway to support other compilers.)
13195b296d0Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
13295b296d0Smrg##   -MM, not -M (despite what the docs say).
13395b296d0Smrg## - Using -M directly means running the compiler twice (even worse
13495b296d0Smrg##   than renaming).
13595b296d0Smrg  if test -z "$gccflag"; then
13695b296d0Smrg    gccflag=-MD,
13795b296d0Smrg  fi
13895b296d0Smrg  "$@" -Wp,"$gccflag$tmpdepfile"
13995b296d0Smrg  stat=$?
14095b296d0Smrg  if test $stat -eq 0; then :
14195b296d0Smrg  else
14295b296d0Smrg    rm -f "$tmpdepfile"
14395b296d0Smrg    exit $stat
14495b296d0Smrg  fi
14595b296d0Smrg  rm -f "$depfile"
14695b296d0Smrg  echo "$object : \\" > "$depfile"
14795b296d0Smrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
14895b296d0Smrg## The second -e expression handles DOS-style file names with drive letters.
14995b296d0Smrg  sed -e 's/^[^:]*: / /' \
15095b296d0Smrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
15195b296d0Smrg## This next piece of magic avoids the `deleted header file' problem.
15295b296d0Smrg## The problem is that when a header file which appears in a .P file
15395b296d0Smrg## is deleted, the dependency causes make to die (because there is
15495b296d0Smrg## typically no way to rebuild the header).  We avoid this by adding
15595b296d0Smrg## dummy dependencies for each header file.  Too bad gcc doesn't do
15695b296d0Smrg## this for us directly.
15795b296d0Smrg  tr ' ' '
15895b296d0Smrg' < "$tmpdepfile" |
15995b296d0Smrg## Some versions of gcc put a space before the `:'.  On the theory
16095b296d0Smrg## that the space means something, we add a space to the output as
16195b296d0Smrg## well.
16295b296d0Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
16395b296d0Smrg## correctly.  Breaking it into two sed invocations is a workaround.
16495b296d0Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
16595b296d0Smrg  rm -f "$tmpdepfile"
16695b296d0Smrg  ;;
16795b296d0Smrg
16895b296d0Smrghp)
16995b296d0Smrg  # This case exists only to let depend.m4 do its work.  It works by
17095b296d0Smrg  # looking at the text of this script.  This case will never be run,
17195b296d0Smrg  # since it is checked for above.
17295b296d0Smrg  exit 1
17395b296d0Smrg  ;;
17495b296d0Smrg
17595b296d0Smrgsgi)
17695b296d0Smrg  if test "$libtool" = yes; then
17795b296d0Smrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
17895b296d0Smrg  else
17995b296d0Smrg    "$@" -MDupdate "$tmpdepfile"
18095b296d0Smrg  fi
18195b296d0Smrg  stat=$?
18295b296d0Smrg  if test $stat -eq 0; then :
18395b296d0Smrg  else
18495b296d0Smrg    rm -f "$tmpdepfile"
18595b296d0Smrg    exit $stat
18695b296d0Smrg  fi
18795b296d0Smrg  rm -f "$depfile"
18895b296d0Smrg
18995b296d0Smrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
19095b296d0Smrg    echo "$object : \\" > "$depfile"
19195b296d0Smrg
19295b296d0Smrg    # Clip off the initial element (the dependent).  Don't try to be
19395b296d0Smrg    # clever and replace this with sed code, as IRIX sed won't handle
19495b296d0Smrg    # lines with more than a fixed number of characters (4096 in
19595b296d0Smrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
19695b296d0Smrg    # the IRIX cc adds comments like `#:fec' to the end of the
19795b296d0Smrg    # dependency line.
19895b296d0Smrg    tr ' ' '
19995b296d0Smrg' < "$tmpdepfile" \
20095b296d0Smrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
20195b296d0Smrg    tr '
20214330f12Smrg' ' ' >> "$depfile"
20314330f12Smrg    echo >> "$depfile"
20495b296d0Smrg
20595b296d0Smrg    # The second pass generates a dummy entry for each header file.
20695b296d0Smrg    tr ' ' '
20795b296d0Smrg' < "$tmpdepfile" \
20895b296d0Smrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
20914330f12Smrg   >> "$depfile"
21095b296d0Smrg  else
21195b296d0Smrg    # The sourcefile does not contain any dependencies, so just
21295b296d0Smrg    # store a dummy comment line, to avoid errors with the Makefile
21395b296d0Smrg    # "include basename.Plo" scheme.
21495b296d0Smrg    echo "#dummy" > "$depfile"
21595b296d0Smrg  fi
21695b296d0Smrg  rm -f "$tmpdepfile"
21795b296d0Smrg  ;;
21895b296d0Smrg
21995b296d0Smrgaix)
22095b296d0Smrg  # The C for AIX Compiler uses -M and outputs the dependencies
22195b296d0Smrg  # in a .u file.  In older versions, this file always lives in the
22295b296d0Smrg  # current directory.  Also, the AIX compiler puts `$object:' at the
22395b296d0Smrg  # start of each line; $object doesn't have directory information.
22495b296d0Smrg  # Version 6 uses the directory in both cases.
225ff89ac2bSmrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
226ff89ac2bSmrg  test "x$dir" = "x$object" && dir=
227ff89ac2bSmrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
22895b296d0Smrg  if test "$libtool" = yes; then
229ff89ac2bSmrg    tmpdepfile1=$dir$base.u
230ff89ac2bSmrg    tmpdepfile2=$base.u
231ff89ac2bSmrg    tmpdepfile3=$dir.libs/$base.u
23295b296d0Smrg    "$@" -Wc,-M
23395b296d0Smrg  else
234ff89ac2bSmrg    tmpdepfile1=$dir$base.u
235ff89ac2bSmrg    tmpdepfile2=$dir$base.u
236ff89ac2bSmrg    tmpdepfile3=$dir$base.u
23795b296d0Smrg    "$@" -M
23895b296d0Smrg  fi
23995b296d0Smrg  stat=$?
24095b296d0Smrg
24195b296d0Smrg  if test $stat -eq 0; then :
24295b296d0Smrg  else
243ff89ac2bSmrg    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
24495b296d0Smrg    exit $stat
24595b296d0Smrg  fi
24695b296d0Smrg
247ff89ac2bSmrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
248ff89ac2bSmrg  do
249ff89ac2bSmrg    test -f "$tmpdepfile" && break
250ff89ac2bSmrg  done
25195b296d0Smrg  if test -f "$tmpdepfile"; then
25295b296d0Smrg    # Each line is of the form `foo.o: dependent.h'.
25395b296d0Smrg    # Do two passes, one to just change these to
25495b296d0Smrg    # `$object: dependent.h' and one to simply `dependent.h:'.
255ff89ac2bSmrg    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
256ff89ac2bSmrg    # That's a tab and a space in the [].
257ff89ac2bSmrg    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
25895b296d0Smrg  else
25995b296d0Smrg    # The sourcefile does not contain any dependencies, so just
26095b296d0Smrg    # store a dummy comment line, to avoid errors with the Makefile
26195b296d0Smrg    # "include basename.Plo" scheme.
26295b296d0Smrg    echo "#dummy" > "$depfile"
26395b296d0Smrg  fi
26495b296d0Smrg  rm -f "$tmpdepfile"
26595b296d0Smrg  ;;
26695b296d0Smrg
26795b296d0Smrgicc)
26895b296d0Smrg  # Intel's C compiler understands `-MD -MF file'.  However on
26995b296d0Smrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
27095b296d0Smrg  # ICC 7.0 will fill foo.d with something like
27195b296d0Smrg  #    foo.o: sub/foo.c
27295b296d0Smrg  #    foo.o: sub/foo.h
27395b296d0Smrg  # which is wrong.  We want:
27495b296d0Smrg  #    sub/foo.o: sub/foo.c
27595b296d0Smrg  #    sub/foo.o: sub/foo.h
27695b296d0Smrg  #    sub/foo.c:
27795b296d0Smrg  #    sub/foo.h:
27895b296d0Smrg  # ICC 7.1 will output
27995b296d0Smrg  #    foo.o: sub/foo.c sub/foo.h
28095b296d0Smrg  # and will wrap long lines using \ :
28195b296d0Smrg  #    foo.o: sub/foo.c ... \
28295b296d0Smrg  #     sub/foo.h ... \
28395b296d0Smrg  #     ...
28495b296d0Smrg
28595b296d0Smrg  "$@" -MD -MF "$tmpdepfile"
28695b296d0Smrg  stat=$?
28795b296d0Smrg  if test $stat -eq 0; then :
28895b296d0Smrg  else
28995b296d0Smrg    rm -f "$tmpdepfile"
29095b296d0Smrg    exit $stat
29195b296d0Smrg  fi
29295b296d0Smrg  rm -f "$depfile"
29395b296d0Smrg  # Each line is of the form `foo.o: dependent.h',
29495b296d0Smrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
29595b296d0Smrg  # Do two passes, one to just change these to
29695b296d0Smrg  # `$object: dependent.h' and one to simply `dependent.h:'.
29795b296d0Smrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
29895b296d0Smrg  # Some versions of the HPUX 10.20 sed can't process this invocation
29995b296d0Smrg  # correctly.  Breaking it into two sed invocations is a workaround.
30095b296d0Smrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
30195b296d0Smrg    sed -e 's/$/ :/' >> "$depfile"
30295b296d0Smrg  rm -f "$tmpdepfile"
30395b296d0Smrg  ;;
30495b296d0Smrg
305ff89ac2bSmrghp2)
306ff89ac2bSmrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
307ff89ac2bSmrg  # compilers, which have integrated preprocessors.  The correct option
308ff89ac2bSmrg  # to use with these is +Maked; it writes dependencies to a file named
309ff89ac2bSmrg  # 'foo.d', which lands next to the object file, wherever that
310ff89ac2bSmrg  # happens to be.
311ff89ac2bSmrg  # Much of this is similar to the tru64 case; see comments there.
312ff89ac2bSmrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
313ff89ac2bSmrg  test "x$dir" = "x$object" && dir=
314ff89ac2bSmrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
315ff89ac2bSmrg  if test "$libtool" = yes; then
316ff89ac2bSmrg    tmpdepfile1=$dir$base.d
317ff89ac2bSmrg    tmpdepfile2=$dir.libs/$base.d
318ff89ac2bSmrg    "$@" -Wc,+Maked
319ff89ac2bSmrg  else
320ff89ac2bSmrg    tmpdepfile1=$dir$base.d
321ff89ac2bSmrg    tmpdepfile2=$dir$base.d
322ff89ac2bSmrg    "$@" +Maked
323ff89ac2bSmrg  fi
324ff89ac2bSmrg  stat=$?
325ff89ac2bSmrg  if test $stat -eq 0; then :
326ff89ac2bSmrg  else
327ff89ac2bSmrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
328ff89ac2bSmrg     exit $stat
329ff89ac2bSmrg  fi
330ff89ac2bSmrg
331ff89ac2bSmrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
332ff89ac2bSmrg  do
333ff89ac2bSmrg    test -f "$tmpdepfile" && break
334ff89ac2bSmrg  done
335ff89ac2bSmrg  if test -f "$tmpdepfile"; then
336ff89ac2bSmrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
337ff89ac2bSmrg    # Add `dependent.h:' lines.
33814330f12Smrg    sed -ne '2,${
33914330f12Smrg	       s/^ *//
34014330f12Smrg	       s/ \\*$//
34114330f12Smrg	       s/$/:/
34214330f12Smrg	       p
34314330f12Smrg	     }' "$tmpdepfile" >> "$depfile"
344ff89ac2bSmrg  else
345ff89ac2bSmrg    echo "#dummy" > "$depfile"
346ff89ac2bSmrg  fi
347ff89ac2bSmrg  rm -f "$tmpdepfile" "$tmpdepfile2"
348ff89ac2bSmrg  ;;
349ff89ac2bSmrg
35095b296d0Smrgtru64)
35195b296d0Smrg   # The Tru64 compiler uses -MD to generate dependencies as a side
35295b296d0Smrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
35395b296d0Smrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
35495b296d0Smrg   # dependencies in `foo.d' instead, so we check for that too.
35595b296d0Smrg   # Subdirectories are respected.
35695b296d0Smrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
35795b296d0Smrg   test "x$dir" = "x$object" && dir=
35895b296d0Smrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
35995b296d0Smrg
36095b296d0Smrg   if test "$libtool" = yes; then
36195b296d0Smrg      # With Tru64 cc, shared objects can also be used to make a
362ff89ac2bSmrg      # static library.  This mechanism is used in libtool 1.4 series to
36395b296d0Smrg      # handle both shared and static libraries in a single compilation.
36495b296d0Smrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
36595b296d0Smrg      #
36695b296d0Smrg      # With libtool 1.5 this exception was removed, and libtool now
36795b296d0Smrg      # generates 2 separate objects for the 2 libraries.  These two
368ff89ac2bSmrg      # compilations output dependencies in $dir.libs/$base.o.d and
36995b296d0Smrg      # in $dir$base.o.d.  We have to check for both files, because
37095b296d0Smrg      # one of the two compilations can be disabled.  We should prefer
37195b296d0Smrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
37295b296d0Smrg      # automatically cleaned when .libs/ is deleted, while ignoring
37395b296d0Smrg      # the former would cause a distcleancheck panic.
37495b296d0Smrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
37595b296d0Smrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
37695b296d0Smrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
37795b296d0Smrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
37895b296d0Smrg      "$@" -Wc,-MD
37995b296d0Smrg   else
38095b296d0Smrg      tmpdepfile1=$dir$base.o.d
38195b296d0Smrg      tmpdepfile2=$dir$base.d
38295b296d0Smrg      tmpdepfile3=$dir$base.d
38395b296d0Smrg      tmpdepfile4=$dir$base.d
38495b296d0Smrg      "$@" -MD
38595b296d0Smrg   fi
38695b296d0Smrg
38795b296d0Smrg   stat=$?
38895b296d0Smrg   if test $stat -eq 0; then :
38995b296d0Smrg   else
39095b296d0Smrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
39195b296d0Smrg      exit $stat
39295b296d0Smrg   fi
39395b296d0Smrg
39495b296d0Smrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
39595b296d0Smrg   do
39695b296d0Smrg     test -f "$tmpdepfile" && break
39795b296d0Smrg   done
39895b296d0Smrg   if test -f "$tmpdepfile"; then
39995b296d0Smrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
40095b296d0Smrg      # That's a tab and a space in the [].
40195b296d0Smrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
40295b296d0Smrg   else
40395b296d0Smrg      echo "#dummy" > "$depfile"
40495b296d0Smrg   fi
40595b296d0Smrg   rm -f "$tmpdepfile"
40695b296d0Smrg   ;;
40795b296d0Smrg
40895b296d0Smrg#nosideeffect)
40995b296d0Smrg  # This comment above is used by automake to tell side-effect
41095b296d0Smrg  # dependency tracking mechanisms from slower ones.
41195b296d0Smrg
41295b296d0Smrgdashmstdout)
41395b296d0Smrg  # Important note: in order to support this mode, a compiler *must*
41495b296d0Smrg  # always write the preprocessed file to stdout, regardless of -o.
41595b296d0Smrg  "$@" || exit $?
41695b296d0Smrg
41795b296d0Smrg  # Remove the call to Libtool.
41895b296d0Smrg  if test "$libtool" = yes; then
41914330f12Smrg    while test "X$1" != 'X--mode=compile'; do
42095b296d0Smrg      shift
42195b296d0Smrg    done
42295b296d0Smrg    shift
42395b296d0Smrg  fi
42495b296d0Smrg
42595b296d0Smrg  # Remove `-o $object'.
42695b296d0Smrg  IFS=" "
42795b296d0Smrg  for arg
42895b296d0Smrg  do
42995b296d0Smrg    case $arg in
43095b296d0Smrg    -o)
43195b296d0Smrg      shift
43295b296d0Smrg      ;;
43395b296d0Smrg    $object)
43495b296d0Smrg      shift
43595b296d0Smrg      ;;
43695b296d0Smrg    *)
43795b296d0Smrg      set fnord "$@" "$arg"
43895b296d0Smrg      shift # fnord
43995b296d0Smrg      shift # $arg
44095b296d0Smrg      ;;
44195b296d0Smrg    esac
44295b296d0Smrg  done
44395b296d0Smrg
44495b296d0Smrg  test -z "$dashmflag" && dashmflag=-M
44595b296d0Smrg  # Require at least two characters before searching for `:'
44695b296d0Smrg  # in the target name.  This is to cope with DOS-style filenames:
44795b296d0Smrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
44895b296d0Smrg  "$@" $dashmflag |
44995b296d0Smrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
45095b296d0Smrg  rm -f "$depfile"
45195b296d0Smrg  cat < "$tmpdepfile" > "$depfile"
45295b296d0Smrg  tr ' ' '
45395b296d0Smrg' < "$tmpdepfile" | \
45495b296d0Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
45595b296d0Smrg## correctly.  Breaking it into two sed invocations is a workaround.
45695b296d0Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
45795b296d0Smrg  rm -f "$tmpdepfile"
45895b296d0Smrg  ;;
45995b296d0Smrg
46095b296d0SmrgdashXmstdout)
46195b296d0Smrg  # This case only exists to satisfy depend.m4.  It is never actually
46295b296d0Smrg  # run, as this mode is specially recognized in the preamble.
46395b296d0Smrg  exit 1
46495b296d0Smrg  ;;
46595b296d0Smrg
46695b296d0Smrgmakedepend)
46795b296d0Smrg  "$@" || exit $?
46895b296d0Smrg  # Remove any Libtool call
46995b296d0Smrg  if test "$libtool" = yes; then
47014330f12Smrg    while test "X$1" != 'X--mode=compile'; do
47195b296d0Smrg      shift
47295b296d0Smrg    done
47395b296d0Smrg    shift
47495b296d0Smrg  fi
47595b296d0Smrg  # X makedepend
47695b296d0Smrg  shift
47714330f12Smrg  cleared=no eat=no
47814330f12Smrg  for arg
47914330f12Smrg  do
48095b296d0Smrg    case $cleared in
48195b296d0Smrg    no)
48295b296d0Smrg      set ""; shift
48395b296d0Smrg      cleared=yes ;;
48495b296d0Smrg    esac
48514330f12Smrg    if test $eat = yes; then
48614330f12Smrg      eat=no
48714330f12Smrg      continue
48814330f12Smrg    fi
48995b296d0Smrg    case "$arg" in
49095b296d0Smrg    -D*|-I*)
49195b296d0Smrg      set fnord "$@" "$arg"; shift ;;
49295b296d0Smrg    # Strip any option that makedepend may not understand.  Remove
49395b296d0Smrg    # the object too, otherwise makedepend will parse it as a source file.
49414330f12Smrg    -arch)
49514330f12Smrg      eat=yes ;;
49695b296d0Smrg    -*|$object)
49795b296d0Smrg      ;;
49895b296d0Smrg    *)
49995b296d0Smrg      set fnord "$@" "$arg"; shift ;;
50095b296d0Smrg    esac
50195b296d0Smrg  done
50214330f12Smrg  obj_suffix=`echo "$object" | sed 's/^.*\././'`
50395b296d0Smrg  touch "$tmpdepfile"
50495b296d0Smrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
50595b296d0Smrg  rm -f "$depfile"
50695b296d0Smrg  cat < "$tmpdepfile" > "$depfile"
50795b296d0Smrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
50895b296d0Smrg' | \
50995b296d0Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
51095b296d0Smrg## correctly.  Breaking it into two sed invocations is a workaround.
51195b296d0Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
51295b296d0Smrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
51395b296d0Smrg  ;;
51495b296d0Smrg
51595b296d0Smrgcpp)
51695b296d0Smrg  # Important note: in order to support this mode, a compiler *must*
51795b296d0Smrg  # always write the preprocessed file to stdout.
51895b296d0Smrg  "$@" || exit $?
51995b296d0Smrg
52095b296d0Smrg  # Remove the call to Libtool.
52195b296d0Smrg  if test "$libtool" = yes; then
52214330f12Smrg    while test "X$1" != 'X--mode=compile'; do
52395b296d0Smrg      shift
52495b296d0Smrg    done
52595b296d0Smrg    shift
52695b296d0Smrg  fi
52795b296d0Smrg
52895b296d0Smrg  # Remove `-o $object'.
52995b296d0Smrg  IFS=" "
53095b296d0Smrg  for arg
53195b296d0Smrg  do
53295b296d0Smrg    case $arg in
53395b296d0Smrg    -o)
53495b296d0Smrg      shift
53595b296d0Smrg      ;;
53695b296d0Smrg    $object)
53795b296d0Smrg      shift
53895b296d0Smrg      ;;
53995b296d0Smrg    *)
54095b296d0Smrg      set fnord "$@" "$arg"
54195b296d0Smrg      shift # fnord
54295b296d0Smrg      shift # $arg
54395b296d0Smrg      ;;
54495b296d0Smrg    esac
54595b296d0Smrg  done
54695b296d0Smrg
54795b296d0Smrg  "$@" -E |
54895b296d0Smrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
54995b296d0Smrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
55095b296d0Smrg    sed '$ s: \\$::' > "$tmpdepfile"
55195b296d0Smrg  rm -f "$depfile"
55295b296d0Smrg  echo "$object : \\" > "$depfile"
55395b296d0Smrg  cat < "$tmpdepfile" >> "$depfile"
55495b296d0Smrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
55595b296d0Smrg  rm -f "$tmpdepfile"
55695b296d0Smrg  ;;
55795b296d0Smrg
55895b296d0Smrgmsvisualcpp)
55995b296d0Smrg  # Important note: in order to support this mode, a compiler *must*
56014330f12Smrg  # always write the preprocessed file to stdout.
56195b296d0Smrg  "$@" || exit $?
56214330f12Smrg
56314330f12Smrg  # Remove the call to Libtool.
56414330f12Smrg  if test "$libtool" = yes; then
56514330f12Smrg    while test "X$1" != 'X--mode=compile'; do
56614330f12Smrg      shift
56714330f12Smrg    done
56814330f12Smrg    shift
56914330f12Smrg  fi
57014330f12Smrg
57195b296d0Smrg  IFS=" "
57295b296d0Smrg  for arg
57395b296d0Smrg  do
57495b296d0Smrg    case "$arg" in
57514330f12Smrg    -o)
57614330f12Smrg      shift
57714330f12Smrg      ;;
57814330f12Smrg    $object)
57914330f12Smrg      shift
58014330f12Smrg      ;;
58195b296d0Smrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
58295b296d0Smrg	set fnord "$@"
58395b296d0Smrg	shift
58495b296d0Smrg	shift
58595b296d0Smrg	;;
58695b296d0Smrg    *)
58795b296d0Smrg	set fnord "$@" "$arg"
58895b296d0Smrg	shift
58995b296d0Smrg	shift
59095b296d0Smrg	;;
59195b296d0Smrg    esac
59295b296d0Smrg  done
59314330f12Smrg  "$@" -E 2>/dev/null |
59414330f12Smrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
59595b296d0Smrg  rm -f "$depfile"
59695b296d0Smrg  echo "$object : \\" > "$depfile"
59714330f12Smrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
59895b296d0Smrg  echo "	" >> "$depfile"
59914330f12Smrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
60095b296d0Smrg  rm -f "$tmpdepfile"
60195b296d0Smrg  ;;
60295b296d0Smrg
60314330f12Smrgmsvcmsys)
60414330f12Smrg  # This case exists only to let depend.m4 do its work.  It works by
60514330f12Smrg  # looking at the text of this script.  This case will never be run,
60614330f12Smrg  # since it is checked for above.
60714330f12Smrg  exit 1
60814330f12Smrg  ;;
60914330f12Smrg
61095b296d0Smrgnone)
61195b296d0Smrg  exec "$@"
61295b296d0Smrg  ;;
61395b296d0Smrg
61495b296d0Smrg*)
61595b296d0Smrg  echo "Unknown depmode $depmode" 1>&2
61695b296d0Smrg  exit 1
61795b296d0Smrg  ;;
61895b296d0Smrgesac
61995b296d0Smrg
62095b296d0Smrgexit 0
62195b296d0Smrg
62295b296d0Smrg# Local Variables:
62395b296d0Smrg# mode: shell-script
62495b296d0Smrg# sh-indentation: 2
62595b296d0Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
62695b296d0Smrg# time-stamp-start: "scriptversion="
62795b296d0Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
62814330f12Smrg# time-stamp-time-zone: "UTC"
62914330f12Smrg# time-stamp-end: "; # UTC"
63095b296d0Smrg# End:
631