depcomp revision 63847c39
176888252Smrg#! /bin/sh
276888252Smrg# depcomp - compile a program generating dependencies as side-effects
376888252Smrg
463847c39Smrgscriptversion=2011-12-04.11; # UTC
576888252Smrg
663847c39Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
763847c39Smrg# 2011 Free Software Foundation, Inc.
876888252Smrg
976888252Smrg# This program is free software; you can redistribute it and/or modify
1076888252Smrg# it under the terms of the GNU General Public License as published by
1176888252Smrg# the Free Software Foundation; either version 2, or (at your option)
1276888252Smrg# any later version.
1376888252Smrg
1476888252Smrg# This program is distributed in the hope that it will be useful,
1576888252Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1676888252Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1776888252Smrg# GNU General Public License for more details.
1876888252Smrg
1976888252Smrg# You should have received a copy of the GNU General Public License
20d8556812Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
2176888252Smrg
2276888252Smrg# As a special exception to the GNU General Public License, if you
2376888252Smrg# distribute this file as part of a program that contains a
2476888252Smrg# configuration script generated by Autoconf, you may include it under
2576888252Smrg# the same distribution terms that you use for the rest of that program.
2676888252Smrg
2776888252Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
2876888252Smrg
2976888252Smrgcase $1 in
3076888252Smrg  '')
3176888252Smrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
3276888252Smrg     exit 1;
3376888252Smrg     ;;
3476888252Smrg  -h | --h*)
3576888252Smrg    cat <<\EOF
3676888252SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
3776888252Smrg
3876888252SmrgRun PROGRAMS ARGS to compile a file, generating dependencies
3976888252Smrgas side-effects.
4076888252Smrg
4176888252SmrgEnvironment variables:
4276888252Smrg  depmode     Dependency tracking mode.
4376888252Smrg  source      Source file read by `PROGRAMS ARGS'.
4476888252Smrg  object      Object file output by `PROGRAMS ARGS'.
4576888252Smrg  DEPDIR      directory where to store dependencies.
4676888252Smrg  depfile     Dependency file to output.
4763847c39Smrg  tmpdepfile  Temporary file to use when outputting dependencies.
4876888252Smrg  libtool     Whether libtool is used (yes/no).
4976888252Smrg
5076888252SmrgReport bugs to <bug-automake@gnu.org>.
5176888252SmrgEOF
5276888252Smrg    exit $?
5376888252Smrg    ;;
5476888252Smrg  -v | --v*)
5576888252Smrg    echo "depcomp $scriptversion"
5676888252Smrg    exit $?
5776888252Smrg    ;;
5876888252Smrgesac
5976888252Smrg
6076888252Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
6176888252Smrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
6276888252Smrg  exit 1
6376888252Smrgfi
6476888252Smrg
6576888252Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
6676888252Smrgdepfile=${depfile-`echo "$object" |
6776888252Smrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
6876888252Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
6976888252Smrg
7076888252Smrgrm -f "$tmpdepfile"
7176888252Smrg
7276888252Smrg# Some modes work just like other modes, but use different flags.  We
7376888252Smrg# parameterize here, but still list the modes in the big case below,
7476888252Smrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
7576888252Smrg# here, because this file can only contain one case statement.
7676888252Smrgif test "$depmode" = hp; then
7776888252Smrg  # HP compiler uses -M and no extra arg.
7876888252Smrg  gccflag=-M
7976888252Smrg  depmode=gcc
8076888252Smrgfi
8176888252Smrg
8276888252Smrgif test "$depmode" = dashXmstdout; then
8376888252Smrg   # This is just like dashmstdout with a different argument.
8476888252Smrg   dashmflag=-xM
8576888252Smrg   depmode=dashmstdout
8676888252Smrgfi
8776888252Smrg
88d8556812Smrgcygpath_u="cygpath -u -f -"
89d8556812Smrgif test "$depmode" = msvcmsys; then
90d8556812Smrg   # This is just like msvisualcpp but w/o cygpath translation.
91d8556812Smrg   # Just convert the backslash-escaped backslashes to single forward
92d8556812Smrg   # slashes to satisfy depend.m4
9363847c39Smrg   cygpath_u='sed s,\\\\,/,g'
94d8556812Smrg   depmode=msvisualcpp
95d8556812Smrgfi
96d8556812Smrg
9763847c39Smrgif test "$depmode" = msvc7msys; then
9863847c39Smrg   # This is just like msvc7 but w/o cygpath translation.
9963847c39Smrg   # Just convert the backslash-escaped backslashes to single forward
10063847c39Smrg   # slashes to satisfy depend.m4
10163847c39Smrg   cygpath_u='sed s,\\\\,/,g'
10263847c39Smrg   depmode=msvc7
10363847c39Smrgfi
10463847c39Smrg
10576888252Smrgcase "$depmode" in
10676888252Smrggcc3)
10776888252Smrg## gcc 3 implements dependency tracking that does exactly what
10876888252Smrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
10976888252Smrg## it if -MD -MP comes after the -MF stuff.  Hmm.
1101ae1b5e8Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
1111ae1b5e8Smrg## the command line argument order; so add the flags where they
1121ae1b5e8Smrg## appear in depend2.am.  Note that the slowdown incurred here
1131ae1b5e8Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
1141ae1b5e8Smrg  for arg
1151ae1b5e8Smrg  do
1161ae1b5e8Smrg    case $arg in
1171ae1b5e8Smrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
1181ae1b5e8Smrg    *)  set fnord "$@" "$arg" ;;
1191ae1b5e8Smrg    esac
1201ae1b5e8Smrg    shift # fnord
1211ae1b5e8Smrg    shift # $arg
1221ae1b5e8Smrg  done
1231ae1b5e8Smrg  "$@"
12476888252Smrg  stat=$?
12576888252Smrg  if test $stat -eq 0; then :
12676888252Smrg  else
12776888252Smrg    rm -f "$tmpdepfile"
12876888252Smrg    exit $stat
12976888252Smrg  fi
13076888252Smrg  mv "$tmpdepfile" "$depfile"
13176888252Smrg  ;;
13276888252Smrg
13376888252Smrggcc)
13476888252Smrg## There are various ways to get dependency output from gcc.  Here's
13576888252Smrg## why we pick this rather obscure method:
13676888252Smrg## - Don't want to use -MD because we'd like the dependencies to end
13776888252Smrg##   up in a subdir.  Having to rename by hand is ugly.
13876888252Smrg##   (We might end up doing this anyway to support other compilers.)
13976888252Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
14076888252Smrg##   -MM, not -M (despite what the docs say).
14176888252Smrg## - Using -M directly means running the compiler twice (even worse
14276888252Smrg##   than renaming).
14376888252Smrg  if test -z "$gccflag"; then
14476888252Smrg    gccflag=-MD,
14576888252Smrg  fi
14676888252Smrg  "$@" -Wp,"$gccflag$tmpdepfile"
14776888252Smrg  stat=$?
14876888252Smrg  if test $stat -eq 0; then :
14976888252Smrg  else
15076888252Smrg    rm -f "$tmpdepfile"
15176888252Smrg    exit $stat
15276888252Smrg  fi
15376888252Smrg  rm -f "$depfile"
15476888252Smrg  echo "$object : \\" > "$depfile"
15576888252Smrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
15676888252Smrg## The second -e expression handles DOS-style file names with drive letters.
15776888252Smrg  sed -e 's/^[^:]*: / /' \
15876888252Smrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
15976888252Smrg## This next piece of magic avoids the `deleted header file' problem.
16076888252Smrg## The problem is that when a header file which appears in a .P file
16176888252Smrg## is deleted, the dependency causes make to die (because there is
16276888252Smrg## typically no way to rebuild the header).  We avoid this by adding
16376888252Smrg## dummy dependencies for each header file.  Too bad gcc doesn't do
16476888252Smrg## this for us directly.
16576888252Smrg  tr ' ' '
16676888252Smrg' < "$tmpdepfile" |
16776888252Smrg## Some versions of gcc put a space before the `:'.  On the theory
16876888252Smrg## that the space means something, we add a space to the output as
16963847c39Smrg## well.  hp depmode also adds that space, but also prefixes the VPATH
17063847c39Smrg## to the object.  Take care to not repeat it in the output.
17176888252Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
17276888252Smrg## correctly.  Breaking it into two sed invocations is a workaround.
17363847c39Smrg    sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
17463847c39Smrg      | sed -e 's/$/ :/' >> "$depfile"
17576888252Smrg  rm -f "$tmpdepfile"
17676888252Smrg  ;;
17776888252Smrg
17876888252Smrghp)
17976888252Smrg  # This case exists only to let depend.m4 do its work.  It works by
18076888252Smrg  # looking at the text of this script.  This case will never be run,
18176888252Smrg  # since it is checked for above.
18276888252Smrg  exit 1
18376888252Smrg  ;;
18476888252Smrg
18576888252Smrgsgi)
18676888252Smrg  if test "$libtool" = yes; then
18776888252Smrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
18876888252Smrg  else
18976888252Smrg    "$@" -MDupdate "$tmpdepfile"
19076888252Smrg  fi
19176888252Smrg  stat=$?
19276888252Smrg  if test $stat -eq 0; then :
19376888252Smrg  else
19476888252Smrg    rm -f "$tmpdepfile"
19576888252Smrg    exit $stat
19676888252Smrg  fi
19776888252Smrg  rm -f "$depfile"
19876888252Smrg
19976888252Smrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
20076888252Smrg    echo "$object : \\" > "$depfile"
20176888252Smrg
20276888252Smrg    # Clip off the initial element (the dependent).  Don't try to be
20376888252Smrg    # clever and replace this with sed code, as IRIX sed won't handle
20476888252Smrg    # lines with more than a fixed number of characters (4096 in
20576888252Smrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
20676888252Smrg    # the IRIX cc adds comments like `#:fec' to the end of the
20776888252Smrg    # dependency line.
20876888252Smrg    tr ' ' '
20976888252Smrg' < "$tmpdepfile" \
21076888252Smrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
21176888252Smrg    tr '
212d8556812Smrg' ' ' >> "$depfile"
213d8556812Smrg    echo >> "$depfile"
21476888252Smrg
21576888252Smrg    # The second pass generates a dummy entry for each header file.
21676888252Smrg    tr ' ' '
21776888252Smrg' < "$tmpdepfile" \
21876888252Smrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
219d8556812Smrg   >> "$depfile"
22076888252Smrg  else
22176888252Smrg    # The sourcefile does not contain any dependencies, so just
22276888252Smrg    # store a dummy comment line, to avoid errors with the Makefile
22376888252Smrg    # "include basename.Plo" scheme.
22476888252Smrg    echo "#dummy" > "$depfile"
22576888252Smrg  fi
22676888252Smrg  rm -f "$tmpdepfile"
22776888252Smrg  ;;
22876888252Smrg
22976888252Smrgaix)
23076888252Smrg  # The C for AIX Compiler uses -M and outputs the dependencies
23176888252Smrg  # in a .u file.  In older versions, this file always lives in the
23276888252Smrg  # current directory.  Also, the AIX compiler puts `$object:' at the
23376888252Smrg  # start of each line; $object doesn't have directory information.
23476888252Smrg  # Version 6 uses the directory in both cases.
23586dafe34Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
23686dafe34Smrg  test "x$dir" = "x$object" && dir=
23786dafe34Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
23876888252Smrg  if test "$libtool" = yes; then
23986dafe34Smrg    tmpdepfile1=$dir$base.u
24086dafe34Smrg    tmpdepfile2=$base.u
24186dafe34Smrg    tmpdepfile3=$dir.libs/$base.u
24276888252Smrg    "$@" -Wc,-M
24376888252Smrg  else
24486dafe34Smrg    tmpdepfile1=$dir$base.u
24586dafe34Smrg    tmpdepfile2=$dir$base.u
24686dafe34Smrg    tmpdepfile3=$dir$base.u
24776888252Smrg    "$@" -M
24876888252Smrg  fi
24976888252Smrg  stat=$?
25076888252Smrg
25176888252Smrg  if test $stat -eq 0; then :
25276888252Smrg  else
25386dafe34Smrg    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
25476888252Smrg    exit $stat
25576888252Smrg  fi
25676888252Smrg
25786dafe34Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
25886dafe34Smrg  do
25986dafe34Smrg    test -f "$tmpdepfile" && break
26086dafe34Smrg  done
26176888252Smrg  if test -f "$tmpdepfile"; then
26276888252Smrg    # Each line is of the form `foo.o: dependent.h'.
26376888252Smrg    # Do two passes, one to just change these to
26476888252Smrg    # `$object: dependent.h' and one to simply `dependent.h:'.
26586dafe34Smrg    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
26686dafe34Smrg    # That's a tab and a space in the [].
26786dafe34Smrg    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
26876888252Smrg  else
26976888252Smrg    # The sourcefile does not contain any dependencies, so just
27076888252Smrg    # store a dummy comment line, to avoid errors with the Makefile
27176888252Smrg    # "include basename.Plo" scheme.
27276888252Smrg    echo "#dummy" > "$depfile"
27376888252Smrg  fi
27476888252Smrg  rm -f "$tmpdepfile"
27576888252Smrg  ;;
27676888252Smrg
27776888252Smrgicc)
27876888252Smrg  # Intel's C compiler understands `-MD -MF file'.  However on
27976888252Smrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
28076888252Smrg  # ICC 7.0 will fill foo.d with something like
28176888252Smrg  #    foo.o: sub/foo.c
28276888252Smrg  #    foo.o: sub/foo.h
28376888252Smrg  # which is wrong.  We want:
28476888252Smrg  #    sub/foo.o: sub/foo.c
28576888252Smrg  #    sub/foo.o: sub/foo.h
28676888252Smrg  #    sub/foo.c:
28776888252Smrg  #    sub/foo.h:
28876888252Smrg  # ICC 7.1 will output
28976888252Smrg  #    foo.o: sub/foo.c sub/foo.h
29076888252Smrg  # and will wrap long lines using \ :
29176888252Smrg  #    foo.o: sub/foo.c ... \
29276888252Smrg  #     sub/foo.h ... \
29376888252Smrg  #     ...
29476888252Smrg
29576888252Smrg  "$@" -MD -MF "$tmpdepfile"
29676888252Smrg  stat=$?
29776888252Smrg  if test $stat -eq 0; then :
29876888252Smrg  else
29976888252Smrg    rm -f "$tmpdepfile"
30076888252Smrg    exit $stat
30176888252Smrg  fi
30276888252Smrg  rm -f "$depfile"
30376888252Smrg  # Each line is of the form `foo.o: dependent.h',
30476888252Smrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
30576888252Smrg  # Do two passes, one to just change these to
30676888252Smrg  # `$object: dependent.h' and one to simply `dependent.h:'.
30776888252Smrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
30876888252Smrg  # Some versions of the HPUX 10.20 sed can't process this invocation
30976888252Smrg  # correctly.  Breaking it into two sed invocations is a workaround.
31076888252Smrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
31176888252Smrg    sed -e 's/$/ :/' >> "$depfile"
31276888252Smrg  rm -f "$tmpdepfile"
31376888252Smrg  ;;
31476888252Smrg
3151ae1b5e8Smrghp2)
3161ae1b5e8Smrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
3171ae1b5e8Smrg  # compilers, which have integrated preprocessors.  The correct option
3181ae1b5e8Smrg  # to use with these is +Maked; it writes dependencies to a file named
3191ae1b5e8Smrg  # 'foo.d', which lands next to the object file, wherever that
3201ae1b5e8Smrg  # happens to be.
3211ae1b5e8Smrg  # Much of this is similar to the tru64 case; see comments there.
3221ae1b5e8Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3231ae1b5e8Smrg  test "x$dir" = "x$object" && dir=
3241ae1b5e8Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3251ae1b5e8Smrg  if test "$libtool" = yes; then
3261ae1b5e8Smrg    tmpdepfile1=$dir$base.d
3271ae1b5e8Smrg    tmpdepfile2=$dir.libs/$base.d
3281ae1b5e8Smrg    "$@" -Wc,+Maked
3291ae1b5e8Smrg  else
3301ae1b5e8Smrg    tmpdepfile1=$dir$base.d
3311ae1b5e8Smrg    tmpdepfile2=$dir$base.d
3321ae1b5e8Smrg    "$@" +Maked
3331ae1b5e8Smrg  fi
3341ae1b5e8Smrg  stat=$?
3351ae1b5e8Smrg  if test $stat -eq 0; then :
3361ae1b5e8Smrg  else
3371ae1b5e8Smrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
3381ae1b5e8Smrg     exit $stat
3391ae1b5e8Smrg  fi
3401ae1b5e8Smrg
3411ae1b5e8Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
3421ae1b5e8Smrg  do
3431ae1b5e8Smrg    test -f "$tmpdepfile" && break
3441ae1b5e8Smrg  done
3451ae1b5e8Smrg  if test -f "$tmpdepfile"; then
3461ae1b5e8Smrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
3471ae1b5e8Smrg    # Add `dependent.h:' lines.
348d8556812Smrg    sed -ne '2,${
349d8556812Smrg	       s/^ *//
350d8556812Smrg	       s/ \\*$//
351d8556812Smrg	       s/$/:/
352d8556812Smrg	       p
353d8556812Smrg	     }' "$tmpdepfile" >> "$depfile"
3541ae1b5e8Smrg  else
3551ae1b5e8Smrg    echo "#dummy" > "$depfile"
3561ae1b5e8Smrg  fi
3571ae1b5e8Smrg  rm -f "$tmpdepfile" "$tmpdepfile2"
3581ae1b5e8Smrg  ;;
3591ae1b5e8Smrg
36076888252Smrgtru64)
36176888252Smrg   # The Tru64 compiler uses -MD to generate dependencies as a side
36276888252Smrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
36376888252Smrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
36476888252Smrg   # dependencies in `foo.d' instead, so we check for that too.
36576888252Smrg   # Subdirectories are respected.
36676888252Smrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
36776888252Smrg   test "x$dir" = "x$object" && dir=
36876888252Smrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
36976888252Smrg
37076888252Smrg   if test "$libtool" = yes; then
37176888252Smrg      # With Tru64 cc, shared objects can also be used to make a
3721ae1b5e8Smrg      # static library.  This mechanism is used in libtool 1.4 series to
37376888252Smrg      # handle both shared and static libraries in a single compilation.
37476888252Smrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
37576888252Smrg      #
37676888252Smrg      # With libtool 1.5 this exception was removed, and libtool now
37776888252Smrg      # generates 2 separate objects for the 2 libraries.  These two
3781ae1b5e8Smrg      # compilations output dependencies in $dir.libs/$base.o.d and
37976888252Smrg      # in $dir$base.o.d.  We have to check for both files, because
38076888252Smrg      # one of the two compilations can be disabled.  We should prefer
38176888252Smrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
38276888252Smrg      # automatically cleaned when .libs/ is deleted, while ignoring
38376888252Smrg      # the former would cause a distcleancheck panic.
38476888252Smrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
38576888252Smrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
38676888252Smrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
38776888252Smrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
38876888252Smrg      "$@" -Wc,-MD
38976888252Smrg   else
39076888252Smrg      tmpdepfile1=$dir$base.o.d
39176888252Smrg      tmpdepfile2=$dir$base.d
39276888252Smrg      tmpdepfile3=$dir$base.d
39376888252Smrg      tmpdepfile4=$dir$base.d
39476888252Smrg      "$@" -MD
39576888252Smrg   fi
39676888252Smrg
39776888252Smrg   stat=$?
39876888252Smrg   if test $stat -eq 0; then :
39976888252Smrg   else
40076888252Smrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
40176888252Smrg      exit $stat
40276888252Smrg   fi
40376888252Smrg
40476888252Smrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
40576888252Smrg   do
40676888252Smrg     test -f "$tmpdepfile" && break
40776888252Smrg   done
40876888252Smrg   if test -f "$tmpdepfile"; then
40976888252Smrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
41076888252Smrg      # That's a tab and a space in the [].
41176888252Smrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
41276888252Smrg   else
41376888252Smrg      echo "#dummy" > "$depfile"
41476888252Smrg   fi
41576888252Smrg   rm -f "$tmpdepfile"
41676888252Smrg   ;;
41776888252Smrg
41863847c39Smrgmsvc7)
41963847c39Smrg  if test "$libtool" = yes; then
42063847c39Smrg    showIncludes=-Wc,-showIncludes
42163847c39Smrg  else
42263847c39Smrg    showIncludes=-showIncludes
42363847c39Smrg  fi
42463847c39Smrg  "$@" $showIncludes > "$tmpdepfile"
42563847c39Smrg  stat=$?
42663847c39Smrg  grep -v '^Note: including file: ' "$tmpdepfile"
42763847c39Smrg  if test "$stat" = 0; then :
42863847c39Smrg  else
42963847c39Smrg    rm -f "$tmpdepfile"
43063847c39Smrg    exit $stat
43163847c39Smrg  fi
43263847c39Smrg  rm -f "$depfile"
43363847c39Smrg  echo "$object : \\" > "$depfile"
43463847c39Smrg  # The first sed program below extracts the file names and escapes
43563847c39Smrg  # backslashes for cygpath.  The second sed program outputs the file
43663847c39Smrg  # name when reading, but also accumulates all include files in the
43763847c39Smrg  # hold buffer in order to output them again at the end.  This only
43863847c39Smrg  # works with sed implementations that can handle large buffers.
43963847c39Smrg  sed < "$tmpdepfile" -n '
44063847c39Smrg/^Note: including file:  *\(.*\)/ {
44163847c39Smrg  s//\1/
44263847c39Smrg  s/\\/\\\\/g
44363847c39Smrg  p
44463847c39Smrg}' | $cygpath_u | sort -u | sed -n '
44563847c39Smrgs/ /\\ /g
44663847c39Smrgs/\(.*\)/	\1 \\/p
44763847c39Smrgs/.\(.*\) \\/\1:/
44863847c39SmrgH
44963847c39Smrg$ {
45063847c39Smrg  s/.*/	/
45163847c39Smrg  G
45263847c39Smrg  p
45363847c39Smrg}' >> "$depfile"
45463847c39Smrg  rm -f "$tmpdepfile"
45563847c39Smrg  ;;
45663847c39Smrg
45763847c39Smrgmsvc7msys)
45863847c39Smrg  # This case exists only to let depend.m4 do its work.  It works by
45963847c39Smrg  # looking at the text of this script.  This case will never be run,
46063847c39Smrg  # since it is checked for above.
46163847c39Smrg  exit 1
46263847c39Smrg  ;;
46363847c39Smrg
46476888252Smrg#nosideeffect)
46576888252Smrg  # This comment above is used by automake to tell side-effect
46676888252Smrg  # dependency tracking mechanisms from slower ones.
46776888252Smrg
46876888252Smrgdashmstdout)
46976888252Smrg  # Important note: in order to support this mode, a compiler *must*
47076888252Smrg  # always write the preprocessed file to stdout, regardless of -o.
47176888252Smrg  "$@" || exit $?
47276888252Smrg
47376888252Smrg  # Remove the call to Libtool.
47476888252Smrg  if test "$libtool" = yes; then
475d8556812Smrg    while test "X$1" != 'X--mode=compile'; do
47676888252Smrg      shift
47776888252Smrg    done
47876888252Smrg    shift
47976888252Smrg  fi
48076888252Smrg
48176888252Smrg  # Remove `-o $object'.
48276888252Smrg  IFS=" "
48376888252Smrg  for arg
48476888252Smrg  do
48576888252Smrg    case $arg in
48676888252Smrg    -o)
48776888252Smrg      shift
48876888252Smrg      ;;
48976888252Smrg    $object)
49076888252Smrg      shift
49176888252Smrg      ;;
49276888252Smrg    *)
49376888252Smrg      set fnord "$@" "$arg"
49476888252Smrg      shift # fnord
49576888252Smrg      shift # $arg
49676888252Smrg      ;;
49776888252Smrg    esac
49876888252Smrg  done
49976888252Smrg
50076888252Smrg  test -z "$dashmflag" && dashmflag=-M
50176888252Smrg  # Require at least two characters before searching for `:'
50276888252Smrg  # in the target name.  This is to cope with DOS-style filenames:
50376888252Smrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
50476888252Smrg  "$@" $dashmflag |
50576888252Smrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
50676888252Smrg  rm -f "$depfile"
50776888252Smrg  cat < "$tmpdepfile" > "$depfile"
50876888252Smrg  tr ' ' '
50976888252Smrg' < "$tmpdepfile" | \
51076888252Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
51176888252Smrg## correctly.  Breaking it into two sed invocations is a workaround.
51276888252Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
51376888252Smrg  rm -f "$tmpdepfile"
51476888252Smrg  ;;
51576888252Smrg
51676888252SmrgdashXmstdout)
51776888252Smrg  # This case only exists to satisfy depend.m4.  It is never actually
51876888252Smrg  # run, as this mode is specially recognized in the preamble.
51976888252Smrg  exit 1
52076888252Smrg  ;;
52176888252Smrg
52276888252Smrgmakedepend)
52376888252Smrg  "$@" || exit $?
52476888252Smrg  # Remove any Libtool call
52576888252Smrg  if test "$libtool" = yes; then
526d8556812Smrg    while test "X$1" != 'X--mode=compile'; do
52776888252Smrg      shift
52876888252Smrg    done
52976888252Smrg    shift
53076888252Smrg  fi
53176888252Smrg  # X makedepend
53276888252Smrg  shift
533d8556812Smrg  cleared=no eat=no
534d8556812Smrg  for arg
535d8556812Smrg  do
53676888252Smrg    case $cleared in
53776888252Smrg    no)
53876888252Smrg      set ""; shift
53976888252Smrg      cleared=yes ;;
54076888252Smrg    esac
541d8556812Smrg    if test $eat = yes; then
542d8556812Smrg      eat=no
543d8556812Smrg      continue
544d8556812Smrg    fi
54576888252Smrg    case "$arg" in
54676888252Smrg    -D*|-I*)
54776888252Smrg      set fnord "$@" "$arg"; shift ;;
54876888252Smrg    # Strip any option that makedepend may not understand.  Remove
54976888252Smrg    # the object too, otherwise makedepend will parse it as a source file.
550d8556812Smrg    -arch)
551d8556812Smrg      eat=yes ;;
55276888252Smrg    -*|$object)
55376888252Smrg      ;;
55476888252Smrg    *)
55576888252Smrg      set fnord "$@" "$arg"; shift ;;
55676888252Smrg    esac
55776888252Smrg  done
558d8556812Smrg  obj_suffix=`echo "$object" | sed 's/^.*\././'`
55976888252Smrg  touch "$tmpdepfile"
56076888252Smrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
56176888252Smrg  rm -f "$depfile"
56263847c39Smrg  # makedepend may prepend the VPATH from the source file name to the object.
56363847c39Smrg  # No need to regex-escape $object, excess matching of '.' is harmless.
56463847c39Smrg  sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
56576888252Smrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
56676888252Smrg' | \
56776888252Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
56876888252Smrg## correctly.  Breaking it into two sed invocations is a workaround.
56976888252Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
57076888252Smrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
57176888252Smrg  ;;
57276888252Smrg
57376888252Smrgcpp)
57476888252Smrg  # Important note: in order to support this mode, a compiler *must*
57576888252Smrg  # always write the preprocessed file to stdout.
57676888252Smrg  "$@" || exit $?
57776888252Smrg
57876888252Smrg  # Remove the call to Libtool.
57976888252Smrg  if test "$libtool" = yes; then
580d8556812Smrg    while test "X$1" != 'X--mode=compile'; do
58176888252Smrg      shift
58276888252Smrg    done
58376888252Smrg    shift
58476888252Smrg  fi
58576888252Smrg
58676888252Smrg  # Remove `-o $object'.
58776888252Smrg  IFS=" "
58876888252Smrg  for arg
58976888252Smrg  do
59076888252Smrg    case $arg in
59176888252Smrg    -o)
59276888252Smrg      shift
59376888252Smrg      ;;
59476888252Smrg    $object)
59576888252Smrg      shift
59676888252Smrg      ;;
59776888252Smrg    *)
59876888252Smrg      set fnord "$@" "$arg"
59976888252Smrg      shift # fnord
60076888252Smrg      shift # $arg
60176888252Smrg      ;;
60276888252Smrg    esac
60376888252Smrg  done
60476888252Smrg
60576888252Smrg  "$@" -E |
60676888252Smrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
60776888252Smrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
60876888252Smrg    sed '$ s: \\$::' > "$tmpdepfile"
60976888252Smrg  rm -f "$depfile"
61076888252Smrg  echo "$object : \\" > "$depfile"
61176888252Smrg  cat < "$tmpdepfile" >> "$depfile"
61276888252Smrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
61376888252Smrg  rm -f "$tmpdepfile"
61476888252Smrg  ;;
61576888252Smrg
61676888252Smrgmsvisualcpp)
61776888252Smrg  # Important note: in order to support this mode, a compiler *must*
618d8556812Smrg  # always write the preprocessed file to stdout.
61976888252Smrg  "$@" || exit $?
620d8556812Smrg
621d8556812Smrg  # Remove the call to Libtool.
622d8556812Smrg  if test "$libtool" = yes; then
623d8556812Smrg    while test "X$1" != 'X--mode=compile'; do
624d8556812Smrg      shift
625d8556812Smrg    done
626d8556812Smrg    shift
627d8556812Smrg  fi
628d8556812Smrg
62976888252Smrg  IFS=" "
63076888252Smrg  for arg
63176888252Smrg  do
63276888252Smrg    case "$arg" in
633d8556812Smrg    -o)
634d8556812Smrg      shift
635d8556812Smrg      ;;
636d8556812Smrg    $object)
637d8556812Smrg      shift
638d8556812Smrg      ;;
63976888252Smrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
64076888252Smrg	set fnord "$@"
64176888252Smrg	shift
64276888252Smrg	shift
64376888252Smrg	;;
64476888252Smrg    *)
64576888252Smrg	set fnord "$@" "$arg"
64676888252Smrg	shift
64776888252Smrg	shift
64876888252Smrg	;;
64976888252Smrg    esac
65076888252Smrg  done
651d8556812Smrg  "$@" -E 2>/dev/null |
652d8556812Smrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
65376888252Smrg  rm -f "$depfile"
65476888252Smrg  echo "$object : \\" > "$depfile"
655d8556812Smrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
65676888252Smrg  echo "	" >> "$depfile"
657d8556812Smrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
65876888252Smrg  rm -f "$tmpdepfile"
65976888252Smrg  ;;
66076888252Smrg
661d8556812Smrgmsvcmsys)
662d8556812Smrg  # This case exists only to let depend.m4 do its work.  It works by
663d8556812Smrg  # looking at the text of this script.  This case will never be run,
664d8556812Smrg  # since it is checked for above.
665d8556812Smrg  exit 1
666d8556812Smrg  ;;
667d8556812Smrg
66876888252Smrgnone)
66976888252Smrg  exec "$@"
67076888252Smrg  ;;
67176888252Smrg
67276888252Smrg*)
67376888252Smrg  echo "Unknown depmode $depmode" 1>&2
67476888252Smrg  exit 1
67576888252Smrg  ;;
67676888252Smrgesac
67776888252Smrg
67876888252Smrgexit 0
67976888252Smrg
68076888252Smrg# Local Variables:
68176888252Smrg# mode: shell-script
68276888252Smrg# sh-indentation: 2
68376888252Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
68476888252Smrg# time-stamp-start: "scriptversion="
68576888252Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
686d8556812Smrg# time-stamp-time-zone: "UTC"
687d8556812Smrg# time-stamp-end: "; # UTC"
68876888252Smrg# End:
689