depcomp revision 8e0ed500
117a48c7cSmrg#! /bin/sh
217a48c7cSmrg# depcomp - compile a program generating dependencies as side-effects
317a48c7cSmrg
48e0ed500Smrgscriptversion=2006-10-15.18
517a48c7cSmrg
68e0ed500Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software
78e0ed500Smrg# Foundation, Inc.
817a48c7cSmrg
917a48c7cSmrg# This program is free software; you can redistribute it and/or modify
1017a48c7cSmrg# it under the terms of the GNU General Public License as published by
1117a48c7cSmrg# the Free Software Foundation; either version 2, or (at your option)
1217a48c7cSmrg# any later version.
1317a48c7cSmrg
1417a48c7cSmrg# This program is distributed in the hope that it will be useful,
1517a48c7cSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1617a48c7cSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1717a48c7cSmrg# GNU General Public License for more details.
1817a48c7cSmrg
1917a48c7cSmrg# You should have received a copy of the GNU General Public License
2017a48c7cSmrg# along with this program; if not, write to the Free Software
2117a48c7cSmrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2217a48c7cSmrg# 02110-1301, USA.
2317a48c7cSmrg
2417a48c7cSmrg# As a special exception to the GNU General Public License, if you
2517a48c7cSmrg# distribute this file as part of a program that contains a
2617a48c7cSmrg# configuration script generated by Autoconf, you may include it under
2717a48c7cSmrg# the same distribution terms that you use for the rest of that program.
2817a48c7cSmrg
2917a48c7cSmrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
3017a48c7cSmrg
3117a48c7cSmrgcase $1 in
3217a48c7cSmrg  '')
3317a48c7cSmrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
3417a48c7cSmrg     exit 1;
3517a48c7cSmrg     ;;
3617a48c7cSmrg  -h | --h*)
3717a48c7cSmrg    cat <<\EOF
3817a48c7cSmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
3917a48c7cSmrg
4017a48c7cSmrgRun PROGRAMS ARGS to compile a file, generating dependencies
4117a48c7cSmrgas side-effects.
4217a48c7cSmrg
4317a48c7cSmrgEnvironment variables:
4417a48c7cSmrg  depmode     Dependency tracking mode.
4517a48c7cSmrg  source      Source file read by `PROGRAMS ARGS'.
4617a48c7cSmrg  object      Object file output by `PROGRAMS ARGS'.
4717a48c7cSmrg  DEPDIR      directory where to store dependencies.
4817a48c7cSmrg  depfile     Dependency file to output.
4917a48c7cSmrg  tmpdepfile  Temporary file to use when outputing dependencies.
5017a48c7cSmrg  libtool     Whether libtool is used (yes/no).
5117a48c7cSmrg
5217a48c7cSmrgReport bugs to <bug-automake@gnu.org>.
5317a48c7cSmrgEOF
5417a48c7cSmrg    exit $?
5517a48c7cSmrg    ;;
5617a48c7cSmrg  -v | --v*)
5717a48c7cSmrg    echo "depcomp $scriptversion"
5817a48c7cSmrg    exit $?
5917a48c7cSmrg    ;;
6017a48c7cSmrgesac
6117a48c7cSmrg
6217a48c7cSmrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
6317a48c7cSmrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
6417a48c7cSmrg  exit 1
6517a48c7cSmrgfi
6617a48c7cSmrg
6717a48c7cSmrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
6817a48c7cSmrgdepfile=${depfile-`echo "$object" |
6917a48c7cSmrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
7017a48c7cSmrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
7117a48c7cSmrg
7217a48c7cSmrgrm -f "$tmpdepfile"
7317a48c7cSmrg
7417a48c7cSmrg# Some modes work just like other modes, but use different flags.  We
7517a48c7cSmrg# parameterize here, but still list the modes in the big case below,
7617a48c7cSmrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
7717a48c7cSmrg# here, because this file can only contain one case statement.
7817a48c7cSmrgif test "$depmode" = hp; then
7917a48c7cSmrg  # HP compiler uses -M and no extra arg.
8017a48c7cSmrg  gccflag=-M
8117a48c7cSmrg  depmode=gcc
8217a48c7cSmrgfi
8317a48c7cSmrg
8417a48c7cSmrgif test "$depmode" = dashXmstdout; then
8517a48c7cSmrg   # This is just like dashmstdout with a different argument.
8617a48c7cSmrg   dashmflag=-xM
8717a48c7cSmrg   depmode=dashmstdout
8817a48c7cSmrgfi
8917a48c7cSmrg
9017a48c7cSmrgcase "$depmode" in
9117a48c7cSmrggcc3)
9217a48c7cSmrg## gcc 3 implements dependency tracking that does exactly what
9317a48c7cSmrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
9417a48c7cSmrg## it if -MD -MP comes after the -MF stuff.  Hmm.
958e0ed500Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
968e0ed500Smrg## the command line argument order; so add the flags where they
978e0ed500Smrg## appear in depend2.am.  Note that the slowdown incurred here
988e0ed500Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
998e0ed500Smrg  for arg
1008e0ed500Smrg  do
1018e0ed500Smrg    case $arg in
1028e0ed500Smrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
1038e0ed500Smrg    *)  set fnord "$@" "$arg" ;;
1048e0ed500Smrg    esac
1058e0ed500Smrg    shift # fnord
1068e0ed500Smrg    shift # $arg
1078e0ed500Smrg  done
1088e0ed500Smrg  "$@"
10917a48c7cSmrg  stat=$?
11017a48c7cSmrg  if test $stat -eq 0; then :
11117a48c7cSmrg  else
11217a48c7cSmrg    rm -f "$tmpdepfile"
11317a48c7cSmrg    exit $stat
11417a48c7cSmrg  fi
11517a48c7cSmrg  mv "$tmpdepfile" "$depfile"
11617a48c7cSmrg  ;;
11717a48c7cSmrg
11817a48c7cSmrggcc)
11917a48c7cSmrg## There are various ways to get dependency output from gcc.  Here's
12017a48c7cSmrg## why we pick this rather obscure method:
12117a48c7cSmrg## - Don't want to use -MD because we'd like the dependencies to end
12217a48c7cSmrg##   up in a subdir.  Having to rename by hand is ugly.
12317a48c7cSmrg##   (We might end up doing this anyway to support other compilers.)
12417a48c7cSmrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
12517a48c7cSmrg##   -MM, not -M (despite what the docs say).
12617a48c7cSmrg## - Using -M directly means running the compiler twice (even worse
12717a48c7cSmrg##   than renaming).
12817a48c7cSmrg  if test -z "$gccflag"; then
12917a48c7cSmrg    gccflag=-MD,
13017a48c7cSmrg  fi
13117a48c7cSmrg  "$@" -Wp,"$gccflag$tmpdepfile"
13217a48c7cSmrg  stat=$?
13317a48c7cSmrg  if test $stat -eq 0; then :
13417a48c7cSmrg  else
13517a48c7cSmrg    rm -f "$tmpdepfile"
13617a48c7cSmrg    exit $stat
13717a48c7cSmrg  fi
13817a48c7cSmrg  rm -f "$depfile"
13917a48c7cSmrg  echo "$object : \\" > "$depfile"
14017a48c7cSmrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
14117a48c7cSmrg## The second -e expression handles DOS-style file names with drive letters.
14217a48c7cSmrg  sed -e 's/^[^:]*: / /' \
14317a48c7cSmrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
14417a48c7cSmrg## This next piece of magic avoids the `deleted header file' problem.
14517a48c7cSmrg## The problem is that when a header file which appears in a .P file
14617a48c7cSmrg## is deleted, the dependency causes make to die (because there is
14717a48c7cSmrg## typically no way to rebuild the header).  We avoid this by adding
14817a48c7cSmrg## dummy dependencies for each header file.  Too bad gcc doesn't do
14917a48c7cSmrg## this for us directly.
15017a48c7cSmrg  tr ' ' '
15117a48c7cSmrg' < "$tmpdepfile" |
15217a48c7cSmrg## Some versions of gcc put a space before the `:'.  On the theory
15317a48c7cSmrg## that the space means something, we add a space to the output as
15417a48c7cSmrg## well.
15517a48c7cSmrg## Some versions of the HPUX 10.20 sed can't process this invocation
15617a48c7cSmrg## correctly.  Breaking it into two sed invocations is a workaround.
15717a48c7cSmrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
15817a48c7cSmrg  rm -f "$tmpdepfile"
15917a48c7cSmrg  ;;
16017a48c7cSmrg
16117a48c7cSmrghp)
16217a48c7cSmrg  # This case exists only to let depend.m4 do its work.  It works by
16317a48c7cSmrg  # looking at the text of this script.  This case will never be run,
16417a48c7cSmrg  # since it is checked for above.
16517a48c7cSmrg  exit 1
16617a48c7cSmrg  ;;
16717a48c7cSmrg
16817a48c7cSmrgsgi)
16917a48c7cSmrg  if test "$libtool" = yes; then
17017a48c7cSmrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
17117a48c7cSmrg  else
17217a48c7cSmrg    "$@" -MDupdate "$tmpdepfile"
17317a48c7cSmrg  fi
17417a48c7cSmrg  stat=$?
17517a48c7cSmrg  if test $stat -eq 0; then :
17617a48c7cSmrg  else
17717a48c7cSmrg    rm -f "$tmpdepfile"
17817a48c7cSmrg    exit $stat
17917a48c7cSmrg  fi
18017a48c7cSmrg  rm -f "$depfile"
18117a48c7cSmrg
18217a48c7cSmrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
18317a48c7cSmrg    echo "$object : \\" > "$depfile"
18417a48c7cSmrg
18517a48c7cSmrg    # Clip off the initial element (the dependent).  Don't try to be
18617a48c7cSmrg    # clever and replace this with sed code, as IRIX sed won't handle
18717a48c7cSmrg    # lines with more than a fixed number of characters (4096 in
18817a48c7cSmrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
18917a48c7cSmrg    # the IRIX cc adds comments like `#:fec' to the end of the
19017a48c7cSmrg    # dependency line.
19117a48c7cSmrg    tr ' ' '
19217a48c7cSmrg' < "$tmpdepfile" \
19317a48c7cSmrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
19417a48c7cSmrg    tr '
19517a48c7cSmrg' ' ' >> $depfile
19617a48c7cSmrg    echo >> $depfile
19717a48c7cSmrg
19817a48c7cSmrg    # The second pass generates a dummy entry for each header file.
19917a48c7cSmrg    tr ' ' '
20017a48c7cSmrg' < "$tmpdepfile" \
20117a48c7cSmrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
20217a48c7cSmrg   >> $depfile
20317a48c7cSmrg  else
20417a48c7cSmrg    # The sourcefile does not contain any dependencies, so just
20517a48c7cSmrg    # store a dummy comment line, to avoid errors with the Makefile
20617a48c7cSmrg    # "include basename.Plo" scheme.
20717a48c7cSmrg    echo "#dummy" > "$depfile"
20817a48c7cSmrg  fi
20917a48c7cSmrg  rm -f "$tmpdepfile"
21017a48c7cSmrg  ;;
21117a48c7cSmrg
21217a48c7cSmrgaix)
21317a48c7cSmrg  # The C for AIX Compiler uses -M and outputs the dependencies
21417a48c7cSmrg  # in a .u file.  In older versions, this file always lives in the
21517a48c7cSmrg  # current directory.  Also, the AIX compiler puts `$object:' at the
21617a48c7cSmrg  # start of each line; $object doesn't have directory information.
21717a48c7cSmrg  # Version 6 uses the directory in both cases.
21817a48c7cSmrg  stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
21917a48c7cSmrg  tmpdepfile="$stripped.u"
22017a48c7cSmrg  if test "$libtool" = yes; then
22117a48c7cSmrg    "$@" -Wc,-M
22217a48c7cSmrg  else
22317a48c7cSmrg    "$@" -M
22417a48c7cSmrg  fi
22517a48c7cSmrg  stat=$?
22617a48c7cSmrg
22717a48c7cSmrg  if test -f "$tmpdepfile"; then :
22817a48c7cSmrg  else
22917a48c7cSmrg    stripped=`echo "$stripped" | sed 's,^.*/,,'`
23017a48c7cSmrg    tmpdepfile="$stripped.u"
23117a48c7cSmrg  fi
23217a48c7cSmrg
23317a48c7cSmrg  if test $stat -eq 0; then :
23417a48c7cSmrg  else
23517a48c7cSmrg    rm -f "$tmpdepfile"
23617a48c7cSmrg    exit $stat
23717a48c7cSmrg  fi
23817a48c7cSmrg
23917a48c7cSmrg  if test -f "$tmpdepfile"; then
24017a48c7cSmrg    outname="$stripped.o"
24117a48c7cSmrg    # Each line is of the form `foo.o: dependent.h'.
24217a48c7cSmrg    # Do two passes, one to just change these to
24317a48c7cSmrg    # `$object: dependent.h' and one to simply `dependent.h:'.
24417a48c7cSmrg    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
24517a48c7cSmrg    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
24617a48c7cSmrg  else
24717a48c7cSmrg    # The sourcefile does not contain any dependencies, so just
24817a48c7cSmrg    # store a dummy comment line, to avoid errors with the Makefile
24917a48c7cSmrg    # "include basename.Plo" scheme.
25017a48c7cSmrg    echo "#dummy" > "$depfile"
25117a48c7cSmrg  fi
25217a48c7cSmrg  rm -f "$tmpdepfile"
25317a48c7cSmrg  ;;
25417a48c7cSmrg
25517a48c7cSmrgicc)
25617a48c7cSmrg  # Intel's C compiler understands `-MD -MF file'.  However on
25717a48c7cSmrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
25817a48c7cSmrg  # ICC 7.0 will fill foo.d with something like
25917a48c7cSmrg  #    foo.o: sub/foo.c
26017a48c7cSmrg  #    foo.o: sub/foo.h
26117a48c7cSmrg  # which is wrong.  We want:
26217a48c7cSmrg  #    sub/foo.o: sub/foo.c
26317a48c7cSmrg  #    sub/foo.o: sub/foo.h
26417a48c7cSmrg  #    sub/foo.c:
26517a48c7cSmrg  #    sub/foo.h:
26617a48c7cSmrg  # ICC 7.1 will output
26717a48c7cSmrg  #    foo.o: sub/foo.c sub/foo.h
26817a48c7cSmrg  # and will wrap long lines using \ :
26917a48c7cSmrg  #    foo.o: sub/foo.c ... \
27017a48c7cSmrg  #     sub/foo.h ... \
27117a48c7cSmrg  #     ...
27217a48c7cSmrg
27317a48c7cSmrg  "$@" -MD -MF "$tmpdepfile"
27417a48c7cSmrg  stat=$?
27517a48c7cSmrg  if test $stat -eq 0; then :
27617a48c7cSmrg  else
27717a48c7cSmrg    rm -f "$tmpdepfile"
27817a48c7cSmrg    exit $stat
27917a48c7cSmrg  fi
28017a48c7cSmrg  rm -f "$depfile"
28117a48c7cSmrg  # Each line is of the form `foo.o: dependent.h',
28217a48c7cSmrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
28317a48c7cSmrg  # Do two passes, one to just change these to
28417a48c7cSmrg  # `$object: dependent.h' and one to simply `dependent.h:'.
28517a48c7cSmrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
28617a48c7cSmrg  # Some versions of the HPUX 10.20 sed can't process this invocation
28717a48c7cSmrg  # correctly.  Breaking it into two sed invocations is a workaround.
28817a48c7cSmrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
28917a48c7cSmrg    sed -e 's/$/ :/' >> "$depfile"
29017a48c7cSmrg  rm -f "$tmpdepfile"
29117a48c7cSmrg  ;;
29217a48c7cSmrg
2938e0ed500Smrghp2)
2948e0ed500Smrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
2958e0ed500Smrg  # compilers, which have integrated preprocessors.  The correct option
2968e0ed500Smrg  # to use with these is +Maked; it writes dependencies to a file named
2978e0ed500Smrg  # 'foo.d', which lands next to the object file, wherever that
2988e0ed500Smrg  # happens to be.
2998e0ed500Smrg  # Much of this is similar to the tru64 case; see comments there.
3008e0ed500Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3018e0ed500Smrg  test "x$dir" = "x$object" && dir=
3028e0ed500Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3038e0ed500Smrg  if test "$libtool" = yes; then
3048e0ed500Smrg    tmpdepfile1=$dir$base.d
3058e0ed500Smrg    tmpdepfile2=$dir.libs/$base.d
3068e0ed500Smrg    "$@" -Wc,+Maked
3078e0ed500Smrg  else
3088e0ed500Smrg    tmpdepfile1=$dir$base.d
3098e0ed500Smrg    tmpdepfile2=$dir$base.d
3108e0ed500Smrg    "$@" +Maked
3118e0ed500Smrg  fi
3128e0ed500Smrg  stat=$?
3138e0ed500Smrg  if test $stat -eq 0; then :
3148e0ed500Smrg  else
3158e0ed500Smrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
3168e0ed500Smrg     exit $stat
3178e0ed500Smrg  fi
3188e0ed500Smrg
3198e0ed500Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
3208e0ed500Smrg  do
3218e0ed500Smrg    test -f "$tmpdepfile" && break
3228e0ed500Smrg  done
3238e0ed500Smrg  if test -f "$tmpdepfile"; then
3248e0ed500Smrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
3258e0ed500Smrg    # Add `dependent.h:' lines.
3268e0ed500Smrg    sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
3278e0ed500Smrg  else
3288e0ed500Smrg    echo "#dummy" > "$depfile"
3298e0ed500Smrg  fi
3308e0ed500Smrg  rm -f "$tmpdepfile" "$tmpdepfile2"
3318e0ed500Smrg  ;;
3328e0ed500Smrg
33317a48c7cSmrgtru64)
33417a48c7cSmrg   # The Tru64 compiler uses -MD to generate dependencies as a side
33517a48c7cSmrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
33617a48c7cSmrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
33717a48c7cSmrg   # dependencies in `foo.d' instead, so we check for that too.
33817a48c7cSmrg   # Subdirectories are respected.
33917a48c7cSmrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
34017a48c7cSmrg   test "x$dir" = "x$object" && dir=
34117a48c7cSmrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
34217a48c7cSmrg
34317a48c7cSmrg   if test "$libtool" = yes; then
34417a48c7cSmrg      # With Tru64 cc, shared objects can also be used to make a
3458e0ed500Smrg      # static library.  This mechanism is used in libtool 1.4 series to
34617a48c7cSmrg      # handle both shared and static libraries in a single compilation.
34717a48c7cSmrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
34817a48c7cSmrg      #
34917a48c7cSmrg      # With libtool 1.5 this exception was removed, and libtool now
35017a48c7cSmrg      # generates 2 separate objects for the 2 libraries.  These two
3518e0ed500Smrg      # compilations output dependencies in $dir.libs/$base.o.d and
35217a48c7cSmrg      # in $dir$base.o.d.  We have to check for both files, because
35317a48c7cSmrg      # one of the two compilations can be disabled.  We should prefer
35417a48c7cSmrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
35517a48c7cSmrg      # automatically cleaned when .libs/ is deleted, while ignoring
35617a48c7cSmrg      # the former would cause a distcleancheck panic.
35717a48c7cSmrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
35817a48c7cSmrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
35917a48c7cSmrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
36017a48c7cSmrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
36117a48c7cSmrg      "$@" -Wc,-MD
36217a48c7cSmrg   else
36317a48c7cSmrg      tmpdepfile1=$dir$base.o.d
36417a48c7cSmrg      tmpdepfile2=$dir$base.d
36517a48c7cSmrg      tmpdepfile3=$dir$base.d
36617a48c7cSmrg      tmpdepfile4=$dir$base.d
36717a48c7cSmrg      "$@" -MD
36817a48c7cSmrg   fi
36917a48c7cSmrg
37017a48c7cSmrg   stat=$?
37117a48c7cSmrg   if test $stat -eq 0; then :
37217a48c7cSmrg   else
37317a48c7cSmrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
37417a48c7cSmrg      exit $stat
37517a48c7cSmrg   fi
37617a48c7cSmrg
37717a48c7cSmrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
37817a48c7cSmrg   do
37917a48c7cSmrg     test -f "$tmpdepfile" && break
38017a48c7cSmrg   done
38117a48c7cSmrg   if test -f "$tmpdepfile"; then
38217a48c7cSmrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
38317a48c7cSmrg      # That's a tab and a space in the [].
38417a48c7cSmrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
38517a48c7cSmrg   else
38617a48c7cSmrg      echo "#dummy" > "$depfile"
38717a48c7cSmrg   fi
38817a48c7cSmrg   rm -f "$tmpdepfile"
38917a48c7cSmrg   ;;
39017a48c7cSmrg
39117a48c7cSmrg#nosideeffect)
39217a48c7cSmrg  # This comment above is used by automake to tell side-effect
39317a48c7cSmrg  # dependency tracking mechanisms from slower ones.
39417a48c7cSmrg
39517a48c7cSmrgdashmstdout)
39617a48c7cSmrg  # Important note: in order to support this mode, a compiler *must*
39717a48c7cSmrg  # always write the preprocessed file to stdout, regardless of -o.
39817a48c7cSmrg  "$@" || exit $?
39917a48c7cSmrg
40017a48c7cSmrg  # Remove the call to Libtool.
40117a48c7cSmrg  if test "$libtool" = yes; then
40217a48c7cSmrg    while test $1 != '--mode=compile'; do
40317a48c7cSmrg      shift
40417a48c7cSmrg    done
40517a48c7cSmrg    shift
40617a48c7cSmrg  fi
40717a48c7cSmrg
40817a48c7cSmrg  # Remove `-o $object'.
40917a48c7cSmrg  IFS=" "
41017a48c7cSmrg  for arg
41117a48c7cSmrg  do
41217a48c7cSmrg    case $arg in
41317a48c7cSmrg    -o)
41417a48c7cSmrg      shift
41517a48c7cSmrg      ;;
41617a48c7cSmrg    $object)
41717a48c7cSmrg      shift
41817a48c7cSmrg      ;;
41917a48c7cSmrg    *)
42017a48c7cSmrg      set fnord "$@" "$arg"
42117a48c7cSmrg      shift # fnord
42217a48c7cSmrg      shift # $arg
42317a48c7cSmrg      ;;
42417a48c7cSmrg    esac
42517a48c7cSmrg  done
42617a48c7cSmrg
42717a48c7cSmrg  test -z "$dashmflag" && dashmflag=-M
42817a48c7cSmrg  # Require at least two characters before searching for `:'
42917a48c7cSmrg  # in the target name.  This is to cope with DOS-style filenames:
43017a48c7cSmrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
43117a48c7cSmrg  "$@" $dashmflag |
43217a48c7cSmrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
43317a48c7cSmrg  rm -f "$depfile"
43417a48c7cSmrg  cat < "$tmpdepfile" > "$depfile"
43517a48c7cSmrg  tr ' ' '
43617a48c7cSmrg' < "$tmpdepfile" | \
43717a48c7cSmrg## Some versions of the HPUX 10.20 sed can't process this invocation
43817a48c7cSmrg## correctly.  Breaking it into two sed invocations is a workaround.
43917a48c7cSmrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
44017a48c7cSmrg  rm -f "$tmpdepfile"
44117a48c7cSmrg  ;;
44217a48c7cSmrg
44317a48c7cSmrgdashXmstdout)
44417a48c7cSmrg  # This case only exists to satisfy depend.m4.  It is never actually
44517a48c7cSmrg  # run, as this mode is specially recognized in the preamble.
44617a48c7cSmrg  exit 1
44717a48c7cSmrg  ;;
44817a48c7cSmrg
44917a48c7cSmrgmakedepend)
45017a48c7cSmrg  "$@" || exit $?
45117a48c7cSmrg  # Remove any Libtool call
45217a48c7cSmrg  if test "$libtool" = yes; then
45317a48c7cSmrg    while test $1 != '--mode=compile'; do
45417a48c7cSmrg      shift
45517a48c7cSmrg    done
45617a48c7cSmrg    shift
45717a48c7cSmrg  fi
45817a48c7cSmrg  # X makedepend
45917a48c7cSmrg  shift
46017a48c7cSmrg  cleared=no
46117a48c7cSmrg  for arg in "$@"; do
46217a48c7cSmrg    case $cleared in
46317a48c7cSmrg    no)
46417a48c7cSmrg      set ""; shift
46517a48c7cSmrg      cleared=yes ;;
46617a48c7cSmrg    esac
46717a48c7cSmrg    case "$arg" in
46817a48c7cSmrg    -D*|-I*)
46917a48c7cSmrg      set fnord "$@" "$arg"; shift ;;
47017a48c7cSmrg    # Strip any option that makedepend may not understand.  Remove
47117a48c7cSmrg    # the object too, otherwise makedepend will parse it as a source file.
47217a48c7cSmrg    -*|$object)
47317a48c7cSmrg      ;;
47417a48c7cSmrg    *)
47517a48c7cSmrg      set fnord "$@" "$arg"; shift ;;
47617a48c7cSmrg    esac
47717a48c7cSmrg  done
47817a48c7cSmrg  obj_suffix="`echo $object | sed 's/^.*\././'`"
47917a48c7cSmrg  touch "$tmpdepfile"
48017a48c7cSmrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
48117a48c7cSmrg  rm -f "$depfile"
48217a48c7cSmrg  cat < "$tmpdepfile" > "$depfile"
48317a48c7cSmrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
48417a48c7cSmrg' | \
48517a48c7cSmrg## Some versions of the HPUX 10.20 sed can't process this invocation
48617a48c7cSmrg## correctly.  Breaking it into two sed invocations is a workaround.
48717a48c7cSmrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
48817a48c7cSmrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
48917a48c7cSmrg  ;;
49017a48c7cSmrg
49117a48c7cSmrgcpp)
49217a48c7cSmrg  # Important note: in order to support this mode, a compiler *must*
49317a48c7cSmrg  # always write the preprocessed file to stdout.
49417a48c7cSmrg  "$@" || exit $?
49517a48c7cSmrg
49617a48c7cSmrg  # Remove the call to Libtool.
49717a48c7cSmrg  if test "$libtool" = yes; then
49817a48c7cSmrg    while test $1 != '--mode=compile'; do
49917a48c7cSmrg      shift
50017a48c7cSmrg    done
50117a48c7cSmrg    shift
50217a48c7cSmrg  fi
50317a48c7cSmrg
50417a48c7cSmrg  # Remove `-o $object'.
50517a48c7cSmrg  IFS=" "
50617a48c7cSmrg  for arg
50717a48c7cSmrg  do
50817a48c7cSmrg    case $arg in
50917a48c7cSmrg    -o)
51017a48c7cSmrg      shift
51117a48c7cSmrg      ;;
51217a48c7cSmrg    $object)
51317a48c7cSmrg      shift
51417a48c7cSmrg      ;;
51517a48c7cSmrg    *)
51617a48c7cSmrg      set fnord "$@" "$arg"
51717a48c7cSmrg      shift # fnord
51817a48c7cSmrg      shift # $arg
51917a48c7cSmrg      ;;
52017a48c7cSmrg    esac
52117a48c7cSmrg  done
52217a48c7cSmrg
52317a48c7cSmrg  "$@" -E |
52417a48c7cSmrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
52517a48c7cSmrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
52617a48c7cSmrg    sed '$ s: \\$::' > "$tmpdepfile"
52717a48c7cSmrg  rm -f "$depfile"
52817a48c7cSmrg  echo "$object : \\" > "$depfile"
52917a48c7cSmrg  cat < "$tmpdepfile" >> "$depfile"
53017a48c7cSmrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
53117a48c7cSmrg  rm -f "$tmpdepfile"
53217a48c7cSmrg  ;;
53317a48c7cSmrg
53417a48c7cSmrgmsvisualcpp)
53517a48c7cSmrg  # Important note: in order to support this mode, a compiler *must*
53617a48c7cSmrg  # always write the preprocessed file to stdout, regardless of -o,
53717a48c7cSmrg  # because we must use -o when running libtool.
53817a48c7cSmrg  "$@" || exit $?
53917a48c7cSmrg  IFS=" "
54017a48c7cSmrg  for arg
54117a48c7cSmrg  do
54217a48c7cSmrg    case "$arg" in
54317a48c7cSmrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
54417a48c7cSmrg	set fnord "$@"
54517a48c7cSmrg	shift
54617a48c7cSmrg	shift
54717a48c7cSmrg	;;
54817a48c7cSmrg    *)
54917a48c7cSmrg	set fnord "$@" "$arg"
55017a48c7cSmrg	shift
55117a48c7cSmrg	shift
55217a48c7cSmrg	;;
55317a48c7cSmrg    esac
55417a48c7cSmrg  done
55517a48c7cSmrg  "$@" -E |
55617a48c7cSmrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
55717a48c7cSmrg  rm -f "$depfile"
55817a48c7cSmrg  echo "$object : \\" > "$depfile"
55917a48c7cSmrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
56017a48c7cSmrg  echo "	" >> "$depfile"
56117a48c7cSmrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
56217a48c7cSmrg  rm -f "$tmpdepfile"
56317a48c7cSmrg  ;;
56417a48c7cSmrg
56517a48c7cSmrgnone)
56617a48c7cSmrg  exec "$@"
56717a48c7cSmrg  ;;
56817a48c7cSmrg
56917a48c7cSmrg*)
57017a48c7cSmrg  echo "Unknown depmode $depmode" 1>&2
57117a48c7cSmrg  exit 1
57217a48c7cSmrg  ;;
57317a48c7cSmrgesac
57417a48c7cSmrg
57517a48c7cSmrgexit 0
57617a48c7cSmrg
57717a48c7cSmrg# Local Variables:
57817a48c7cSmrg# mode: shell-script
57917a48c7cSmrg# sh-indentation: 2
58017a48c7cSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
58117a48c7cSmrg# time-stamp-start: "scriptversion="
58217a48c7cSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
58317a48c7cSmrg# time-stamp-end: "$"
58417a48c7cSmrg# End:
585