depcomp revision 12391620
121c2f794Smrg#! /bin/sh
221c2f794Smrg# depcomp - compile a program generating dependencies as side-effects
321c2f794Smrg
412391620Smrgscriptversion=2009-04-28.21; # UTC
521c2f794Smrg
612391620Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
712391620Smrg# Software Foundation, Inc.
821c2f794Smrg
921c2f794Smrg# This program is free software; you can redistribute it and/or modify
1021c2f794Smrg# it under the terms of the GNU General Public License as published by
1121c2f794Smrg# the Free Software Foundation; either version 2, or (at your option)
1221c2f794Smrg# any later version.
1321c2f794Smrg
1421c2f794Smrg# This program is distributed in the hope that it will be useful,
1521c2f794Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1621c2f794Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1721c2f794Smrg# GNU General Public License for more details.
1821c2f794Smrg
1921c2f794Smrg# You should have received a copy of the GNU General Public License
2012391620Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2121c2f794Smrg
2221c2f794Smrg# As a special exception to the GNU General Public License, if you
2321c2f794Smrg# distribute this file as part of a program that contains a
2421c2f794Smrg# configuration script generated by Autoconf, you may include it under
2521c2f794Smrg# the same distribution terms that you use for the rest of that program.
2621c2f794Smrg
2721c2f794Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
2821c2f794Smrg
2921c2f794Smrgcase $1 in
3021c2f794Smrg  '')
3121c2f794Smrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
3221c2f794Smrg     exit 1;
3321c2f794Smrg     ;;
3421c2f794Smrg  -h | --h*)
3521c2f794Smrg    cat <<\EOF
3621c2f794SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
3721c2f794Smrg
3821c2f794SmrgRun PROGRAMS ARGS to compile a file, generating dependencies
3921c2f794Smrgas side-effects.
4021c2f794Smrg
4121c2f794SmrgEnvironment variables:
4221c2f794Smrg  depmode     Dependency tracking mode.
4321c2f794Smrg  source      Source file read by `PROGRAMS ARGS'.
4421c2f794Smrg  object      Object file output by `PROGRAMS ARGS'.
4521c2f794Smrg  DEPDIR      directory where to store dependencies.
4621c2f794Smrg  depfile     Dependency file to output.
4721c2f794Smrg  tmpdepfile  Temporary file to use when outputing dependencies.
4821c2f794Smrg  libtool     Whether libtool is used (yes/no).
4921c2f794Smrg
5021c2f794SmrgReport bugs to <bug-automake@gnu.org>.
5121c2f794SmrgEOF
5221c2f794Smrg    exit $?
5321c2f794Smrg    ;;
5421c2f794Smrg  -v | --v*)
5521c2f794Smrg    echo "depcomp $scriptversion"
5621c2f794Smrg    exit $?
5721c2f794Smrg    ;;
5821c2f794Smrgesac
5921c2f794Smrg
6021c2f794Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
6121c2f794Smrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
6221c2f794Smrg  exit 1
6321c2f794Smrgfi
6421c2f794Smrg
6521c2f794Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
6621c2f794Smrgdepfile=${depfile-`echo "$object" |
6721c2f794Smrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
6821c2f794Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
6921c2f794Smrg
7021c2f794Smrgrm -f "$tmpdepfile"
7121c2f794Smrg
7221c2f794Smrg# Some modes work just like other modes, but use different flags.  We
7321c2f794Smrg# parameterize here, but still list the modes in the big case below,
7421c2f794Smrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
7521c2f794Smrg# here, because this file can only contain one case statement.
7621c2f794Smrgif test "$depmode" = hp; then
7721c2f794Smrg  # HP compiler uses -M and no extra arg.
7821c2f794Smrg  gccflag=-M
7921c2f794Smrg  depmode=gcc
8021c2f794Smrgfi
8121c2f794Smrg
8221c2f794Smrgif test "$depmode" = dashXmstdout; then
8321c2f794Smrg   # This is just like dashmstdout with a different argument.
8421c2f794Smrg   dashmflag=-xM
8521c2f794Smrg   depmode=dashmstdout
8621c2f794Smrgfi
8721c2f794Smrg
8812391620Smrgcygpath_u="cygpath -u -f -"
8912391620Smrgif test "$depmode" = msvcmsys; then
9012391620Smrg   # This is just like msvisualcpp but w/o cygpath translation.
9112391620Smrg   # Just convert the backslash-escaped backslashes to single forward
9212391620Smrg   # slashes to satisfy depend.m4
9312391620Smrg   cygpath_u="sed s,\\\\\\\\,/,g"
9412391620Smrg   depmode=msvisualcpp
9512391620Smrgfi
9612391620Smrg
9721c2f794Smrgcase "$depmode" in
9821c2f794Smrggcc3)
9921c2f794Smrg## gcc 3 implements dependency tracking that does exactly what
10021c2f794Smrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
10121c2f794Smrg## it if -MD -MP comes after the -MF stuff.  Hmm.
10221c2f794Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
10321c2f794Smrg## the command line argument order; so add the flags where they
10421c2f794Smrg## appear in depend2.am.  Note that the slowdown incurred here
10521c2f794Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
10621c2f794Smrg  for arg
10721c2f794Smrg  do
10821c2f794Smrg    case $arg in
10921c2f794Smrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
11021c2f794Smrg    *)  set fnord "$@" "$arg" ;;
11121c2f794Smrg    esac
11221c2f794Smrg    shift # fnord
11321c2f794Smrg    shift # $arg
11421c2f794Smrg  done
11521c2f794Smrg  "$@"
11621c2f794Smrg  stat=$?
11721c2f794Smrg  if test $stat -eq 0; then :
11821c2f794Smrg  else
11921c2f794Smrg    rm -f "$tmpdepfile"
12021c2f794Smrg    exit $stat
12121c2f794Smrg  fi
12221c2f794Smrg  mv "$tmpdepfile" "$depfile"
12321c2f794Smrg  ;;
12421c2f794Smrg
12521c2f794Smrggcc)
12621c2f794Smrg## There are various ways to get dependency output from gcc.  Here's
12721c2f794Smrg## why we pick this rather obscure method:
12821c2f794Smrg## - Don't want to use -MD because we'd like the dependencies to end
12921c2f794Smrg##   up in a subdir.  Having to rename by hand is ugly.
13021c2f794Smrg##   (We might end up doing this anyway to support other compilers.)
13121c2f794Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
13221c2f794Smrg##   -MM, not -M (despite what the docs say).
13321c2f794Smrg## - Using -M directly means running the compiler twice (even worse
13421c2f794Smrg##   than renaming).
13521c2f794Smrg  if test -z "$gccflag"; then
13621c2f794Smrg    gccflag=-MD,
13721c2f794Smrg  fi
13821c2f794Smrg  "$@" -Wp,"$gccflag$tmpdepfile"
13921c2f794Smrg  stat=$?
14021c2f794Smrg  if test $stat -eq 0; then :
14121c2f794Smrg  else
14221c2f794Smrg    rm -f "$tmpdepfile"
14321c2f794Smrg    exit $stat
14421c2f794Smrg  fi
14521c2f794Smrg  rm -f "$depfile"
14621c2f794Smrg  echo "$object : \\" > "$depfile"
14721c2f794Smrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
14821c2f794Smrg## The second -e expression handles DOS-style file names with drive letters.
14921c2f794Smrg  sed -e 's/^[^:]*: / /' \
15021c2f794Smrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
15121c2f794Smrg## This next piece of magic avoids the `deleted header file' problem.
15221c2f794Smrg## The problem is that when a header file which appears in a .P file
15321c2f794Smrg## is deleted, the dependency causes make to die (because there is
15421c2f794Smrg## typically no way to rebuild the header).  We avoid this by adding
15521c2f794Smrg## dummy dependencies for each header file.  Too bad gcc doesn't do
15621c2f794Smrg## this for us directly.
15721c2f794Smrg  tr ' ' '
15821c2f794Smrg' < "$tmpdepfile" |
15921c2f794Smrg## Some versions of gcc put a space before the `:'.  On the theory
16021c2f794Smrg## that the space means something, we add a space to the output as
16121c2f794Smrg## well.
16221c2f794Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
16321c2f794Smrg## correctly.  Breaking it into two sed invocations is a workaround.
16421c2f794Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
16521c2f794Smrg  rm -f "$tmpdepfile"
16621c2f794Smrg  ;;
16721c2f794Smrg
16821c2f794Smrghp)
16921c2f794Smrg  # This case exists only to let depend.m4 do its work.  It works by
17021c2f794Smrg  # looking at the text of this script.  This case will never be run,
17121c2f794Smrg  # since it is checked for above.
17221c2f794Smrg  exit 1
17321c2f794Smrg  ;;
17421c2f794Smrg
17521c2f794Smrgsgi)
17621c2f794Smrg  if test "$libtool" = yes; then
17721c2f794Smrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
17821c2f794Smrg  else
17921c2f794Smrg    "$@" -MDupdate "$tmpdepfile"
18021c2f794Smrg  fi
18121c2f794Smrg  stat=$?
18221c2f794Smrg  if test $stat -eq 0; then :
18321c2f794Smrg  else
18421c2f794Smrg    rm -f "$tmpdepfile"
18521c2f794Smrg    exit $stat
18621c2f794Smrg  fi
18721c2f794Smrg  rm -f "$depfile"
18821c2f794Smrg
18921c2f794Smrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
19021c2f794Smrg    echo "$object : \\" > "$depfile"
19121c2f794Smrg
19221c2f794Smrg    # Clip off the initial element (the dependent).  Don't try to be
19321c2f794Smrg    # clever and replace this with sed code, as IRIX sed won't handle
19421c2f794Smrg    # lines with more than a fixed number of characters (4096 in
19521c2f794Smrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
19621c2f794Smrg    # the IRIX cc adds comments like `#:fec' to the end of the
19721c2f794Smrg    # dependency line.
19821c2f794Smrg    tr ' ' '
19921c2f794Smrg' < "$tmpdepfile" \
20021c2f794Smrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
20121c2f794Smrg    tr '
20212391620Smrg' ' ' >> "$depfile"
20312391620Smrg    echo >> "$depfile"
20421c2f794Smrg
20521c2f794Smrg    # The second pass generates a dummy entry for each header file.
20621c2f794Smrg    tr ' ' '
20721c2f794Smrg' < "$tmpdepfile" \
20821c2f794Smrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
20912391620Smrg   >> "$depfile"
21021c2f794Smrg  else
21121c2f794Smrg    # The sourcefile does not contain any dependencies, so just
21221c2f794Smrg    # store a dummy comment line, to avoid errors with the Makefile
21321c2f794Smrg    # "include basename.Plo" scheme.
21421c2f794Smrg    echo "#dummy" > "$depfile"
21521c2f794Smrg  fi
21621c2f794Smrg  rm -f "$tmpdepfile"
21721c2f794Smrg  ;;
21821c2f794Smrg
21921c2f794Smrgaix)
22021c2f794Smrg  # The C for AIX Compiler uses -M and outputs the dependencies
22121c2f794Smrg  # in a .u file.  In older versions, this file always lives in the
22221c2f794Smrg  # current directory.  Also, the AIX compiler puts `$object:' at the
22321c2f794Smrg  # start of each line; $object doesn't have directory information.
22421c2f794Smrg  # Version 6 uses the directory in both cases.
22512391620Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
22612391620Smrg  test "x$dir" = "x$object" && dir=
22712391620Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
22821c2f794Smrg  if test "$libtool" = yes; then
22912391620Smrg    tmpdepfile1=$dir$base.u
23012391620Smrg    tmpdepfile2=$base.u
23112391620Smrg    tmpdepfile3=$dir.libs/$base.u
23221c2f794Smrg    "$@" -Wc,-M
23321c2f794Smrg  else
23412391620Smrg    tmpdepfile1=$dir$base.u
23512391620Smrg    tmpdepfile2=$dir$base.u
23612391620Smrg    tmpdepfile3=$dir$base.u
23721c2f794Smrg    "$@" -M
23821c2f794Smrg  fi
23921c2f794Smrg  stat=$?
24021c2f794Smrg
24121c2f794Smrg  if test $stat -eq 0; then :
24221c2f794Smrg  else
24312391620Smrg    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
24421c2f794Smrg    exit $stat
24521c2f794Smrg  fi
24621c2f794Smrg
24712391620Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
24812391620Smrg  do
24912391620Smrg    test -f "$tmpdepfile" && break
25012391620Smrg  done
25121c2f794Smrg  if test -f "$tmpdepfile"; then
25221c2f794Smrg    # Each line is of the form `foo.o: dependent.h'.
25321c2f794Smrg    # Do two passes, one to just change these to
25421c2f794Smrg    # `$object: dependent.h' and one to simply `dependent.h:'.
25512391620Smrg    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
25612391620Smrg    # That's a tab and a space in the [].
25712391620Smrg    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
25821c2f794Smrg  else
25921c2f794Smrg    # The sourcefile does not contain any dependencies, so just
26021c2f794Smrg    # store a dummy comment line, to avoid errors with the Makefile
26121c2f794Smrg    # "include basename.Plo" scheme.
26221c2f794Smrg    echo "#dummy" > "$depfile"
26321c2f794Smrg  fi
26421c2f794Smrg  rm -f "$tmpdepfile"
26521c2f794Smrg  ;;
26621c2f794Smrg
26721c2f794Smrgicc)
26821c2f794Smrg  # Intel's C compiler understands `-MD -MF file'.  However on
26921c2f794Smrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
27021c2f794Smrg  # ICC 7.0 will fill foo.d with something like
27121c2f794Smrg  #    foo.o: sub/foo.c
27221c2f794Smrg  #    foo.o: sub/foo.h
27321c2f794Smrg  # which is wrong.  We want:
27421c2f794Smrg  #    sub/foo.o: sub/foo.c
27521c2f794Smrg  #    sub/foo.o: sub/foo.h
27621c2f794Smrg  #    sub/foo.c:
27721c2f794Smrg  #    sub/foo.h:
27821c2f794Smrg  # ICC 7.1 will output
27921c2f794Smrg  #    foo.o: sub/foo.c sub/foo.h
28021c2f794Smrg  # and will wrap long lines using \ :
28121c2f794Smrg  #    foo.o: sub/foo.c ... \
28221c2f794Smrg  #     sub/foo.h ... \
28321c2f794Smrg  #     ...
28421c2f794Smrg
28521c2f794Smrg  "$@" -MD -MF "$tmpdepfile"
28621c2f794Smrg  stat=$?
28721c2f794Smrg  if test $stat -eq 0; then :
28821c2f794Smrg  else
28921c2f794Smrg    rm -f "$tmpdepfile"
29021c2f794Smrg    exit $stat
29121c2f794Smrg  fi
29221c2f794Smrg  rm -f "$depfile"
29321c2f794Smrg  # Each line is of the form `foo.o: dependent.h',
29421c2f794Smrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
29521c2f794Smrg  # Do two passes, one to just change these to
29621c2f794Smrg  # `$object: dependent.h' and one to simply `dependent.h:'.
29721c2f794Smrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
29821c2f794Smrg  # Some versions of the HPUX 10.20 sed can't process this invocation
29921c2f794Smrg  # correctly.  Breaking it into two sed invocations is a workaround.
30021c2f794Smrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
30121c2f794Smrg    sed -e 's/$/ :/' >> "$depfile"
30221c2f794Smrg  rm -f "$tmpdepfile"
30321c2f794Smrg  ;;
30421c2f794Smrg
30521c2f794Smrghp2)
30621c2f794Smrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
30721c2f794Smrg  # compilers, which have integrated preprocessors.  The correct option
30821c2f794Smrg  # to use with these is +Maked; it writes dependencies to a file named
30921c2f794Smrg  # 'foo.d', which lands next to the object file, wherever that
31021c2f794Smrg  # happens to be.
31121c2f794Smrg  # Much of this is similar to the tru64 case; see comments there.
31221c2f794Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
31321c2f794Smrg  test "x$dir" = "x$object" && dir=
31421c2f794Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
31521c2f794Smrg  if test "$libtool" = yes; then
31621c2f794Smrg    tmpdepfile1=$dir$base.d
31721c2f794Smrg    tmpdepfile2=$dir.libs/$base.d
31821c2f794Smrg    "$@" -Wc,+Maked
31921c2f794Smrg  else
32021c2f794Smrg    tmpdepfile1=$dir$base.d
32121c2f794Smrg    tmpdepfile2=$dir$base.d
32221c2f794Smrg    "$@" +Maked
32321c2f794Smrg  fi
32421c2f794Smrg  stat=$?
32521c2f794Smrg  if test $stat -eq 0; then :
32621c2f794Smrg  else
32721c2f794Smrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
32821c2f794Smrg     exit $stat
32921c2f794Smrg  fi
33021c2f794Smrg
33121c2f794Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
33221c2f794Smrg  do
33321c2f794Smrg    test -f "$tmpdepfile" && break
33421c2f794Smrg  done
33521c2f794Smrg  if test -f "$tmpdepfile"; then
33621c2f794Smrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
33721c2f794Smrg    # Add `dependent.h:' lines.
33812391620Smrg    sed -ne '2,${
33912391620Smrg	       s/^ *//
34012391620Smrg	       s/ \\*$//
34112391620Smrg	       s/$/:/
34212391620Smrg	       p
34312391620Smrg	     }' "$tmpdepfile" >> "$depfile"
34421c2f794Smrg  else
34521c2f794Smrg    echo "#dummy" > "$depfile"
34621c2f794Smrg  fi
34721c2f794Smrg  rm -f "$tmpdepfile" "$tmpdepfile2"
34821c2f794Smrg  ;;
34921c2f794Smrg
35021c2f794Smrgtru64)
35121c2f794Smrg   # The Tru64 compiler uses -MD to generate dependencies as a side
35221c2f794Smrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
35321c2f794Smrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
35421c2f794Smrg   # dependencies in `foo.d' instead, so we check for that too.
35521c2f794Smrg   # Subdirectories are respected.
35621c2f794Smrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
35721c2f794Smrg   test "x$dir" = "x$object" && dir=
35821c2f794Smrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
35921c2f794Smrg
36021c2f794Smrg   if test "$libtool" = yes; then
36121c2f794Smrg      # With Tru64 cc, shared objects can also be used to make a
36221c2f794Smrg      # static library.  This mechanism is used in libtool 1.4 series to
36321c2f794Smrg      # handle both shared and static libraries in a single compilation.
36421c2f794Smrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
36521c2f794Smrg      #
36621c2f794Smrg      # With libtool 1.5 this exception was removed, and libtool now
36721c2f794Smrg      # generates 2 separate objects for the 2 libraries.  These two
36821c2f794Smrg      # compilations output dependencies in $dir.libs/$base.o.d and
36921c2f794Smrg      # in $dir$base.o.d.  We have to check for both files, because
37021c2f794Smrg      # one of the two compilations can be disabled.  We should prefer
37121c2f794Smrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
37221c2f794Smrg      # automatically cleaned when .libs/ is deleted, while ignoring
37321c2f794Smrg      # the former would cause a distcleancheck panic.
37421c2f794Smrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
37521c2f794Smrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
37621c2f794Smrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
37721c2f794Smrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
37821c2f794Smrg      "$@" -Wc,-MD
37921c2f794Smrg   else
38021c2f794Smrg      tmpdepfile1=$dir$base.o.d
38121c2f794Smrg      tmpdepfile2=$dir$base.d
38221c2f794Smrg      tmpdepfile3=$dir$base.d
38321c2f794Smrg      tmpdepfile4=$dir$base.d
38421c2f794Smrg      "$@" -MD
38521c2f794Smrg   fi
38621c2f794Smrg
38721c2f794Smrg   stat=$?
38821c2f794Smrg   if test $stat -eq 0; then :
38921c2f794Smrg   else
39021c2f794Smrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
39121c2f794Smrg      exit $stat
39221c2f794Smrg   fi
39321c2f794Smrg
39421c2f794Smrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
39521c2f794Smrg   do
39621c2f794Smrg     test -f "$tmpdepfile" && break
39721c2f794Smrg   done
39821c2f794Smrg   if test -f "$tmpdepfile"; then
39921c2f794Smrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
40021c2f794Smrg      # That's a tab and a space in the [].
40121c2f794Smrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
40221c2f794Smrg   else
40321c2f794Smrg      echo "#dummy" > "$depfile"
40421c2f794Smrg   fi
40521c2f794Smrg   rm -f "$tmpdepfile"
40621c2f794Smrg   ;;
40721c2f794Smrg
40821c2f794Smrg#nosideeffect)
40921c2f794Smrg  # This comment above is used by automake to tell side-effect
41021c2f794Smrg  # dependency tracking mechanisms from slower ones.
41121c2f794Smrg
41221c2f794Smrgdashmstdout)
41321c2f794Smrg  # Important note: in order to support this mode, a compiler *must*
41421c2f794Smrg  # always write the preprocessed file to stdout, regardless of -o.
41521c2f794Smrg  "$@" || exit $?
41621c2f794Smrg
41721c2f794Smrg  # Remove the call to Libtool.
41821c2f794Smrg  if test "$libtool" = yes; then
41912391620Smrg    while test "X$1" != 'X--mode=compile'; do
42021c2f794Smrg      shift
42121c2f794Smrg    done
42221c2f794Smrg    shift
42321c2f794Smrg  fi
42421c2f794Smrg
42521c2f794Smrg  # Remove `-o $object'.
42621c2f794Smrg  IFS=" "
42721c2f794Smrg  for arg
42821c2f794Smrg  do
42921c2f794Smrg    case $arg in
43021c2f794Smrg    -o)
43121c2f794Smrg      shift
43221c2f794Smrg      ;;
43321c2f794Smrg    $object)
43421c2f794Smrg      shift
43521c2f794Smrg      ;;
43621c2f794Smrg    *)
43721c2f794Smrg      set fnord "$@" "$arg"
43821c2f794Smrg      shift # fnord
43921c2f794Smrg      shift # $arg
44021c2f794Smrg      ;;
44121c2f794Smrg    esac
44221c2f794Smrg  done
44321c2f794Smrg
44421c2f794Smrg  test -z "$dashmflag" && dashmflag=-M
44521c2f794Smrg  # Require at least two characters before searching for `:'
44621c2f794Smrg  # in the target name.  This is to cope with DOS-style filenames:
44721c2f794Smrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
44821c2f794Smrg  "$@" $dashmflag |
44921c2f794Smrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
45021c2f794Smrg  rm -f "$depfile"
45121c2f794Smrg  cat < "$tmpdepfile" > "$depfile"
45221c2f794Smrg  tr ' ' '
45321c2f794Smrg' < "$tmpdepfile" | \
45421c2f794Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
45521c2f794Smrg## correctly.  Breaking it into two sed invocations is a workaround.
45621c2f794Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
45721c2f794Smrg  rm -f "$tmpdepfile"
45821c2f794Smrg  ;;
45921c2f794Smrg
46021c2f794SmrgdashXmstdout)
46121c2f794Smrg  # This case only exists to satisfy depend.m4.  It is never actually
46221c2f794Smrg  # run, as this mode is specially recognized in the preamble.
46321c2f794Smrg  exit 1
46421c2f794Smrg  ;;
46521c2f794Smrg
46621c2f794Smrgmakedepend)
46721c2f794Smrg  "$@" || exit $?
46821c2f794Smrg  # Remove any Libtool call
46921c2f794Smrg  if test "$libtool" = yes; then
47012391620Smrg    while test "X$1" != 'X--mode=compile'; do
47121c2f794Smrg      shift
47221c2f794Smrg    done
47321c2f794Smrg    shift
47421c2f794Smrg  fi
47521c2f794Smrg  # X makedepend
47621c2f794Smrg  shift
47712391620Smrg  cleared=no eat=no
47812391620Smrg  for arg
47912391620Smrg  do
48021c2f794Smrg    case $cleared in
48121c2f794Smrg    no)
48221c2f794Smrg      set ""; shift
48321c2f794Smrg      cleared=yes ;;
48421c2f794Smrg    esac
48512391620Smrg    if test $eat = yes; then
48612391620Smrg      eat=no
48712391620Smrg      continue
48812391620Smrg    fi
48921c2f794Smrg    case "$arg" in
49021c2f794Smrg    -D*|-I*)
49121c2f794Smrg      set fnord "$@" "$arg"; shift ;;
49221c2f794Smrg    # Strip any option that makedepend may not understand.  Remove
49321c2f794Smrg    # the object too, otherwise makedepend will parse it as a source file.
49412391620Smrg    -arch)
49512391620Smrg      eat=yes ;;
49621c2f794Smrg    -*|$object)
49721c2f794Smrg      ;;
49821c2f794Smrg    *)
49921c2f794Smrg      set fnord "$@" "$arg"; shift ;;
50021c2f794Smrg    esac
50121c2f794Smrg  done
50212391620Smrg  obj_suffix=`echo "$object" | sed 's/^.*\././'`
50321c2f794Smrg  touch "$tmpdepfile"
50421c2f794Smrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
50521c2f794Smrg  rm -f "$depfile"
50621c2f794Smrg  cat < "$tmpdepfile" > "$depfile"
50721c2f794Smrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
50821c2f794Smrg' | \
50921c2f794Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
51021c2f794Smrg## correctly.  Breaking it into two sed invocations is a workaround.
51121c2f794Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
51221c2f794Smrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
51321c2f794Smrg  ;;
51421c2f794Smrg
51521c2f794Smrgcpp)
51621c2f794Smrg  # Important note: in order to support this mode, a compiler *must*
51721c2f794Smrg  # always write the preprocessed file to stdout.
51821c2f794Smrg  "$@" || exit $?
51921c2f794Smrg
52021c2f794Smrg  # Remove the call to Libtool.
52121c2f794Smrg  if test "$libtool" = yes; then
52212391620Smrg    while test "X$1" != 'X--mode=compile'; do
52321c2f794Smrg      shift
52421c2f794Smrg    done
52521c2f794Smrg    shift
52621c2f794Smrg  fi
52721c2f794Smrg
52821c2f794Smrg  # Remove `-o $object'.
52921c2f794Smrg  IFS=" "
53021c2f794Smrg  for arg
53121c2f794Smrg  do
53221c2f794Smrg    case $arg in
53321c2f794Smrg    -o)
53421c2f794Smrg      shift
53521c2f794Smrg      ;;
53621c2f794Smrg    $object)
53721c2f794Smrg      shift
53821c2f794Smrg      ;;
53921c2f794Smrg    *)
54021c2f794Smrg      set fnord "$@" "$arg"
54121c2f794Smrg      shift # fnord
54221c2f794Smrg      shift # $arg
54321c2f794Smrg      ;;
54421c2f794Smrg    esac
54521c2f794Smrg  done
54621c2f794Smrg
54721c2f794Smrg  "$@" -E |
54821c2f794Smrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
54921c2f794Smrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
55021c2f794Smrg    sed '$ s: \\$::' > "$tmpdepfile"
55121c2f794Smrg  rm -f "$depfile"
55221c2f794Smrg  echo "$object : \\" > "$depfile"
55321c2f794Smrg  cat < "$tmpdepfile" >> "$depfile"
55421c2f794Smrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
55521c2f794Smrg  rm -f "$tmpdepfile"
55621c2f794Smrg  ;;
55721c2f794Smrg
55821c2f794Smrgmsvisualcpp)
55921c2f794Smrg  # Important note: in order to support this mode, a compiler *must*
56012391620Smrg  # always write the preprocessed file to stdout.
56121c2f794Smrg  "$@" || exit $?
56212391620Smrg
56312391620Smrg  # Remove the call to Libtool.
56412391620Smrg  if test "$libtool" = yes; then
56512391620Smrg    while test "X$1" != 'X--mode=compile'; do
56612391620Smrg      shift
56712391620Smrg    done
56812391620Smrg    shift
56912391620Smrg  fi
57012391620Smrg
57121c2f794Smrg  IFS=" "
57221c2f794Smrg  for arg
57321c2f794Smrg  do
57421c2f794Smrg    case "$arg" in
57512391620Smrg    -o)
57612391620Smrg      shift
57712391620Smrg      ;;
57812391620Smrg    $object)
57912391620Smrg      shift
58012391620Smrg      ;;
58121c2f794Smrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
58221c2f794Smrg	set fnord "$@"
58321c2f794Smrg	shift
58421c2f794Smrg	shift
58521c2f794Smrg	;;
58621c2f794Smrg    *)
58721c2f794Smrg	set fnord "$@" "$arg"
58821c2f794Smrg	shift
58921c2f794Smrg	shift
59021c2f794Smrg	;;
59121c2f794Smrg    esac
59221c2f794Smrg  done
59312391620Smrg  "$@" -E 2>/dev/null |
59412391620Smrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
59521c2f794Smrg  rm -f "$depfile"
59621c2f794Smrg  echo "$object : \\" > "$depfile"
59712391620Smrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
59821c2f794Smrg  echo "	" >> "$depfile"
59912391620Smrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
60021c2f794Smrg  rm -f "$tmpdepfile"
60121c2f794Smrg  ;;
60221c2f794Smrg
60312391620Smrgmsvcmsys)
60412391620Smrg  # This case exists only to let depend.m4 do its work.  It works by
60512391620Smrg  # looking at the text of this script.  This case will never be run,
60612391620Smrg  # since it is checked for above.
60712391620Smrg  exit 1
60812391620Smrg  ;;
60912391620Smrg
61021c2f794Smrgnone)
61121c2f794Smrg  exec "$@"
61221c2f794Smrg  ;;
61321c2f794Smrg
61421c2f794Smrg*)
61521c2f794Smrg  echo "Unknown depmode $depmode" 1>&2
61621c2f794Smrg  exit 1
61721c2f794Smrg  ;;
61821c2f794Smrgesac
61921c2f794Smrg
62021c2f794Smrgexit 0
62121c2f794Smrg
62221c2f794Smrg# Local Variables:
62321c2f794Smrg# mode: shell-script
62421c2f794Smrg# sh-indentation: 2
62521c2f794Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
62621c2f794Smrg# time-stamp-start: "scriptversion="
62721c2f794Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
62812391620Smrg# time-stamp-time-zone: "UTC"
62912391620Smrg# time-stamp-end: "; # UTC"
63021c2f794Smrg# End:
631