depcomp revision 23a0898a
123a0898aSmrg#! /bin/sh
223a0898aSmrg# depcomp - compile a program generating dependencies as side-effects
323a0898aSmrg
423a0898aSmrgscriptversion=2007-03-29.01
523a0898aSmrg
623a0898aSmrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software
723a0898aSmrg# Foundation, Inc.
823a0898aSmrg
923a0898aSmrg# This program is free software; you can redistribute it and/or modify
1023a0898aSmrg# it under the terms of the GNU General Public License as published by
1123a0898aSmrg# the Free Software Foundation; either version 2, or (at your option)
1223a0898aSmrg# any later version.
1323a0898aSmrg
1423a0898aSmrg# This program is distributed in the hope that it will be useful,
1523a0898aSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
1623a0898aSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1723a0898aSmrg# GNU General Public License for more details.
1823a0898aSmrg
1923a0898aSmrg# You should have received a copy of the GNU General Public License
2023a0898aSmrg# along with this program; if not, write to the Free Software
2123a0898aSmrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2223a0898aSmrg# 02110-1301, USA.
2323a0898aSmrg
2423a0898aSmrg# As a special exception to the GNU General Public License, if you
2523a0898aSmrg# distribute this file as part of a program that contains a
2623a0898aSmrg# configuration script generated by Autoconf, you may include it under
2723a0898aSmrg# the same distribution terms that you use for the rest of that program.
2823a0898aSmrg
2923a0898aSmrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
3023a0898aSmrg
3123a0898aSmrgcase $1 in
3223a0898aSmrg  '')
3323a0898aSmrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
3423a0898aSmrg     exit 1;
3523a0898aSmrg     ;;
3623a0898aSmrg  -h | --h*)
3723a0898aSmrg    cat <<\EOF
3823a0898aSmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
3923a0898aSmrg
4023a0898aSmrgRun PROGRAMS ARGS to compile a file, generating dependencies
4123a0898aSmrgas side-effects.
4223a0898aSmrg
4323a0898aSmrgEnvironment variables:
4423a0898aSmrg  depmode     Dependency tracking mode.
4523a0898aSmrg  source      Source file read by `PROGRAMS ARGS'.
4623a0898aSmrg  object      Object file output by `PROGRAMS ARGS'.
4723a0898aSmrg  DEPDIR      directory where to store dependencies.
4823a0898aSmrg  depfile     Dependency file to output.
4923a0898aSmrg  tmpdepfile  Temporary file to use when outputing dependencies.
5023a0898aSmrg  libtool     Whether libtool is used (yes/no).
5123a0898aSmrg
5223a0898aSmrgReport bugs to <bug-automake@gnu.org>.
5323a0898aSmrgEOF
5423a0898aSmrg    exit $?
5523a0898aSmrg    ;;
5623a0898aSmrg  -v | --v*)
5723a0898aSmrg    echo "depcomp $scriptversion"
5823a0898aSmrg    exit $?
5923a0898aSmrg    ;;
6023a0898aSmrgesac
6123a0898aSmrg
6223a0898aSmrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
6323a0898aSmrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
6423a0898aSmrg  exit 1
6523a0898aSmrgfi
6623a0898aSmrg
6723a0898aSmrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
6823a0898aSmrgdepfile=${depfile-`echo "$object" |
6923a0898aSmrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
7023a0898aSmrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
7123a0898aSmrg
7223a0898aSmrgrm -f "$tmpdepfile"
7323a0898aSmrg
7423a0898aSmrg# Some modes work just like other modes, but use different flags.  We
7523a0898aSmrg# parameterize here, but still list the modes in the big case below,
7623a0898aSmrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
7723a0898aSmrg# here, because this file can only contain one case statement.
7823a0898aSmrgif test "$depmode" = hp; then
7923a0898aSmrg  # HP compiler uses -M and no extra arg.
8023a0898aSmrg  gccflag=-M
8123a0898aSmrg  depmode=gcc
8223a0898aSmrgfi
8323a0898aSmrg
8423a0898aSmrgif test "$depmode" = dashXmstdout; then
8523a0898aSmrg   # This is just like dashmstdout with a different argument.
8623a0898aSmrg   dashmflag=-xM
8723a0898aSmrg   depmode=dashmstdout
8823a0898aSmrgfi
8923a0898aSmrg
9023a0898aSmrgcase "$depmode" in
9123a0898aSmrggcc3)
9223a0898aSmrg## gcc 3 implements dependency tracking that does exactly what
9323a0898aSmrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
9423a0898aSmrg## it if -MD -MP comes after the -MF stuff.  Hmm.
9523a0898aSmrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
9623a0898aSmrg## the command line argument order; so add the flags where they
9723a0898aSmrg## appear in depend2.am.  Note that the slowdown incurred here
9823a0898aSmrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
9923a0898aSmrg  for arg
10023a0898aSmrg  do
10123a0898aSmrg    case $arg in
10223a0898aSmrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
10323a0898aSmrg    *)  set fnord "$@" "$arg" ;;
10423a0898aSmrg    esac
10523a0898aSmrg    shift # fnord
10623a0898aSmrg    shift # $arg
10723a0898aSmrg  done
10823a0898aSmrg  "$@"
10923a0898aSmrg  stat=$?
11023a0898aSmrg  if test $stat -eq 0; then :
11123a0898aSmrg  else
11223a0898aSmrg    rm -f "$tmpdepfile"
11323a0898aSmrg    exit $stat
11423a0898aSmrg  fi
11523a0898aSmrg  mv "$tmpdepfile" "$depfile"
11623a0898aSmrg  ;;
11723a0898aSmrg
11823a0898aSmrggcc)
11923a0898aSmrg## There are various ways to get dependency output from gcc.  Here's
12023a0898aSmrg## why we pick this rather obscure method:
12123a0898aSmrg## - Don't want to use -MD because we'd like the dependencies to end
12223a0898aSmrg##   up in a subdir.  Having to rename by hand is ugly.
12323a0898aSmrg##   (We might end up doing this anyway to support other compilers.)
12423a0898aSmrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
12523a0898aSmrg##   -MM, not -M (despite what the docs say).
12623a0898aSmrg## - Using -M directly means running the compiler twice (even worse
12723a0898aSmrg##   than renaming).
12823a0898aSmrg  if test -z "$gccflag"; then
12923a0898aSmrg    gccflag=-MD,
13023a0898aSmrg  fi
13123a0898aSmrg  "$@" -Wp,"$gccflag$tmpdepfile"
13223a0898aSmrg  stat=$?
13323a0898aSmrg  if test $stat -eq 0; then :
13423a0898aSmrg  else
13523a0898aSmrg    rm -f "$tmpdepfile"
13623a0898aSmrg    exit $stat
13723a0898aSmrg  fi
13823a0898aSmrg  rm -f "$depfile"
13923a0898aSmrg  echo "$object : \\" > "$depfile"
14023a0898aSmrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
14123a0898aSmrg## The second -e expression handles DOS-style file names with drive letters.
14223a0898aSmrg  sed -e 's/^[^:]*: / /' \
14323a0898aSmrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
14423a0898aSmrg## This next piece of magic avoids the `deleted header file' problem.
14523a0898aSmrg## The problem is that when a header file which appears in a .P file
14623a0898aSmrg## is deleted, the dependency causes make to die (because there is
14723a0898aSmrg## typically no way to rebuild the header).  We avoid this by adding
14823a0898aSmrg## dummy dependencies for each header file.  Too bad gcc doesn't do
14923a0898aSmrg## this for us directly.
15023a0898aSmrg  tr ' ' '
15123a0898aSmrg' < "$tmpdepfile" |
15223a0898aSmrg## Some versions of gcc put a space before the `:'.  On the theory
15323a0898aSmrg## that the space means something, we add a space to the output as
15423a0898aSmrg## well.
15523a0898aSmrg## Some versions of the HPUX 10.20 sed can't process this invocation
15623a0898aSmrg## correctly.  Breaking it into two sed invocations is a workaround.
15723a0898aSmrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
15823a0898aSmrg  rm -f "$tmpdepfile"
15923a0898aSmrg  ;;
16023a0898aSmrg
16123a0898aSmrghp)
16223a0898aSmrg  # This case exists only to let depend.m4 do its work.  It works by
16323a0898aSmrg  # looking at the text of this script.  This case will never be run,
16423a0898aSmrg  # since it is checked for above.
16523a0898aSmrg  exit 1
16623a0898aSmrg  ;;
16723a0898aSmrg
16823a0898aSmrgsgi)
16923a0898aSmrg  if test "$libtool" = yes; then
17023a0898aSmrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
17123a0898aSmrg  else
17223a0898aSmrg    "$@" -MDupdate "$tmpdepfile"
17323a0898aSmrg  fi
17423a0898aSmrg  stat=$?
17523a0898aSmrg  if test $stat -eq 0; then :
17623a0898aSmrg  else
17723a0898aSmrg    rm -f "$tmpdepfile"
17823a0898aSmrg    exit $stat
17923a0898aSmrg  fi
18023a0898aSmrg  rm -f "$depfile"
18123a0898aSmrg
18223a0898aSmrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
18323a0898aSmrg    echo "$object : \\" > "$depfile"
18423a0898aSmrg
18523a0898aSmrg    # Clip off the initial element (the dependent).  Don't try to be
18623a0898aSmrg    # clever and replace this with sed code, as IRIX sed won't handle
18723a0898aSmrg    # lines with more than a fixed number of characters (4096 in
18823a0898aSmrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
18923a0898aSmrg    # the IRIX cc adds comments like `#:fec' to the end of the
19023a0898aSmrg    # dependency line.
19123a0898aSmrg    tr ' ' '
19223a0898aSmrg' < "$tmpdepfile" \
19323a0898aSmrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
19423a0898aSmrg    tr '
19523a0898aSmrg' ' ' >> $depfile
19623a0898aSmrg    echo >> $depfile
19723a0898aSmrg
19823a0898aSmrg    # The second pass generates a dummy entry for each header file.
19923a0898aSmrg    tr ' ' '
20023a0898aSmrg' < "$tmpdepfile" \
20123a0898aSmrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
20223a0898aSmrg   >> $depfile
20323a0898aSmrg  else
20423a0898aSmrg    # The sourcefile does not contain any dependencies, so just
20523a0898aSmrg    # store a dummy comment line, to avoid errors with the Makefile
20623a0898aSmrg    # "include basename.Plo" scheme.
20723a0898aSmrg    echo "#dummy" > "$depfile"
20823a0898aSmrg  fi
20923a0898aSmrg  rm -f "$tmpdepfile"
21023a0898aSmrg  ;;
21123a0898aSmrg
21223a0898aSmrgaix)
21323a0898aSmrg  # The C for AIX Compiler uses -M and outputs the dependencies
21423a0898aSmrg  # in a .u file.  In older versions, this file always lives in the
21523a0898aSmrg  # current directory.  Also, the AIX compiler puts `$object:' at the
21623a0898aSmrg  # start of each line; $object doesn't have directory information.
21723a0898aSmrg  # Version 6 uses the directory in both cases.
21823a0898aSmrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
21923a0898aSmrg  test "x$dir" = "x$object" && dir=
22023a0898aSmrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
22123a0898aSmrg  if test "$libtool" = yes; then
22223a0898aSmrg    tmpdepfile1=$dir$base.u
22323a0898aSmrg    tmpdepfile2=$base.u
22423a0898aSmrg    tmpdepfile3=$dir.libs/$base.u
22523a0898aSmrg    "$@" -Wc,-M
22623a0898aSmrg  else
22723a0898aSmrg    tmpdepfile1=$dir$base.u
22823a0898aSmrg    tmpdepfile2=$dir$base.u
22923a0898aSmrg    tmpdepfile3=$dir$base.u
23023a0898aSmrg    "$@" -M
23123a0898aSmrg  fi
23223a0898aSmrg  stat=$?
23323a0898aSmrg
23423a0898aSmrg  if test $stat -eq 0; then :
23523a0898aSmrg  else
23623a0898aSmrg    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
23723a0898aSmrg    exit $stat
23823a0898aSmrg  fi
23923a0898aSmrg
24023a0898aSmrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
24123a0898aSmrg  do
24223a0898aSmrg    test -f "$tmpdepfile" && break
24323a0898aSmrg  done
24423a0898aSmrg  if test -f "$tmpdepfile"; then
24523a0898aSmrg    # Each line is of the form `foo.o: dependent.h'.
24623a0898aSmrg    # Do two passes, one to just change these to
24723a0898aSmrg    # `$object: dependent.h' and one to simply `dependent.h:'.
24823a0898aSmrg    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
24923a0898aSmrg    # That's a tab and a space in the [].
25023a0898aSmrg    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
25123a0898aSmrg  else
25223a0898aSmrg    # The sourcefile does not contain any dependencies, so just
25323a0898aSmrg    # store a dummy comment line, to avoid errors with the Makefile
25423a0898aSmrg    # "include basename.Plo" scheme.
25523a0898aSmrg    echo "#dummy" > "$depfile"
25623a0898aSmrg  fi
25723a0898aSmrg  rm -f "$tmpdepfile"
25823a0898aSmrg  ;;
25923a0898aSmrg
26023a0898aSmrgicc)
26123a0898aSmrg  # Intel's C compiler understands `-MD -MF file'.  However on
26223a0898aSmrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
26323a0898aSmrg  # ICC 7.0 will fill foo.d with something like
26423a0898aSmrg  #    foo.o: sub/foo.c
26523a0898aSmrg  #    foo.o: sub/foo.h
26623a0898aSmrg  # which is wrong.  We want:
26723a0898aSmrg  #    sub/foo.o: sub/foo.c
26823a0898aSmrg  #    sub/foo.o: sub/foo.h
26923a0898aSmrg  #    sub/foo.c:
27023a0898aSmrg  #    sub/foo.h:
27123a0898aSmrg  # ICC 7.1 will output
27223a0898aSmrg  #    foo.o: sub/foo.c sub/foo.h
27323a0898aSmrg  # and will wrap long lines using \ :
27423a0898aSmrg  #    foo.o: sub/foo.c ... \
27523a0898aSmrg  #     sub/foo.h ... \
27623a0898aSmrg  #     ...
27723a0898aSmrg
27823a0898aSmrg  "$@" -MD -MF "$tmpdepfile"
27923a0898aSmrg  stat=$?
28023a0898aSmrg  if test $stat -eq 0; then :
28123a0898aSmrg  else
28223a0898aSmrg    rm -f "$tmpdepfile"
28323a0898aSmrg    exit $stat
28423a0898aSmrg  fi
28523a0898aSmrg  rm -f "$depfile"
28623a0898aSmrg  # Each line is of the form `foo.o: dependent.h',
28723a0898aSmrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
28823a0898aSmrg  # Do two passes, one to just change these to
28923a0898aSmrg  # `$object: dependent.h' and one to simply `dependent.h:'.
29023a0898aSmrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
29123a0898aSmrg  # Some versions of the HPUX 10.20 sed can't process this invocation
29223a0898aSmrg  # correctly.  Breaking it into two sed invocations is a workaround.
29323a0898aSmrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
29423a0898aSmrg    sed -e 's/$/ :/' >> "$depfile"
29523a0898aSmrg  rm -f "$tmpdepfile"
29623a0898aSmrg  ;;
29723a0898aSmrg
29823a0898aSmrghp2)
29923a0898aSmrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
30023a0898aSmrg  # compilers, which have integrated preprocessors.  The correct option
30123a0898aSmrg  # to use with these is +Maked; it writes dependencies to a file named
30223a0898aSmrg  # 'foo.d', which lands next to the object file, wherever that
30323a0898aSmrg  # happens to be.
30423a0898aSmrg  # Much of this is similar to the tru64 case; see comments there.
30523a0898aSmrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
30623a0898aSmrg  test "x$dir" = "x$object" && dir=
30723a0898aSmrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
30823a0898aSmrg  if test "$libtool" = yes; then
30923a0898aSmrg    tmpdepfile1=$dir$base.d
31023a0898aSmrg    tmpdepfile2=$dir.libs/$base.d
31123a0898aSmrg    "$@" -Wc,+Maked
31223a0898aSmrg  else
31323a0898aSmrg    tmpdepfile1=$dir$base.d
31423a0898aSmrg    tmpdepfile2=$dir$base.d
31523a0898aSmrg    "$@" +Maked
31623a0898aSmrg  fi
31723a0898aSmrg  stat=$?
31823a0898aSmrg  if test $stat -eq 0; then :
31923a0898aSmrg  else
32023a0898aSmrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
32123a0898aSmrg     exit $stat
32223a0898aSmrg  fi
32323a0898aSmrg
32423a0898aSmrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
32523a0898aSmrg  do
32623a0898aSmrg    test -f "$tmpdepfile" && break
32723a0898aSmrg  done
32823a0898aSmrg  if test -f "$tmpdepfile"; then
32923a0898aSmrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
33023a0898aSmrg    # Add `dependent.h:' lines.
33123a0898aSmrg    sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
33223a0898aSmrg  else
33323a0898aSmrg    echo "#dummy" > "$depfile"
33423a0898aSmrg  fi
33523a0898aSmrg  rm -f "$tmpdepfile" "$tmpdepfile2"
33623a0898aSmrg  ;;
33723a0898aSmrg
33823a0898aSmrgtru64)
33923a0898aSmrg   # The Tru64 compiler uses -MD to generate dependencies as a side
34023a0898aSmrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
34123a0898aSmrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
34223a0898aSmrg   # dependencies in `foo.d' instead, so we check for that too.
34323a0898aSmrg   # Subdirectories are respected.
34423a0898aSmrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
34523a0898aSmrg   test "x$dir" = "x$object" && dir=
34623a0898aSmrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
34723a0898aSmrg
34823a0898aSmrg   if test "$libtool" = yes; then
34923a0898aSmrg      # With Tru64 cc, shared objects can also be used to make a
35023a0898aSmrg      # static library.  This mechanism is used in libtool 1.4 series to
35123a0898aSmrg      # handle both shared and static libraries in a single compilation.
35223a0898aSmrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
35323a0898aSmrg      #
35423a0898aSmrg      # With libtool 1.5 this exception was removed, and libtool now
35523a0898aSmrg      # generates 2 separate objects for the 2 libraries.  These two
35623a0898aSmrg      # compilations output dependencies in $dir.libs/$base.o.d and
35723a0898aSmrg      # in $dir$base.o.d.  We have to check for both files, because
35823a0898aSmrg      # one of the two compilations can be disabled.  We should prefer
35923a0898aSmrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
36023a0898aSmrg      # automatically cleaned when .libs/ is deleted, while ignoring
36123a0898aSmrg      # the former would cause a distcleancheck panic.
36223a0898aSmrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
36323a0898aSmrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
36423a0898aSmrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
36523a0898aSmrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
36623a0898aSmrg      "$@" -Wc,-MD
36723a0898aSmrg   else
36823a0898aSmrg      tmpdepfile1=$dir$base.o.d
36923a0898aSmrg      tmpdepfile2=$dir$base.d
37023a0898aSmrg      tmpdepfile3=$dir$base.d
37123a0898aSmrg      tmpdepfile4=$dir$base.d
37223a0898aSmrg      "$@" -MD
37323a0898aSmrg   fi
37423a0898aSmrg
37523a0898aSmrg   stat=$?
37623a0898aSmrg   if test $stat -eq 0; then :
37723a0898aSmrg   else
37823a0898aSmrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
37923a0898aSmrg      exit $stat
38023a0898aSmrg   fi
38123a0898aSmrg
38223a0898aSmrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
38323a0898aSmrg   do
38423a0898aSmrg     test -f "$tmpdepfile" && break
38523a0898aSmrg   done
38623a0898aSmrg   if test -f "$tmpdepfile"; then
38723a0898aSmrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
38823a0898aSmrg      # That's a tab and a space in the [].
38923a0898aSmrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
39023a0898aSmrg   else
39123a0898aSmrg      echo "#dummy" > "$depfile"
39223a0898aSmrg   fi
39323a0898aSmrg   rm -f "$tmpdepfile"
39423a0898aSmrg   ;;
39523a0898aSmrg
39623a0898aSmrg#nosideeffect)
39723a0898aSmrg  # This comment above is used by automake to tell side-effect
39823a0898aSmrg  # dependency tracking mechanisms from slower ones.
39923a0898aSmrg
40023a0898aSmrgdashmstdout)
40123a0898aSmrg  # Important note: in order to support this mode, a compiler *must*
40223a0898aSmrg  # always write the preprocessed file to stdout, regardless of -o.
40323a0898aSmrg  "$@" || exit $?
40423a0898aSmrg
40523a0898aSmrg  # Remove the call to Libtool.
40623a0898aSmrg  if test "$libtool" = yes; then
40723a0898aSmrg    while test $1 != '--mode=compile'; do
40823a0898aSmrg      shift
40923a0898aSmrg    done
41023a0898aSmrg    shift
41123a0898aSmrg  fi
41223a0898aSmrg
41323a0898aSmrg  # Remove `-o $object'.
41423a0898aSmrg  IFS=" "
41523a0898aSmrg  for arg
41623a0898aSmrg  do
41723a0898aSmrg    case $arg in
41823a0898aSmrg    -o)
41923a0898aSmrg      shift
42023a0898aSmrg      ;;
42123a0898aSmrg    $object)
42223a0898aSmrg      shift
42323a0898aSmrg      ;;
42423a0898aSmrg    *)
42523a0898aSmrg      set fnord "$@" "$arg"
42623a0898aSmrg      shift # fnord
42723a0898aSmrg      shift # $arg
42823a0898aSmrg      ;;
42923a0898aSmrg    esac
43023a0898aSmrg  done
43123a0898aSmrg
43223a0898aSmrg  test -z "$dashmflag" && dashmflag=-M
43323a0898aSmrg  # Require at least two characters before searching for `:'
43423a0898aSmrg  # in the target name.  This is to cope with DOS-style filenames:
43523a0898aSmrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
43623a0898aSmrg  "$@" $dashmflag |
43723a0898aSmrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
43823a0898aSmrg  rm -f "$depfile"
43923a0898aSmrg  cat < "$tmpdepfile" > "$depfile"
44023a0898aSmrg  tr ' ' '
44123a0898aSmrg' < "$tmpdepfile" | \
44223a0898aSmrg## Some versions of the HPUX 10.20 sed can't process this invocation
44323a0898aSmrg## correctly.  Breaking it into two sed invocations is a workaround.
44423a0898aSmrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
44523a0898aSmrg  rm -f "$tmpdepfile"
44623a0898aSmrg  ;;
44723a0898aSmrg
44823a0898aSmrgdashXmstdout)
44923a0898aSmrg  # This case only exists to satisfy depend.m4.  It is never actually
45023a0898aSmrg  # run, as this mode is specially recognized in the preamble.
45123a0898aSmrg  exit 1
45223a0898aSmrg  ;;
45323a0898aSmrg
45423a0898aSmrgmakedepend)
45523a0898aSmrg  "$@" || exit $?
45623a0898aSmrg  # Remove any Libtool call
45723a0898aSmrg  if test "$libtool" = yes; then
45823a0898aSmrg    while test $1 != '--mode=compile'; do
45923a0898aSmrg      shift
46023a0898aSmrg    done
46123a0898aSmrg    shift
46223a0898aSmrg  fi
46323a0898aSmrg  # X makedepend
46423a0898aSmrg  shift
46523a0898aSmrg  cleared=no
46623a0898aSmrg  for arg in "$@"; do
46723a0898aSmrg    case $cleared in
46823a0898aSmrg    no)
46923a0898aSmrg      set ""; shift
47023a0898aSmrg      cleared=yes ;;
47123a0898aSmrg    esac
47223a0898aSmrg    case "$arg" in
47323a0898aSmrg    -D*|-I*)
47423a0898aSmrg      set fnord "$@" "$arg"; shift ;;
47523a0898aSmrg    # Strip any option that makedepend may not understand.  Remove
47623a0898aSmrg    # the object too, otherwise makedepend will parse it as a source file.
47723a0898aSmrg    -*|$object)
47823a0898aSmrg      ;;
47923a0898aSmrg    *)
48023a0898aSmrg      set fnord "$@" "$arg"; shift ;;
48123a0898aSmrg    esac
48223a0898aSmrg  done
48323a0898aSmrg  obj_suffix="`echo $object | sed 's/^.*\././'`"
48423a0898aSmrg  touch "$tmpdepfile"
48523a0898aSmrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
48623a0898aSmrg  rm -f "$depfile"
48723a0898aSmrg  cat < "$tmpdepfile" > "$depfile"
48823a0898aSmrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
48923a0898aSmrg' | \
49023a0898aSmrg## Some versions of the HPUX 10.20 sed can't process this invocation
49123a0898aSmrg## correctly.  Breaking it into two sed invocations is a workaround.
49223a0898aSmrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
49323a0898aSmrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
49423a0898aSmrg  ;;
49523a0898aSmrg
49623a0898aSmrgcpp)
49723a0898aSmrg  # Important note: in order to support this mode, a compiler *must*
49823a0898aSmrg  # always write the preprocessed file to stdout.
49923a0898aSmrg  "$@" || exit $?
50023a0898aSmrg
50123a0898aSmrg  # Remove the call to Libtool.
50223a0898aSmrg  if test "$libtool" = yes; then
50323a0898aSmrg    while test $1 != '--mode=compile'; do
50423a0898aSmrg      shift
50523a0898aSmrg    done
50623a0898aSmrg    shift
50723a0898aSmrg  fi
50823a0898aSmrg
50923a0898aSmrg  # Remove `-o $object'.
51023a0898aSmrg  IFS=" "
51123a0898aSmrg  for arg
51223a0898aSmrg  do
51323a0898aSmrg    case $arg in
51423a0898aSmrg    -o)
51523a0898aSmrg      shift
51623a0898aSmrg      ;;
51723a0898aSmrg    $object)
51823a0898aSmrg      shift
51923a0898aSmrg      ;;
52023a0898aSmrg    *)
52123a0898aSmrg      set fnord "$@" "$arg"
52223a0898aSmrg      shift # fnord
52323a0898aSmrg      shift # $arg
52423a0898aSmrg      ;;
52523a0898aSmrg    esac
52623a0898aSmrg  done
52723a0898aSmrg
52823a0898aSmrg  "$@" -E |
52923a0898aSmrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
53023a0898aSmrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
53123a0898aSmrg    sed '$ s: \\$::' > "$tmpdepfile"
53223a0898aSmrg  rm -f "$depfile"
53323a0898aSmrg  echo "$object : \\" > "$depfile"
53423a0898aSmrg  cat < "$tmpdepfile" >> "$depfile"
53523a0898aSmrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
53623a0898aSmrg  rm -f "$tmpdepfile"
53723a0898aSmrg  ;;
53823a0898aSmrg
53923a0898aSmrgmsvisualcpp)
54023a0898aSmrg  # Important note: in order to support this mode, a compiler *must*
54123a0898aSmrg  # always write the preprocessed file to stdout, regardless of -o,
54223a0898aSmrg  # because we must use -o when running libtool.
54323a0898aSmrg  "$@" || exit $?
54423a0898aSmrg  IFS=" "
54523a0898aSmrg  for arg
54623a0898aSmrg  do
54723a0898aSmrg    case "$arg" in
54823a0898aSmrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
54923a0898aSmrg	set fnord "$@"
55023a0898aSmrg	shift
55123a0898aSmrg	shift
55223a0898aSmrg	;;
55323a0898aSmrg    *)
55423a0898aSmrg	set fnord "$@" "$arg"
55523a0898aSmrg	shift
55623a0898aSmrg	shift
55723a0898aSmrg	;;
55823a0898aSmrg    esac
55923a0898aSmrg  done
56023a0898aSmrg  "$@" -E |
56123a0898aSmrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
56223a0898aSmrg  rm -f "$depfile"
56323a0898aSmrg  echo "$object : \\" > "$depfile"
56423a0898aSmrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
56523a0898aSmrg  echo "	" >> "$depfile"
56623a0898aSmrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
56723a0898aSmrg  rm -f "$tmpdepfile"
56823a0898aSmrg  ;;
56923a0898aSmrg
57023a0898aSmrgnone)
57123a0898aSmrg  exec "$@"
57223a0898aSmrg  ;;
57323a0898aSmrg
57423a0898aSmrg*)
57523a0898aSmrg  echo "Unknown depmode $depmode" 1>&2
57623a0898aSmrg  exit 1
57723a0898aSmrg  ;;
57823a0898aSmrgesac
57923a0898aSmrg
58023a0898aSmrgexit 0
58123a0898aSmrg
58223a0898aSmrg# Local Variables:
58323a0898aSmrg# mode: shell-script
58423a0898aSmrg# sh-indentation: 2
58523a0898aSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
58623a0898aSmrg# time-stamp-start: "scriptversion="
58723a0898aSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
58823a0898aSmrg# time-stamp-end: "$"
58923a0898aSmrg# End:
590