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