depcomp revision 9aa228fd
19aa228fdSmrg#! /bin/sh
29aa228fdSmrg# depcomp - compile a program generating dependencies as side-effects
39aa228fdSmrg
49aa228fdSmrgscriptversion=2006-10-15.18
59aa228fdSmrg
69aa228fdSmrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software
79aa228fdSmrg# Foundation, Inc.
89aa228fdSmrg
99aa228fdSmrg# This program is free software; you can redistribute it and/or modify
109aa228fdSmrg# it under the terms of the GNU General Public License as published by
119aa228fdSmrg# the Free Software Foundation; either version 2, or (at your option)
129aa228fdSmrg# any later version.
139aa228fdSmrg
149aa228fdSmrg# This program is distributed in the hope that it will be useful,
159aa228fdSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
169aa228fdSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
179aa228fdSmrg# GNU General Public License for more details.
189aa228fdSmrg
199aa228fdSmrg# You should have received a copy of the GNU General Public License
209aa228fdSmrg# along with this program; if not, write to the Free Software
219aa228fdSmrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
229aa228fdSmrg# 02110-1301, USA.
239aa228fdSmrg
249aa228fdSmrg# As a special exception to the GNU General Public License, if you
259aa228fdSmrg# distribute this file as part of a program that contains a
269aa228fdSmrg# configuration script generated by Autoconf, you may include it under
279aa228fdSmrg# the same distribution terms that you use for the rest of that program.
289aa228fdSmrg
299aa228fdSmrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
309aa228fdSmrg
319aa228fdSmrgcase $1 in
329aa228fdSmrg  '')
339aa228fdSmrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
349aa228fdSmrg     exit 1;
359aa228fdSmrg     ;;
369aa228fdSmrg  -h | --h*)
379aa228fdSmrg    cat <<\EOF
389aa228fdSmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
399aa228fdSmrg
409aa228fdSmrgRun PROGRAMS ARGS to compile a file, generating dependencies
419aa228fdSmrgas side-effects.
429aa228fdSmrg
439aa228fdSmrgEnvironment variables:
449aa228fdSmrg  depmode     Dependency tracking mode.
459aa228fdSmrg  source      Source file read by `PROGRAMS ARGS'.
469aa228fdSmrg  object      Object file output by `PROGRAMS ARGS'.
479aa228fdSmrg  DEPDIR      directory where to store dependencies.
489aa228fdSmrg  depfile     Dependency file to output.
499aa228fdSmrg  tmpdepfile  Temporary file to use when outputing dependencies.
509aa228fdSmrg  libtool     Whether libtool is used (yes/no).
519aa228fdSmrg
529aa228fdSmrgReport bugs to <bug-automake@gnu.org>.
539aa228fdSmrgEOF
549aa228fdSmrg    exit $?
559aa228fdSmrg    ;;
569aa228fdSmrg  -v | --v*)
579aa228fdSmrg    echo "depcomp $scriptversion"
589aa228fdSmrg    exit $?
599aa228fdSmrg    ;;
609aa228fdSmrgesac
619aa228fdSmrg
629aa228fdSmrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
639aa228fdSmrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
649aa228fdSmrg  exit 1
659aa228fdSmrgfi
669aa228fdSmrg
679aa228fdSmrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
689aa228fdSmrgdepfile=${depfile-`echo "$object" |
699aa228fdSmrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
709aa228fdSmrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
719aa228fdSmrg
729aa228fdSmrgrm -f "$tmpdepfile"
739aa228fdSmrg
749aa228fdSmrg# Some modes work just like other modes, but use different flags.  We
759aa228fdSmrg# parameterize here, but still list the modes in the big case below,
769aa228fdSmrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
779aa228fdSmrg# here, because this file can only contain one case statement.
789aa228fdSmrgif test "$depmode" = hp; then
799aa228fdSmrg  # HP compiler uses -M and no extra arg.
809aa228fdSmrg  gccflag=-M
819aa228fdSmrg  depmode=gcc
829aa228fdSmrgfi
839aa228fdSmrg
849aa228fdSmrgif test "$depmode" = dashXmstdout; then
859aa228fdSmrg   # This is just like dashmstdout with a different argument.
869aa228fdSmrg   dashmflag=-xM
879aa228fdSmrg   depmode=dashmstdout
889aa228fdSmrgfi
899aa228fdSmrg
909aa228fdSmrgcase "$depmode" in
919aa228fdSmrggcc3)
929aa228fdSmrg## gcc 3 implements dependency tracking that does exactly what
939aa228fdSmrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
949aa228fdSmrg## it if -MD -MP comes after the -MF stuff.  Hmm.
959aa228fdSmrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
969aa228fdSmrg## the command line argument order; so add the flags where they
979aa228fdSmrg## appear in depend2.am.  Note that the slowdown incurred here
989aa228fdSmrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
999aa228fdSmrg  for arg
1009aa228fdSmrg  do
1019aa228fdSmrg    case $arg in
1029aa228fdSmrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
1039aa228fdSmrg    *)  set fnord "$@" "$arg" ;;
1049aa228fdSmrg    esac
1059aa228fdSmrg    shift # fnord
1069aa228fdSmrg    shift # $arg
1079aa228fdSmrg  done
1089aa228fdSmrg  "$@"
1099aa228fdSmrg  stat=$?
1109aa228fdSmrg  if test $stat -eq 0; then :
1119aa228fdSmrg  else
1129aa228fdSmrg    rm -f "$tmpdepfile"
1139aa228fdSmrg    exit $stat
1149aa228fdSmrg  fi
1159aa228fdSmrg  mv "$tmpdepfile" "$depfile"
1169aa228fdSmrg  ;;
1179aa228fdSmrg
1189aa228fdSmrggcc)
1199aa228fdSmrg## There are various ways to get dependency output from gcc.  Here's
1209aa228fdSmrg## why we pick this rather obscure method:
1219aa228fdSmrg## - Don't want to use -MD because we'd like the dependencies to end
1229aa228fdSmrg##   up in a subdir.  Having to rename by hand is ugly.
1239aa228fdSmrg##   (We might end up doing this anyway to support other compilers.)
1249aa228fdSmrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
1259aa228fdSmrg##   -MM, not -M (despite what the docs say).
1269aa228fdSmrg## - Using -M directly means running the compiler twice (even worse
1279aa228fdSmrg##   than renaming).
1289aa228fdSmrg  if test -z "$gccflag"; then
1299aa228fdSmrg    gccflag=-MD,
1309aa228fdSmrg  fi
1319aa228fdSmrg  "$@" -Wp,"$gccflag$tmpdepfile"
1329aa228fdSmrg  stat=$?
1339aa228fdSmrg  if test $stat -eq 0; then :
1349aa228fdSmrg  else
1359aa228fdSmrg    rm -f "$tmpdepfile"
1369aa228fdSmrg    exit $stat
1379aa228fdSmrg  fi
1389aa228fdSmrg  rm -f "$depfile"
1399aa228fdSmrg  echo "$object : \\" > "$depfile"
1409aa228fdSmrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
1419aa228fdSmrg## The second -e expression handles DOS-style file names with drive letters.
1429aa228fdSmrg  sed -e 's/^[^:]*: / /' \
1439aa228fdSmrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
1449aa228fdSmrg## This next piece of magic avoids the `deleted header file' problem.
1459aa228fdSmrg## The problem is that when a header file which appears in a .P file
1469aa228fdSmrg## is deleted, the dependency causes make to die (because there is
1479aa228fdSmrg## typically no way to rebuild the header).  We avoid this by adding
1489aa228fdSmrg## dummy dependencies for each header file.  Too bad gcc doesn't do
1499aa228fdSmrg## this for us directly.
1509aa228fdSmrg  tr ' ' '
1519aa228fdSmrg' < "$tmpdepfile" |
1529aa228fdSmrg## Some versions of gcc put a space before the `:'.  On the theory
1539aa228fdSmrg## that the space means something, we add a space to the output as
1549aa228fdSmrg## well.
1559aa228fdSmrg## Some versions of the HPUX 10.20 sed can't process this invocation
1569aa228fdSmrg## correctly.  Breaking it into two sed invocations is a workaround.
1579aa228fdSmrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
1589aa228fdSmrg  rm -f "$tmpdepfile"
1599aa228fdSmrg  ;;
1609aa228fdSmrg
1619aa228fdSmrghp)
1629aa228fdSmrg  # This case exists only to let depend.m4 do its work.  It works by
1639aa228fdSmrg  # looking at the text of this script.  This case will never be run,
1649aa228fdSmrg  # since it is checked for above.
1659aa228fdSmrg  exit 1
1669aa228fdSmrg  ;;
1679aa228fdSmrg
1689aa228fdSmrgsgi)
1699aa228fdSmrg  if test "$libtool" = yes; then
1709aa228fdSmrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
1719aa228fdSmrg  else
1729aa228fdSmrg    "$@" -MDupdate "$tmpdepfile"
1739aa228fdSmrg  fi
1749aa228fdSmrg  stat=$?
1759aa228fdSmrg  if test $stat -eq 0; then :
1769aa228fdSmrg  else
1779aa228fdSmrg    rm -f "$tmpdepfile"
1789aa228fdSmrg    exit $stat
1799aa228fdSmrg  fi
1809aa228fdSmrg  rm -f "$depfile"
1819aa228fdSmrg
1829aa228fdSmrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
1839aa228fdSmrg    echo "$object : \\" > "$depfile"
1849aa228fdSmrg
1859aa228fdSmrg    # Clip off the initial element (the dependent).  Don't try to be
1869aa228fdSmrg    # clever and replace this with sed code, as IRIX sed won't handle
1879aa228fdSmrg    # lines with more than a fixed number of characters (4096 in
1889aa228fdSmrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
1899aa228fdSmrg    # the IRIX cc adds comments like `#:fec' to the end of the
1909aa228fdSmrg    # dependency line.
1919aa228fdSmrg    tr ' ' '
1929aa228fdSmrg' < "$tmpdepfile" \
1939aa228fdSmrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
1949aa228fdSmrg    tr '
1959aa228fdSmrg' ' ' >> $depfile
1969aa228fdSmrg    echo >> $depfile
1979aa228fdSmrg
1989aa228fdSmrg    # The second pass generates a dummy entry for each header file.
1999aa228fdSmrg    tr ' ' '
2009aa228fdSmrg' < "$tmpdepfile" \
2019aa228fdSmrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
2029aa228fdSmrg   >> $depfile
2039aa228fdSmrg  else
2049aa228fdSmrg    # The sourcefile does not contain any dependencies, so just
2059aa228fdSmrg    # store a dummy comment line, to avoid errors with the Makefile
2069aa228fdSmrg    # "include basename.Plo" scheme.
2079aa228fdSmrg    echo "#dummy" > "$depfile"
2089aa228fdSmrg  fi
2099aa228fdSmrg  rm -f "$tmpdepfile"
2109aa228fdSmrg  ;;
2119aa228fdSmrg
2129aa228fdSmrgaix)
2139aa228fdSmrg  # The C for AIX Compiler uses -M and outputs the dependencies
2149aa228fdSmrg  # in a .u file.  In older versions, this file always lives in the
2159aa228fdSmrg  # current directory.  Also, the AIX compiler puts `$object:' at the
2169aa228fdSmrg  # start of each line; $object doesn't have directory information.
2179aa228fdSmrg  # Version 6 uses the directory in both cases.
2189aa228fdSmrg  stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
2199aa228fdSmrg  tmpdepfile="$stripped.u"
2209aa228fdSmrg  if test "$libtool" = yes; then
2219aa228fdSmrg    "$@" -Wc,-M
2229aa228fdSmrg  else
2239aa228fdSmrg    "$@" -M
2249aa228fdSmrg  fi
2259aa228fdSmrg  stat=$?
2269aa228fdSmrg
2279aa228fdSmrg  if test -f "$tmpdepfile"; then :
2289aa228fdSmrg  else
2299aa228fdSmrg    stripped=`echo "$stripped" | sed 's,^.*/,,'`
2309aa228fdSmrg    tmpdepfile="$stripped.u"
2319aa228fdSmrg  fi
2329aa228fdSmrg
2339aa228fdSmrg  if test $stat -eq 0; then :
2349aa228fdSmrg  else
2359aa228fdSmrg    rm -f "$tmpdepfile"
2369aa228fdSmrg    exit $stat
2379aa228fdSmrg  fi
2389aa228fdSmrg
2399aa228fdSmrg  if test -f "$tmpdepfile"; then
2409aa228fdSmrg    outname="$stripped.o"
2419aa228fdSmrg    # Each line is of the form `foo.o: dependent.h'.
2429aa228fdSmrg    # Do two passes, one to just change these to
2439aa228fdSmrg    # `$object: dependent.h' and one to simply `dependent.h:'.
2449aa228fdSmrg    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
2459aa228fdSmrg    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
2469aa228fdSmrg  else
2479aa228fdSmrg    # The sourcefile does not contain any dependencies, so just
2489aa228fdSmrg    # store a dummy comment line, to avoid errors with the Makefile
2499aa228fdSmrg    # "include basename.Plo" scheme.
2509aa228fdSmrg    echo "#dummy" > "$depfile"
2519aa228fdSmrg  fi
2529aa228fdSmrg  rm -f "$tmpdepfile"
2539aa228fdSmrg  ;;
2549aa228fdSmrg
2559aa228fdSmrgicc)
2569aa228fdSmrg  # Intel's C compiler understands `-MD -MF file'.  However on
2579aa228fdSmrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
2589aa228fdSmrg  # ICC 7.0 will fill foo.d with something like
2599aa228fdSmrg  #    foo.o: sub/foo.c
2609aa228fdSmrg  #    foo.o: sub/foo.h
2619aa228fdSmrg  # which is wrong.  We want:
2629aa228fdSmrg  #    sub/foo.o: sub/foo.c
2639aa228fdSmrg  #    sub/foo.o: sub/foo.h
2649aa228fdSmrg  #    sub/foo.c:
2659aa228fdSmrg  #    sub/foo.h:
2669aa228fdSmrg  # ICC 7.1 will output
2679aa228fdSmrg  #    foo.o: sub/foo.c sub/foo.h
2689aa228fdSmrg  # and will wrap long lines using \ :
2699aa228fdSmrg  #    foo.o: sub/foo.c ... \
2709aa228fdSmrg  #     sub/foo.h ... \
2719aa228fdSmrg  #     ...
2729aa228fdSmrg
2739aa228fdSmrg  "$@" -MD -MF "$tmpdepfile"
2749aa228fdSmrg  stat=$?
2759aa228fdSmrg  if test $stat -eq 0; then :
2769aa228fdSmrg  else
2779aa228fdSmrg    rm -f "$tmpdepfile"
2789aa228fdSmrg    exit $stat
2799aa228fdSmrg  fi
2809aa228fdSmrg  rm -f "$depfile"
2819aa228fdSmrg  # Each line is of the form `foo.o: dependent.h',
2829aa228fdSmrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
2839aa228fdSmrg  # Do two passes, one to just change these to
2849aa228fdSmrg  # `$object: dependent.h' and one to simply `dependent.h:'.
2859aa228fdSmrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
2869aa228fdSmrg  # Some versions of the HPUX 10.20 sed can't process this invocation
2879aa228fdSmrg  # correctly.  Breaking it into two sed invocations is a workaround.
2889aa228fdSmrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
2899aa228fdSmrg    sed -e 's/$/ :/' >> "$depfile"
2909aa228fdSmrg  rm -f "$tmpdepfile"
2919aa228fdSmrg  ;;
2929aa228fdSmrg
2939aa228fdSmrghp2)
2949aa228fdSmrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
2959aa228fdSmrg  # compilers, which have integrated preprocessors.  The correct option
2969aa228fdSmrg  # to use with these is +Maked; it writes dependencies to a file named
2979aa228fdSmrg  # 'foo.d', which lands next to the object file, wherever that
2989aa228fdSmrg  # happens to be.
2999aa228fdSmrg  # Much of this is similar to the tru64 case; see comments there.
3009aa228fdSmrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3019aa228fdSmrg  test "x$dir" = "x$object" && dir=
3029aa228fdSmrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3039aa228fdSmrg  if test "$libtool" = yes; then
3049aa228fdSmrg    tmpdepfile1=$dir$base.d
3059aa228fdSmrg    tmpdepfile2=$dir.libs/$base.d
3069aa228fdSmrg    "$@" -Wc,+Maked
3079aa228fdSmrg  else
3089aa228fdSmrg    tmpdepfile1=$dir$base.d
3099aa228fdSmrg    tmpdepfile2=$dir$base.d
3109aa228fdSmrg    "$@" +Maked
3119aa228fdSmrg  fi
3129aa228fdSmrg  stat=$?
3139aa228fdSmrg  if test $stat -eq 0; then :
3149aa228fdSmrg  else
3159aa228fdSmrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
3169aa228fdSmrg     exit $stat
3179aa228fdSmrg  fi
3189aa228fdSmrg
3199aa228fdSmrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
3209aa228fdSmrg  do
3219aa228fdSmrg    test -f "$tmpdepfile" && break
3229aa228fdSmrg  done
3239aa228fdSmrg  if test -f "$tmpdepfile"; then
3249aa228fdSmrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
3259aa228fdSmrg    # Add `dependent.h:' lines.
3269aa228fdSmrg    sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
3279aa228fdSmrg  else
3289aa228fdSmrg    echo "#dummy" > "$depfile"
3299aa228fdSmrg  fi
3309aa228fdSmrg  rm -f "$tmpdepfile" "$tmpdepfile2"
3319aa228fdSmrg  ;;
3329aa228fdSmrg
3339aa228fdSmrgtru64)
3349aa228fdSmrg   # The Tru64 compiler uses -MD to generate dependencies as a side
3359aa228fdSmrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
3369aa228fdSmrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
3379aa228fdSmrg   # dependencies in `foo.d' instead, so we check for that too.
3389aa228fdSmrg   # Subdirectories are respected.
3399aa228fdSmrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3409aa228fdSmrg   test "x$dir" = "x$object" && dir=
3419aa228fdSmrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3429aa228fdSmrg
3439aa228fdSmrg   if test "$libtool" = yes; then
3449aa228fdSmrg      # With Tru64 cc, shared objects can also be used to make a
3459aa228fdSmrg      # static library.  This mechanism is used in libtool 1.4 series to
3469aa228fdSmrg      # handle both shared and static libraries in a single compilation.
3479aa228fdSmrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
3489aa228fdSmrg      #
3499aa228fdSmrg      # With libtool 1.5 this exception was removed, and libtool now
3509aa228fdSmrg      # generates 2 separate objects for the 2 libraries.  These two
3519aa228fdSmrg      # compilations output dependencies in $dir.libs/$base.o.d and
3529aa228fdSmrg      # in $dir$base.o.d.  We have to check for both files, because
3539aa228fdSmrg      # one of the two compilations can be disabled.  We should prefer
3549aa228fdSmrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
3559aa228fdSmrg      # automatically cleaned when .libs/ is deleted, while ignoring
3569aa228fdSmrg      # the former would cause a distcleancheck panic.
3579aa228fdSmrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
3589aa228fdSmrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
3599aa228fdSmrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
3609aa228fdSmrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
3619aa228fdSmrg      "$@" -Wc,-MD
3629aa228fdSmrg   else
3639aa228fdSmrg      tmpdepfile1=$dir$base.o.d
3649aa228fdSmrg      tmpdepfile2=$dir$base.d
3659aa228fdSmrg      tmpdepfile3=$dir$base.d
3669aa228fdSmrg      tmpdepfile4=$dir$base.d
3679aa228fdSmrg      "$@" -MD
3689aa228fdSmrg   fi
3699aa228fdSmrg
3709aa228fdSmrg   stat=$?
3719aa228fdSmrg   if test $stat -eq 0; then :
3729aa228fdSmrg   else
3739aa228fdSmrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
3749aa228fdSmrg      exit $stat
3759aa228fdSmrg   fi
3769aa228fdSmrg
3779aa228fdSmrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
3789aa228fdSmrg   do
3799aa228fdSmrg     test -f "$tmpdepfile" && break
3809aa228fdSmrg   done
3819aa228fdSmrg   if test -f "$tmpdepfile"; then
3829aa228fdSmrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
3839aa228fdSmrg      # That's a tab and a space in the [].
3849aa228fdSmrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
3859aa228fdSmrg   else
3869aa228fdSmrg      echo "#dummy" > "$depfile"
3879aa228fdSmrg   fi
3889aa228fdSmrg   rm -f "$tmpdepfile"
3899aa228fdSmrg   ;;
3909aa228fdSmrg
3919aa228fdSmrg#nosideeffect)
3929aa228fdSmrg  # This comment above is used by automake to tell side-effect
3939aa228fdSmrg  # dependency tracking mechanisms from slower ones.
3949aa228fdSmrg
3959aa228fdSmrgdashmstdout)
3969aa228fdSmrg  # Important note: in order to support this mode, a compiler *must*
3979aa228fdSmrg  # always write the preprocessed file to stdout, regardless of -o.
3989aa228fdSmrg  "$@" || exit $?
3999aa228fdSmrg
4009aa228fdSmrg  # Remove the call to Libtool.
4019aa228fdSmrg  if test "$libtool" = yes; then
4029aa228fdSmrg    while test $1 != '--mode=compile'; do
4039aa228fdSmrg      shift
4049aa228fdSmrg    done
4059aa228fdSmrg    shift
4069aa228fdSmrg  fi
4079aa228fdSmrg
4089aa228fdSmrg  # Remove `-o $object'.
4099aa228fdSmrg  IFS=" "
4109aa228fdSmrg  for arg
4119aa228fdSmrg  do
4129aa228fdSmrg    case $arg in
4139aa228fdSmrg    -o)
4149aa228fdSmrg      shift
4159aa228fdSmrg      ;;
4169aa228fdSmrg    $object)
4179aa228fdSmrg      shift
4189aa228fdSmrg      ;;
4199aa228fdSmrg    *)
4209aa228fdSmrg      set fnord "$@" "$arg"
4219aa228fdSmrg      shift # fnord
4229aa228fdSmrg      shift # $arg
4239aa228fdSmrg      ;;
4249aa228fdSmrg    esac
4259aa228fdSmrg  done
4269aa228fdSmrg
4279aa228fdSmrg  test -z "$dashmflag" && dashmflag=-M
4289aa228fdSmrg  # Require at least two characters before searching for `:'
4299aa228fdSmrg  # in the target name.  This is to cope with DOS-style filenames:
4309aa228fdSmrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
4319aa228fdSmrg  "$@" $dashmflag |
4329aa228fdSmrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
4339aa228fdSmrg  rm -f "$depfile"
4349aa228fdSmrg  cat < "$tmpdepfile" > "$depfile"
4359aa228fdSmrg  tr ' ' '
4369aa228fdSmrg' < "$tmpdepfile" | \
4379aa228fdSmrg## Some versions of the HPUX 10.20 sed can't process this invocation
4389aa228fdSmrg## correctly.  Breaking it into two sed invocations is a workaround.
4399aa228fdSmrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
4409aa228fdSmrg  rm -f "$tmpdepfile"
4419aa228fdSmrg  ;;
4429aa228fdSmrg
4439aa228fdSmrgdashXmstdout)
4449aa228fdSmrg  # This case only exists to satisfy depend.m4.  It is never actually
4459aa228fdSmrg  # run, as this mode is specially recognized in the preamble.
4469aa228fdSmrg  exit 1
4479aa228fdSmrg  ;;
4489aa228fdSmrg
4499aa228fdSmrgmakedepend)
4509aa228fdSmrg  "$@" || exit $?
4519aa228fdSmrg  # Remove any Libtool call
4529aa228fdSmrg  if test "$libtool" = yes; then
4539aa228fdSmrg    while test $1 != '--mode=compile'; do
4549aa228fdSmrg      shift
4559aa228fdSmrg    done
4569aa228fdSmrg    shift
4579aa228fdSmrg  fi
4589aa228fdSmrg  # X makedepend
4599aa228fdSmrg  shift
4609aa228fdSmrg  cleared=no
4619aa228fdSmrg  for arg in "$@"; do
4629aa228fdSmrg    case $cleared in
4639aa228fdSmrg    no)
4649aa228fdSmrg      set ""; shift
4659aa228fdSmrg      cleared=yes ;;
4669aa228fdSmrg    esac
4679aa228fdSmrg    case "$arg" in
4689aa228fdSmrg    -D*|-I*)
4699aa228fdSmrg      set fnord "$@" "$arg"; shift ;;
4709aa228fdSmrg    # Strip any option that makedepend may not understand.  Remove
4719aa228fdSmrg    # the object too, otherwise makedepend will parse it as a source file.
4729aa228fdSmrg    -*|$object)
4739aa228fdSmrg      ;;
4749aa228fdSmrg    *)
4759aa228fdSmrg      set fnord "$@" "$arg"; shift ;;
4769aa228fdSmrg    esac
4779aa228fdSmrg  done
4789aa228fdSmrg  obj_suffix="`echo $object | sed 's/^.*\././'`"
4799aa228fdSmrg  touch "$tmpdepfile"
4809aa228fdSmrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
4819aa228fdSmrg  rm -f "$depfile"
4829aa228fdSmrg  cat < "$tmpdepfile" > "$depfile"
4839aa228fdSmrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
4849aa228fdSmrg' | \
4859aa228fdSmrg## Some versions of the HPUX 10.20 sed can't process this invocation
4869aa228fdSmrg## correctly.  Breaking it into two sed invocations is a workaround.
4879aa228fdSmrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
4889aa228fdSmrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
4899aa228fdSmrg  ;;
4909aa228fdSmrg
4919aa228fdSmrgcpp)
4929aa228fdSmrg  # Important note: in order to support this mode, a compiler *must*
4939aa228fdSmrg  # always write the preprocessed file to stdout.
4949aa228fdSmrg  "$@" || exit $?
4959aa228fdSmrg
4969aa228fdSmrg  # Remove the call to Libtool.
4979aa228fdSmrg  if test "$libtool" = yes; then
4989aa228fdSmrg    while test $1 != '--mode=compile'; do
4999aa228fdSmrg      shift
5009aa228fdSmrg    done
5019aa228fdSmrg    shift
5029aa228fdSmrg  fi
5039aa228fdSmrg
5049aa228fdSmrg  # Remove `-o $object'.
5059aa228fdSmrg  IFS=" "
5069aa228fdSmrg  for arg
5079aa228fdSmrg  do
5089aa228fdSmrg    case $arg in
5099aa228fdSmrg    -o)
5109aa228fdSmrg      shift
5119aa228fdSmrg      ;;
5129aa228fdSmrg    $object)
5139aa228fdSmrg      shift
5149aa228fdSmrg      ;;
5159aa228fdSmrg    *)
5169aa228fdSmrg      set fnord "$@" "$arg"
5179aa228fdSmrg      shift # fnord
5189aa228fdSmrg      shift # $arg
5199aa228fdSmrg      ;;
5209aa228fdSmrg    esac
5219aa228fdSmrg  done
5229aa228fdSmrg
5239aa228fdSmrg  "$@" -E |
5249aa228fdSmrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
5259aa228fdSmrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
5269aa228fdSmrg    sed '$ s: \\$::' > "$tmpdepfile"
5279aa228fdSmrg  rm -f "$depfile"
5289aa228fdSmrg  echo "$object : \\" > "$depfile"
5299aa228fdSmrg  cat < "$tmpdepfile" >> "$depfile"
5309aa228fdSmrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
5319aa228fdSmrg  rm -f "$tmpdepfile"
5329aa228fdSmrg  ;;
5339aa228fdSmrg
5349aa228fdSmrgmsvisualcpp)
5359aa228fdSmrg  # Important note: in order to support this mode, a compiler *must*
5369aa228fdSmrg  # always write the preprocessed file to stdout, regardless of -o,
5379aa228fdSmrg  # because we must use -o when running libtool.
5389aa228fdSmrg  "$@" || exit $?
5399aa228fdSmrg  IFS=" "
5409aa228fdSmrg  for arg
5419aa228fdSmrg  do
5429aa228fdSmrg    case "$arg" in
5439aa228fdSmrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
5449aa228fdSmrg	set fnord "$@"
5459aa228fdSmrg	shift
5469aa228fdSmrg	shift
5479aa228fdSmrg	;;
5489aa228fdSmrg    *)
5499aa228fdSmrg	set fnord "$@" "$arg"
5509aa228fdSmrg	shift
5519aa228fdSmrg	shift
5529aa228fdSmrg	;;
5539aa228fdSmrg    esac
5549aa228fdSmrg  done
5559aa228fdSmrg  "$@" -E |
5569aa228fdSmrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
5579aa228fdSmrg  rm -f "$depfile"
5589aa228fdSmrg  echo "$object : \\" > "$depfile"
5599aa228fdSmrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
5609aa228fdSmrg  echo "	" >> "$depfile"
5619aa228fdSmrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
5629aa228fdSmrg  rm -f "$tmpdepfile"
5639aa228fdSmrg  ;;
5649aa228fdSmrg
5659aa228fdSmrgnone)
5669aa228fdSmrg  exec "$@"
5679aa228fdSmrg  ;;
5689aa228fdSmrg
5699aa228fdSmrg*)
5709aa228fdSmrg  echo "Unknown depmode $depmode" 1>&2
5719aa228fdSmrg  exit 1
5729aa228fdSmrg  ;;
5739aa228fdSmrgesac
5749aa228fdSmrg
5759aa228fdSmrgexit 0
5769aa228fdSmrg
5779aa228fdSmrg# Local Variables:
5789aa228fdSmrg# mode: shell-script
5799aa228fdSmrg# sh-indentation: 2
5809aa228fdSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
5819aa228fdSmrg# time-stamp-start: "scriptversion="
5829aa228fdSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
5839aa228fdSmrg# time-stamp-end: "$"
5849aa228fdSmrg# End:
585