depcomp revision 27702724
127702724Smrg#! /bin/sh
227702724Smrg# depcomp - compile a program generating dependencies as side-effects
327702724Smrg
427702724Smrgscriptversion=2005-07-09.11
527702724Smrg
627702724Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
727702724Smrg
827702724Smrg# This program is free software; you can redistribute it and/or modify
927702724Smrg# it under the terms of the GNU General Public License as published by
1027702724Smrg# the Free Software Foundation; either version 2, or (at your option)
1127702724Smrg# any later version.
1227702724Smrg
1327702724Smrg# This program is distributed in the hope that it will be useful,
1427702724Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1527702724Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1627702724Smrg# GNU General Public License for more details.
1727702724Smrg
1827702724Smrg# You should have received a copy of the GNU General Public License
1927702724Smrg# along with this program; if not, write to the Free Software
2027702724Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2127702724Smrg# 02110-1301, USA.
2227702724Smrg
2327702724Smrg# As a special exception to the GNU General Public License, if you
2427702724Smrg# distribute this file as part of a program that contains a
2527702724Smrg# configuration script generated by Autoconf, you may include it under
2627702724Smrg# the same distribution terms that you use for the rest of that program.
2727702724Smrg
2827702724Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
2927702724Smrg
3027702724Smrgcase $1 in
3127702724Smrg  '')
3227702724Smrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
3327702724Smrg     exit 1;
3427702724Smrg     ;;
3527702724Smrg  -h | --h*)
3627702724Smrg    cat <<\EOF
3727702724SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
3827702724Smrg
3927702724SmrgRun PROGRAMS ARGS to compile a file, generating dependencies
4027702724Smrgas side-effects.
4127702724Smrg
4227702724SmrgEnvironment variables:
4327702724Smrg  depmode     Dependency tracking mode.
4427702724Smrg  source      Source file read by `PROGRAMS ARGS'.
4527702724Smrg  object      Object file output by `PROGRAMS ARGS'.
4627702724Smrg  DEPDIR      directory where to store dependencies.
4727702724Smrg  depfile     Dependency file to output.
4827702724Smrg  tmpdepfile  Temporary file to use when outputing dependencies.
4927702724Smrg  libtool     Whether libtool is used (yes/no).
5027702724Smrg
5127702724SmrgReport bugs to <bug-automake@gnu.org>.
5227702724SmrgEOF
5327702724Smrg    exit $?
5427702724Smrg    ;;
5527702724Smrg  -v | --v*)
5627702724Smrg    echo "depcomp $scriptversion"
5727702724Smrg    exit $?
5827702724Smrg    ;;
5927702724Smrgesac
6027702724Smrg
6127702724Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
6227702724Smrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
6327702724Smrg  exit 1
6427702724Smrgfi
6527702724Smrg
6627702724Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
6727702724Smrgdepfile=${depfile-`echo "$object" |
6827702724Smrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
6927702724Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
7027702724Smrg
7127702724Smrgrm -f "$tmpdepfile"
7227702724Smrg
7327702724Smrg# Some modes work just like other modes, but use different flags.  We
7427702724Smrg# parameterize here, but still list the modes in the big case below,
7527702724Smrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
7627702724Smrg# here, because this file can only contain one case statement.
7727702724Smrgif test "$depmode" = hp; then
7827702724Smrg  # HP compiler uses -M and no extra arg.
7927702724Smrg  gccflag=-M
8027702724Smrg  depmode=gcc
8127702724Smrgfi
8227702724Smrg
8327702724Smrgif test "$depmode" = dashXmstdout; then
8427702724Smrg   # This is just like dashmstdout with a different argument.
8527702724Smrg   dashmflag=-xM
8627702724Smrg   depmode=dashmstdout
8727702724Smrgfi
8827702724Smrg
8927702724Smrgcase "$depmode" in
9027702724Smrggcc3)
9127702724Smrg## gcc 3 implements dependency tracking that does exactly what
9227702724Smrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
9327702724Smrg## it if -MD -MP comes after the -MF stuff.  Hmm.
9427702724Smrg  "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
9527702724Smrg  stat=$?
9627702724Smrg  if test $stat -eq 0; then :
9727702724Smrg  else
9827702724Smrg    rm -f "$tmpdepfile"
9927702724Smrg    exit $stat
10027702724Smrg  fi
10127702724Smrg  mv "$tmpdepfile" "$depfile"
10227702724Smrg  ;;
10327702724Smrg
10427702724Smrggcc)
10527702724Smrg## There are various ways to get dependency output from gcc.  Here's
10627702724Smrg## why we pick this rather obscure method:
10727702724Smrg## - Don't want to use -MD because we'd like the dependencies to end
10827702724Smrg##   up in a subdir.  Having to rename by hand is ugly.
10927702724Smrg##   (We might end up doing this anyway to support other compilers.)
11027702724Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
11127702724Smrg##   -MM, not -M (despite what the docs say).
11227702724Smrg## - Using -M directly means running the compiler twice (even worse
11327702724Smrg##   than renaming).
11427702724Smrg  if test -z "$gccflag"; then
11527702724Smrg    gccflag=-MD,
11627702724Smrg  fi
11727702724Smrg  "$@" -Wp,"$gccflag$tmpdepfile"
11827702724Smrg  stat=$?
11927702724Smrg  if test $stat -eq 0; then :
12027702724Smrg  else
12127702724Smrg    rm -f "$tmpdepfile"
12227702724Smrg    exit $stat
12327702724Smrg  fi
12427702724Smrg  rm -f "$depfile"
12527702724Smrg  echo "$object : \\" > "$depfile"
12627702724Smrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
12727702724Smrg## The second -e expression handles DOS-style file names with drive letters.
12827702724Smrg  sed -e 's/^[^:]*: / /' \
12927702724Smrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
13027702724Smrg## This next piece of magic avoids the `deleted header file' problem.
13127702724Smrg## The problem is that when a header file which appears in a .P file
13227702724Smrg## is deleted, the dependency causes make to die (because there is
13327702724Smrg## typically no way to rebuild the header).  We avoid this by adding
13427702724Smrg## dummy dependencies for each header file.  Too bad gcc doesn't do
13527702724Smrg## this for us directly.
13627702724Smrg  tr ' ' '
13727702724Smrg' < "$tmpdepfile" |
13827702724Smrg## Some versions of gcc put a space before the `:'.  On the theory
13927702724Smrg## that the space means something, we add a space to the output as
14027702724Smrg## well.
14127702724Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
14227702724Smrg## correctly.  Breaking it into two sed invocations is a workaround.
14327702724Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
14427702724Smrg  rm -f "$tmpdepfile"
14527702724Smrg  ;;
14627702724Smrg
14727702724Smrghp)
14827702724Smrg  # This case exists only to let depend.m4 do its work.  It works by
14927702724Smrg  # looking at the text of this script.  This case will never be run,
15027702724Smrg  # since it is checked for above.
15127702724Smrg  exit 1
15227702724Smrg  ;;
15327702724Smrg
15427702724Smrgsgi)
15527702724Smrg  if test "$libtool" = yes; then
15627702724Smrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
15727702724Smrg  else
15827702724Smrg    "$@" -MDupdate "$tmpdepfile"
15927702724Smrg  fi
16027702724Smrg  stat=$?
16127702724Smrg  if test $stat -eq 0; then :
16227702724Smrg  else
16327702724Smrg    rm -f "$tmpdepfile"
16427702724Smrg    exit $stat
16527702724Smrg  fi
16627702724Smrg  rm -f "$depfile"
16727702724Smrg
16827702724Smrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
16927702724Smrg    echo "$object : \\" > "$depfile"
17027702724Smrg
17127702724Smrg    # Clip off the initial element (the dependent).  Don't try to be
17227702724Smrg    # clever and replace this with sed code, as IRIX sed won't handle
17327702724Smrg    # lines with more than a fixed number of characters (4096 in
17427702724Smrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
17527702724Smrg    # the IRIX cc adds comments like `#:fec' to the end of the
17627702724Smrg    # dependency line.
17727702724Smrg    tr ' ' '
17827702724Smrg' < "$tmpdepfile" \
17927702724Smrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
18027702724Smrg    tr '
18127702724Smrg' ' ' >> $depfile
18227702724Smrg    echo >> $depfile
18327702724Smrg
18427702724Smrg    # The second pass generates a dummy entry for each header file.
18527702724Smrg    tr ' ' '
18627702724Smrg' < "$tmpdepfile" \
18727702724Smrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
18827702724Smrg   >> $depfile
18927702724Smrg  else
19027702724Smrg    # The sourcefile does not contain any dependencies, so just
19127702724Smrg    # store a dummy comment line, to avoid errors with the Makefile
19227702724Smrg    # "include basename.Plo" scheme.
19327702724Smrg    echo "#dummy" > "$depfile"
19427702724Smrg  fi
19527702724Smrg  rm -f "$tmpdepfile"
19627702724Smrg  ;;
19727702724Smrg
19827702724Smrgaix)
19927702724Smrg  # The C for AIX Compiler uses -M and outputs the dependencies
20027702724Smrg  # in a .u file.  In older versions, this file always lives in the
20127702724Smrg  # current directory.  Also, the AIX compiler puts `$object:' at the
20227702724Smrg  # start of each line; $object doesn't have directory information.
20327702724Smrg  # Version 6 uses the directory in both cases.
20427702724Smrg  stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
20527702724Smrg  tmpdepfile="$stripped.u"
20627702724Smrg  if test "$libtool" = yes; then
20727702724Smrg    "$@" -Wc,-M
20827702724Smrg  else
20927702724Smrg    "$@" -M
21027702724Smrg  fi
21127702724Smrg  stat=$?
21227702724Smrg
21327702724Smrg  if test -f "$tmpdepfile"; then :
21427702724Smrg  else
21527702724Smrg    stripped=`echo "$stripped" | sed 's,^.*/,,'`
21627702724Smrg    tmpdepfile="$stripped.u"
21727702724Smrg  fi
21827702724Smrg
21927702724Smrg  if test $stat -eq 0; then :
22027702724Smrg  else
22127702724Smrg    rm -f "$tmpdepfile"
22227702724Smrg    exit $stat
22327702724Smrg  fi
22427702724Smrg
22527702724Smrg  if test -f "$tmpdepfile"; then
22627702724Smrg    outname="$stripped.o"
22727702724Smrg    # Each line is of the form `foo.o: dependent.h'.
22827702724Smrg    # Do two passes, one to just change these to
22927702724Smrg    # `$object: dependent.h' and one to simply `dependent.h:'.
23027702724Smrg    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
23127702724Smrg    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
23227702724Smrg  else
23327702724Smrg    # The sourcefile does not contain any dependencies, so just
23427702724Smrg    # store a dummy comment line, to avoid errors with the Makefile
23527702724Smrg    # "include basename.Plo" scheme.
23627702724Smrg    echo "#dummy" > "$depfile"
23727702724Smrg  fi
23827702724Smrg  rm -f "$tmpdepfile"
23927702724Smrg  ;;
24027702724Smrg
24127702724Smrgicc)
24227702724Smrg  # Intel's C compiler understands `-MD -MF file'.  However on
24327702724Smrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
24427702724Smrg  # ICC 7.0 will fill foo.d with something like
24527702724Smrg  #    foo.o: sub/foo.c
24627702724Smrg  #    foo.o: sub/foo.h
24727702724Smrg  # which is wrong.  We want:
24827702724Smrg  #    sub/foo.o: sub/foo.c
24927702724Smrg  #    sub/foo.o: sub/foo.h
25027702724Smrg  #    sub/foo.c:
25127702724Smrg  #    sub/foo.h:
25227702724Smrg  # ICC 7.1 will output
25327702724Smrg  #    foo.o: sub/foo.c sub/foo.h
25427702724Smrg  # and will wrap long lines using \ :
25527702724Smrg  #    foo.o: sub/foo.c ... \
25627702724Smrg  #     sub/foo.h ... \
25727702724Smrg  #     ...
25827702724Smrg
25927702724Smrg  "$@" -MD -MF "$tmpdepfile"
26027702724Smrg  stat=$?
26127702724Smrg  if test $stat -eq 0; then :
26227702724Smrg  else
26327702724Smrg    rm -f "$tmpdepfile"
26427702724Smrg    exit $stat
26527702724Smrg  fi
26627702724Smrg  rm -f "$depfile"
26727702724Smrg  # Each line is of the form `foo.o: dependent.h',
26827702724Smrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
26927702724Smrg  # Do two passes, one to just change these to
27027702724Smrg  # `$object: dependent.h' and one to simply `dependent.h:'.
27127702724Smrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
27227702724Smrg  # Some versions of the HPUX 10.20 sed can't process this invocation
27327702724Smrg  # correctly.  Breaking it into two sed invocations is a workaround.
27427702724Smrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
27527702724Smrg    sed -e 's/$/ :/' >> "$depfile"
27627702724Smrg  rm -f "$tmpdepfile"
27727702724Smrg  ;;
27827702724Smrg
27927702724Smrgtru64)
28027702724Smrg   # The Tru64 compiler uses -MD to generate dependencies as a side
28127702724Smrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
28227702724Smrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
28327702724Smrg   # dependencies in `foo.d' instead, so we check for that too.
28427702724Smrg   # Subdirectories are respected.
28527702724Smrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
28627702724Smrg   test "x$dir" = "x$object" && dir=
28727702724Smrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
28827702724Smrg
28927702724Smrg   if test "$libtool" = yes; then
29027702724Smrg      # With Tru64 cc, shared objects can also be used to make a
29127702724Smrg      # static library.  This mecanism is used in libtool 1.4 series to
29227702724Smrg      # handle both shared and static libraries in a single compilation.
29327702724Smrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
29427702724Smrg      #
29527702724Smrg      # With libtool 1.5 this exception was removed, and libtool now
29627702724Smrg      # generates 2 separate objects for the 2 libraries.  These two
29727702724Smrg      # compilations output dependencies in in $dir.libs/$base.o.d and
29827702724Smrg      # in $dir$base.o.d.  We have to check for both files, because
29927702724Smrg      # one of the two compilations can be disabled.  We should prefer
30027702724Smrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
30127702724Smrg      # automatically cleaned when .libs/ is deleted, while ignoring
30227702724Smrg      # the former would cause a distcleancheck panic.
30327702724Smrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
30427702724Smrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
30527702724Smrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
30627702724Smrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
30727702724Smrg      "$@" -Wc,-MD
30827702724Smrg   else
30927702724Smrg      tmpdepfile1=$dir$base.o.d
31027702724Smrg      tmpdepfile2=$dir$base.d
31127702724Smrg      tmpdepfile3=$dir$base.d
31227702724Smrg      tmpdepfile4=$dir$base.d
31327702724Smrg      "$@" -MD
31427702724Smrg   fi
31527702724Smrg
31627702724Smrg   stat=$?
31727702724Smrg   if test $stat -eq 0; then :
31827702724Smrg   else
31927702724Smrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
32027702724Smrg      exit $stat
32127702724Smrg   fi
32227702724Smrg
32327702724Smrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
32427702724Smrg   do
32527702724Smrg     test -f "$tmpdepfile" && break
32627702724Smrg   done
32727702724Smrg   if test -f "$tmpdepfile"; then
32827702724Smrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
32927702724Smrg      # That's a tab and a space in the [].
33027702724Smrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
33127702724Smrg   else
33227702724Smrg      echo "#dummy" > "$depfile"
33327702724Smrg   fi
33427702724Smrg   rm -f "$tmpdepfile"
33527702724Smrg   ;;
33627702724Smrg
33727702724Smrg#nosideeffect)
33827702724Smrg  # This comment above is used by automake to tell side-effect
33927702724Smrg  # dependency tracking mechanisms from slower ones.
34027702724Smrg
34127702724Smrgdashmstdout)
34227702724Smrg  # Important note: in order to support this mode, a compiler *must*
34327702724Smrg  # always write the preprocessed file to stdout, regardless of -o.
34427702724Smrg  "$@" || exit $?
34527702724Smrg
34627702724Smrg  # Remove the call to Libtool.
34727702724Smrg  if test "$libtool" = yes; then
34827702724Smrg    while test $1 != '--mode=compile'; do
34927702724Smrg      shift
35027702724Smrg    done
35127702724Smrg    shift
35227702724Smrg  fi
35327702724Smrg
35427702724Smrg  # Remove `-o $object'.
35527702724Smrg  IFS=" "
35627702724Smrg  for arg
35727702724Smrg  do
35827702724Smrg    case $arg in
35927702724Smrg    -o)
36027702724Smrg      shift
36127702724Smrg      ;;
36227702724Smrg    $object)
36327702724Smrg      shift
36427702724Smrg      ;;
36527702724Smrg    *)
36627702724Smrg      set fnord "$@" "$arg"
36727702724Smrg      shift # fnord
36827702724Smrg      shift # $arg
36927702724Smrg      ;;
37027702724Smrg    esac
37127702724Smrg  done
37227702724Smrg
37327702724Smrg  test -z "$dashmflag" && dashmflag=-M
37427702724Smrg  # Require at least two characters before searching for `:'
37527702724Smrg  # in the target name.  This is to cope with DOS-style filenames:
37627702724Smrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
37727702724Smrg  "$@" $dashmflag |
37827702724Smrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
37927702724Smrg  rm -f "$depfile"
38027702724Smrg  cat < "$tmpdepfile" > "$depfile"
38127702724Smrg  tr ' ' '
38227702724Smrg' < "$tmpdepfile" | \
38327702724Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
38427702724Smrg## correctly.  Breaking it into two sed invocations is a workaround.
38527702724Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
38627702724Smrg  rm -f "$tmpdepfile"
38727702724Smrg  ;;
38827702724Smrg
38927702724SmrgdashXmstdout)
39027702724Smrg  # This case only exists to satisfy depend.m4.  It is never actually
39127702724Smrg  # run, as this mode is specially recognized in the preamble.
39227702724Smrg  exit 1
39327702724Smrg  ;;
39427702724Smrg
39527702724Smrgmakedepend)
39627702724Smrg  "$@" || exit $?
39727702724Smrg  # Remove any Libtool call
39827702724Smrg  if test "$libtool" = yes; then
39927702724Smrg    while test $1 != '--mode=compile'; do
40027702724Smrg      shift
40127702724Smrg    done
40227702724Smrg    shift
40327702724Smrg  fi
40427702724Smrg  # X makedepend
40527702724Smrg  shift
40627702724Smrg  cleared=no
40727702724Smrg  for arg in "$@"; do
40827702724Smrg    case $cleared in
40927702724Smrg    no)
41027702724Smrg      set ""; shift
41127702724Smrg      cleared=yes ;;
41227702724Smrg    esac
41327702724Smrg    case "$arg" in
41427702724Smrg    -D*|-I*)
41527702724Smrg      set fnord "$@" "$arg"; shift ;;
41627702724Smrg    # Strip any option that makedepend may not understand.  Remove
41727702724Smrg    # the object too, otherwise makedepend will parse it as a source file.
41827702724Smrg    -*|$object)
41927702724Smrg      ;;
42027702724Smrg    *)
42127702724Smrg      set fnord "$@" "$arg"; shift ;;
42227702724Smrg    esac
42327702724Smrg  done
42427702724Smrg  obj_suffix="`echo $object | sed 's/^.*\././'`"
42527702724Smrg  touch "$tmpdepfile"
42627702724Smrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
42727702724Smrg  rm -f "$depfile"
42827702724Smrg  cat < "$tmpdepfile" > "$depfile"
42927702724Smrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
43027702724Smrg' | \
43127702724Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
43227702724Smrg## correctly.  Breaking it into two sed invocations is a workaround.
43327702724Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
43427702724Smrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
43527702724Smrg  ;;
43627702724Smrg
43727702724Smrgcpp)
43827702724Smrg  # Important note: in order to support this mode, a compiler *must*
43927702724Smrg  # always write the preprocessed file to stdout.
44027702724Smrg  "$@" || exit $?
44127702724Smrg
44227702724Smrg  # Remove the call to Libtool.
44327702724Smrg  if test "$libtool" = yes; then
44427702724Smrg    while test $1 != '--mode=compile'; do
44527702724Smrg      shift
44627702724Smrg    done
44727702724Smrg    shift
44827702724Smrg  fi
44927702724Smrg
45027702724Smrg  # Remove `-o $object'.
45127702724Smrg  IFS=" "
45227702724Smrg  for arg
45327702724Smrg  do
45427702724Smrg    case $arg in
45527702724Smrg    -o)
45627702724Smrg      shift
45727702724Smrg      ;;
45827702724Smrg    $object)
45927702724Smrg      shift
46027702724Smrg      ;;
46127702724Smrg    *)
46227702724Smrg      set fnord "$@" "$arg"
46327702724Smrg      shift # fnord
46427702724Smrg      shift # $arg
46527702724Smrg      ;;
46627702724Smrg    esac
46727702724Smrg  done
46827702724Smrg
46927702724Smrg  "$@" -E |
47027702724Smrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
47127702724Smrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
47227702724Smrg    sed '$ s: \\$::' > "$tmpdepfile"
47327702724Smrg  rm -f "$depfile"
47427702724Smrg  echo "$object : \\" > "$depfile"
47527702724Smrg  cat < "$tmpdepfile" >> "$depfile"
47627702724Smrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
47727702724Smrg  rm -f "$tmpdepfile"
47827702724Smrg  ;;
47927702724Smrg
48027702724Smrgmsvisualcpp)
48127702724Smrg  # Important note: in order to support this mode, a compiler *must*
48227702724Smrg  # always write the preprocessed file to stdout, regardless of -o,
48327702724Smrg  # because we must use -o when running libtool.
48427702724Smrg  "$@" || exit $?
48527702724Smrg  IFS=" "
48627702724Smrg  for arg
48727702724Smrg  do
48827702724Smrg    case "$arg" in
48927702724Smrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
49027702724Smrg	set fnord "$@"
49127702724Smrg	shift
49227702724Smrg	shift
49327702724Smrg	;;
49427702724Smrg    *)
49527702724Smrg	set fnord "$@" "$arg"
49627702724Smrg	shift
49727702724Smrg	shift
49827702724Smrg	;;
49927702724Smrg    esac
50027702724Smrg  done
50127702724Smrg  "$@" -E |
50227702724Smrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
50327702724Smrg  rm -f "$depfile"
50427702724Smrg  echo "$object : \\" > "$depfile"
50527702724Smrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
50627702724Smrg  echo "	" >> "$depfile"
50727702724Smrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
50827702724Smrg  rm -f "$tmpdepfile"
50927702724Smrg  ;;
51027702724Smrg
51127702724Smrgnone)
51227702724Smrg  exec "$@"
51327702724Smrg  ;;
51427702724Smrg
51527702724Smrg*)
51627702724Smrg  echo "Unknown depmode $depmode" 1>&2
51727702724Smrg  exit 1
51827702724Smrg  ;;
51927702724Smrgesac
52027702724Smrg
52127702724Smrgexit 0
52227702724Smrg
52327702724Smrg# Local Variables:
52427702724Smrg# mode: shell-script
52527702724Smrg# sh-indentation: 2
52627702724Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
52727702724Smrg# time-stamp-start: "scriptversion="
52827702724Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
52927702724Smrg# time-stamp-end: "$"
53027702724Smrg# End:
531