depcomp revision 6df26cac
16df26cacSmrg#! /bin/sh
26df26cacSmrg# depcomp - compile a program generating dependencies as side-effects
36df26cacSmrg
46df26cacSmrgscriptversion=2006-10-15.18
56df26cacSmrg
66df26cacSmrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software
76df26cacSmrg# 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.
956df26cacSmrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
966df26cacSmrg## the command line argument order; so add the flags where they
976df26cacSmrg## appear in depend2.am.  Note that the slowdown incurred here
986df26cacSmrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
996df26cacSmrg  for arg
1006df26cacSmrg  do
1016df26cacSmrg    case $arg in
1026df26cacSmrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
1036df26cacSmrg    *)  set fnord "$@" "$arg" ;;
1046df26cacSmrg    esac
1056df26cacSmrg    shift # fnord
1066df26cacSmrg    shift # $arg
1076df26cacSmrg  done
1086df26cacSmrg  "$@"
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.
2186df26cacSmrg  stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
2196df26cacSmrg  tmpdepfile="$stripped.u"
2206df26cacSmrg  if test "$libtool" = yes; then
2216df26cacSmrg    "$@" -Wc,-M
2226df26cacSmrg  else
2236df26cacSmrg    "$@" -M
2246df26cacSmrg  fi
2256df26cacSmrg  stat=$?
2266df26cacSmrg
2276df26cacSmrg  if test -f "$tmpdepfile"; then :
2286df26cacSmrg  else
2296df26cacSmrg    stripped=`echo "$stripped" | sed 's,^.*/,,'`
2306df26cacSmrg    tmpdepfile="$stripped.u"
2316df26cacSmrg  fi
2326df26cacSmrg
2336df26cacSmrg  if test $stat -eq 0; then :
2346df26cacSmrg  else
2356df26cacSmrg    rm -f "$tmpdepfile"
2366df26cacSmrg    exit $stat
2376df26cacSmrg  fi
2386df26cacSmrg
2396df26cacSmrg  if test -f "$tmpdepfile"; then
2406df26cacSmrg    outname="$stripped.o"
2416df26cacSmrg    # Each line is of the form `foo.o: dependent.h'.
2426df26cacSmrg    # Do two passes, one to just change these to
2436df26cacSmrg    # `$object: dependent.h' and one to simply `dependent.h:'.
2446df26cacSmrg    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
2456df26cacSmrg    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
2466df26cacSmrg  else
2476df26cacSmrg    # The sourcefile does not contain any dependencies, so just
2486df26cacSmrg    # store a dummy comment line, to avoid errors with the Makefile
2496df26cacSmrg    # "include basename.Plo" scheme.
2506df26cacSmrg    echo "#dummy" > "$depfile"
2516df26cacSmrg  fi
2526df26cacSmrg  rm -f "$tmpdepfile"
2536df26cacSmrg  ;;
2546df26cacSmrg
2556df26cacSmrgicc)
2566df26cacSmrg  # Intel's C compiler understands `-MD -MF file'.  However on
2576df26cacSmrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
2586df26cacSmrg  # ICC 7.0 will fill foo.d with something like
2596df26cacSmrg  #    foo.o: sub/foo.c
2606df26cacSmrg  #    foo.o: sub/foo.h
2616df26cacSmrg  # which is wrong.  We want:
2626df26cacSmrg  #    sub/foo.o: sub/foo.c
2636df26cacSmrg  #    sub/foo.o: sub/foo.h
2646df26cacSmrg  #    sub/foo.c:
2656df26cacSmrg  #    sub/foo.h:
2666df26cacSmrg  # ICC 7.1 will output
2676df26cacSmrg  #    foo.o: sub/foo.c sub/foo.h
2686df26cacSmrg  # and will wrap long lines using \ :
2696df26cacSmrg  #    foo.o: sub/foo.c ... \
2706df26cacSmrg  #     sub/foo.h ... \
2716df26cacSmrg  #     ...
2726df26cacSmrg
2736df26cacSmrg  "$@" -MD -MF "$tmpdepfile"
2746df26cacSmrg  stat=$?
2756df26cacSmrg  if test $stat -eq 0; then :
2766df26cacSmrg  else
2776df26cacSmrg    rm -f "$tmpdepfile"
2786df26cacSmrg    exit $stat
2796df26cacSmrg  fi
2806df26cacSmrg  rm -f "$depfile"
2816df26cacSmrg  # Each line is of the form `foo.o: dependent.h',
2826df26cacSmrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
2836df26cacSmrg  # Do two passes, one to just change these to
2846df26cacSmrg  # `$object: dependent.h' and one to simply `dependent.h:'.
2856df26cacSmrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
2866df26cacSmrg  # Some versions of the HPUX 10.20 sed can't process this invocation
2876df26cacSmrg  # correctly.  Breaking it into two sed invocations is a workaround.
2886df26cacSmrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
2896df26cacSmrg    sed -e 's/$/ :/' >> "$depfile"
2906df26cacSmrg  rm -f "$tmpdepfile"
2916df26cacSmrg  ;;
2926df26cacSmrg
2936df26cacSmrghp2)
2946df26cacSmrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
2956df26cacSmrg  # compilers, which have integrated preprocessors.  The correct option
2966df26cacSmrg  # to use with these is +Maked; it writes dependencies to a file named
2976df26cacSmrg  # 'foo.d', which lands next to the object file, wherever that
2986df26cacSmrg  # happens to be.
2996df26cacSmrg  # Much of this is similar to the tru64 case; see comments there.
3006df26cacSmrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3016df26cacSmrg  test "x$dir" = "x$object" && dir=
3026df26cacSmrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3036df26cacSmrg  if test "$libtool" = yes; then
3046df26cacSmrg    tmpdepfile1=$dir$base.d
3056df26cacSmrg    tmpdepfile2=$dir.libs/$base.d
3066df26cacSmrg    "$@" -Wc,+Maked
3076df26cacSmrg  else
3086df26cacSmrg    tmpdepfile1=$dir$base.d
3096df26cacSmrg    tmpdepfile2=$dir$base.d
3106df26cacSmrg    "$@" +Maked
3116df26cacSmrg  fi
3126df26cacSmrg  stat=$?
3136df26cacSmrg  if test $stat -eq 0; then :
3146df26cacSmrg  else
3156df26cacSmrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
3166df26cacSmrg     exit $stat
3176df26cacSmrg  fi
3186df26cacSmrg
3196df26cacSmrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
3206df26cacSmrg  do
3216df26cacSmrg    test -f "$tmpdepfile" && break
3226df26cacSmrg  done
3236df26cacSmrg  if test -f "$tmpdepfile"; then
3246df26cacSmrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
3256df26cacSmrg    # Add `dependent.h:' lines.
3266df26cacSmrg    sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
3276df26cacSmrg  else
3286df26cacSmrg    echo "#dummy" > "$depfile"
3296df26cacSmrg  fi
3306df26cacSmrg  rm -f "$tmpdepfile" "$tmpdepfile2"
3316df26cacSmrg  ;;
3326df26cacSmrg
3336df26cacSmrgtru64)
3346df26cacSmrg   # The Tru64 compiler uses -MD to generate dependencies as a side
3356df26cacSmrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
3366df26cacSmrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
3376df26cacSmrg   # dependencies in `foo.d' instead, so we check for that too.
3386df26cacSmrg   # Subdirectories are respected.
3396df26cacSmrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3406df26cacSmrg   test "x$dir" = "x$object" && dir=
3416df26cacSmrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3426df26cacSmrg
3436df26cacSmrg   if test "$libtool" = yes; then
3446df26cacSmrg      # With Tru64 cc, shared objects can also be used to make a
3456df26cacSmrg      # static library.  This mechanism is used in libtool 1.4 series to
3466df26cacSmrg      # handle both shared and static libraries in a single compilation.
3476df26cacSmrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
3486df26cacSmrg      #
3496df26cacSmrg      # With libtool 1.5 this exception was removed, and libtool now
3506df26cacSmrg      # generates 2 separate objects for the 2 libraries.  These two
3516df26cacSmrg      # compilations output dependencies in $dir.libs/$base.o.d and
3526df26cacSmrg      # in $dir$base.o.d.  We have to check for both files, because
3536df26cacSmrg      # one of the two compilations can be disabled.  We should prefer
3546df26cacSmrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
3556df26cacSmrg      # automatically cleaned when .libs/ is deleted, while ignoring
3566df26cacSmrg      # the former would cause a distcleancheck panic.
3576df26cacSmrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
3586df26cacSmrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
3596df26cacSmrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
3606df26cacSmrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
3616df26cacSmrg      "$@" -Wc,-MD
3626df26cacSmrg   else
3636df26cacSmrg      tmpdepfile1=$dir$base.o.d
3646df26cacSmrg      tmpdepfile2=$dir$base.d
3656df26cacSmrg      tmpdepfile3=$dir$base.d
3666df26cacSmrg      tmpdepfile4=$dir$base.d
3676df26cacSmrg      "$@" -MD
3686df26cacSmrg   fi
3696df26cacSmrg
3706df26cacSmrg   stat=$?
3716df26cacSmrg   if test $stat -eq 0; then :
3726df26cacSmrg   else
3736df26cacSmrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
3746df26cacSmrg      exit $stat
3756df26cacSmrg   fi
3766df26cacSmrg
3776df26cacSmrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
3786df26cacSmrg   do
3796df26cacSmrg     test -f "$tmpdepfile" && break
3806df26cacSmrg   done
3816df26cacSmrg   if test -f "$tmpdepfile"; then
3826df26cacSmrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
3836df26cacSmrg      # That's a tab and a space in the [].
3846df26cacSmrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
3856df26cacSmrg   else
3866df26cacSmrg      echo "#dummy" > "$depfile"
3876df26cacSmrg   fi
3886df26cacSmrg   rm -f "$tmpdepfile"
3896df26cacSmrg   ;;
3906df26cacSmrg
3916df26cacSmrg#nosideeffect)
3926df26cacSmrg  # This comment above is used by automake to tell side-effect
3936df26cacSmrg  # dependency tracking mechanisms from slower ones.
3946df26cacSmrg
3956df26cacSmrgdashmstdout)
3966df26cacSmrg  # Important note: in order to support this mode, a compiler *must*
3976df26cacSmrg  # always write the preprocessed file to stdout, regardless of -o.
3986df26cacSmrg  "$@" || exit $?
3996df26cacSmrg
4006df26cacSmrg  # Remove the call to Libtool.
4016df26cacSmrg  if test "$libtool" = yes; then
4026df26cacSmrg    while test $1 != '--mode=compile'; do
4036df26cacSmrg      shift
4046df26cacSmrg    done
4056df26cacSmrg    shift
4066df26cacSmrg  fi
4076df26cacSmrg
4086df26cacSmrg  # Remove `-o $object'.
4096df26cacSmrg  IFS=" "
4106df26cacSmrg  for arg
4116df26cacSmrg  do
4126df26cacSmrg    case $arg in
4136df26cacSmrg    -o)
4146df26cacSmrg      shift
4156df26cacSmrg      ;;
4166df26cacSmrg    $object)
4176df26cacSmrg      shift
4186df26cacSmrg      ;;
4196df26cacSmrg    *)
4206df26cacSmrg      set fnord "$@" "$arg"
4216df26cacSmrg      shift # fnord
4226df26cacSmrg      shift # $arg
4236df26cacSmrg      ;;
4246df26cacSmrg    esac
4256df26cacSmrg  done
4266df26cacSmrg
4276df26cacSmrg  test -z "$dashmflag" && dashmflag=-M
4286df26cacSmrg  # Require at least two characters before searching for `:'
4296df26cacSmrg  # in the target name.  This is to cope with DOS-style filenames:
4306df26cacSmrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
4316df26cacSmrg  "$@" $dashmflag |
4326df26cacSmrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
4336df26cacSmrg  rm -f "$depfile"
4346df26cacSmrg  cat < "$tmpdepfile" > "$depfile"
4356df26cacSmrg  tr ' ' '
4366df26cacSmrg' < "$tmpdepfile" | \
4376df26cacSmrg## Some versions of the HPUX 10.20 sed can't process this invocation
4386df26cacSmrg## correctly.  Breaking it into two sed invocations is a workaround.
4396df26cacSmrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
4406df26cacSmrg  rm -f "$tmpdepfile"
4416df26cacSmrg  ;;
4426df26cacSmrg
4436df26cacSmrgdashXmstdout)
4446df26cacSmrg  # This case only exists to satisfy depend.m4.  It is never actually
4456df26cacSmrg  # run, as this mode is specially recognized in the preamble.
4466df26cacSmrg  exit 1
4476df26cacSmrg  ;;
4486df26cacSmrg
4496df26cacSmrgmakedepend)
4506df26cacSmrg  "$@" || exit $?
4516df26cacSmrg  # Remove any Libtool call
4526df26cacSmrg  if test "$libtool" = yes; then
4536df26cacSmrg    while test $1 != '--mode=compile'; do
4546df26cacSmrg      shift
4556df26cacSmrg    done
4566df26cacSmrg    shift
4576df26cacSmrg  fi
4586df26cacSmrg  # X makedepend
4596df26cacSmrg  shift
4606df26cacSmrg  cleared=no
4616df26cacSmrg  for arg in "$@"; do
4626df26cacSmrg    case $cleared in
4636df26cacSmrg    no)
4646df26cacSmrg      set ""; shift
4656df26cacSmrg      cleared=yes ;;
4666df26cacSmrg    esac
4676df26cacSmrg    case "$arg" in
4686df26cacSmrg    -D*|-I*)
4696df26cacSmrg      set fnord "$@" "$arg"; shift ;;
4706df26cacSmrg    # Strip any option that makedepend may not understand.  Remove
4716df26cacSmrg    # the object too, otherwise makedepend will parse it as a source file.
4726df26cacSmrg    -*|$object)
4736df26cacSmrg      ;;
4746df26cacSmrg    *)
4756df26cacSmrg      set fnord "$@" "$arg"; shift ;;
4766df26cacSmrg    esac
4776df26cacSmrg  done
4786df26cacSmrg  obj_suffix="`echo $object | sed 's/^.*\././'`"
4796df26cacSmrg  touch "$tmpdepfile"
4806df26cacSmrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
4816df26cacSmrg  rm -f "$depfile"
4826df26cacSmrg  cat < "$tmpdepfile" > "$depfile"
4836df26cacSmrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
4846df26cacSmrg' | \
4856df26cacSmrg## Some versions of the HPUX 10.20 sed can't process this invocation
4866df26cacSmrg## correctly.  Breaking it into two sed invocations is a workaround.
4876df26cacSmrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
4886df26cacSmrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
4896df26cacSmrg  ;;
4906df26cacSmrg
4916df26cacSmrgcpp)
4926df26cacSmrg  # Important note: in order to support this mode, a compiler *must*
4936df26cacSmrg  # always write the preprocessed file to stdout.
4946df26cacSmrg  "$@" || exit $?
4956df26cacSmrg
4966df26cacSmrg  # Remove the call to Libtool.
4976df26cacSmrg  if test "$libtool" = yes; then
4986df26cacSmrg    while test $1 != '--mode=compile'; do
4996df26cacSmrg      shift
5006df26cacSmrg    done
5016df26cacSmrg    shift
5026df26cacSmrg  fi
5036df26cacSmrg
5046df26cacSmrg  # Remove `-o $object'.
5056df26cacSmrg  IFS=" "
5066df26cacSmrg  for arg
5076df26cacSmrg  do
5086df26cacSmrg    case $arg in
5096df26cacSmrg    -o)
5106df26cacSmrg      shift
5116df26cacSmrg      ;;
5126df26cacSmrg    $object)
5136df26cacSmrg      shift
5146df26cacSmrg      ;;
5156df26cacSmrg    *)
5166df26cacSmrg      set fnord "$@" "$arg"
5176df26cacSmrg      shift # fnord
5186df26cacSmrg      shift # $arg
5196df26cacSmrg      ;;
5206df26cacSmrg    esac
5216df26cacSmrg  done
5226df26cacSmrg
5236df26cacSmrg  "$@" -E |
5246df26cacSmrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
5256df26cacSmrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
5266df26cacSmrg    sed '$ s: \\$::' > "$tmpdepfile"
5276df26cacSmrg  rm -f "$depfile"
5286df26cacSmrg  echo "$object : \\" > "$depfile"
5296df26cacSmrg  cat < "$tmpdepfile" >> "$depfile"
5306df26cacSmrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
5316df26cacSmrg  rm -f "$tmpdepfile"
5326df26cacSmrg  ;;
5336df26cacSmrg
5346df26cacSmrgmsvisualcpp)
5356df26cacSmrg  # Important note: in order to support this mode, a compiler *must*
5366df26cacSmrg  # always write the preprocessed file to stdout, regardless of -o,
5376df26cacSmrg  # because we must use -o when running libtool.
5386df26cacSmrg  "$@" || exit $?
5396df26cacSmrg  IFS=" "
5406df26cacSmrg  for arg
5416df26cacSmrg  do
5426df26cacSmrg    case "$arg" in
5436df26cacSmrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
5446df26cacSmrg	set fnord "$@"
5456df26cacSmrg	shift
5466df26cacSmrg	shift
5476df26cacSmrg	;;
5486df26cacSmrg    *)
5496df26cacSmrg	set fnord "$@" "$arg"
5506df26cacSmrg	shift
5516df26cacSmrg	shift
5526df26cacSmrg	;;
5536df26cacSmrg    esac
5546df26cacSmrg  done
5556df26cacSmrg  "$@" -E |
5566df26cacSmrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
5576df26cacSmrg  rm -f "$depfile"
5586df26cacSmrg  echo "$object : \\" > "$depfile"
5596df26cacSmrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
5606df26cacSmrg  echo "	" >> "$depfile"
5616df26cacSmrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
5626df26cacSmrg  rm -f "$tmpdepfile"
5636df26cacSmrg  ;;
5646df26cacSmrg
5656df26cacSmrgnone)
5666df26cacSmrg  exec "$@"
5676df26cacSmrg  ;;
5686df26cacSmrg
5696df26cacSmrg*)
5706df26cacSmrg  echo "Unknown depmode $depmode" 1>&2
5716df26cacSmrg  exit 1
5726df26cacSmrg  ;;
5736df26cacSmrgesac
5746df26cacSmrg
5756df26cacSmrgexit 0
5766df26cacSmrg
5776df26cacSmrg# Local Variables:
5786df26cacSmrg# mode: shell-script
5796df26cacSmrg# sh-indentation: 2
5806df26cacSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
5816df26cacSmrg# time-stamp-start: "scriptversion="
5826df26cacSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
5836df26cacSmrg# time-stamp-end: "$"
5846df26cacSmrg# End:
585