depcomp revision 278eca22
133c89af1Smrg#! /bin/sh
233c89af1Smrg# depcomp - compile a program generating dependencies as side-effects
333c89af1Smrg
4278eca22Smrgscriptversion=2009-04-28.21; # UTC
533c89af1Smrg
6278eca22Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
7278eca22Smrg# Software Foundation, Inc.
833c89af1Smrg
933c89af1Smrg# This program is free software; you can redistribute it and/or modify
1033c89af1Smrg# it under the terms of the GNU General Public License as published by
1133c89af1Smrg# the Free Software Foundation; either version 2, or (at your option)
1233c89af1Smrg# any later version.
1333c89af1Smrg
1433c89af1Smrg# This program is distributed in the hope that it will be useful,
1533c89af1Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1633c89af1Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1733c89af1Smrg# GNU General Public License for more details.
1833c89af1Smrg
1933c89af1Smrg# You should have received a copy of the GNU General Public License
20278eca22Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2133c89af1Smrg
2233c89af1Smrg# As a special exception to the GNU General Public License, if you
2333c89af1Smrg# distribute this file as part of a program that contains a
2433c89af1Smrg# configuration script generated by Autoconf, you may include it under
2533c89af1Smrg# the same distribution terms that you use for the rest of that program.
2633c89af1Smrg
2733c89af1Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
2833c89af1Smrg
2933c89af1Smrgcase $1 in
3033c89af1Smrg  '')
3133c89af1Smrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
3233c89af1Smrg     exit 1;
3333c89af1Smrg     ;;
3433c89af1Smrg  -h | --h*)
3533c89af1Smrg    cat <<\EOF
3633c89af1SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
3733c89af1Smrg
3833c89af1SmrgRun PROGRAMS ARGS to compile a file, generating dependencies
3933c89af1Smrgas side-effects.
4033c89af1Smrg
4133c89af1SmrgEnvironment variables:
4233c89af1Smrg  depmode     Dependency tracking mode.
4333c89af1Smrg  source      Source file read by `PROGRAMS ARGS'.
4433c89af1Smrg  object      Object file output by `PROGRAMS ARGS'.
4533c89af1Smrg  DEPDIR      directory where to store dependencies.
4633c89af1Smrg  depfile     Dependency file to output.
4733c89af1Smrg  tmpdepfile  Temporary file to use when outputing dependencies.
4833c89af1Smrg  libtool     Whether libtool is used (yes/no).
4933c89af1Smrg
5033c89af1SmrgReport bugs to <bug-automake@gnu.org>.
5133c89af1SmrgEOF
5233c89af1Smrg    exit $?
5333c89af1Smrg    ;;
5433c89af1Smrg  -v | --v*)
5533c89af1Smrg    echo "depcomp $scriptversion"
5633c89af1Smrg    exit $?
5733c89af1Smrg    ;;
5833c89af1Smrgesac
5933c89af1Smrg
6033c89af1Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
6133c89af1Smrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
6233c89af1Smrg  exit 1
6333c89af1Smrgfi
6433c89af1Smrg
6533c89af1Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
6633c89af1Smrgdepfile=${depfile-`echo "$object" |
6733c89af1Smrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
6833c89af1Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
6933c89af1Smrg
7033c89af1Smrgrm -f "$tmpdepfile"
7133c89af1Smrg
7233c89af1Smrg# Some modes work just like other modes, but use different flags.  We
7333c89af1Smrg# parameterize here, but still list the modes in the big case below,
7433c89af1Smrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
7533c89af1Smrg# here, because this file can only contain one case statement.
7633c89af1Smrgif test "$depmode" = hp; then
7733c89af1Smrg  # HP compiler uses -M and no extra arg.
7833c89af1Smrg  gccflag=-M
7933c89af1Smrg  depmode=gcc
8033c89af1Smrgfi
8133c89af1Smrg
8233c89af1Smrgif test "$depmode" = dashXmstdout; then
8333c89af1Smrg   # This is just like dashmstdout with a different argument.
8433c89af1Smrg   dashmflag=-xM
8533c89af1Smrg   depmode=dashmstdout
8633c89af1Smrgfi
8733c89af1Smrg
88278eca22Smrgcygpath_u="cygpath -u -f -"
89278eca22Smrgif test "$depmode" = msvcmsys; then
90278eca22Smrg   # This is just like msvisualcpp but w/o cygpath translation.
91278eca22Smrg   # Just convert the backslash-escaped backslashes to single forward
92278eca22Smrg   # slashes to satisfy depend.m4
93278eca22Smrg   cygpath_u="sed s,\\\\\\\\,/,g"
94278eca22Smrg   depmode=msvisualcpp
95278eca22Smrgfi
96278eca22Smrg
9733c89af1Smrgcase "$depmode" in
9833c89af1Smrggcc3)
9933c89af1Smrg## gcc 3 implements dependency tracking that does exactly what
10033c89af1Smrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
10133c89af1Smrg## it if -MD -MP comes after the -MF stuff.  Hmm.
102278eca22Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
103278eca22Smrg## the command line argument order; so add the flags where they
104278eca22Smrg## appear in depend2.am.  Note that the slowdown incurred here
105278eca22Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
106278eca22Smrg  for arg
107278eca22Smrg  do
108278eca22Smrg    case $arg in
109278eca22Smrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
110278eca22Smrg    *)  set fnord "$@" "$arg" ;;
111278eca22Smrg    esac
112278eca22Smrg    shift # fnord
113278eca22Smrg    shift # $arg
114278eca22Smrg  done
115278eca22Smrg  "$@"
11633c89af1Smrg  stat=$?
11733c89af1Smrg  if test $stat -eq 0; then :
11833c89af1Smrg  else
11933c89af1Smrg    rm -f "$tmpdepfile"
12033c89af1Smrg    exit $stat
12133c89af1Smrg  fi
12233c89af1Smrg  mv "$tmpdepfile" "$depfile"
12333c89af1Smrg  ;;
12433c89af1Smrg
12533c89af1Smrggcc)
12633c89af1Smrg## There are various ways to get dependency output from gcc.  Here's
12733c89af1Smrg## why we pick this rather obscure method:
12833c89af1Smrg## - Don't want to use -MD because we'd like the dependencies to end
12933c89af1Smrg##   up in a subdir.  Having to rename by hand is ugly.
13033c89af1Smrg##   (We might end up doing this anyway to support other compilers.)
13133c89af1Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
13233c89af1Smrg##   -MM, not -M (despite what the docs say).
13333c89af1Smrg## - Using -M directly means running the compiler twice (even worse
13433c89af1Smrg##   than renaming).
13533c89af1Smrg  if test -z "$gccflag"; then
13633c89af1Smrg    gccflag=-MD,
13733c89af1Smrg  fi
13833c89af1Smrg  "$@" -Wp,"$gccflag$tmpdepfile"
13933c89af1Smrg  stat=$?
14033c89af1Smrg  if test $stat -eq 0; then :
14133c89af1Smrg  else
14233c89af1Smrg    rm -f "$tmpdepfile"
14333c89af1Smrg    exit $stat
14433c89af1Smrg  fi
14533c89af1Smrg  rm -f "$depfile"
14633c89af1Smrg  echo "$object : \\" > "$depfile"
14733c89af1Smrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
14833c89af1Smrg## The second -e expression handles DOS-style file names with drive letters.
14933c89af1Smrg  sed -e 's/^[^:]*: / /' \
15033c89af1Smrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
15133c89af1Smrg## This next piece of magic avoids the `deleted header file' problem.
15233c89af1Smrg## The problem is that when a header file which appears in a .P file
15333c89af1Smrg## is deleted, the dependency causes make to die (because there is
15433c89af1Smrg## typically no way to rebuild the header).  We avoid this by adding
15533c89af1Smrg## dummy dependencies for each header file.  Too bad gcc doesn't do
15633c89af1Smrg## this for us directly.
15733c89af1Smrg  tr ' ' '
15833c89af1Smrg' < "$tmpdepfile" |
15933c89af1Smrg## Some versions of gcc put a space before the `:'.  On the theory
16033c89af1Smrg## that the space means something, we add a space to the output as
16133c89af1Smrg## well.
16233c89af1Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
16333c89af1Smrg## correctly.  Breaking it into two sed invocations is a workaround.
16433c89af1Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
16533c89af1Smrg  rm -f "$tmpdepfile"
16633c89af1Smrg  ;;
16733c89af1Smrg
16833c89af1Smrghp)
16933c89af1Smrg  # This case exists only to let depend.m4 do its work.  It works by
17033c89af1Smrg  # looking at the text of this script.  This case will never be run,
17133c89af1Smrg  # since it is checked for above.
17233c89af1Smrg  exit 1
17333c89af1Smrg  ;;
17433c89af1Smrg
17533c89af1Smrgsgi)
17633c89af1Smrg  if test "$libtool" = yes; then
17733c89af1Smrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
17833c89af1Smrg  else
17933c89af1Smrg    "$@" -MDupdate "$tmpdepfile"
18033c89af1Smrg  fi
18133c89af1Smrg  stat=$?
18233c89af1Smrg  if test $stat -eq 0; then :
18333c89af1Smrg  else
18433c89af1Smrg    rm -f "$tmpdepfile"
18533c89af1Smrg    exit $stat
18633c89af1Smrg  fi
18733c89af1Smrg  rm -f "$depfile"
18833c89af1Smrg
18933c89af1Smrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
19033c89af1Smrg    echo "$object : \\" > "$depfile"
19133c89af1Smrg
19233c89af1Smrg    # Clip off the initial element (the dependent).  Don't try to be
19333c89af1Smrg    # clever and replace this with sed code, as IRIX sed won't handle
19433c89af1Smrg    # lines with more than a fixed number of characters (4096 in
19533c89af1Smrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
19633c89af1Smrg    # the IRIX cc adds comments like `#:fec' to the end of the
19733c89af1Smrg    # dependency line.
19833c89af1Smrg    tr ' ' '
19933c89af1Smrg' < "$tmpdepfile" \
20033c89af1Smrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
20133c89af1Smrg    tr '
202278eca22Smrg' ' ' >> "$depfile"
203278eca22Smrg    echo >> "$depfile"
20433c89af1Smrg
20533c89af1Smrg    # The second pass generates a dummy entry for each header file.
20633c89af1Smrg    tr ' ' '
20733c89af1Smrg' < "$tmpdepfile" \
20833c89af1Smrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
209278eca22Smrg   >> "$depfile"
21033c89af1Smrg  else
21133c89af1Smrg    # The sourcefile does not contain any dependencies, so just
21233c89af1Smrg    # store a dummy comment line, to avoid errors with the Makefile
21333c89af1Smrg    # "include basename.Plo" scheme.
21433c89af1Smrg    echo "#dummy" > "$depfile"
21533c89af1Smrg  fi
21633c89af1Smrg  rm -f "$tmpdepfile"
21733c89af1Smrg  ;;
21833c89af1Smrg
21933c89af1Smrgaix)
22033c89af1Smrg  # The C for AIX Compiler uses -M and outputs the dependencies
22133c89af1Smrg  # in a .u file.  In older versions, this file always lives in the
22233c89af1Smrg  # current directory.  Also, the AIX compiler puts `$object:' at the
22333c89af1Smrg  # start of each line; $object doesn't have directory information.
22433c89af1Smrg  # Version 6 uses the directory in both cases.
225278eca22Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
226278eca22Smrg  test "x$dir" = "x$object" && dir=
227278eca22Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
22833c89af1Smrg  if test "$libtool" = yes; then
229278eca22Smrg    tmpdepfile1=$dir$base.u
230278eca22Smrg    tmpdepfile2=$base.u
231278eca22Smrg    tmpdepfile3=$dir.libs/$base.u
23233c89af1Smrg    "$@" -Wc,-M
23333c89af1Smrg  else
234278eca22Smrg    tmpdepfile1=$dir$base.u
235278eca22Smrg    tmpdepfile2=$dir$base.u
236278eca22Smrg    tmpdepfile3=$dir$base.u
23733c89af1Smrg    "$@" -M
23833c89af1Smrg  fi
23933c89af1Smrg  stat=$?
24033c89af1Smrg
24133c89af1Smrg  if test $stat -eq 0; then :
24233c89af1Smrg  else
243278eca22Smrg    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
24433c89af1Smrg    exit $stat
24533c89af1Smrg  fi
24633c89af1Smrg
247278eca22Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
248278eca22Smrg  do
249278eca22Smrg    test -f "$tmpdepfile" && break
250278eca22Smrg  done
25133c89af1Smrg  if test -f "$tmpdepfile"; then
25233c89af1Smrg    # Each line is of the form `foo.o: dependent.h'.
25333c89af1Smrg    # Do two passes, one to just change these to
25433c89af1Smrg    # `$object: dependent.h' and one to simply `dependent.h:'.
255278eca22Smrg    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
256278eca22Smrg    # That's a tab and a space in the [].
257278eca22Smrg    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
25833c89af1Smrg  else
25933c89af1Smrg    # The sourcefile does not contain any dependencies, so just
26033c89af1Smrg    # store a dummy comment line, to avoid errors with the Makefile
26133c89af1Smrg    # "include basename.Plo" scheme.
26233c89af1Smrg    echo "#dummy" > "$depfile"
26333c89af1Smrg  fi
26433c89af1Smrg  rm -f "$tmpdepfile"
26533c89af1Smrg  ;;
26633c89af1Smrg
26733c89af1Smrgicc)
26833c89af1Smrg  # Intel's C compiler understands `-MD -MF file'.  However on
26933c89af1Smrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
27033c89af1Smrg  # ICC 7.0 will fill foo.d with something like
27133c89af1Smrg  #    foo.o: sub/foo.c
27233c89af1Smrg  #    foo.o: sub/foo.h
27333c89af1Smrg  # which is wrong.  We want:
27433c89af1Smrg  #    sub/foo.o: sub/foo.c
27533c89af1Smrg  #    sub/foo.o: sub/foo.h
27633c89af1Smrg  #    sub/foo.c:
27733c89af1Smrg  #    sub/foo.h:
27833c89af1Smrg  # ICC 7.1 will output
27933c89af1Smrg  #    foo.o: sub/foo.c sub/foo.h
28033c89af1Smrg  # and will wrap long lines using \ :
28133c89af1Smrg  #    foo.o: sub/foo.c ... \
28233c89af1Smrg  #     sub/foo.h ... \
28333c89af1Smrg  #     ...
28433c89af1Smrg
28533c89af1Smrg  "$@" -MD -MF "$tmpdepfile"
28633c89af1Smrg  stat=$?
28733c89af1Smrg  if test $stat -eq 0; then :
28833c89af1Smrg  else
28933c89af1Smrg    rm -f "$tmpdepfile"
29033c89af1Smrg    exit $stat
29133c89af1Smrg  fi
29233c89af1Smrg  rm -f "$depfile"
29333c89af1Smrg  # Each line is of the form `foo.o: dependent.h',
29433c89af1Smrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
29533c89af1Smrg  # Do two passes, one to just change these to
29633c89af1Smrg  # `$object: dependent.h' and one to simply `dependent.h:'.
29733c89af1Smrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
29833c89af1Smrg  # Some versions of the HPUX 10.20 sed can't process this invocation
29933c89af1Smrg  # correctly.  Breaking it into two sed invocations is a workaround.
30033c89af1Smrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
30133c89af1Smrg    sed -e 's/$/ :/' >> "$depfile"
30233c89af1Smrg  rm -f "$tmpdepfile"
30333c89af1Smrg  ;;
30433c89af1Smrg
305278eca22Smrghp2)
306278eca22Smrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
307278eca22Smrg  # compilers, which have integrated preprocessors.  The correct option
308278eca22Smrg  # to use with these is +Maked; it writes dependencies to a file named
309278eca22Smrg  # 'foo.d', which lands next to the object file, wherever that
310278eca22Smrg  # happens to be.
311278eca22Smrg  # Much of this is similar to the tru64 case; see comments there.
312278eca22Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
313278eca22Smrg  test "x$dir" = "x$object" && dir=
314278eca22Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
315278eca22Smrg  if test "$libtool" = yes; then
316278eca22Smrg    tmpdepfile1=$dir$base.d
317278eca22Smrg    tmpdepfile2=$dir.libs/$base.d
318278eca22Smrg    "$@" -Wc,+Maked
319278eca22Smrg  else
320278eca22Smrg    tmpdepfile1=$dir$base.d
321278eca22Smrg    tmpdepfile2=$dir$base.d
322278eca22Smrg    "$@" +Maked
323278eca22Smrg  fi
324278eca22Smrg  stat=$?
325278eca22Smrg  if test $stat -eq 0; then :
326278eca22Smrg  else
327278eca22Smrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
328278eca22Smrg     exit $stat
329278eca22Smrg  fi
330278eca22Smrg
331278eca22Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
332278eca22Smrg  do
333278eca22Smrg    test -f "$tmpdepfile" && break
334278eca22Smrg  done
335278eca22Smrg  if test -f "$tmpdepfile"; then
336278eca22Smrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
337278eca22Smrg    # Add `dependent.h:' lines.
338278eca22Smrg    sed -ne '2,${
339278eca22Smrg	       s/^ *//
340278eca22Smrg	       s/ \\*$//
341278eca22Smrg	       s/$/:/
342278eca22Smrg	       p
343278eca22Smrg	     }' "$tmpdepfile" >> "$depfile"
344278eca22Smrg  else
345278eca22Smrg    echo "#dummy" > "$depfile"
346278eca22Smrg  fi
347278eca22Smrg  rm -f "$tmpdepfile" "$tmpdepfile2"
348278eca22Smrg  ;;
349278eca22Smrg
35033c89af1Smrgtru64)
35133c89af1Smrg   # The Tru64 compiler uses -MD to generate dependencies as a side
35233c89af1Smrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
35333c89af1Smrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
35433c89af1Smrg   # dependencies in `foo.d' instead, so we check for that too.
35533c89af1Smrg   # Subdirectories are respected.
35633c89af1Smrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
35733c89af1Smrg   test "x$dir" = "x$object" && dir=
35833c89af1Smrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
35933c89af1Smrg
36033c89af1Smrg   if test "$libtool" = yes; then
36133c89af1Smrg      # With Tru64 cc, shared objects can also be used to make a
362278eca22Smrg      # static library.  This mechanism is used in libtool 1.4 series to
36333c89af1Smrg      # handle both shared and static libraries in a single compilation.
36433c89af1Smrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
36533c89af1Smrg      #
36633c89af1Smrg      # With libtool 1.5 this exception was removed, and libtool now
36733c89af1Smrg      # generates 2 separate objects for the 2 libraries.  These two
368278eca22Smrg      # compilations output dependencies in $dir.libs/$base.o.d and
36933c89af1Smrg      # in $dir$base.o.d.  We have to check for both files, because
37033c89af1Smrg      # one of the two compilations can be disabled.  We should prefer
37133c89af1Smrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
37233c89af1Smrg      # automatically cleaned when .libs/ is deleted, while ignoring
37333c89af1Smrg      # the former would cause a distcleancheck panic.
37433c89af1Smrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
37533c89af1Smrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
37633c89af1Smrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
37733c89af1Smrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
37833c89af1Smrg      "$@" -Wc,-MD
37933c89af1Smrg   else
38033c89af1Smrg      tmpdepfile1=$dir$base.o.d
38133c89af1Smrg      tmpdepfile2=$dir$base.d
38233c89af1Smrg      tmpdepfile3=$dir$base.d
38333c89af1Smrg      tmpdepfile4=$dir$base.d
38433c89af1Smrg      "$@" -MD
38533c89af1Smrg   fi
38633c89af1Smrg
38733c89af1Smrg   stat=$?
38833c89af1Smrg   if test $stat -eq 0; then :
38933c89af1Smrg   else
39033c89af1Smrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
39133c89af1Smrg      exit $stat
39233c89af1Smrg   fi
39333c89af1Smrg
39433c89af1Smrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
39533c89af1Smrg   do
39633c89af1Smrg     test -f "$tmpdepfile" && break
39733c89af1Smrg   done
39833c89af1Smrg   if test -f "$tmpdepfile"; then
39933c89af1Smrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
40033c89af1Smrg      # That's a tab and a space in the [].
40133c89af1Smrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
40233c89af1Smrg   else
40333c89af1Smrg      echo "#dummy" > "$depfile"
40433c89af1Smrg   fi
40533c89af1Smrg   rm -f "$tmpdepfile"
40633c89af1Smrg   ;;
40733c89af1Smrg
40833c89af1Smrg#nosideeffect)
40933c89af1Smrg  # This comment above is used by automake to tell side-effect
41033c89af1Smrg  # dependency tracking mechanisms from slower ones.
41133c89af1Smrg
41233c89af1Smrgdashmstdout)
41333c89af1Smrg  # Important note: in order to support this mode, a compiler *must*
41433c89af1Smrg  # always write the preprocessed file to stdout, regardless of -o.
41533c89af1Smrg  "$@" || exit $?
41633c89af1Smrg
41733c89af1Smrg  # Remove the call to Libtool.
41833c89af1Smrg  if test "$libtool" = yes; then
419278eca22Smrg    while test "X$1" != 'X--mode=compile'; do
42033c89af1Smrg      shift
42133c89af1Smrg    done
42233c89af1Smrg    shift
42333c89af1Smrg  fi
42433c89af1Smrg
42533c89af1Smrg  # Remove `-o $object'.
42633c89af1Smrg  IFS=" "
42733c89af1Smrg  for arg
42833c89af1Smrg  do
42933c89af1Smrg    case $arg in
43033c89af1Smrg    -o)
43133c89af1Smrg      shift
43233c89af1Smrg      ;;
43333c89af1Smrg    $object)
43433c89af1Smrg      shift
43533c89af1Smrg      ;;
43633c89af1Smrg    *)
43733c89af1Smrg      set fnord "$@" "$arg"
43833c89af1Smrg      shift # fnord
43933c89af1Smrg      shift # $arg
44033c89af1Smrg      ;;
44133c89af1Smrg    esac
44233c89af1Smrg  done
44333c89af1Smrg
44433c89af1Smrg  test -z "$dashmflag" && dashmflag=-M
44533c89af1Smrg  # Require at least two characters before searching for `:'
44633c89af1Smrg  # in the target name.  This is to cope with DOS-style filenames:
44733c89af1Smrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
44833c89af1Smrg  "$@" $dashmflag |
44933c89af1Smrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
45033c89af1Smrg  rm -f "$depfile"
45133c89af1Smrg  cat < "$tmpdepfile" > "$depfile"
45233c89af1Smrg  tr ' ' '
45333c89af1Smrg' < "$tmpdepfile" | \
45433c89af1Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
45533c89af1Smrg## correctly.  Breaking it into two sed invocations is a workaround.
45633c89af1Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
45733c89af1Smrg  rm -f "$tmpdepfile"
45833c89af1Smrg  ;;
45933c89af1Smrg
46033c89af1SmrgdashXmstdout)
46133c89af1Smrg  # This case only exists to satisfy depend.m4.  It is never actually
46233c89af1Smrg  # run, as this mode is specially recognized in the preamble.
46333c89af1Smrg  exit 1
46433c89af1Smrg  ;;
46533c89af1Smrg
46633c89af1Smrgmakedepend)
46733c89af1Smrg  "$@" || exit $?
46833c89af1Smrg  # Remove any Libtool call
46933c89af1Smrg  if test "$libtool" = yes; then
470278eca22Smrg    while test "X$1" != 'X--mode=compile'; do
47133c89af1Smrg      shift
47233c89af1Smrg    done
47333c89af1Smrg    shift
47433c89af1Smrg  fi
47533c89af1Smrg  # X makedepend
47633c89af1Smrg  shift
477278eca22Smrg  cleared=no eat=no
478278eca22Smrg  for arg
479278eca22Smrg  do
48033c89af1Smrg    case $cleared in
48133c89af1Smrg    no)
48233c89af1Smrg      set ""; shift
48333c89af1Smrg      cleared=yes ;;
48433c89af1Smrg    esac
485278eca22Smrg    if test $eat = yes; then
486278eca22Smrg      eat=no
487278eca22Smrg      continue
488278eca22Smrg    fi
48933c89af1Smrg    case "$arg" in
49033c89af1Smrg    -D*|-I*)
49133c89af1Smrg      set fnord "$@" "$arg"; shift ;;
49233c89af1Smrg    # Strip any option that makedepend may not understand.  Remove
49333c89af1Smrg    # the object too, otherwise makedepend will parse it as a source file.
494278eca22Smrg    -arch)
495278eca22Smrg      eat=yes ;;
49633c89af1Smrg    -*|$object)
49733c89af1Smrg      ;;
49833c89af1Smrg    *)
49933c89af1Smrg      set fnord "$@" "$arg"; shift ;;
50033c89af1Smrg    esac
50133c89af1Smrg  done
502278eca22Smrg  obj_suffix=`echo "$object" | sed 's/^.*\././'`
50333c89af1Smrg  touch "$tmpdepfile"
50433c89af1Smrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
50533c89af1Smrg  rm -f "$depfile"
50633c89af1Smrg  cat < "$tmpdepfile" > "$depfile"
50733c89af1Smrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
50833c89af1Smrg' | \
50933c89af1Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
51033c89af1Smrg## correctly.  Breaking it into two sed invocations is a workaround.
51133c89af1Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
51233c89af1Smrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
51333c89af1Smrg  ;;
51433c89af1Smrg
51533c89af1Smrgcpp)
51633c89af1Smrg  # Important note: in order to support this mode, a compiler *must*
51733c89af1Smrg  # always write the preprocessed file to stdout.
51833c89af1Smrg  "$@" || exit $?
51933c89af1Smrg
52033c89af1Smrg  # Remove the call to Libtool.
52133c89af1Smrg  if test "$libtool" = yes; then
522278eca22Smrg    while test "X$1" != 'X--mode=compile'; do
52333c89af1Smrg      shift
52433c89af1Smrg    done
52533c89af1Smrg    shift
52633c89af1Smrg  fi
52733c89af1Smrg
52833c89af1Smrg  # Remove `-o $object'.
52933c89af1Smrg  IFS=" "
53033c89af1Smrg  for arg
53133c89af1Smrg  do
53233c89af1Smrg    case $arg in
53333c89af1Smrg    -o)
53433c89af1Smrg      shift
53533c89af1Smrg      ;;
53633c89af1Smrg    $object)
53733c89af1Smrg      shift
53833c89af1Smrg      ;;
53933c89af1Smrg    *)
54033c89af1Smrg      set fnord "$@" "$arg"
54133c89af1Smrg      shift # fnord
54233c89af1Smrg      shift # $arg
54333c89af1Smrg      ;;
54433c89af1Smrg    esac
54533c89af1Smrg  done
54633c89af1Smrg
54733c89af1Smrg  "$@" -E |
54833c89af1Smrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
54933c89af1Smrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
55033c89af1Smrg    sed '$ s: \\$::' > "$tmpdepfile"
55133c89af1Smrg  rm -f "$depfile"
55233c89af1Smrg  echo "$object : \\" > "$depfile"
55333c89af1Smrg  cat < "$tmpdepfile" >> "$depfile"
55433c89af1Smrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
55533c89af1Smrg  rm -f "$tmpdepfile"
55633c89af1Smrg  ;;
55733c89af1Smrg
55833c89af1Smrgmsvisualcpp)
55933c89af1Smrg  # Important note: in order to support this mode, a compiler *must*
560278eca22Smrg  # always write the preprocessed file to stdout.
56133c89af1Smrg  "$@" || exit $?
562278eca22Smrg
563278eca22Smrg  # Remove the call to Libtool.
564278eca22Smrg  if test "$libtool" = yes; then
565278eca22Smrg    while test "X$1" != 'X--mode=compile'; do
566278eca22Smrg      shift
567278eca22Smrg    done
568278eca22Smrg    shift
569278eca22Smrg  fi
570278eca22Smrg
57133c89af1Smrg  IFS=" "
57233c89af1Smrg  for arg
57333c89af1Smrg  do
57433c89af1Smrg    case "$arg" in
575278eca22Smrg    -o)
576278eca22Smrg      shift
577278eca22Smrg      ;;
578278eca22Smrg    $object)
579278eca22Smrg      shift
580278eca22Smrg      ;;
58133c89af1Smrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
58233c89af1Smrg	set fnord "$@"
58333c89af1Smrg	shift
58433c89af1Smrg	shift
58533c89af1Smrg	;;
58633c89af1Smrg    *)
58733c89af1Smrg	set fnord "$@" "$arg"
58833c89af1Smrg	shift
58933c89af1Smrg	shift
59033c89af1Smrg	;;
59133c89af1Smrg    esac
59233c89af1Smrg  done
593278eca22Smrg  "$@" -E 2>/dev/null |
594278eca22Smrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
59533c89af1Smrg  rm -f "$depfile"
59633c89af1Smrg  echo "$object : \\" > "$depfile"
597278eca22Smrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
59833c89af1Smrg  echo "	" >> "$depfile"
599278eca22Smrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
60033c89af1Smrg  rm -f "$tmpdepfile"
60133c89af1Smrg  ;;
60233c89af1Smrg
603278eca22Smrgmsvcmsys)
604278eca22Smrg  # This case exists only to let depend.m4 do its work.  It works by
605278eca22Smrg  # looking at the text of this script.  This case will never be run,
606278eca22Smrg  # since it is checked for above.
607278eca22Smrg  exit 1
608278eca22Smrg  ;;
609278eca22Smrg
61033c89af1Smrgnone)
61133c89af1Smrg  exec "$@"
61233c89af1Smrg  ;;
61333c89af1Smrg
61433c89af1Smrg*)
61533c89af1Smrg  echo "Unknown depmode $depmode" 1>&2
61633c89af1Smrg  exit 1
61733c89af1Smrg  ;;
61833c89af1Smrgesac
61933c89af1Smrg
62033c89af1Smrgexit 0
62133c89af1Smrg
62233c89af1Smrg# Local Variables:
62333c89af1Smrg# mode: shell-script
62433c89af1Smrg# sh-indentation: 2
62533c89af1Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
62633c89af1Smrg# time-stamp-start: "scriptversion="
62733c89af1Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
628278eca22Smrg# time-stamp-time-zone: "UTC"
629278eca22Smrg# time-stamp-end: "; # UTC"
63033c89af1Smrg# End:
631