depcomp revision 32b578d3
132b578d3Smrg#! /bin/sh
232b578d3Smrg# depcomp - compile a program generating dependencies as side-effects
332b578d3Smrg
432b578d3Smrgscriptversion=2007-03-29.01
532b578d3Smrg
632b578d3Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software
732b578d3Smrg# Foundation, Inc.
832b578d3Smrg
932b578d3Smrg# This program is free software; you can redistribute it and/or modify
1032b578d3Smrg# it under the terms of the GNU General Public License as published by
1132b578d3Smrg# the Free Software Foundation; either version 2, or (at your option)
1232b578d3Smrg# any later version.
1332b578d3Smrg
1432b578d3Smrg# This program is distributed in the hope that it will be useful,
1532b578d3Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1632b578d3Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1732b578d3Smrg# GNU General Public License for more details.
1832b578d3Smrg
1932b578d3Smrg# You should have received a copy of the GNU General Public License
2032b578d3Smrg# along with this program; if not, write to the Free Software
2132b578d3Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2232b578d3Smrg# 02110-1301, USA.
2332b578d3Smrg
2432b578d3Smrg# As a special exception to the GNU General Public License, if you
2532b578d3Smrg# distribute this file as part of a program that contains a
2632b578d3Smrg# configuration script generated by Autoconf, you may include it under
2732b578d3Smrg# the same distribution terms that you use for the rest of that program.
2832b578d3Smrg
2932b578d3Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
3032b578d3Smrg
3132b578d3Smrgcase $1 in
3232b578d3Smrg  '')
3332b578d3Smrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
3432b578d3Smrg     exit 1;
3532b578d3Smrg     ;;
3632b578d3Smrg  -h | --h*)
3732b578d3Smrg    cat <<\EOF
3832b578d3SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
3932b578d3Smrg
4032b578d3SmrgRun PROGRAMS ARGS to compile a file, generating dependencies
4132b578d3Smrgas side-effects.
4232b578d3Smrg
4332b578d3SmrgEnvironment variables:
4432b578d3Smrg  depmode     Dependency tracking mode.
4532b578d3Smrg  source      Source file read by `PROGRAMS ARGS'.
4632b578d3Smrg  object      Object file output by `PROGRAMS ARGS'.
4732b578d3Smrg  DEPDIR      directory where to store dependencies.
4832b578d3Smrg  depfile     Dependency file to output.
4932b578d3Smrg  tmpdepfile  Temporary file to use when outputing dependencies.
5032b578d3Smrg  libtool     Whether libtool is used (yes/no).
5132b578d3Smrg
5232b578d3SmrgReport bugs to <bug-automake@gnu.org>.
5332b578d3SmrgEOF
5432b578d3Smrg    exit $?
5532b578d3Smrg    ;;
5632b578d3Smrg  -v | --v*)
5732b578d3Smrg    echo "depcomp $scriptversion"
5832b578d3Smrg    exit $?
5932b578d3Smrg    ;;
6032b578d3Smrgesac
6132b578d3Smrg
6232b578d3Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
6332b578d3Smrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
6432b578d3Smrg  exit 1
6532b578d3Smrgfi
6632b578d3Smrg
6732b578d3Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
6832b578d3Smrgdepfile=${depfile-`echo "$object" |
6932b578d3Smrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
7032b578d3Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
7132b578d3Smrg
7232b578d3Smrgrm -f "$tmpdepfile"
7332b578d3Smrg
7432b578d3Smrg# Some modes work just like other modes, but use different flags.  We
7532b578d3Smrg# parameterize here, but still list the modes in the big case below,
7632b578d3Smrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
7732b578d3Smrg# here, because this file can only contain one case statement.
7832b578d3Smrgif test "$depmode" = hp; then
7932b578d3Smrg  # HP compiler uses -M and no extra arg.
8032b578d3Smrg  gccflag=-M
8132b578d3Smrg  depmode=gcc
8232b578d3Smrgfi
8332b578d3Smrg
8432b578d3Smrgif test "$depmode" = dashXmstdout; then
8532b578d3Smrg   # This is just like dashmstdout with a different argument.
8632b578d3Smrg   dashmflag=-xM
8732b578d3Smrg   depmode=dashmstdout
8832b578d3Smrgfi
8932b578d3Smrg
9032b578d3Smrgcase "$depmode" in
9132b578d3Smrggcc3)
9232b578d3Smrg## gcc 3 implements dependency tracking that does exactly what
9332b578d3Smrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
9432b578d3Smrg## it if -MD -MP comes after the -MF stuff.  Hmm.
9532b578d3Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
9632b578d3Smrg## the command line argument order; so add the flags where they
9732b578d3Smrg## appear in depend2.am.  Note that the slowdown incurred here
9832b578d3Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
9932b578d3Smrg  for arg
10032b578d3Smrg  do
10132b578d3Smrg    case $arg in
10232b578d3Smrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
10332b578d3Smrg    *)  set fnord "$@" "$arg" ;;
10432b578d3Smrg    esac
10532b578d3Smrg    shift # fnord
10632b578d3Smrg    shift # $arg
10732b578d3Smrg  done
10832b578d3Smrg  "$@"
10932b578d3Smrg  stat=$?
11032b578d3Smrg  if test $stat -eq 0; then :
11132b578d3Smrg  else
11232b578d3Smrg    rm -f "$tmpdepfile"
11332b578d3Smrg    exit $stat
11432b578d3Smrg  fi
11532b578d3Smrg  mv "$tmpdepfile" "$depfile"
11632b578d3Smrg  ;;
11732b578d3Smrg
11832b578d3Smrggcc)
11932b578d3Smrg## There are various ways to get dependency output from gcc.  Here's
12032b578d3Smrg## why we pick this rather obscure method:
12132b578d3Smrg## - Don't want to use -MD because we'd like the dependencies to end
12232b578d3Smrg##   up in a subdir.  Having to rename by hand is ugly.
12332b578d3Smrg##   (We might end up doing this anyway to support other compilers.)
12432b578d3Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
12532b578d3Smrg##   -MM, not -M (despite what the docs say).
12632b578d3Smrg## - Using -M directly means running the compiler twice (even worse
12732b578d3Smrg##   than renaming).
12832b578d3Smrg  if test -z "$gccflag"; then
12932b578d3Smrg    gccflag=-MD,
13032b578d3Smrg  fi
13132b578d3Smrg  "$@" -Wp,"$gccflag$tmpdepfile"
13232b578d3Smrg  stat=$?
13332b578d3Smrg  if test $stat -eq 0; then :
13432b578d3Smrg  else
13532b578d3Smrg    rm -f "$tmpdepfile"
13632b578d3Smrg    exit $stat
13732b578d3Smrg  fi
13832b578d3Smrg  rm -f "$depfile"
13932b578d3Smrg  echo "$object : \\" > "$depfile"
14032b578d3Smrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
14132b578d3Smrg## The second -e expression handles DOS-style file names with drive letters.
14232b578d3Smrg  sed -e 's/^[^:]*: / /' \
14332b578d3Smrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
14432b578d3Smrg## This next piece of magic avoids the `deleted header file' problem.
14532b578d3Smrg## The problem is that when a header file which appears in a .P file
14632b578d3Smrg## is deleted, the dependency causes make to die (because there is
14732b578d3Smrg## typically no way to rebuild the header).  We avoid this by adding
14832b578d3Smrg## dummy dependencies for each header file.  Too bad gcc doesn't do
14932b578d3Smrg## this for us directly.
15032b578d3Smrg  tr ' ' '
15132b578d3Smrg' < "$tmpdepfile" |
15232b578d3Smrg## Some versions of gcc put a space before the `:'.  On the theory
15332b578d3Smrg## that the space means something, we add a space to the output as
15432b578d3Smrg## well.
15532b578d3Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
15632b578d3Smrg## correctly.  Breaking it into two sed invocations is a workaround.
15732b578d3Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
15832b578d3Smrg  rm -f "$tmpdepfile"
15932b578d3Smrg  ;;
16032b578d3Smrg
16132b578d3Smrghp)
16232b578d3Smrg  # This case exists only to let depend.m4 do its work.  It works by
16332b578d3Smrg  # looking at the text of this script.  This case will never be run,
16432b578d3Smrg  # since it is checked for above.
16532b578d3Smrg  exit 1
16632b578d3Smrg  ;;
16732b578d3Smrg
16832b578d3Smrgsgi)
16932b578d3Smrg  if test "$libtool" = yes; then
17032b578d3Smrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
17132b578d3Smrg  else
17232b578d3Smrg    "$@" -MDupdate "$tmpdepfile"
17332b578d3Smrg  fi
17432b578d3Smrg  stat=$?
17532b578d3Smrg  if test $stat -eq 0; then :
17632b578d3Smrg  else
17732b578d3Smrg    rm -f "$tmpdepfile"
17832b578d3Smrg    exit $stat
17932b578d3Smrg  fi
18032b578d3Smrg  rm -f "$depfile"
18132b578d3Smrg
18232b578d3Smrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
18332b578d3Smrg    echo "$object : \\" > "$depfile"
18432b578d3Smrg
18532b578d3Smrg    # Clip off the initial element (the dependent).  Don't try to be
18632b578d3Smrg    # clever and replace this with sed code, as IRIX sed won't handle
18732b578d3Smrg    # lines with more than a fixed number of characters (4096 in
18832b578d3Smrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
18932b578d3Smrg    # the IRIX cc adds comments like `#:fec' to the end of the
19032b578d3Smrg    # dependency line.
19132b578d3Smrg    tr ' ' '
19232b578d3Smrg' < "$tmpdepfile" \
19332b578d3Smrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
19432b578d3Smrg    tr '
19532b578d3Smrg' ' ' >> $depfile
19632b578d3Smrg    echo >> $depfile
19732b578d3Smrg
19832b578d3Smrg    # The second pass generates a dummy entry for each header file.
19932b578d3Smrg    tr ' ' '
20032b578d3Smrg' < "$tmpdepfile" \
20132b578d3Smrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
20232b578d3Smrg   >> $depfile
20332b578d3Smrg  else
20432b578d3Smrg    # The sourcefile does not contain any dependencies, so just
20532b578d3Smrg    # store a dummy comment line, to avoid errors with the Makefile
20632b578d3Smrg    # "include basename.Plo" scheme.
20732b578d3Smrg    echo "#dummy" > "$depfile"
20832b578d3Smrg  fi
20932b578d3Smrg  rm -f "$tmpdepfile"
21032b578d3Smrg  ;;
21132b578d3Smrg
21232b578d3Smrgaix)
21332b578d3Smrg  # The C for AIX Compiler uses -M and outputs the dependencies
21432b578d3Smrg  # in a .u file.  In older versions, this file always lives in the
21532b578d3Smrg  # current directory.  Also, the AIX compiler puts `$object:' at the
21632b578d3Smrg  # start of each line; $object doesn't have directory information.
21732b578d3Smrg  # Version 6 uses the directory in both cases.
21832b578d3Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
21932b578d3Smrg  test "x$dir" = "x$object" && dir=
22032b578d3Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
22132b578d3Smrg  if test "$libtool" = yes; then
22232b578d3Smrg    tmpdepfile1=$dir$base.u
22332b578d3Smrg    tmpdepfile2=$base.u
22432b578d3Smrg    tmpdepfile3=$dir.libs/$base.u
22532b578d3Smrg    "$@" -Wc,-M
22632b578d3Smrg  else
22732b578d3Smrg    tmpdepfile1=$dir$base.u
22832b578d3Smrg    tmpdepfile2=$dir$base.u
22932b578d3Smrg    tmpdepfile3=$dir$base.u
23032b578d3Smrg    "$@" -M
23132b578d3Smrg  fi
23232b578d3Smrg  stat=$?
23332b578d3Smrg
23432b578d3Smrg  if test $stat -eq 0; then :
23532b578d3Smrg  else
23632b578d3Smrg    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
23732b578d3Smrg    exit $stat
23832b578d3Smrg  fi
23932b578d3Smrg
24032b578d3Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
24132b578d3Smrg  do
24232b578d3Smrg    test -f "$tmpdepfile" && break
24332b578d3Smrg  done
24432b578d3Smrg  if test -f "$tmpdepfile"; then
24532b578d3Smrg    # Each line is of the form `foo.o: dependent.h'.
24632b578d3Smrg    # Do two passes, one to just change these to
24732b578d3Smrg    # `$object: dependent.h' and one to simply `dependent.h:'.
24832b578d3Smrg    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
24932b578d3Smrg    # That's a tab and a space in the [].
25032b578d3Smrg    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
25132b578d3Smrg  else
25232b578d3Smrg    # The sourcefile does not contain any dependencies, so just
25332b578d3Smrg    # store a dummy comment line, to avoid errors with the Makefile
25432b578d3Smrg    # "include basename.Plo" scheme.
25532b578d3Smrg    echo "#dummy" > "$depfile"
25632b578d3Smrg  fi
25732b578d3Smrg  rm -f "$tmpdepfile"
25832b578d3Smrg  ;;
25932b578d3Smrg
26032b578d3Smrgicc)
26132b578d3Smrg  # Intel's C compiler understands `-MD -MF file'.  However on
26232b578d3Smrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
26332b578d3Smrg  # ICC 7.0 will fill foo.d with something like
26432b578d3Smrg  #    foo.o: sub/foo.c
26532b578d3Smrg  #    foo.o: sub/foo.h
26632b578d3Smrg  # which is wrong.  We want:
26732b578d3Smrg  #    sub/foo.o: sub/foo.c
26832b578d3Smrg  #    sub/foo.o: sub/foo.h
26932b578d3Smrg  #    sub/foo.c:
27032b578d3Smrg  #    sub/foo.h:
27132b578d3Smrg  # ICC 7.1 will output
27232b578d3Smrg  #    foo.o: sub/foo.c sub/foo.h
27332b578d3Smrg  # and will wrap long lines using \ :
27432b578d3Smrg  #    foo.o: sub/foo.c ... \
27532b578d3Smrg  #     sub/foo.h ... \
27632b578d3Smrg  #     ...
27732b578d3Smrg
27832b578d3Smrg  "$@" -MD -MF "$tmpdepfile"
27932b578d3Smrg  stat=$?
28032b578d3Smrg  if test $stat -eq 0; then :
28132b578d3Smrg  else
28232b578d3Smrg    rm -f "$tmpdepfile"
28332b578d3Smrg    exit $stat
28432b578d3Smrg  fi
28532b578d3Smrg  rm -f "$depfile"
28632b578d3Smrg  # Each line is of the form `foo.o: dependent.h',
28732b578d3Smrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
28832b578d3Smrg  # Do two passes, one to just change these to
28932b578d3Smrg  # `$object: dependent.h' and one to simply `dependent.h:'.
29032b578d3Smrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
29132b578d3Smrg  # Some versions of the HPUX 10.20 sed can't process this invocation
29232b578d3Smrg  # correctly.  Breaking it into two sed invocations is a workaround.
29332b578d3Smrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
29432b578d3Smrg    sed -e 's/$/ :/' >> "$depfile"
29532b578d3Smrg  rm -f "$tmpdepfile"
29632b578d3Smrg  ;;
29732b578d3Smrg
29832b578d3Smrghp2)
29932b578d3Smrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
30032b578d3Smrg  # compilers, which have integrated preprocessors.  The correct option
30132b578d3Smrg  # to use with these is +Maked; it writes dependencies to a file named
30232b578d3Smrg  # 'foo.d', which lands next to the object file, wherever that
30332b578d3Smrg  # happens to be.
30432b578d3Smrg  # Much of this is similar to the tru64 case; see comments there.
30532b578d3Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
30632b578d3Smrg  test "x$dir" = "x$object" && dir=
30732b578d3Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
30832b578d3Smrg  if test "$libtool" = yes; then
30932b578d3Smrg    tmpdepfile1=$dir$base.d
31032b578d3Smrg    tmpdepfile2=$dir.libs/$base.d
31132b578d3Smrg    "$@" -Wc,+Maked
31232b578d3Smrg  else
31332b578d3Smrg    tmpdepfile1=$dir$base.d
31432b578d3Smrg    tmpdepfile2=$dir$base.d
31532b578d3Smrg    "$@" +Maked
31632b578d3Smrg  fi
31732b578d3Smrg  stat=$?
31832b578d3Smrg  if test $stat -eq 0; then :
31932b578d3Smrg  else
32032b578d3Smrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
32132b578d3Smrg     exit $stat
32232b578d3Smrg  fi
32332b578d3Smrg
32432b578d3Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
32532b578d3Smrg  do
32632b578d3Smrg    test -f "$tmpdepfile" && break
32732b578d3Smrg  done
32832b578d3Smrg  if test -f "$tmpdepfile"; then
32932b578d3Smrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
33032b578d3Smrg    # Add `dependent.h:' lines.
33132b578d3Smrg    sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
33232b578d3Smrg  else
33332b578d3Smrg    echo "#dummy" > "$depfile"
33432b578d3Smrg  fi
33532b578d3Smrg  rm -f "$tmpdepfile" "$tmpdepfile2"
33632b578d3Smrg  ;;
33732b578d3Smrg
33832b578d3Smrgtru64)
33932b578d3Smrg   # The Tru64 compiler uses -MD to generate dependencies as a side
34032b578d3Smrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
34132b578d3Smrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
34232b578d3Smrg   # dependencies in `foo.d' instead, so we check for that too.
34332b578d3Smrg   # Subdirectories are respected.
34432b578d3Smrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
34532b578d3Smrg   test "x$dir" = "x$object" && dir=
34632b578d3Smrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
34732b578d3Smrg
34832b578d3Smrg   if test "$libtool" = yes; then
34932b578d3Smrg      # With Tru64 cc, shared objects can also be used to make a
35032b578d3Smrg      # static library.  This mechanism is used in libtool 1.4 series to
35132b578d3Smrg      # handle both shared and static libraries in a single compilation.
35232b578d3Smrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
35332b578d3Smrg      #
35432b578d3Smrg      # With libtool 1.5 this exception was removed, and libtool now
35532b578d3Smrg      # generates 2 separate objects for the 2 libraries.  These two
35632b578d3Smrg      # compilations output dependencies in $dir.libs/$base.o.d and
35732b578d3Smrg      # in $dir$base.o.d.  We have to check for both files, because
35832b578d3Smrg      # one of the two compilations can be disabled.  We should prefer
35932b578d3Smrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
36032b578d3Smrg      # automatically cleaned when .libs/ is deleted, while ignoring
36132b578d3Smrg      # the former would cause a distcleancheck panic.
36232b578d3Smrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
36332b578d3Smrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
36432b578d3Smrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
36532b578d3Smrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
36632b578d3Smrg      "$@" -Wc,-MD
36732b578d3Smrg   else
36832b578d3Smrg      tmpdepfile1=$dir$base.o.d
36932b578d3Smrg      tmpdepfile2=$dir$base.d
37032b578d3Smrg      tmpdepfile3=$dir$base.d
37132b578d3Smrg      tmpdepfile4=$dir$base.d
37232b578d3Smrg      "$@" -MD
37332b578d3Smrg   fi
37432b578d3Smrg
37532b578d3Smrg   stat=$?
37632b578d3Smrg   if test $stat -eq 0; then :
37732b578d3Smrg   else
37832b578d3Smrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
37932b578d3Smrg      exit $stat
38032b578d3Smrg   fi
38132b578d3Smrg
38232b578d3Smrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
38332b578d3Smrg   do
38432b578d3Smrg     test -f "$tmpdepfile" && break
38532b578d3Smrg   done
38632b578d3Smrg   if test -f "$tmpdepfile"; then
38732b578d3Smrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
38832b578d3Smrg      # That's a tab and a space in the [].
38932b578d3Smrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
39032b578d3Smrg   else
39132b578d3Smrg      echo "#dummy" > "$depfile"
39232b578d3Smrg   fi
39332b578d3Smrg   rm -f "$tmpdepfile"
39432b578d3Smrg   ;;
39532b578d3Smrg
39632b578d3Smrg#nosideeffect)
39732b578d3Smrg  # This comment above is used by automake to tell side-effect
39832b578d3Smrg  # dependency tracking mechanisms from slower ones.
39932b578d3Smrg
40032b578d3Smrgdashmstdout)
40132b578d3Smrg  # Important note: in order to support this mode, a compiler *must*
40232b578d3Smrg  # always write the preprocessed file to stdout, regardless of -o.
40332b578d3Smrg  "$@" || exit $?
40432b578d3Smrg
40532b578d3Smrg  # Remove the call to Libtool.
40632b578d3Smrg  if test "$libtool" = yes; then
40732b578d3Smrg    while test $1 != '--mode=compile'; do
40832b578d3Smrg      shift
40932b578d3Smrg    done
41032b578d3Smrg    shift
41132b578d3Smrg  fi
41232b578d3Smrg
41332b578d3Smrg  # Remove `-o $object'.
41432b578d3Smrg  IFS=" "
41532b578d3Smrg  for arg
41632b578d3Smrg  do
41732b578d3Smrg    case $arg in
41832b578d3Smrg    -o)
41932b578d3Smrg      shift
42032b578d3Smrg      ;;
42132b578d3Smrg    $object)
42232b578d3Smrg      shift
42332b578d3Smrg      ;;
42432b578d3Smrg    *)
42532b578d3Smrg      set fnord "$@" "$arg"
42632b578d3Smrg      shift # fnord
42732b578d3Smrg      shift # $arg
42832b578d3Smrg      ;;
42932b578d3Smrg    esac
43032b578d3Smrg  done
43132b578d3Smrg
43232b578d3Smrg  test -z "$dashmflag" && dashmflag=-M
43332b578d3Smrg  # Require at least two characters before searching for `:'
43432b578d3Smrg  # in the target name.  This is to cope with DOS-style filenames:
43532b578d3Smrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
43632b578d3Smrg  "$@" $dashmflag |
43732b578d3Smrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
43832b578d3Smrg  rm -f "$depfile"
43932b578d3Smrg  cat < "$tmpdepfile" > "$depfile"
44032b578d3Smrg  tr ' ' '
44132b578d3Smrg' < "$tmpdepfile" | \
44232b578d3Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
44332b578d3Smrg## correctly.  Breaking it into two sed invocations is a workaround.
44432b578d3Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
44532b578d3Smrg  rm -f "$tmpdepfile"
44632b578d3Smrg  ;;
44732b578d3Smrg
44832b578d3SmrgdashXmstdout)
44932b578d3Smrg  # This case only exists to satisfy depend.m4.  It is never actually
45032b578d3Smrg  # run, as this mode is specially recognized in the preamble.
45132b578d3Smrg  exit 1
45232b578d3Smrg  ;;
45332b578d3Smrg
45432b578d3Smrgmakedepend)
45532b578d3Smrg  "$@" || exit $?
45632b578d3Smrg  # Remove any Libtool call
45732b578d3Smrg  if test "$libtool" = yes; then
45832b578d3Smrg    while test $1 != '--mode=compile'; do
45932b578d3Smrg      shift
46032b578d3Smrg    done
46132b578d3Smrg    shift
46232b578d3Smrg  fi
46332b578d3Smrg  # X makedepend
46432b578d3Smrg  shift
46532b578d3Smrg  cleared=no
46632b578d3Smrg  for arg in "$@"; do
46732b578d3Smrg    case $cleared in
46832b578d3Smrg    no)
46932b578d3Smrg      set ""; shift
47032b578d3Smrg      cleared=yes ;;
47132b578d3Smrg    esac
47232b578d3Smrg    case "$arg" in
47332b578d3Smrg    -D*|-I*)
47432b578d3Smrg      set fnord "$@" "$arg"; shift ;;
47532b578d3Smrg    # Strip any option that makedepend may not understand.  Remove
47632b578d3Smrg    # the object too, otherwise makedepend will parse it as a source file.
47732b578d3Smrg    -*|$object)
47832b578d3Smrg      ;;
47932b578d3Smrg    *)
48032b578d3Smrg      set fnord "$@" "$arg"; shift ;;
48132b578d3Smrg    esac
48232b578d3Smrg  done
48332b578d3Smrg  obj_suffix="`echo $object | sed 's/^.*\././'`"
48432b578d3Smrg  touch "$tmpdepfile"
48532b578d3Smrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
48632b578d3Smrg  rm -f "$depfile"
48732b578d3Smrg  cat < "$tmpdepfile" > "$depfile"
48832b578d3Smrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
48932b578d3Smrg' | \
49032b578d3Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
49132b578d3Smrg## correctly.  Breaking it into two sed invocations is a workaround.
49232b578d3Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
49332b578d3Smrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
49432b578d3Smrg  ;;
49532b578d3Smrg
49632b578d3Smrgcpp)
49732b578d3Smrg  # Important note: in order to support this mode, a compiler *must*
49832b578d3Smrg  # always write the preprocessed file to stdout.
49932b578d3Smrg  "$@" || exit $?
50032b578d3Smrg
50132b578d3Smrg  # Remove the call to Libtool.
50232b578d3Smrg  if test "$libtool" = yes; then
50332b578d3Smrg    while test $1 != '--mode=compile'; do
50432b578d3Smrg      shift
50532b578d3Smrg    done
50632b578d3Smrg    shift
50732b578d3Smrg  fi
50832b578d3Smrg
50932b578d3Smrg  # Remove `-o $object'.
51032b578d3Smrg  IFS=" "
51132b578d3Smrg  for arg
51232b578d3Smrg  do
51332b578d3Smrg    case $arg in
51432b578d3Smrg    -o)
51532b578d3Smrg      shift
51632b578d3Smrg      ;;
51732b578d3Smrg    $object)
51832b578d3Smrg      shift
51932b578d3Smrg      ;;
52032b578d3Smrg    *)
52132b578d3Smrg      set fnord "$@" "$arg"
52232b578d3Smrg      shift # fnord
52332b578d3Smrg      shift # $arg
52432b578d3Smrg      ;;
52532b578d3Smrg    esac
52632b578d3Smrg  done
52732b578d3Smrg
52832b578d3Smrg  "$@" -E |
52932b578d3Smrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
53032b578d3Smrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
53132b578d3Smrg    sed '$ s: \\$::' > "$tmpdepfile"
53232b578d3Smrg  rm -f "$depfile"
53332b578d3Smrg  echo "$object : \\" > "$depfile"
53432b578d3Smrg  cat < "$tmpdepfile" >> "$depfile"
53532b578d3Smrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
53632b578d3Smrg  rm -f "$tmpdepfile"
53732b578d3Smrg  ;;
53832b578d3Smrg
53932b578d3Smrgmsvisualcpp)
54032b578d3Smrg  # Important note: in order to support this mode, a compiler *must*
54132b578d3Smrg  # always write the preprocessed file to stdout, regardless of -o,
54232b578d3Smrg  # because we must use -o when running libtool.
54332b578d3Smrg  "$@" || exit $?
54432b578d3Smrg  IFS=" "
54532b578d3Smrg  for arg
54632b578d3Smrg  do
54732b578d3Smrg    case "$arg" in
54832b578d3Smrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
54932b578d3Smrg	set fnord "$@"
55032b578d3Smrg	shift
55132b578d3Smrg	shift
55232b578d3Smrg	;;
55332b578d3Smrg    *)
55432b578d3Smrg	set fnord "$@" "$arg"
55532b578d3Smrg	shift
55632b578d3Smrg	shift
55732b578d3Smrg	;;
55832b578d3Smrg    esac
55932b578d3Smrg  done
56032b578d3Smrg  "$@" -E |
56132b578d3Smrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
56232b578d3Smrg  rm -f "$depfile"
56332b578d3Smrg  echo "$object : \\" > "$depfile"
56432b578d3Smrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
56532b578d3Smrg  echo "	" >> "$depfile"
56632b578d3Smrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
56732b578d3Smrg  rm -f "$tmpdepfile"
56832b578d3Smrg  ;;
56932b578d3Smrg
57032b578d3Smrgnone)
57132b578d3Smrg  exec "$@"
57232b578d3Smrg  ;;
57332b578d3Smrg
57432b578d3Smrg*)
57532b578d3Smrg  echo "Unknown depmode $depmode" 1>&2
57632b578d3Smrg  exit 1
57732b578d3Smrg  ;;
57832b578d3Smrgesac
57932b578d3Smrg
58032b578d3Smrgexit 0
58132b578d3Smrg
58232b578d3Smrg# Local Variables:
58332b578d3Smrg# mode: shell-script
58432b578d3Smrg# sh-indentation: 2
58532b578d3Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
58632b578d3Smrg# time-stamp-start: "scriptversion="
58732b578d3Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
58832b578d3Smrg# time-stamp-end: "$"
58932b578d3Smrg# End:
590