depcomp revision 29459361
129459361Smrg#! /bin/sh
229459361Smrg# depcomp - compile a program generating dependencies as side-effects
329459361Smrg
429459361Smrgscriptversion=2005-07-09.11
529459361Smrg
629459361Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
729459361Smrg
829459361Smrg# This program is free software; you can redistribute it and/or modify
929459361Smrg# it under the terms of the GNU General Public License as published by
1029459361Smrg# the Free Software Foundation; either version 2, or (at your option)
1129459361Smrg# any later version.
1229459361Smrg
1329459361Smrg# This program is distributed in the hope that it will be useful,
1429459361Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1529459361Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1629459361Smrg# GNU General Public License for more details.
1729459361Smrg
1829459361Smrg# You should have received a copy of the GNU General Public License
1929459361Smrg# along with this program; if not, write to the Free Software
2029459361Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2129459361Smrg# 02110-1301, USA.
2229459361Smrg
2329459361Smrg# As a special exception to the GNU General Public License, if you
2429459361Smrg# distribute this file as part of a program that contains a
2529459361Smrg# configuration script generated by Autoconf, you may include it under
2629459361Smrg# the same distribution terms that you use for the rest of that program.
2729459361Smrg
2829459361Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
2929459361Smrg
3029459361Smrgcase $1 in
3129459361Smrg  '')
3229459361Smrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
3329459361Smrg     exit 1;
3429459361Smrg     ;;
3529459361Smrg  -h | --h*)
3629459361Smrg    cat <<\EOF
3729459361SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
3829459361Smrg
3929459361SmrgRun PROGRAMS ARGS to compile a file, generating dependencies
4029459361Smrgas side-effects.
4129459361Smrg
4229459361SmrgEnvironment variables:
4329459361Smrg  depmode     Dependency tracking mode.
4429459361Smrg  source      Source file read by `PROGRAMS ARGS'.
4529459361Smrg  object      Object file output by `PROGRAMS ARGS'.
4629459361Smrg  DEPDIR      directory where to store dependencies.
4729459361Smrg  depfile     Dependency file to output.
4829459361Smrg  tmpdepfile  Temporary file to use when outputing dependencies.
4929459361Smrg  libtool     Whether libtool is used (yes/no).
5029459361Smrg
5129459361SmrgReport bugs to <bug-automake@gnu.org>.
5229459361SmrgEOF
5329459361Smrg    exit $?
5429459361Smrg    ;;
5529459361Smrg  -v | --v*)
5629459361Smrg    echo "depcomp $scriptversion"
5729459361Smrg    exit $?
5829459361Smrg    ;;
5929459361Smrgesac
6029459361Smrg
6129459361Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
6229459361Smrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
6329459361Smrg  exit 1
6429459361Smrgfi
6529459361Smrg
6629459361Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
6729459361Smrgdepfile=${depfile-`echo "$object" |
6829459361Smrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
6929459361Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
7029459361Smrg
7129459361Smrgrm -f "$tmpdepfile"
7229459361Smrg
7329459361Smrg# Some modes work just like other modes, but use different flags.  We
7429459361Smrg# parameterize here, but still list the modes in the big case below,
7529459361Smrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
7629459361Smrg# here, because this file can only contain one case statement.
7729459361Smrgif test "$depmode" = hp; then
7829459361Smrg  # HP compiler uses -M and no extra arg.
7929459361Smrg  gccflag=-M
8029459361Smrg  depmode=gcc
8129459361Smrgfi
8229459361Smrg
8329459361Smrgif test "$depmode" = dashXmstdout; then
8429459361Smrg   # This is just like dashmstdout with a different argument.
8529459361Smrg   dashmflag=-xM
8629459361Smrg   depmode=dashmstdout
8729459361Smrgfi
8829459361Smrg
8929459361Smrgcase "$depmode" in
9029459361Smrggcc3)
9129459361Smrg## gcc 3 implements dependency tracking that does exactly what
9229459361Smrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
9329459361Smrg## it if -MD -MP comes after the -MF stuff.  Hmm.
9429459361Smrg  "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
9529459361Smrg  stat=$?
9629459361Smrg  if test $stat -eq 0; then :
9729459361Smrg  else
9829459361Smrg    rm -f "$tmpdepfile"
9929459361Smrg    exit $stat
10029459361Smrg  fi
10129459361Smrg  mv "$tmpdepfile" "$depfile"
10229459361Smrg  ;;
10329459361Smrg
10429459361Smrggcc)
10529459361Smrg## There are various ways to get dependency output from gcc.  Here's
10629459361Smrg## why we pick this rather obscure method:
10729459361Smrg## - Don't want to use -MD because we'd like the dependencies to end
10829459361Smrg##   up in a subdir.  Having to rename by hand is ugly.
10929459361Smrg##   (We might end up doing this anyway to support other compilers.)
11029459361Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
11129459361Smrg##   -MM, not -M (despite what the docs say).
11229459361Smrg## - Using -M directly means running the compiler twice (even worse
11329459361Smrg##   than renaming).
11429459361Smrg  if test -z "$gccflag"; then
11529459361Smrg    gccflag=-MD,
11629459361Smrg  fi
11729459361Smrg  "$@" -Wp,"$gccflag$tmpdepfile"
11829459361Smrg  stat=$?
11929459361Smrg  if test $stat -eq 0; then :
12029459361Smrg  else
12129459361Smrg    rm -f "$tmpdepfile"
12229459361Smrg    exit $stat
12329459361Smrg  fi
12429459361Smrg  rm -f "$depfile"
12529459361Smrg  echo "$object : \\" > "$depfile"
12629459361Smrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
12729459361Smrg## The second -e expression handles DOS-style file names with drive letters.
12829459361Smrg  sed -e 's/^[^:]*: / /' \
12929459361Smrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
13029459361Smrg## This next piece of magic avoids the `deleted header file' problem.
13129459361Smrg## The problem is that when a header file which appears in a .P file
13229459361Smrg## is deleted, the dependency causes make to die (because there is
13329459361Smrg## typically no way to rebuild the header).  We avoid this by adding
13429459361Smrg## dummy dependencies for each header file.  Too bad gcc doesn't do
13529459361Smrg## this for us directly.
13629459361Smrg  tr ' ' '
13729459361Smrg' < "$tmpdepfile" |
13829459361Smrg## Some versions of gcc put a space before the `:'.  On the theory
13929459361Smrg## that the space means something, we add a space to the output as
14029459361Smrg## well.
14129459361Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
14229459361Smrg## correctly.  Breaking it into two sed invocations is a workaround.
14329459361Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
14429459361Smrg  rm -f "$tmpdepfile"
14529459361Smrg  ;;
14629459361Smrg
14729459361Smrghp)
14829459361Smrg  # This case exists only to let depend.m4 do its work.  It works by
14929459361Smrg  # looking at the text of this script.  This case will never be run,
15029459361Smrg  # since it is checked for above.
15129459361Smrg  exit 1
15229459361Smrg  ;;
15329459361Smrg
15429459361Smrgsgi)
15529459361Smrg  if test "$libtool" = yes; then
15629459361Smrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
15729459361Smrg  else
15829459361Smrg    "$@" -MDupdate "$tmpdepfile"
15929459361Smrg  fi
16029459361Smrg  stat=$?
16129459361Smrg  if test $stat -eq 0; then :
16229459361Smrg  else
16329459361Smrg    rm -f "$tmpdepfile"
16429459361Smrg    exit $stat
16529459361Smrg  fi
16629459361Smrg  rm -f "$depfile"
16729459361Smrg
16829459361Smrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
16929459361Smrg    echo "$object : \\" > "$depfile"
17029459361Smrg
17129459361Smrg    # Clip off the initial element (the dependent).  Don't try to be
17229459361Smrg    # clever and replace this with sed code, as IRIX sed won't handle
17329459361Smrg    # lines with more than a fixed number of characters (4096 in
17429459361Smrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
17529459361Smrg    # the IRIX cc adds comments like `#:fec' to the end of the
17629459361Smrg    # dependency line.
17729459361Smrg    tr ' ' '
17829459361Smrg' < "$tmpdepfile" \
17929459361Smrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
18029459361Smrg    tr '
18129459361Smrg' ' ' >> $depfile
18229459361Smrg    echo >> $depfile
18329459361Smrg
18429459361Smrg    # The second pass generates a dummy entry for each header file.
18529459361Smrg    tr ' ' '
18629459361Smrg' < "$tmpdepfile" \
18729459361Smrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
18829459361Smrg   >> $depfile
18929459361Smrg  else
19029459361Smrg    # The sourcefile does not contain any dependencies, so just
19129459361Smrg    # store a dummy comment line, to avoid errors with the Makefile
19229459361Smrg    # "include basename.Plo" scheme.
19329459361Smrg    echo "#dummy" > "$depfile"
19429459361Smrg  fi
19529459361Smrg  rm -f "$tmpdepfile"
19629459361Smrg  ;;
19729459361Smrg
19829459361Smrgaix)
19929459361Smrg  # The C for AIX Compiler uses -M and outputs the dependencies
20029459361Smrg  # in a .u file.  In older versions, this file always lives in the
20129459361Smrg  # current directory.  Also, the AIX compiler puts `$object:' at the
20229459361Smrg  # start of each line; $object doesn't have directory information.
20329459361Smrg  # Version 6 uses the directory in both cases.
20429459361Smrg  stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
20529459361Smrg  tmpdepfile="$stripped.u"
20629459361Smrg  if test "$libtool" = yes; then
20729459361Smrg    "$@" -Wc,-M
20829459361Smrg  else
20929459361Smrg    "$@" -M
21029459361Smrg  fi
21129459361Smrg  stat=$?
21229459361Smrg
21329459361Smrg  if test -f "$tmpdepfile"; then :
21429459361Smrg  else
21529459361Smrg    stripped=`echo "$stripped" | sed 's,^.*/,,'`
21629459361Smrg    tmpdepfile="$stripped.u"
21729459361Smrg  fi
21829459361Smrg
21929459361Smrg  if test $stat -eq 0; then :
22029459361Smrg  else
22129459361Smrg    rm -f "$tmpdepfile"
22229459361Smrg    exit $stat
22329459361Smrg  fi
22429459361Smrg
22529459361Smrg  if test -f "$tmpdepfile"; then
22629459361Smrg    outname="$stripped.o"
22729459361Smrg    # Each line is of the form `foo.o: dependent.h'.
22829459361Smrg    # Do two passes, one to just change these to
22929459361Smrg    # `$object: dependent.h' and one to simply `dependent.h:'.
23029459361Smrg    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
23129459361Smrg    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
23229459361Smrg  else
23329459361Smrg    # The sourcefile does not contain any dependencies, so just
23429459361Smrg    # store a dummy comment line, to avoid errors with the Makefile
23529459361Smrg    # "include basename.Plo" scheme.
23629459361Smrg    echo "#dummy" > "$depfile"
23729459361Smrg  fi
23829459361Smrg  rm -f "$tmpdepfile"
23929459361Smrg  ;;
24029459361Smrg
24129459361Smrgicc)
24229459361Smrg  # Intel's C compiler understands `-MD -MF file'.  However on
24329459361Smrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
24429459361Smrg  # ICC 7.0 will fill foo.d with something like
24529459361Smrg  #    foo.o: sub/foo.c
24629459361Smrg  #    foo.o: sub/foo.h
24729459361Smrg  # which is wrong.  We want:
24829459361Smrg  #    sub/foo.o: sub/foo.c
24929459361Smrg  #    sub/foo.o: sub/foo.h
25029459361Smrg  #    sub/foo.c:
25129459361Smrg  #    sub/foo.h:
25229459361Smrg  # ICC 7.1 will output
25329459361Smrg  #    foo.o: sub/foo.c sub/foo.h
25429459361Smrg  # and will wrap long lines using \ :
25529459361Smrg  #    foo.o: sub/foo.c ... \
25629459361Smrg  #     sub/foo.h ... \
25729459361Smrg  #     ...
25829459361Smrg
25929459361Smrg  "$@" -MD -MF "$tmpdepfile"
26029459361Smrg  stat=$?
26129459361Smrg  if test $stat -eq 0; then :
26229459361Smrg  else
26329459361Smrg    rm -f "$tmpdepfile"
26429459361Smrg    exit $stat
26529459361Smrg  fi
26629459361Smrg  rm -f "$depfile"
26729459361Smrg  # Each line is of the form `foo.o: dependent.h',
26829459361Smrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
26929459361Smrg  # Do two passes, one to just change these to
27029459361Smrg  # `$object: dependent.h' and one to simply `dependent.h:'.
27129459361Smrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
27229459361Smrg  # Some versions of the HPUX 10.20 sed can't process this invocation
27329459361Smrg  # correctly.  Breaking it into two sed invocations is a workaround.
27429459361Smrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
27529459361Smrg    sed -e 's/$/ :/' >> "$depfile"
27629459361Smrg  rm -f "$tmpdepfile"
27729459361Smrg  ;;
27829459361Smrg
27929459361Smrgtru64)
28029459361Smrg   # The Tru64 compiler uses -MD to generate dependencies as a side
28129459361Smrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
28229459361Smrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
28329459361Smrg   # dependencies in `foo.d' instead, so we check for that too.
28429459361Smrg   # Subdirectories are respected.
28529459361Smrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
28629459361Smrg   test "x$dir" = "x$object" && dir=
28729459361Smrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
28829459361Smrg
28929459361Smrg   if test "$libtool" = yes; then
29029459361Smrg      # With Tru64 cc, shared objects can also be used to make a
29129459361Smrg      # static library.  This mecanism is used in libtool 1.4 series to
29229459361Smrg      # handle both shared and static libraries in a single compilation.
29329459361Smrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
29429459361Smrg      #
29529459361Smrg      # With libtool 1.5 this exception was removed, and libtool now
29629459361Smrg      # generates 2 separate objects for the 2 libraries.  These two
29729459361Smrg      # compilations output dependencies in in $dir.libs/$base.o.d and
29829459361Smrg      # in $dir$base.o.d.  We have to check for both files, because
29929459361Smrg      # one of the two compilations can be disabled.  We should prefer
30029459361Smrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
30129459361Smrg      # automatically cleaned when .libs/ is deleted, while ignoring
30229459361Smrg      # the former would cause a distcleancheck panic.
30329459361Smrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
30429459361Smrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
30529459361Smrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
30629459361Smrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
30729459361Smrg      "$@" -Wc,-MD
30829459361Smrg   else
30929459361Smrg      tmpdepfile1=$dir$base.o.d
31029459361Smrg      tmpdepfile2=$dir$base.d
31129459361Smrg      tmpdepfile3=$dir$base.d
31229459361Smrg      tmpdepfile4=$dir$base.d
31329459361Smrg      "$@" -MD
31429459361Smrg   fi
31529459361Smrg
31629459361Smrg   stat=$?
31729459361Smrg   if test $stat -eq 0; then :
31829459361Smrg   else
31929459361Smrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
32029459361Smrg      exit $stat
32129459361Smrg   fi
32229459361Smrg
32329459361Smrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
32429459361Smrg   do
32529459361Smrg     test -f "$tmpdepfile" && break
32629459361Smrg   done
32729459361Smrg   if test -f "$tmpdepfile"; then
32829459361Smrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
32929459361Smrg      # That's a tab and a space in the [].
33029459361Smrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
33129459361Smrg   else
33229459361Smrg      echo "#dummy" > "$depfile"
33329459361Smrg   fi
33429459361Smrg   rm -f "$tmpdepfile"
33529459361Smrg   ;;
33629459361Smrg
33729459361Smrg#nosideeffect)
33829459361Smrg  # This comment above is used by automake to tell side-effect
33929459361Smrg  # dependency tracking mechanisms from slower ones.
34029459361Smrg
34129459361Smrgdashmstdout)
34229459361Smrg  # Important note: in order to support this mode, a compiler *must*
34329459361Smrg  # always write the preprocessed file to stdout, regardless of -o.
34429459361Smrg  "$@" || exit $?
34529459361Smrg
34629459361Smrg  # Remove the call to Libtool.
34729459361Smrg  if test "$libtool" = yes; then
34829459361Smrg    while test $1 != '--mode=compile'; do
34929459361Smrg      shift
35029459361Smrg    done
35129459361Smrg    shift
35229459361Smrg  fi
35329459361Smrg
35429459361Smrg  # Remove `-o $object'.
35529459361Smrg  IFS=" "
35629459361Smrg  for arg
35729459361Smrg  do
35829459361Smrg    case $arg in
35929459361Smrg    -o)
36029459361Smrg      shift
36129459361Smrg      ;;
36229459361Smrg    $object)
36329459361Smrg      shift
36429459361Smrg      ;;
36529459361Smrg    *)
36629459361Smrg      set fnord "$@" "$arg"
36729459361Smrg      shift # fnord
36829459361Smrg      shift # $arg
36929459361Smrg      ;;
37029459361Smrg    esac
37129459361Smrg  done
37229459361Smrg
37329459361Smrg  test -z "$dashmflag" && dashmflag=-M
37429459361Smrg  # Require at least two characters before searching for `:'
37529459361Smrg  # in the target name.  This is to cope with DOS-style filenames:
37629459361Smrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
37729459361Smrg  "$@" $dashmflag |
37829459361Smrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
37929459361Smrg  rm -f "$depfile"
38029459361Smrg  cat < "$tmpdepfile" > "$depfile"
38129459361Smrg  tr ' ' '
38229459361Smrg' < "$tmpdepfile" | \
38329459361Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
38429459361Smrg## correctly.  Breaking it into two sed invocations is a workaround.
38529459361Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
38629459361Smrg  rm -f "$tmpdepfile"
38729459361Smrg  ;;
38829459361Smrg
38929459361SmrgdashXmstdout)
39029459361Smrg  # This case only exists to satisfy depend.m4.  It is never actually
39129459361Smrg  # run, as this mode is specially recognized in the preamble.
39229459361Smrg  exit 1
39329459361Smrg  ;;
39429459361Smrg
39529459361Smrgmakedepend)
39629459361Smrg  "$@" || exit $?
39729459361Smrg  # Remove any Libtool call
39829459361Smrg  if test "$libtool" = yes; then
39929459361Smrg    while test $1 != '--mode=compile'; do
40029459361Smrg      shift
40129459361Smrg    done
40229459361Smrg    shift
40329459361Smrg  fi
40429459361Smrg  # X makedepend
40529459361Smrg  shift
40629459361Smrg  cleared=no
40729459361Smrg  for arg in "$@"; do
40829459361Smrg    case $cleared in
40929459361Smrg    no)
41029459361Smrg      set ""; shift
41129459361Smrg      cleared=yes ;;
41229459361Smrg    esac
41329459361Smrg    case "$arg" in
41429459361Smrg    -D*|-I*)
41529459361Smrg      set fnord "$@" "$arg"; shift ;;
41629459361Smrg    # Strip any option that makedepend may not understand.  Remove
41729459361Smrg    # the object too, otherwise makedepend will parse it as a source file.
41829459361Smrg    -*|$object)
41929459361Smrg      ;;
42029459361Smrg    *)
42129459361Smrg      set fnord "$@" "$arg"; shift ;;
42229459361Smrg    esac
42329459361Smrg  done
42429459361Smrg  obj_suffix="`echo $object | sed 's/^.*\././'`"
42529459361Smrg  touch "$tmpdepfile"
42629459361Smrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
42729459361Smrg  rm -f "$depfile"
42829459361Smrg  cat < "$tmpdepfile" > "$depfile"
42929459361Smrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
43029459361Smrg' | \
43129459361Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
43229459361Smrg## correctly.  Breaking it into two sed invocations is a workaround.
43329459361Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
43429459361Smrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
43529459361Smrg  ;;
43629459361Smrg
43729459361Smrgcpp)
43829459361Smrg  # Important note: in order to support this mode, a compiler *must*
43929459361Smrg  # always write the preprocessed file to stdout.
44029459361Smrg  "$@" || exit $?
44129459361Smrg
44229459361Smrg  # Remove the call to Libtool.
44329459361Smrg  if test "$libtool" = yes; then
44429459361Smrg    while test $1 != '--mode=compile'; do
44529459361Smrg      shift
44629459361Smrg    done
44729459361Smrg    shift
44829459361Smrg  fi
44929459361Smrg
45029459361Smrg  # Remove `-o $object'.
45129459361Smrg  IFS=" "
45229459361Smrg  for arg
45329459361Smrg  do
45429459361Smrg    case $arg in
45529459361Smrg    -o)
45629459361Smrg      shift
45729459361Smrg      ;;
45829459361Smrg    $object)
45929459361Smrg      shift
46029459361Smrg      ;;
46129459361Smrg    *)
46229459361Smrg      set fnord "$@" "$arg"
46329459361Smrg      shift # fnord
46429459361Smrg      shift # $arg
46529459361Smrg      ;;
46629459361Smrg    esac
46729459361Smrg  done
46829459361Smrg
46929459361Smrg  "$@" -E |
47029459361Smrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
47129459361Smrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
47229459361Smrg    sed '$ s: \\$::' > "$tmpdepfile"
47329459361Smrg  rm -f "$depfile"
47429459361Smrg  echo "$object : \\" > "$depfile"
47529459361Smrg  cat < "$tmpdepfile" >> "$depfile"
47629459361Smrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
47729459361Smrg  rm -f "$tmpdepfile"
47829459361Smrg  ;;
47929459361Smrg
48029459361Smrgmsvisualcpp)
48129459361Smrg  # Important note: in order to support this mode, a compiler *must*
48229459361Smrg  # always write the preprocessed file to stdout, regardless of -o,
48329459361Smrg  # because we must use -o when running libtool.
48429459361Smrg  "$@" || exit $?
48529459361Smrg  IFS=" "
48629459361Smrg  for arg
48729459361Smrg  do
48829459361Smrg    case "$arg" in
48929459361Smrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
49029459361Smrg	set fnord "$@"
49129459361Smrg	shift
49229459361Smrg	shift
49329459361Smrg	;;
49429459361Smrg    *)
49529459361Smrg	set fnord "$@" "$arg"
49629459361Smrg	shift
49729459361Smrg	shift
49829459361Smrg	;;
49929459361Smrg    esac
50029459361Smrg  done
50129459361Smrg  "$@" -E |
50229459361Smrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
50329459361Smrg  rm -f "$depfile"
50429459361Smrg  echo "$object : \\" > "$depfile"
50529459361Smrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
50629459361Smrg  echo "	" >> "$depfile"
50729459361Smrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
50829459361Smrg  rm -f "$tmpdepfile"
50929459361Smrg  ;;
51029459361Smrg
51129459361Smrgnone)
51229459361Smrg  exec "$@"
51329459361Smrg  ;;
51429459361Smrg
51529459361Smrg*)
51629459361Smrg  echo "Unknown depmode $depmode" 1>&2
51729459361Smrg  exit 1
51829459361Smrg  ;;
51929459361Smrgesac
52029459361Smrg
52129459361Smrgexit 0
52229459361Smrg
52329459361Smrg# Local Variables:
52429459361Smrg# mode: shell-script
52529459361Smrg# sh-indentation: 2
52629459361Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
52729459361Smrg# time-stamp-start: "scriptversion="
52829459361Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
52929459361Smrg# time-stamp-end: "$"
53029459361Smrg# End:
531