depcomp revision 76910425
176910425Smrg#! /bin/sh
276910425Smrg# depcomp - compile a program generating dependencies as side-effects
376910425Smrg
476910425Smrgscriptversion=2005-07-09.11
576910425Smrg
676910425Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
776910425Smrg
876910425Smrg# This program is free software; you can redistribute it and/or modify
976910425Smrg# it under the terms of the GNU General Public License as published by
1076910425Smrg# the Free Software Foundation; either version 2, or (at your option)
1176910425Smrg# any later version.
1276910425Smrg
1376910425Smrg# This program is distributed in the hope that it will be useful,
1476910425Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1576910425Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1676910425Smrg# GNU General Public License for more details.
1776910425Smrg
1876910425Smrg# You should have received a copy of the GNU General Public License
1976910425Smrg# along with this program; if not, write to the Free Software
2076910425Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2176910425Smrg# 02110-1301, USA.
2276910425Smrg
2376910425Smrg# As a special exception to the GNU General Public License, if you
2476910425Smrg# distribute this file as part of a program that contains a
2576910425Smrg# configuration script generated by Autoconf, you may include it under
2676910425Smrg# the same distribution terms that you use for the rest of that program.
2776910425Smrg
2876910425Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
2976910425Smrg
3076910425Smrgcase $1 in
3176910425Smrg  '')
3276910425Smrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
3376910425Smrg     exit 1;
3476910425Smrg     ;;
3576910425Smrg  -h | --h*)
3676910425Smrg    cat <<\EOF
3776910425SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
3876910425Smrg
3976910425SmrgRun PROGRAMS ARGS to compile a file, generating dependencies
4076910425Smrgas side-effects.
4176910425Smrg
4276910425SmrgEnvironment variables:
4376910425Smrg  depmode     Dependency tracking mode.
4476910425Smrg  source      Source file read by `PROGRAMS ARGS'.
4576910425Smrg  object      Object file output by `PROGRAMS ARGS'.
4676910425Smrg  DEPDIR      directory where to store dependencies.
4776910425Smrg  depfile     Dependency file to output.
4876910425Smrg  tmpdepfile  Temporary file to use when outputing dependencies.
4976910425Smrg  libtool     Whether libtool is used (yes/no).
5076910425Smrg
5176910425SmrgReport bugs to <bug-automake@gnu.org>.
5276910425SmrgEOF
5376910425Smrg    exit $?
5476910425Smrg    ;;
5576910425Smrg  -v | --v*)
5676910425Smrg    echo "depcomp $scriptversion"
5776910425Smrg    exit $?
5876910425Smrg    ;;
5976910425Smrgesac
6076910425Smrg
6176910425Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
6276910425Smrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
6376910425Smrg  exit 1
6476910425Smrgfi
6576910425Smrg
6676910425Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
6776910425Smrgdepfile=${depfile-`echo "$object" |
6876910425Smrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
6976910425Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
7076910425Smrg
7176910425Smrgrm -f "$tmpdepfile"
7276910425Smrg
7376910425Smrg# Some modes work just like other modes, but use different flags.  We
7476910425Smrg# parameterize here, but still list the modes in the big case below,
7576910425Smrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
7676910425Smrg# here, because this file can only contain one case statement.
7776910425Smrgif test "$depmode" = hp; then
7876910425Smrg  # HP compiler uses -M and no extra arg.
7976910425Smrg  gccflag=-M
8076910425Smrg  depmode=gcc
8176910425Smrgfi
8276910425Smrg
8376910425Smrgif test "$depmode" = dashXmstdout; then
8476910425Smrg   # This is just like dashmstdout with a different argument.
8576910425Smrg   dashmflag=-xM
8676910425Smrg   depmode=dashmstdout
8776910425Smrgfi
8876910425Smrg
8976910425Smrgcase "$depmode" in
9076910425Smrggcc3)
9176910425Smrg## gcc 3 implements dependency tracking that does exactly what
9276910425Smrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
9376910425Smrg## it if -MD -MP comes after the -MF stuff.  Hmm.
9476910425Smrg  "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
9576910425Smrg  stat=$?
9676910425Smrg  if test $stat -eq 0; then :
9776910425Smrg  else
9876910425Smrg    rm -f "$tmpdepfile"
9976910425Smrg    exit $stat
10076910425Smrg  fi
10176910425Smrg  mv "$tmpdepfile" "$depfile"
10276910425Smrg  ;;
10376910425Smrg
10476910425Smrggcc)
10576910425Smrg## There are various ways to get dependency output from gcc.  Here's
10676910425Smrg## why we pick this rather obscure method:
10776910425Smrg## - Don't want to use -MD because we'd like the dependencies to end
10876910425Smrg##   up in a subdir.  Having to rename by hand is ugly.
10976910425Smrg##   (We might end up doing this anyway to support other compilers.)
11076910425Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
11176910425Smrg##   -MM, not -M (despite what the docs say).
11276910425Smrg## - Using -M directly means running the compiler twice (even worse
11376910425Smrg##   than renaming).
11476910425Smrg  if test -z "$gccflag"; then
11576910425Smrg    gccflag=-MD,
11676910425Smrg  fi
11776910425Smrg  "$@" -Wp,"$gccflag$tmpdepfile"
11876910425Smrg  stat=$?
11976910425Smrg  if test $stat -eq 0; then :
12076910425Smrg  else
12176910425Smrg    rm -f "$tmpdepfile"
12276910425Smrg    exit $stat
12376910425Smrg  fi
12476910425Smrg  rm -f "$depfile"
12576910425Smrg  echo "$object : \\" > "$depfile"
12676910425Smrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
12776910425Smrg## The second -e expression handles DOS-style file names with drive letters.
12876910425Smrg  sed -e 's/^[^:]*: / /' \
12976910425Smrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
13076910425Smrg## This next piece of magic avoids the `deleted header file' problem.
13176910425Smrg## The problem is that when a header file which appears in a .P file
13276910425Smrg## is deleted, the dependency causes make to die (because there is
13376910425Smrg## typically no way to rebuild the header).  We avoid this by adding
13476910425Smrg## dummy dependencies for each header file.  Too bad gcc doesn't do
13576910425Smrg## this for us directly.
13676910425Smrg  tr ' ' '
13776910425Smrg' < "$tmpdepfile" |
13876910425Smrg## Some versions of gcc put a space before the `:'.  On the theory
13976910425Smrg## that the space means something, we add a space to the output as
14076910425Smrg## well.
14176910425Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
14276910425Smrg## correctly.  Breaking it into two sed invocations is a workaround.
14376910425Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
14476910425Smrg  rm -f "$tmpdepfile"
14576910425Smrg  ;;
14676910425Smrg
14776910425Smrghp)
14876910425Smrg  # This case exists only to let depend.m4 do its work.  It works by
14976910425Smrg  # looking at the text of this script.  This case will never be run,
15076910425Smrg  # since it is checked for above.
15176910425Smrg  exit 1
15276910425Smrg  ;;
15376910425Smrg
15476910425Smrgsgi)
15576910425Smrg  if test "$libtool" = yes; then
15676910425Smrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
15776910425Smrg  else
15876910425Smrg    "$@" -MDupdate "$tmpdepfile"
15976910425Smrg  fi
16076910425Smrg  stat=$?
16176910425Smrg  if test $stat -eq 0; then :
16276910425Smrg  else
16376910425Smrg    rm -f "$tmpdepfile"
16476910425Smrg    exit $stat
16576910425Smrg  fi
16676910425Smrg  rm -f "$depfile"
16776910425Smrg
16876910425Smrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
16976910425Smrg    echo "$object : \\" > "$depfile"
17076910425Smrg
17176910425Smrg    # Clip off the initial element (the dependent).  Don't try to be
17276910425Smrg    # clever and replace this with sed code, as IRIX sed won't handle
17376910425Smrg    # lines with more than a fixed number of characters (4096 in
17476910425Smrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
17576910425Smrg    # the IRIX cc adds comments like `#:fec' to the end of the
17676910425Smrg    # dependency line.
17776910425Smrg    tr ' ' '
17876910425Smrg' < "$tmpdepfile" \
17976910425Smrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
18076910425Smrg    tr '
18176910425Smrg' ' ' >> $depfile
18276910425Smrg    echo >> $depfile
18376910425Smrg
18476910425Smrg    # The second pass generates a dummy entry for each header file.
18576910425Smrg    tr ' ' '
18676910425Smrg' < "$tmpdepfile" \
18776910425Smrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
18876910425Smrg   >> $depfile
18976910425Smrg  else
19076910425Smrg    # The sourcefile does not contain any dependencies, so just
19176910425Smrg    # store a dummy comment line, to avoid errors with the Makefile
19276910425Smrg    # "include basename.Plo" scheme.
19376910425Smrg    echo "#dummy" > "$depfile"
19476910425Smrg  fi
19576910425Smrg  rm -f "$tmpdepfile"
19676910425Smrg  ;;
19776910425Smrg
19876910425Smrgaix)
19976910425Smrg  # The C for AIX Compiler uses -M and outputs the dependencies
20076910425Smrg  # in a .u file.  In older versions, this file always lives in the
20176910425Smrg  # current directory.  Also, the AIX compiler puts `$object:' at the
20276910425Smrg  # start of each line; $object doesn't have directory information.
20376910425Smrg  # Version 6 uses the directory in both cases.
20476910425Smrg  stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
20576910425Smrg  tmpdepfile="$stripped.u"
20676910425Smrg  if test "$libtool" = yes; then
20776910425Smrg    "$@" -Wc,-M
20876910425Smrg  else
20976910425Smrg    "$@" -M
21076910425Smrg  fi
21176910425Smrg  stat=$?
21276910425Smrg
21376910425Smrg  if test -f "$tmpdepfile"; then :
21476910425Smrg  else
21576910425Smrg    stripped=`echo "$stripped" | sed 's,^.*/,,'`
21676910425Smrg    tmpdepfile="$stripped.u"
21776910425Smrg  fi
21876910425Smrg
21976910425Smrg  if test $stat -eq 0; then :
22076910425Smrg  else
22176910425Smrg    rm -f "$tmpdepfile"
22276910425Smrg    exit $stat
22376910425Smrg  fi
22476910425Smrg
22576910425Smrg  if test -f "$tmpdepfile"; then
22676910425Smrg    outname="$stripped.o"
22776910425Smrg    # Each line is of the form `foo.o: dependent.h'.
22876910425Smrg    # Do two passes, one to just change these to
22976910425Smrg    # `$object: dependent.h' and one to simply `dependent.h:'.
23076910425Smrg    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
23176910425Smrg    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
23276910425Smrg  else
23376910425Smrg    # The sourcefile does not contain any dependencies, so just
23476910425Smrg    # store a dummy comment line, to avoid errors with the Makefile
23576910425Smrg    # "include basename.Plo" scheme.
23676910425Smrg    echo "#dummy" > "$depfile"
23776910425Smrg  fi
23876910425Smrg  rm -f "$tmpdepfile"
23976910425Smrg  ;;
24076910425Smrg
24176910425Smrgicc)
24276910425Smrg  # Intel's C compiler understands `-MD -MF file'.  However on
24376910425Smrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
24476910425Smrg  # ICC 7.0 will fill foo.d with something like
24576910425Smrg  #    foo.o: sub/foo.c
24676910425Smrg  #    foo.o: sub/foo.h
24776910425Smrg  # which is wrong.  We want:
24876910425Smrg  #    sub/foo.o: sub/foo.c
24976910425Smrg  #    sub/foo.o: sub/foo.h
25076910425Smrg  #    sub/foo.c:
25176910425Smrg  #    sub/foo.h:
25276910425Smrg  # ICC 7.1 will output
25376910425Smrg  #    foo.o: sub/foo.c sub/foo.h
25476910425Smrg  # and will wrap long lines using \ :
25576910425Smrg  #    foo.o: sub/foo.c ... \
25676910425Smrg  #     sub/foo.h ... \
25776910425Smrg  #     ...
25876910425Smrg
25976910425Smrg  "$@" -MD -MF "$tmpdepfile"
26076910425Smrg  stat=$?
26176910425Smrg  if test $stat -eq 0; then :
26276910425Smrg  else
26376910425Smrg    rm -f "$tmpdepfile"
26476910425Smrg    exit $stat
26576910425Smrg  fi
26676910425Smrg  rm -f "$depfile"
26776910425Smrg  # Each line is of the form `foo.o: dependent.h',
26876910425Smrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
26976910425Smrg  # Do two passes, one to just change these to
27076910425Smrg  # `$object: dependent.h' and one to simply `dependent.h:'.
27176910425Smrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
27276910425Smrg  # Some versions of the HPUX 10.20 sed can't process this invocation
27376910425Smrg  # correctly.  Breaking it into two sed invocations is a workaround.
27476910425Smrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
27576910425Smrg    sed -e 's/$/ :/' >> "$depfile"
27676910425Smrg  rm -f "$tmpdepfile"
27776910425Smrg  ;;
27876910425Smrg
27976910425Smrgtru64)
28076910425Smrg   # The Tru64 compiler uses -MD to generate dependencies as a side
28176910425Smrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
28276910425Smrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
28376910425Smrg   # dependencies in `foo.d' instead, so we check for that too.
28476910425Smrg   # Subdirectories are respected.
28576910425Smrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
28676910425Smrg   test "x$dir" = "x$object" && dir=
28776910425Smrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
28876910425Smrg
28976910425Smrg   if test "$libtool" = yes; then
29076910425Smrg      # With Tru64 cc, shared objects can also be used to make a
29176910425Smrg      # static library.  This mecanism is used in libtool 1.4 series to
29276910425Smrg      # handle both shared and static libraries in a single compilation.
29376910425Smrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
29476910425Smrg      #
29576910425Smrg      # With libtool 1.5 this exception was removed, and libtool now
29676910425Smrg      # generates 2 separate objects for the 2 libraries.  These two
29776910425Smrg      # compilations output dependencies in in $dir.libs/$base.o.d and
29876910425Smrg      # in $dir$base.o.d.  We have to check for both files, because
29976910425Smrg      # one of the two compilations can be disabled.  We should prefer
30076910425Smrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
30176910425Smrg      # automatically cleaned when .libs/ is deleted, while ignoring
30276910425Smrg      # the former would cause a distcleancheck panic.
30376910425Smrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
30476910425Smrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
30576910425Smrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
30676910425Smrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
30776910425Smrg      "$@" -Wc,-MD
30876910425Smrg   else
30976910425Smrg      tmpdepfile1=$dir$base.o.d
31076910425Smrg      tmpdepfile2=$dir$base.d
31176910425Smrg      tmpdepfile3=$dir$base.d
31276910425Smrg      tmpdepfile4=$dir$base.d
31376910425Smrg      "$@" -MD
31476910425Smrg   fi
31576910425Smrg
31676910425Smrg   stat=$?
31776910425Smrg   if test $stat -eq 0; then :
31876910425Smrg   else
31976910425Smrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
32076910425Smrg      exit $stat
32176910425Smrg   fi
32276910425Smrg
32376910425Smrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
32476910425Smrg   do
32576910425Smrg     test -f "$tmpdepfile" && break
32676910425Smrg   done
32776910425Smrg   if test -f "$tmpdepfile"; then
32876910425Smrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
32976910425Smrg      # That's a tab and a space in the [].
33076910425Smrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
33176910425Smrg   else
33276910425Smrg      echo "#dummy" > "$depfile"
33376910425Smrg   fi
33476910425Smrg   rm -f "$tmpdepfile"
33576910425Smrg   ;;
33676910425Smrg
33776910425Smrg#nosideeffect)
33876910425Smrg  # This comment above is used by automake to tell side-effect
33976910425Smrg  # dependency tracking mechanisms from slower ones.
34076910425Smrg
34176910425Smrgdashmstdout)
34276910425Smrg  # Important note: in order to support this mode, a compiler *must*
34376910425Smrg  # always write the preprocessed file to stdout, regardless of -o.
34476910425Smrg  "$@" || exit $?
34576910425Smrg
34676910425Smrg  # Remove the call to Libtool.
34776910425Smrg  if test "$libtool" = yes; then
34876910425Smrg    while test $1 != '--mode=compile'; do
34976910425Smrg      shift
35076910425Smrg    done
35176910425Smrg    shift
35276910425Smrg  fi
35376910425Smrg
35476910425Smrg  # Remove `-o $object'.
35576910425Smrg  IFS=" "
35676910425Smrg  for arg
35776910425Smrg  do
35876910425Smrg    case $arg in
35976910425Smrg    -o)
36076910425Smrg      shift
36176910425Smrg      ;;
36276910425Smrg    $object)
36376910425Smrg      shift
36476910425Smrg      ;;
36576910425Smrg    *)
36676910425Smrg      set fnord "$@" "$arg"
36776910425Smrg      shift # fnord
36876910425Smrg      shift # $arg
36976910425Smrg      ;;
37076910425Smrg    esac
37176910425Smrg  done
37276910425Smrg
37376910425Smrg  test -z "$dashmflag" && dashmflag=-M
37476910425Smrg  # Require at least two characters before searching for `:'
37576910425Smrg  # in the target name.  This is to cope with DOS-style filenames:
37676910425Smrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
37776910425Smrg  "$@" $dashmflag |
37876910425Smrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
37976910425Smrg  rm -f "$depfile"
38076910425Smrg  cat < "$tmpdepfile" > "$depfile"
38176910425Smrg  tr ' ' '
38276910425Smrg' < "$tmpdepfile" | \
38376910425Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
38476910425Smrg## correctly.  Breaking it into two sed invocations is a workaround.
38576910425Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
38676910425Smrg  rm -f "$tmpdepfile"
38776910425Smrg  ;;
38876910425Smrg
38976910425SmrgdashXmstdout)
39076910425Smrg  # This case only exists to satisfy depend.m4.  It is never actually
39176910425Smrg  # run, as this mode is specially recognized in the preamble.
39276910425Smrg  exit 1
39376910425Smrg  ;;
39476910425Smrg
39576910425Smrgmakedepend)
39676910425Smrg  "$@" || exit $?
39776910425Smrg  # Remove any Libtool call
39876910425Smrg  if test "$libtool" = yes; then
39976910425Smrg    while test $1 != '--mode=compile'; do
40076910425Smrg      shift
40176910425Smrg    done
40276910425Smrg    shift
40376910425Smrg  fi
40476910425Smrg  # X makedepend
40576910425Smrg  shift
40676910425Smrg  cleared=no
40776910425Smrg  for arg in "$@"; do
40876910425Smrg    case $cleared in
40976910425Smrg    no)
41076910425Smrg      set ""; shift
41176910425Smrg      cleared=yes ;;
41276910425Smrg    esac
41376910425Smrg    case "$arg" in
41476910425Smrg    -D*|-I*)
41576910425Smrg      set fnord "$@" "$arg"; shift ;;
41676910425Smrg    # Strip any option that makedepend may not understand.  Remove
41776910425Smrg    # the object too, otherwise makedepend will parse it as a source file.
41876910425Smrg    -*|$object)
41976910425Smrg      ;;
42076910425Smrg    *)
42176910425Smrg      set fnord "$@" "$arg"; shift ;;
42276910425Smrg    esac
42376910425Smrg  done
42476910425Smrg  obj_suffix="`echo $object | sed 's/^.*\././'`"
42576910425Smrg  touch "$tmpdepfile"
42676910425Smrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
42776910425Smrg  rm -f "$depfile"
42876910425Smrg  cat < "$tmpdepfile" > "$depfile"
42976910425Smrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
43076910425Smrg' | \
43176910425Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
43276910425Smrg## correctly.  Breaking it into two sed invocations is a workaround.
43376910425Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
43476910425Smrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
43576910425Smrg  ;;
43676910425Smrg
43776910425Smrgcpp)
43876910425Smrg  # Important note: in order to support this mode, a compiler *must*
43976910425Smrg  # always write the preprocessed file to stdout.
44076910425Smrg  "$@" || exit $?
44176910425Smrg
44276910425Smrg  # Remove the call to Libtool.
44376910425Smrg  if test "$libtool" = yes; then
44476910425Smrg    while test $1 != '--mode=compile'; do
44576910425Smrg      shift
44676910425Smrg    done
44776910425Smrg    shift
44876910425Smrg  fi
44976910425Smrg
45076910425Smrg  # Remove `-o $object'.
45176910425Smrg  IFS=" "
45276910425Smrg  for arg
45376910425Smrg  do
45476910425Smrg    case $arg in
45576910425Smrg    -o)
45676910425Smrg      shift
45776910425Smrg      ;;
45876910425Smrg    $object)
45976910425Smrg      shift
46076910425Smrg      ;;
46176910425Smrg    *)
46276910425Smrg      set fnord "$@" "$arg"
46376910425Smrg      shift # fnord
46476910425Smrg      shift # $arg
46576910425Smrg      ;;
46676910425Smrg    esac
46776910425Smrg  done
46876910425Smrg
46976910425Smrg  "$@" -E |
47076910425Smrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
47176910425Smrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
47276910425Smrg    sed '$ s: \\$::' > "$tmpdepfile"
47376910425Smrg  rm -f "$depfile"
47476910425Smrg  echo "$object : \\" > "$depfile"
47576910425Smrg  cat < "$tmpdepfile" >> "$depfile"
47676910425Smrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
47776910425Smrg  rm -f "$tmpdepfile"
47876910425Smrg  ;;
47976910425Smrg
48076910425Smrgmsvisualcpp)
48176910425Smrg  # Important note: in order to support this mode, a compiler *must*
48276910425Smrg  # always write the preprocessed file to stdout, regardless of -o,
48376910425Smrg  # because we must use -o when running libtool.
48476910425Smrg  "$@" || exit $?
48576910425Smrg  IFS=" "
48676910425Smrg  for arg
48776910425Smrg  do
48876910425Smrg    case "$arg" in
48976910425Smrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
49076910425Smrg	set fnord "$@"
49176910425Smrg	shift
49276910425Smrg	shift
49376910425Smrg	;;
49476910425Smrg    *)
49576910425Smrg	set fnord "$@" "$arg"
49676910425Smrg	shift
49776910425Smrg	shift
49876910425Smrg	;;
49976910425Smrg    esac
50076910425Smrg  done
50176910425Smrg  "$@" -E |
50276910425Smrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
50376910425Smrg  rm -f "$depfile"
50476910425Smrg  echo "$object : \\" > "$depfile"
50576910425Smrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
50676910425Smrg  echo "	" >> "$depfile"
50776910425Smrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
50876910425Smrg  rm -f "$tmpdepfile"
50976910425Smrg  ;;
51076910425Smrg
51176910425Smrgnone)
51276910425Smrg  exec "$@"
51376910425Smrg  ;;
51476910425Smrg
51576910425Smrg*)
51676910425Smrg  echo "Unknown depmode $depmode" 1>&2
51776910425Smrg  exit 1
51876910425Smrg  ;;
51976910425Smrgesac
52076910425Smrg
52176910425Smrgexit 0
52276910425Smrg
52376910425Smrg# Local Variables:
52476910425Smrg# mode: shell-script
52576910425Smrg# sh-indentation: 2
52676910425Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
52776910425Smrg# time-stamp-start: "scriptversion="
52876910425Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
52976910425Smrg# time-stamp-end: "$"
53076910425Smrg# End:
531