depcomp revision b68e1f86
16df26cacSmrg#! /bin/sh
26df26cacSmrg# depcomp - compile a program generating dependencies as side-effects
36df26cacSmrg
4b68e1f86Smrgscriptversion=2007-03-29.01
56df26cacSmrg
6b68e1f86Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software
7b68e1f86Smrg# Foundation, Inc.
86df26cacSmrg
96df26cacSmrg# This program is free software; you can redistribute it and/or modify
106df26cacSmrg# it under the terms of the GNU General Public License as published by
116df26cacSmrg# the Free Software Foundation; either version 2, or (at your option)
126df26cacSmrg# any later version.
136df26cacSmrg
146df26cacSmrg# This program is distributed in the hope that it will be useful,
156df26cacSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
166df26cacSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
176df26cacSmrg# GNU General Public License for more details.
186df26cacSmrg
196df26cacSmrg# You should have received a copy of the GNU General Public License
206df26cacSmrg# along with this program; if not, write to the Free Software
216df26cacSmrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
226df26cacSmrg# 02110-1301, USA.
236df26cacSmrg
246df26cacSmrg# As a special exception to the GNU General Public License, if you
256df26cacSmrg# distribute this file as part of a program that contains a
266df26cacSmrg# configuration script generated by Autoconf, you may include it under
276df26cacSmrg# the same distribution terms that you use for the rest of that program.
286df26cacSmrg
296df26cacSmrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
306df26cacSmrg
316df26cacSmrgcase $1 in
326df26cacSmrg  '')
336df26cacSmrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
346df26cacSmrg     exit 1;
356df26cacSmrg     ;;
366df26cacSmrg  -h | --h*)
376df26cacSmrg    cat <<\EOF
386df26cacSmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
396df26cacSmrg
406df26cacSmrgRun PROGRAMS ARGS to compile a file, generating dependencies
416df26cacSmrgas side-effects.
426df26cacSmrg
436df26cacSmrgEnvironment variables:
446df26cacSmrg  depmode     Dependency tracking mode.
456df26cacSmrg  source      Source file read by `PROGRAMS ARGS'.
466df26cacSmrg  object      Object file output by `PROGRAMS ARGS'.
476df26cacSmrg  DEPDIR      directory where to store dependencies.
486df26cacSmrg  depfile     Dependency file to output.
496df26cacSmrg  tmpdepfile  Temporary file to use when outputing dependencies.
506df26cacSmrg  libtool     Whether libtool is used (yes/no).
516df26cacSmrg
526df26cacSmrgReport bugs to <bug-automake@gnu.org>.
536df26cacSmrgEOF
546df26cacSmrg    exit $?
556df26cacSmrg    ;;
566df26cacSmrg  -v | --v*)
576df26cacSmrg    echo "depcomp $scriptversion"
586df26cacSmrg    exit $?
596df26cacSmrg    ;;
606df26cacSmrgesac
616df26cacSmrg
626df26cacSmrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
636df26cacSmrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
646df26cacSmrg  exit 1
656df26cacSmrgfi
666df26cacSmrg
676df26cacSmrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
686df26cacSmrgdepfile=${depfile-`echo "$object" |
696df26cacSmrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
706df26cacSmrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
716df26cacSmrg
726df26cacSmrgrm -f "$tmpdepfile"
736df26cacSmrg
746df26cacSmrg# Some modes work just like other modes, but use different flags.  We
756df26cacSmrg# parameterize here, but still list the modes in the big case below,
766df26cacSmrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
776df26cacSmrg# here, because this file can only contain one case statement.
786df26cacSmrgif test "$depmode" = hp; then
796df26cacSmrg  # HP compiler uses -M and no extra arg.
806df26cacSmrg  gccflag=-M
816df26cacSmrg  depmode=gcc
826df26cacSmrgfi
836df26cacSmrg
846df26cacSmrgif test "$depmode" = dashXmstdout; then
856df26cacSmrg   # This is just like dashmstdout with a different argument.
866df26cacSmrg   dashmflag=-xM
876df26cacSmrg   depmode=dashmstdout
886df26cacSmrgfi
896df26cacSmrg
906df26cacSmrgcase "$depmode" in
916df26cacSmrggcc3)
926df26cacSmrg## gcc 3 implements dependency tracking that does exactly what
936df26cacSmrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
946df26cacSmrg## it if -MD -MP comes after the -MF stuff.  Hmm.
95b68e1f86Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
96b68e1f86Smrg## the command line argument order; so add the flags where they
97b68e1f86Smrg## appear in depend2.am.  Note that the slowdown incurred here
98b68e1f86Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
99b68e1f86Smrg  for arg
100b68e1f86Smrg  do
101b68e1f86Smrg    case $arg in
102b68e1f86Smrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
103b68e1f86Smrg    *)  set fnord "$@" "$arg" ;;
104b68e1f86Smrg    esac
105b68e1f86Smrg    shift # fnord
106b68e1f86Smrg    shift # $arg
107b68e1f86Smrg  done
108b68e1f86Smrg  "$@"
1096df26cacSmrg  stat=$?
1106df26cacSmrg  if test $stat -eq 0; then :
1116df26cacSmrg  else
1126df26cacSmrg    rm -f "$tmpdepfile"
1136df26cacSmrg    exit $stat
1146df26cacSmrg  fi
1156df26cacSmrg  mv "$tmpdepfile" "$depfile"
1166df26cacSmrg  ;;
1176df26cacSmrg
1186df26cacSmrggcc)
1196df26cacSmrg## There are various ways to get dependency output from gcc.  Here's
1206df26cacSmrg## why we pick this rather obscure method:
1216df26cacSmrg## - Don't want to use -MD because we'd like the dependencies to end
1226df26cacSmrg##   up in a subdir.  Having to rename by hand is ugly.
1236df26cacSmrg##   (We might end up doing this anyway to support other compilers.)
1246df26cacSmrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
1256df26cacSmrg##   -MM, not -M (despite what the docs say).
1266df26cacSmrg## - Using -M directly means running the compiler twice (even worse
1276df26cacSmrg##   than renaming).
1286df26cacSmrg  if test -z "$gccflag"; then
1296df26cacSmrg    gccflag=-MD,
1306df26cacSmrg  fi
1316df26cacSmrg  "$@" -Wp,"$gccflag$tmpdepfile"
1326df26cacSmrg  stat=$?
1336df26cacSmrg  if test $stat -eq 0; then :
1346df26cacSmrg  else
1356df26cacSmrg    rm -f "$tmpdepfile"
1366df26cacSmrg    exit $stat
1376df26cacSmrg  fi
1386df26cacSmrg  rm -f "$depfile"
1396df26cacSmrg  echo "$object : \\" > "$depfile"
1406df26cacSmrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
1416df26cacSmrg## The second -e expression handles DOS-style file names with drive letters.
1426df26cacSmrg  sed -e 's/^[^:]*: / /' \
1436df26cacSmrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
1446df26cacSmrg## This next piece of magic avoids the `deleted header file' problem.
1456df26cacSmrg## The problem is that when a header file which appears in a .P file
1466df26cacSmrg## is deleted, the dependency causes make to die (because there is
1476df26cacSmrg## typically no way to rebuild the header).  We avoid this by adding
1486df26cacSmrg## dummy dependencies for each header file.  Too bad gcc doesn't do
1496df26cacSmrg## this for us directly.
1506df26cacSmrg  tr ' ' '
1516df26cacSmrg' < "$tmpdepfile" |
1526df26cacSmrg## Some versions of gcc put a space before the `:'.  On the theory
1536df26cacSmrg## that the space means something, we add a space to the output as
1546df26cacSmrg## well.
1556df26cacSmrg## Some versions of the HPUX 10.20 sed can't process this invocation
1566df26cacSmrg## correctly.  Breaking it into two sed invocations is a workaround.
1576df26cacSmrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
1586df26cacSmrg  rm -f "$tmpdepfile"
1596df26cacSmrg  ;;
1606df26cacSmrg
1616df26cacSmrghp)
1626df26cacSmrg  # This case exists only to let depend.m4 do its work.  It works by
1636df26cacSmrg  # looking at the text of this script.  This case will never be run,
1646df26cacSmrg  # since it is checked for above.
1656df26cacSmrg  exit 1
1666df26cacSmrg  ;;
1676df26cacSmrg
1686df26cacSmrgsgi)
1696df26cacSmrg  if test "$libtool" = yes; then
1706df26cacSmrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
1716df26cacSmrg  else
1726df26cacSmrg    "$@" -MDupdate "$tmpdepfile"
1736df26cacSmrg  fi
1746df26cacSmrg  stat=$?
1756df26cacSmrg  if test $stat -eq 0; then :
1766df26cacSmrg  else
1776df26cacSmrg    rm -f "$tmpdepfile"
1786df26cacSmrg    exit $stat
1796df26cacSmrg  fi
1806df26cacSmrg  rm -f "$depfile"
1816df26cacSmrg
1826df26cacSmrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
1836df26cacSmrg    echo "$object : \\" > "$depfile"
1846df26cacSmrg
1856df26cacSmrg    # Clip off the initial element (the dependent).  Don't try to be
1866df26cacSmrg    # clever and replace this with sed code, as IRIX sed won't handle
1876df26cacSmrg    # lines with more than a fixed number of characters (4096 in
1886df26cacSmrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
1896df26cacSmrg    # the IRIX cc adds comments like `#:fec' to the end of the
1906df26cacSmrg    # dependency line.
1916df26cacSmrg    tr ' ' '
1926df26cacSmrg' < "$tmpdepfile" \
1936df26cacSmrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
1946df26cacSmrg    tr '
1956df26cacSmrg' ' ' >> $depfile
1966df26cacSmrg    echo >> $depfile
1976df26cacSmrg
1986df26cacSmrg    # The second pass generates a dummy entry for each header file.
1996df26cacSmrg    tr ' ' '
2006df26cacSmrg' < "$tmpdepfile" \
2016df26cacSmrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
2026df26cacSmrg   >> $depfile
2036df26cacSmrg  else
2046df26cacSmrg    # The sourcefile does not contain any dependencies, so just
2056df26cacSmrg    # store a dummy comment line, to avoid errors with the Makefile
2066df26cacSmrg    # "include basename.Plo" scheme.
2076df26cacSmrg    echo "#dummy" > "$depfile"
2086df26cacSmrg  fi
2096df26cacSmrg  rm -f "$tmpdepfile"
2106df26cacSmrg  ;;
2116df26cacSmrg
2126df26cacSmrgaix)
2136df26cacSmrg  # The C for AIX Compiler uses -M and outputs the dependencies
2146df26cacSmrg  # in a .u file.  In older versions, this file always lives in the
2156df26cacSmrg  # current directory.  Also, the AIX compiler puts `$object:' at the
2166df26cacSmrg  # start of each line; $object doesn't have directory information.
2176df26cacSmrg  # Version 6 uses the directory in both cases.
218b68e1f86Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
219b68e1f86Smrg  test "x$dir" = "x$object" && dir=
220b68e1f86Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
2216df26cacSmrg  if test "$libtool" = yes; then
222b68e1f86Smrg    tmpdepfile1=$dir$base.u
223b68e1f86Smrg    tmpdepfile2=$base.u
224b68e1f86Smrg    tmpdepfile3=$dir.libs/$base.u
2256df26cacSmrg    "$@" -Wc,-M
2266df26cacSmrg  else
227b68e1f86Smrg    tmpdepfile1=$dir$base.u
228b68e1f86Smrg    tmpdepfile2=$dir$base.u
229b68e1f86Smrg    tmpdepfile3=$dir$base.u
2306df26cacSmrg    "$@" -M
2316df26cacSmrg  fi
2326df26cacSmrg  stat=$?
2336df26cacSmrg
2346df26cacSmrg  if test $stat -eq 0; then :
2356df26cacSmrg  else
236b68e1f86Smrg    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
2376df26cacSmrg    exit $stat
2386df26cacSmrg  fi
2396df26cacSmrg
240b68e1f86Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
241b68e1f86Smrg  do
242b68e1f86Smrg    test -f "$tmpdepfile" && break
243b68e1f86Smrg  done
2446df26cacSmrg  if test -f "$tmpdepfile"; then
2456df26cacSmrg    # Each line is of the form `foo.o: dependent.h'.
2466df26cacSmrg    # Do two passes, one to just change these to
2476df26cacSmrg    # `$object: dependent.h' and one to simply `dependent.h:'.
248b68e1f86Smrg    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
249b68e1f86Smrg    # That's a tab and a space in the [].
250b68e1f86Smrg    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
2516df26cacSmrg  else
2526df26cacSmrg    # The sourcefile does not contain any dependencies, so just
2536df26cacSmrg    # store a dummy comment line, to avoid errors with the Makefile
2546df26cacSmrg    # "include basename.Plo" scheme.
2556df26cacSmrg    echo "#dummy" > "$depfile"
2566df26cacSmrg  fi
2576df26cacSmrg  rm -f "$tmpdepfile"
2586df26cacSmrg  ;;
2596df26cacSmrg
2606df26cacSmrgicc)
2616df26cacSmrg  # Intel's C compiler understands `-MD -MF file'.  However on
2626df26cacSmrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
2636df26cacSmrg  # ICC 7.0 will fill foo.d with something like
2646df26cacSmrg  #    foo.o: sub/foo.c
2656df26cacSmrg  #    foo.o: sub/foo.h
2666df26cacSmrg  # which is wrong.  We want:
2676df26cacSmrg  #    sub/foo.o: sub/foo.c
2686df26cacSmrg  #    sub/foo.o: sub/foo.h
2696df26cacSmrg  #    sub/foo.c:
2706df26cacSmrg  #    sub/foo.h:
2716df26cacSmrg  # ICC 7.1 will output
2726df26cacSmrg  #    foo.o: sub/foo.c sub/foo.h
2736df26cacSmrg  # and will wrap long lines using \ :
2746df26cacSmrg  #    foo.o: sub/foo.c ... \
2756df26cacSmrg  #     sub/foo.h ... \
2766df26cacSmrg  #     ...
2776df26cacSmrg
2786df26cacSmrg  "$@" -MD -MF "$tmpdepfile"
2796df26cacSmrg  stat=$?
2806df26cacSmrg  if test $stat -eq 0; then :
2816df26cacSmrg  else
2826df26cacSmrg    rm -f "$tmpdepfile"
2836df26cacSmrg    exit $stat
2846df26cacSmrg  fi
2856df26cacSmrg  rm -f "$depfile"
2866df26cacSmrg  # Each line is of the form `foo.o: dependent.h',
2876df26cacSmrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
2886df26cacSmrg  # Do two passes, one to just change these to
2896df26cacSmrg  # `$object: dependent.h' and one to simply `dependent.h:'.
2906df26cacSmrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
2916df26cacSmrg  # Some versions of the HPUX 10.20 sed can't process this invocation
2926df26cacSmrg  # correctly.  Breaking it into two sed invocations is a workaround.
2936df26cacSmrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
2946df26cacSmrg    sed -e 's/$/ :/' >> "$depfile"
2956df26cacSmrg  rm -f "$tmpdepfile"
2966df26cacSmrg  ;;
2976df26cacSmrg
298b68e1f86Smrghp2)
299b68e1f86Smrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
300b68e1f86Smrg  # compilers, which have integrated preprocessors.  The correct option
301b68e1f86Smrg  # to use with these is +Maked; it writes dependencies to a file named
302b68e1f86Smrg  # 'foo.d', which lands next to the object file, wherever that
303b68e1f86Smrg  # happens to be.
304b68e1f86Smrg  # Much of this is similar to the tru64 case; see comments there.
305b68e1f86Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
306b68e1f86Smrg  test "x$dir" = "x$object" && dir=
307b68e1f86Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
308b68e1f86Smrg  if test "$libtool" = yes; then
309b68e1f86Smrg    tmpdepfile1=$dir$base.d
310b68e1f86Smrg    tmpdepfile2=$dir.libs/$base.d
311b68e1f86Smrg    "$@" -Wc,+Maked
312b68e1f86Smrg  else
313b68e1f86Smrg    tmpdepfile1=$dir$base.d
314b68e1f86Smrg    tmpdepfile2=$dir$base.d
315b68e1f86Smrg    "$@" +Maked
316b68e1f86Smrg  fi
317b68e1f86Smrg  stat=$?
318b68e1f86Smrg  if test $stat -eq 0; then :
319b68e1f86Smrg  else
320b68e1f86Smrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
321b68e1f86Smrg     exit $stat
322b68e1f86Smrg  fi
323b68e1f86Smrg
324b68e1f86Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
325b68e1f86Smrg  do
326b68e1f86Smrg    test -f "$tmpdepfile" && break
327b68e1f86Smrg  done
328b68e1f86Smrg  if test -f "$tmpdepfile"; then
329b68e1f86Smrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
330b68e1f86Smrg    # Add `dependent.h:' lines.
331b68e1f86Smrg    sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
332b68e1f86Smrg  else
333b68e1f86Smrg    echo "#dummy" > "$depfile"
334b68e1f86Smrg  fi
335b68e1f86Smrg  rm -f "$tmpdepfile" "$tmpdepfile2"
336b68e1f86Smrg  ;;
337b68e1f86Smrg
3386df26cacSmrgtru64)
3396df26cacSmrg   # The Tru64 compiler uses -MD to generate dependencies as a side
3406df26cacSmrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
3416df26cacSmrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
3426df26cacSmrg   # dependencies in `foo.d' instead, so we check for that too.
3436df26cacSmrg   # Subdirectories are respected.
3446df26cacSmrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3456df26cacSmrg   test "x$dir" = "x$object" && dir=
3466df26cacSmrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3476df26cacSmrg
3486df26cacSmrg   if test "$libtool" = yes; then
3496df26cacSmrg      # With Tru64 cc, shared objects can also be used to make a
350b68e1f86Smrg      # static library.  This mechanism is used in libtool 1.4 series to
3516df26cacSmrg      # handle both shared and static libraries in a single compilation.
3526df26cacSmrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
3536df26cacSmrg      #
3546df26cacSmrg      # With libtool 1.5 this exception was removed, and libtool now
3556df26cacSmrg      # generates 2 separate objects for the 2 libraries.  These two
356b68e1f86Smrg      # compilations output dependencies in $dir.libs/$base.o.d and
3576df26cacSmrg      # in $dir$base.o.d.  We have to check for both files, because
3586df26cacSmrg      # one of the two compilations can be disabled.  We should prefer
3596df26cacSmrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
3606df26cacSmrg      # automatically cleaned when .libs/ is deleted, while ignoring
3616df26cacSmrg      # the former would cause a distcleancheck panic.
3626df26cacSmrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
3636df26cacSmrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
3646df26cacSmrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
3656df26cacSmrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
3666df26cacSmrg      "$@" -Wc,-MD
3676df26cacSmrg   else
3686df26cacSmrg      tmpdepfile1=$dir$base.o.d
3696df26cacSmrg      tmpdepfile2=$dir$base.d
3706df26cacSmrg      tmpdepfile3=$dir$base.d
3716df26cacSmrg      tmpdepfile4=$dir$base.d
3726df26cacSmrg      "$@" -MD
3736df26cacSmrg   fi
3746df26cacSmrg
3756df26cacSmrg   stat=$?
3766df26cacSmrg   if test $stat -eq 0; then :
3776df26cacSmrg   else
3786df26cacSmrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
3796df26cacSmrg      exit $stat
3806df26cacSmrg   fi
3816df26cacSmrg
3826df26cacSmrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
3836df26cacSmrg   do
3846df26cacSmrg     test -f "$tmpdepfile" && break
3856df26cacSmrg   done
3866df26cacSmrg   if test -f "$tmpdepfile"; then
3876df26cacSmrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
3886df26cacSmrg      # That's a tab and a space in the [].
3896df26cacSmrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
3906df26cacSmrg   else
3916df26cacSmrg      echo "#dummy" > "$depfile"
3926df26cacSmrg   fi
3936df26cacSmrg   rm -f "$tmpdepfile"
3946df26cacSmrg   ;;
3956df26cacSmrg
3966df26cacSmrg#nosideeffect)
3976df26cacSmrg  # This comment above is used by automake to tell side-effect
3986df26cacSmrg  # dependency tracking mechanisms from slower ones.
3996df26cacSmrg
4006df26cacSmrgdashmstdout)
4016df26cacSmrg  # Important note: in order to support this mode, a compiler *must*
4026df26cacSmrg  # always write the preprocessed file to stdout, regardless of -o.
4036df26cacSmrg  "$@" || exit $?
4046df26cacSmrg
4056df26cacSmrg  # Remove the call to Libtool.
4066df26cacSmrg  if test "$libtool" = yes; then
4076df26cacSmrg    while test $1 != '--mode=compile'; do
4086df26cacSmrg      shift
4096df26cacSmrg    done
4106df26cacSmrg    shift
4116df26cacSmrg  fi
4126df26cacSmrg
4136df26cacSmrg  # Remove `-o $object'.
4146df26cacSmrg  IFS=" "
4156df26cacSmrg  for arg
4166df26cacSmrg  do
4176df26cacSmrg    case $arg in
4186df26cacSmrg    -o)
4196df26cacSmrg      shift
4206df26cacSmrg      ;;
4216df26cacSmrg    $object)
4226df26cacSmrg      shift
4236df26cacSmrg      ;;
4246df26cacSmrg    *)
4256df26cacSmrg      set fnord "$@" "$arg"
4266df26cacSmrg      shift # fnord
4276df26cacSmrg      shift # $arg
4286df26cacSmrg      ;;
4296df26cacSmrg    esac
4306df26cacSmrg  done
4316df26cacSmrg
4326df26cacSmrg  test -z "$dashmflag" && dashmflag=-M
4336df26cacSmrg  # Require at least two characters before searching for `:'
4346df26cacSmrg  # in the target name.  This is to cope with DOS-style filenames:
4356df26cacSmrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
4366df26cacSmrg  "$@" $dashmflag |
4376df26cacSmrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
4386df26cacSmrg  rm -f "$depfile"
4396df26cacSmrg  cat < "$tmpdepfile" > "$depfile"
4406df26cacSmrg  tr ' ' '
4416df26cacSmrg' < "$tmpdepfile" | \
4426df26cacSmrg## Some versions of the HPUX 10.20 sed can't process this invocation
4436df26cacSmrg## correctly.  Breaking it into two sed invocations is a workaround.
4446df26cacSmrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
4456df26cacSmrg  rm -f "$tmpdepfile"
4466df26cacSmrg  ;;
4476df26cacSmrg
4486df26cacSmrgdashXmstdout)
4496df26cacSmrg  # This case only exists to satisfy depend.m4.  It is never actually
4506df26cacSmrg  # run, as this mode is specially recognized in the preamble.
4516df26cacSmrg  exit 1
4526df26cacSmrg  ;;
4536df26cacSmrg
4546df26cacSmrgmakedepend)
4556df26cacSmrg  "$@" || exit $?
4566df26cacSmrg  # Remove any Libtool call
4576df26cacSmrg  if test "$libtool" = yes; then
4586df26cacSmrg    while test $1 != '--mode=compile'; do
4596df26cacSmrg      shift
4606df26cacSmrg    done
4616df26cacSmrg    shift
4626df26cacSmrg  fi
4636df26cacSmrg  # X makedepend
4646df26cacSmrg  shift
4656df26cacSmrg  cleared=no
4666df26cacSmrg  for arg in "$@"; do
4676df26cacSmrg    case $cleared in
4686df26cacSmrg    no)
4696df26cacSmrg      set ""; shift
4706df26cacSmrg      cleared=yes ;;
4716df26cacSmrg    esac
4726df26cacSmrg    case "$arg" in
4736df26cacSmrg    -D*|-I*)
4746df26cacSmrg      set fnord "$@" "$arg"; shift ;;
4756df26cacSmrg    # Strip any option that makedepend may not understand.  Remove
4766df26cacSmrg    # the object too, otherwise makedepend will parse it as a source file.
4776df26cacSmrg    -*|$object)
4786df26cacSmrg      ;;
4796df26cacSmrg    *)
4806df26cacSmrg      set fnord "$@" "$arg"; shift ;;
4816df26cacSmrg    esac
4826df26cacSmrg  done
4836df26cacSmrg  obj_suffix="`echo $object | sed 's/^.*\././'`"
4846df26cacSmrg  touch "$tmpdepfile"
4856df26cacSmrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
4866df26cacSmrg  rm -f "$depfile"
4876df26cacSmrg  cat < "$tmpdepfile" > "$depfile"
4886df26cacSmrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
4896df26cacSmrg' | \
4906df26cacSmrg## Some versions of the HPUX 10.20 sed can't process this invocation
4916df26cacSmrg## correctly.  Breaking it into two sed invocations is a workaround.
4926df26cacSmrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
4936df26cacSmrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
4946df26cacSmrg  ;;
4956df26cacSmrg
4966df26cacSmrgcpp)
4976df26cacSmrg  # Important note: in order to support this mode, a compiler *must*
4986df26cacSmrg  # always write the preprocessed file to stdout.
4996df26cacSmrg  "$@" || exit $?
5006df26cacSmrg
5016df26cacSmrg  # Remove the call to Libtool.
5026df26cacSmrg  if test "$libtool" = yes; then
5036df26cacSmrg    while test $1 != '--mode=compile'; do
5046df26cacSmrg      shift
5056df26cacSmrg    done
5066df26cacSmrg    shift
5076df26cacSmrg  fi
5086df26cacSmrg
5096df26cacSmrg  # Remove `-o $object'.
5106df26cacSmrg  IFS=" "
5116df26cacSmrg  for arg
5126df26cacSmrg  do
5136df26cacSmrg    case $arg in
5146df26cacSmrg    -o)
5156df26cacSmrg      shift
5166df26cacSmrg      ;;
5176df26cacSmrg    $object)
5186df26cacSmrg      shift
5196df26cacSmrg      ;;
5206df26cacSmrg    *)
5216df26cacSmrg      set fnord "$@" "$arg"
5226df26cacSmrg      shift # fnord
5236df26cacSmrg      shift # $arg
5246df26cacSmrg      ;;
5256df26cacSmrg    esac
5266df26cacSmrg  done
5276df26cacSmrg
5286df26cacSmrg  "$@" -E |
5296df26cacSmrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
5306df26cacSmrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
5316df26cacSmrg    sed '$ s: \\$::' > "$tmpdepfile"
5326df26cacSmrg  rm -f "$depfile"
5336df26cacSmrg  echo "$object : \\" > "$depfile"
5346df26cacSmrg  cat < "$tmpdepfile" >> "$depfile"
5356df26cacSmrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
5366df26cacSmrg  rm -f "$tmpdepfile"
5376df26cacSmrg  ;;
5386df26cacSmrg
5396df26cacSmrgmsvisualcpp)
5406df26cacSmrg  # Important note: in order to support this mode, a compiler *must*
5416df26cacSmrg  # always write the preprocessed file to stdout, regardless of -o,
5426df26cacSmrg  # because we must use -o when running libtool.
5436df26cacSmrg  "$@" || exit $?
5446df26cacSmrg  IFS=" "
5456df26cacSmrg  for arg
5466df26cacSmrg  do
5476df26cacSmrg    case "$arg" in
5486df26cacSmrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
5496df26cacSmrg	set fnord "$@"
5506df26cacSmrg	shift
5516df26cacSmrg	shift
5526df26cacSmrg	;;
5536df26cacSmrg    *)
5546df26cacSmrg	set fnord "$@" "$arg"
5556df26cacSmrg	shift
5566df26cacSmrg	shift
5576df26cacSmrg	;;
5586df26cacSmrg    esac
5596df26cacSmrg  done
5606df26cacSmrg  "$@" -E |
5616df26cacSmrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
5626df26cacSmrg  rm -f "$depfile"
5636df26cacSmrg  echo "$object : \\" > "$depfile"
5646df26cacSmrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
5656df26cacSmrg  echo "	" >> "$depfile"
5666df26cacSmrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
5676df26cacSmrg  rm -f "$tmpdepfile"
5686df26cacSmrg  ;;
5696df26cacSmrg
5706df26cacSmrgnone)
5716df26cacSmrg  exec "$@"
5726df26cacSmrg  ;;
5736df26cacSmrg
5746df26cacSmrg*)
5756df26cacSmrg  echo "Unknown depmode $depmode" 1>&2
5766df26cacSmrg  exit 1
5776df26cacSmrg  ;;
5786df26cacSmrgesac
5796df26cacSmrg
5806df26cacSmrgexit 0
5816df26cacSmrg
5826df26cacSmrg# Local Variables:
5836df26cacSmrg# mode: shell-script
5846df26cacSmrg# sh-indentation: 2
5856df26cacSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
5866df26cacSmrg# time-stamp-start: "scriptversion="
5876df26cacSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
5886df26cacSmrg# time-stamp-end: "$"
5896df26cacSmrg# End:
590