depcomp revision 76888252
176888252Smrg#! /bin/sh
276888252Smrg# depcomp - compile a program generating dependencies as side-effects
376888252Smrg
476888252Smrgscriptversion=2005-07-09.11
576888252Smrg
676888252Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
776888252Smrg
876888252Smrg# This program is free software; you can redistribute it and/or modify
976888252Smrg# it under the terms of the GNU General Public License as published by
1076888252Smrg# the Free Software Foundation; either version 2, or (at your option)
1176888252Smrg# any later version.
1276888252Smrg
1376888252Smrg# This program is distributed in the hope that it will be useful,
1476888252Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1576888252Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1676888252Smrg# GNU General Public License for more details.
1776888252Smrg
1876888252Smrg# You should have received a copy of the GNU General Public License
1976888252Smrg# along with this program; if not, write to the Free Software
2076888252Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2176888252Smrg# 02110-1301, USA.
2276888252Smrg
2376888252Smrg# As a special exception to the GNU General Public License, if you
2476888252Smrg# distribute this file as part of a program that contains a
2576888252Smrg# configuration script generated by Autoconf, you may include it under
2676888252Smrg# the same distribution terms that you use for the rest of that program.
2776888252Smrg
2876888252Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
2976888252Smrg
3076888252Smrgcase $1 in
3176888252Smrg  '')
3276888252Smrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
3376888252Smrg     exit 1;
3476888252Smrg     ;;
3576888252Smrg  -h | --h*)
3676888252Smrg    cat <<\EOF
3776888252SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
3876888252Smrg
3976888252SmrgRun PROGRAMS ARGS to compile a file, generating dependencies
4076888252Smrgas side-effects.
4176888252Smrg
4276888252SmrgEnvironment variables:
4376888252Smrg  depmode     Dependency tracking mode.
4476888252Smrg  source      Source file read by `PROGRAMS ARGS'.
4576888252Smrg  object      Object file output by `PROGRAMS ARGS'.
4676888252Smrg  DEPDIR      directory where to store dependencies.
4776888252Smrg  depfile     Dependency file to output.
4876888252Smrg  tmpdepfile  Temporary file to use when outputing dependencies.
4976888252Smrg  libtool     Whether libtool is used (yes/no).
5076888252Smrg
5176888252SmrgReport bugs to <bug-automake@gnu.org>.
5276888252SmrgEOF
5376888252Smrg    exit $?
5476888252Smrg    ;;
5576888252Smrg  -v | --v*)
5676888252Smrg    echo "depcomp $scriptversion"
5776888252Smrg    exit $?
5876888252Smrg    ;;
5976888252Smrgesac
6076888252Smrg
6176888252Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
6276888252Smrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
6376888252Smrg  exit 1
6476888252Smrgfi
6576888252Smrg
6676888252Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
6776888252Smrgdepfile=${depfile-`echo "$object" |
6876888252Smrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
6976888252Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
7076888252Smrg
7176888252Smrgrm -f "$tmpdepfile"
7276888252Smrg
7376888252Smrg# Some modes work just like other modes, but use different flags.  We
7476888252Smrg# parameterize here, but still list the modes in the big case below,
7576888252Smrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
7676888252Smrg# here, because this file can only contain one case statement.
7776888252Smrgif test "$depmode" = hp; then
7876888252Smrg  # HP compiler uses -M and no extra arg.
7976888252Smrg  gccflag=-M
8076888252Smrg  depmode=gcc
8176888252Smrgfi
8276888252Smrg
8376888252Smrgif test "$depmode" = dashXmstdout; then
8476888252Smrg   # This is just like dashmstdout with a different argument.
8576888252Smrg   dashmflag=-xM
8676888252Smrg   depmode=dashmstdout
8776888252Smrgfi
8876888252Smrg
8976888252Smrgcase "$depmode" in
9076888252Smrggcc3)
9176888252Smrg## gcc 3 implements dependency tracking that does exactly what
9276888252Smrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
9376888252Smrg## it if -MD -MP comes after the -MF stuff.  Hmm.
9476888252Smrg  "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
9576888252Smrg  stat=$?
9676888252Smrg  if test $stat -eq 0; then :
9776888252Smrg  else
9876888252Smrg    rm -f "$tmpdepfile"
9976888252Smrg    exit $stat
10076888252Smrg  fi
10176888252Smrg  mv "$tmpdepfile" "$depfile"
10276888252Smrg  ;;
10376888252Smrg
10476888252Smrggcc)
10576888252Smrg## There are various ways to get dependency output from gcc.  Here's
10676888252Smrg## why we pick this rather obscure method:
10776888252Smrg## - Don't want to use -MD because we'd like the dependencies to end
10876888252Smrg##   up in a subdir.  Having to rename by hand is ugly.
10976888252Smrg##   (We might end up doing this anyway to support other compilers.)
11076888252Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
11176888252Smrg##   -MM, not -M (despite what the docs say).
11276888252Smrg## - Using -M directly means running the compiler twice (even worse
11376888252Smrg##   than renaming).
11476888252Smrg  if test -z "$gccflag"; then
11576888252Smrg    gccflag=-MD,
11676888252Smrg  fi
11776888252Smrg  "$@" -Wp,"$gccflag$tmpdepfile"
11876888252Smrg  stat=$?
11976888252Smrg  if test $stat -eq 0; then :
12076888252Smrg  else
12176888252Smrg    rm -f "$tmpdepfile"
12276888252Smrg    exit $stat
12376888252Smrg  fi
12476888252Smrg  rm -f "$depfile"
12576888252Smrg  echo "$object : \\" > "$depfile"
12676888252Smrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
12776888252Smrg## The second -e expression handles DOS-style file names with drive letters.
12876888252Smrg  sed -e 's/^[^:]*: / /' \
12976888252Smrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
13076888252Smrg## This next piece of magic avoids the `deleted header file' problem.
13176888252Smrg## The problem is that when a header file which appears in a .P file
13276888252Smrg## is deleted, the dependency causes make to die (because there is
13376888252Smrg## typically no way to rebuild the header).  We avoid this by adding
13476888252Smrg## dummy dependencies for each header file.  Too bad gcc doesn't do
13576888252Smrg## this for us directly.
13676888252Smrg  tr ' ' '
13776888252Smrg' < "$tmpdepfile" |
13876888252Smrg## Some versions of gcc put a space before the `:'.  On the theory
13976888252Smrg## that the space means something, we add a space to the output as
14076888252Smrg## well.
14176888252Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
14276888252Smrg## correctly.  Breaking it into two sed invocations is a workaround.
14376888252Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
14476888252Smrg  rm -f "$tmpdepfile"
14576888252Smrg  ;;
14676888252Smrg
14776888252Smrghp)
14876888252Smrg  # This case exists only to let depend.m4 do its work.  It works by
14976888252Smrg  # looking at the text of this script.  This case will never be run,
15076888252Smrg  # since it is checked for above.
15176888252Smrg  exit 1
15276888252Smrg  ;;
15376888252Smrg
15476888252Smrgsgi)
15576888252Smrg  if test "$libtool" = yes; then
15676888252Smrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
15776888252Smrg  else
15876888252Smrg    "$@" -MDupdate "$tmpdepfile"
15976888252Smrg  fi
16076888252Smrg  stat=$?
16176888252Smrg  if test $stat -eq 0; then :
16276888252Smrg  else
16376888252Smrg    rm -f "$tmpdepfile"
16476888252Smrg    exit $stat
16576888252Smrg  fi
16676888252Smrg  rm -f "$depfile"
16776888252Smrg
16876888252Smrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
16976888252Smrg    echo "$object : \\" > "$depfile"
17076888252Smrg
17176888252Smrg    # Clip off the initial element (the dependent).  Don't try to be
17276888252Smrg    # clever and replace this with sed code, as IRIX sed won't handle
17376888252Smrg    # lines with more than a fixed number of characters (4096 in
17476888252Smrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
17576888252Smrg    # the IRIX cc adds comments like `#:fec' to the end of the
17676888252Smrg    # dependency line.
17776888252Smrg    tr ' ' '
17876888252Smrg' < "$tmpdepfile" \
17976888252Smrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
18076888252Smrg    tr '
18176888252Smrg' ' ' >> $depfile
18276888252Smrg    echo >> $depfile
18376888252Smrg
18476888252Smrg    # The second pass generates a dummy entry for each header file.
18576888252Smrg    tr ' ' '
18676888252Smrg' < "$tmpdepfile" \
18776888252Smrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
18876888252Smrg   >> $depfile
18976888252Smrg  else
19076888252Smrg    # The sourcefile does not contain any dependencies, so just
19176888252Smrg    # store a dummy comment line, to avoid errors with the Makefile
19276888252Smrg    # "include basename.Plo" scheme.
19376888252Smrg    echo "#dummy" > "$depfile"
19476888252Smrg  fi
19576888252Smrg  rm -f "$tmpdepfile"
19676888252Smrg  ;;
19776888252Smrg
19876888252Smrgaix)
19976888252Smrg  # The C for AIX Compiler uses -M and outputs the dependencies
20076888252Smrg  # in a .u file.  In older versions, this file always lives in the
20176888252Smrg  # current directory.  Also, the AIX compiler puts `$object:' at the
20276888252Smrg  # start of each line; $object doesn't have directory information.
20376888252Smrg  # Version 6 uses the directory in both cases.
20476888252Smrg  stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
20576888252Smrg  tmpdepfile="$stripped.u"
20676888252Smrg  if test "$libtool" = yes; then
20776888252Smrg    "$@" -Wc,-M
20876888252Smrg  else
20976888252Smrg    "$@" -M
21076888252Smrg  fi
21176888252Smrg  stat=$?
21276888252Smrg
21376888252Smrg  if test -f "$tmpdepfile"; then :
21476888252Smrg  else
21576888252Smrg    stripped=`echo "$stripped" | sed 's,^.*/,,'`
21676888252Smrg    tmpdepfile="$stripped.u"
21776888252Smrg  fi
21876888252Smrg
21976888252Smrg  if test $stat -eq 0; then :
22076888252Smrg  else
22176888252Smrg    rm -f "$tmpdepfile"
22276888252Smrg    exit $stat
22376888252Smrg  fi
22476888252Smrg
22576888252Smrg  if test -f "$tmpdepfile"; then
22676888252Smrg    outname="$stripped.o"
22776888252Smrg    # Each line is of the form `foo.o: dependent.h'.
22876888252Smrg    # Do two passes, one to just change these to
22976888252Smrg    # `$object: dependent.h' and one to simply `dependent.h:'.
23076888252Smrg    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
23176888252Smrg    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
23276888252Smrg  else
23376888252Smrg    # The sourcefile does not contain any dependencies, so just
23476888252Smrg    # store a dummy comment line, to avoid errors with the Makefile
23576888252Smrg    # "include basename.Plo" scheme.
23676888252Smrg    echo "#dummy" > "$depfile"
23776888252Smrg  fi
23876888252Smrg  rm -f "$tmpdepfile"
23976888252Smrg  ;;
24076888252Smrg
24176888252Smrgicc)
24276888252Smrg  # Intel's C compiler understands `-MD -MF file'.  However on
24376888252Smrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
24476888252Smrg  # ICC 7.0 will fill foo.d with something like
24576888252Smrg  #    foo.o: sub/foo.c
24676888252Smrg  #    foo.o: sub/foo.h
24776888252Smrg  # which is wrong.  We want:
24876888252Smrg  #    sub/foo.o: sub/foo.c
24976888252Smrg  #    sub/foo.o: sub/foo.h
25076888252Smrg  #    sub/foo.c:
25176888252Smrg  #    sub/foo.h:
25276888252Smrg  # ICC 7.1 will output
25376888252Smrg  #    foo.o: sub/foo.c sub/foo.h
25476888252Smrg  # and will wrap long lines using \ :
25576888252Smrg  #    foo.o: sub/foo.c ... \
25676888252Smrg  #     sub/foo.h ... \
25776888252Smrg  #     ...
25876888252Smrg
25976888252Smrg  "$@" -MD -MF "$tmpdepfile"
26076888252Smrg  stat=$?
26176888252Smrg  if test $stat -eq 0; then :
26276888252Smrg  else
26376888252Smrg    rm -f "$tmpdepfile"
26476888252Smrg    exit $stat
26576888252Smrg  fi
26676888252Smrg  rm -f "$depfile"
26776888252Smrg  # Each line is of the form `foo.o: dependent.h',
26876888252Smrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
26976888252Smrg  # Do two passes, one to just change these to
27076888252Smrg  # `$object: dependent.h' and one to simply `dependent.h:'.
27176888252Smrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
27276888252Smrg  # Some versions of the HPUX 10.20 sed can't process this invocation
27376888252Smrg  # correctly.  Breaking it into two sed invocations is a workaround.
27476888252Smrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
27576888252Smrg    sed -e 's/$/ :/' >> "$depfile"
27676888252Smrg  rm -f "$tmpdepfile"
27776888252Smrg  ;;
27876888252Smrg
27976888252Smrgtru64)
28076888252Smrg   # The Tru64 compiler uses -MD to generate dependencies as a side
28176888252Smrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
28276888252Smrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
28376888252Smrg   # dependencies in `foo.d' instead, so we check for that too.
28476888252Smrg   # Subdirectories are respected.
28576888252Smrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
28676888252Smrg   test "x$dir" = "x$object" && dir=
28776888252Smrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
28876888252Smrg
28976888252Smrg   if test "$libtool" = yes; then
29076888252Smrg      # With Tru64 cc, shared objects can also be used to make a
29176888252Smrg      # static library.  This mecanism is used in libtool 1.4 series to
29276888252Smrg      # handle both shared and static libraries in a single compilation.
29376888252Smrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
29476888252Smrg      #
29576888252Smrg      # With libtool 1.5 this exception was removed, and libtool now
29676888252Smrg      # generates 2 separate objects for the 2 libraries.  These two
29776888252Smrg      # compilations output dependencies in in $dir.libs/$base.o.d and
29876888252Smrg      # in $dir$base.o.d.  We have to check for both files, because
29976888252Smrg      # one of the two compilations can be disabled.  We should prefer
30076888252Smrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
30176888252Smrg      # automatically cleaned when .libs/ is deleted, while ignoring
30276888252Smrg      # the former would cause a distcleancheck panic.
30376888252Smrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
30476888252Smrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
30576888252Smrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
30676888252Smrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
30776888252Smrg      "$@" -Wc,-MD
30876888252Smrg   else
30976888252Smrg      tmpdepfile1=$dir$base.o.d
31076888252Smrg      tmpdepfile2=$dir$base.d
31176888252Smrg      tmpdepfile3=$dir$base.d
31276888252Smrg      tmpdepfile4=$dir$base.d
31376888252Smrg      "$@" -MD
31476888252Smrg   fi
31576888252Smrg
31676888252Smrg   stat=$?
31776888252Smrg   if test $stat -eq 0; then :
31876888252Smrg   else
31976888252Smrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
32076888252Smrg      exit $stat
32176888252Smrg   fi
32276888252Smrg
32376888252Smrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
32476888252Smrg   do
32576888252Smrg     test -f "$tmpdepfile" && break
32676888252Smrg   done
32776888252Smrg   if test -f "$tmpdepfile"; then
32876888252Smrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
32976888252Smrg      # That's a tab and a space in the [].
33076888252Smrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
33176888252Smrg   else
33276888252Smrg      echo "#dummy" > "$depfile"
33376888252Smrg   fi
33476888252Smrg   rm -f "$tmpdepfile"
33576888252Smrg   ;;
33676888252Smrg
33776888252Smrg#nosideeffect)
33876888252Smrg  # This comment above is used by automake to tell side-effect
33976888252Smrg  # dependency tracking mechanisms from slower ones.
34076888252Smrg
34176888252Smrgdashmstdout)
34276888252Smrg  # Important note: in order to support this mode, a compiler *must*
34376888252Smrg  # always write the preprocessed file to stdout, regardless of -o.
34476888252Smrg  "$@" || exit $?
34576888252Smrg
34676888252Smrg  # Remove the call to Libtool.
34776888252Smrg  if test "$libtool" = yes; then
34876888252Smrg    while test $1 != '--mode=compile'; do
34976888252Smrg      shift
35076888252Smrg    done
35176888252Smrg    shift
35276888252Smrg  fi
35376888252Smrg
35476888252Smrg  # Remove `-o $object'.
35576888252Smrg  IFS=" "
35676888252Smrg  for arg
35776888252Smrg  do
35876888252Smrg    case $arg in
35976888252Smrg    -o)
36076888252Smrg      shift
36176888252Smrg      ;;
36276888252Smrg    $object)
36376888252Smrg      shift
36476888252Smrg      ;;
36576888252Smrg    *)
36676888252Smrg      set fnord "$@" "$arg"
36776888252Smrg      shift # fnord
36876888252Smrg      shift # $arg
36976888252Smrg      ;;
37076888252Smrg    esac
37176888252Smrg  done
37276888252Smrg
37376888252Smrg  test -z "$dashmflag" && dashmflag=-M
37476888252Smrg  # Require at least two characters before searching for `:'
37576888252Smrg  # in the target name.  This is to cope with DOS-style filenames:
37676888252Smrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
37776888252Smrg  "$@" $dashmflag |
37876888252Smrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
37976888252Smrg  rm -f "$depfile"
38076888252Smrg  cat < "$tmpdepfile" > "$depfile"
38176888252Smrg  tr ' ' '
38276888252Smrg' < "$tmpdepfile" | \
38376888252Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
38476888252Smrg## correctly.  Breaking it into two sed invocations is a workaround.
38576888252Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
38676888252Smrg  rm -f "$tmpdepfile"
38776888252Smrg  ;;
38876888252Smrg
38976888252SmrgdashXmstdout)
39076888252Smrg  # This case only exists to satisfy depend.m4.  It is never actually
39176888252Smrg  # run, as this mode is specially recognized in the preamble.
39276888252Smrg  exit 1
39376888252Smrg  ;;
39476888252Smrg
39576888252Smrgmakedepend)
39676888252Smrg  "$@" || exit $?
39776888252Smrg  # Remove any Libtool call
39876888252Smrg  if test "$libtool" = yes; then
39976888252Smrg    while test $1 != '--mode=compile'; do
40076888252Smrg      shift
40176888252Smrg    done
40276888252Smrg    shift
40376888252Smrg  fi
40476888252Smrg  # X makedepend
40576888252Smrg  shift
40676888252Smrg  cleared=no
40776888252Smrg  for arg in "$@"; do
40876888252Smrg    case $cleared in
40976888252Smrg    no)
41076888252Smrg      set ""; shift
41176888252Smrg      cleared=yes ;;
41276888252Smrg    esac
41376888252Smrg    case "$arg" in
41476888252Smrg    -D*|-I*)
41576888252Smrg      set fnord "$@" "$arg"; shift ;;
41676888252Smrg    # Strip any option that makedepend may not understand.  Remove
41776888252Smrg    # the object too, otherwise makedepend will parse it as a source file.
41876888252Smrg    -*|$object)
41976888252Smrg      ;;
42076888252Smrg    *)
42176888252Smrg      set fnord "$@" "$arg"; shift ;;
42276888252Smrg    esac
42376888252Smrg  done
42476888252Smrg  obj_suffix="`echo $object | sed 's/^.*\././'`"
42576888252Smrg  touch "$tmpdepfile"
42676888252Smrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
42776888252Smrg  rm -f "$depfile"
42876888252Smrg  cat < "$tmpdepfile" > "$depfile"
42976888252Smrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
43076888252Smrg' | \
43176888252Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
43276888252Smrg## correctly.  Breaking it into two sed invocations is a workaround.
43376888252Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
43476888252Smrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
43576888252Smrg  ;;
43676888252Smrg
43776888252Smrgcpp)
43876888252Smrg  # Important note: in order to support this mode, a compiler *must*
43976888252Smrg  # always write the preprocessed file to stdout.
44076888252Smrg  "$@" || exit $?
44176888252Smrg
44276888252Smrg  # Remove the call to Libtool.
44376888252Smrg  if test "$libtool" = yes; then
44476888252Smrg    while test $1 != '--mode=compile'; do
44576888252Smrg      shift
44676888252Smrg    done
44776888252Smrg    shift
44876888252Smrg  fi
44976888252Smrg
45076888252Smrg  # Remove `-o $object'.
45176888252Smrg  IFS=" "
45276888252Smrg  for arg
45376888252Smrg  do
45476888252Smrg    case $arg in
45576888252Smrg    -o)
45676888252Smrg      shift
45776888252Smrg      ;;
45876888252Smrg    $object)
45976888252Smrg      shift
46076888252Smrg      ;;
46176888252Smrg    *)
46276888252Smrg      set fnord "$@" "$arg"
46376888252Smrg      shift # fnord
46476888252Smrg      shift # $arg
46576888252Smrg      ;;
46676888252Smrg    esac
46776888252Smrg  done
46876888252Smrg
46976888252Smrg  "$@" -E |
47076888252Smrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
47176888252Smrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
47276888252Smrg    sed '$ s: \\$::' > "$tmpdepfile"
47376888252Smrg  rm -f "$depfile"
47476888252Smrg  echo "$object : \\" > "$depfile"
47576888252Smrg  cat < "$tmpdepfile" >> "$depfile"
47676888252Smrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
47776888252Smrg  rm -f "$tmpdepfile"
47876888252Smrg  ;;
47976888252Smrg
48076888252Smrgmsvisualcpp)
48176888252Smrg  # Important note: in order to support this mode, a compiler *must*
48276888252Smrg  # always write the preprocessed file to stdout, regardless of -o,
48376888252Smrg  # because we must use -o when running libtool.
48476888252Smrg  "$@" || exit $?
48576888252Smrg  IFS=" "
48676888252Smrg  for arg
48776888252Smrg  do
48876888252Smrg    case "$arg" in
48976888252Smrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
49076888252Smrg	set fnord "$@"
49176888252Smrg	shift
49276888252Smrg	shift
49376888252Smrg	;;
49476888252Smrg    *)
49576888252Smrg	set fnord "$@" "$arg"
49676888252Smrg	shift
49776888252Smrg	shift
49876888252Smrg	;;
49976888252Smrg    esac
50076888252Smrg  done
50176888252Smrg  "$@" -E |
50276888252Smrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
50376888252Smrg  rm -f "$depfile"
50476888252Smrg  echo "$object : \\" > "$depfile"
50576888252Smrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
50676888252Smrg  echo "	" >> "$depfile"
50776888252Smrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
50876888252Smrg  rm -f "$tmpdepfile"
50976888252Smrg  ;;
51076888252Smrg
51176888252Smrgnone)
51276888252Smrg  exec "$@"
51376888252Smrg  ;;
51476888252Smrg
51576888252Smrg*)
51676888252Smrg  echo "Unknown depmode $depmode" 1>&2
51776888252Smrg  exit 1
51876888252Smrg  ;;
51976888252Smrgesac
52076888252Smrg
52176888252Smrgexit 0
52276888252Smrg
52376888252Smrg# Local Variables:
52476888252Smrg# mode: shell-script
52576888252Smrg# sh-indentation: 2
52676888252Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
52776888252Smrg# time-stamp-start: "scriptversion="
52876888252Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
52976888252Smrg# time-stamp-end: "$"
53076888252Smrg# End:
531