depcomp revision 53354cdb
11.362Sjschauma#! /bin/sh
21.53Sjmmv# depcomp - compile a program generating dependencies as side-effects
31.127Sjruoho
41.120Sjruohoscriptversion=2006-10-15.18
51.131Swiz
61.120Sjruoho# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software
71.331Sjschauma# Foundation, Inc.
81.6Sjschauma
91.239Ssevan# This program is free software; you can redistribute it and/or modify
101.121Sjruoho# it under the terms of the GNU General Public License as published by
111.199Sginsbach# the Free Software Foundation; either version 2, or (at your option)
121.120Sjruoho# any later version.
131.127Sjruoho
141.117Sjruoho# This program is distributed in the hope that it will be useful,
151.131Swiz# but WITHOUT ANY WARRANTY; without even the implied warranty of
161.120Sjruoho# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
171.53Sjmmv# GNU General Public License for more details.
181.120Sjruoho
191.223Ssevan# You should have received a copy of the GNU General Public License
201.198Sginsbach# along with this program; if not, write to the Free Software
211.18Sjmmv# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
221.121Sjruoho# 02110-1301, USA.
231.121Sjruoho
241.78Sdholland# As a special exception to the GNU General Public License, if you
251.26Swennmach# distribute this file as part of a program that contains a
261.122Sjruoho# configuration script generated by Autoconf, you may include it under
271.278Ssevan# the same distribution terms that you use for the rest of that program.
281.121Sjruoho
291.121Sjruoho# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
301.49Swiz
311.122Sjruohocase $1 in
321.53Sjmmv  '')
331.131Swiz     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
341.330Sjschauma     exit 1;
351.278Ssevan     ;;
361.199Sginsbach  -h | --h*)
371.96Sdholland    cat <<\EOF
381.202SsevanUsage: depcomp [--help] [--version] PROGRAM [ARGS]
391.96Sdholland
401.121SjruohoRun PROGRAMS ARGS to compile a file, generating dependencies
411.15Skeihanas side-effects.
421.121Sjruoho
431.120SjruohoEnvironment variables:
441.120Sjruoho  depmode     Dependency tracking mode.
451.120Sjruoho  source      Source file read by `PROGRAMS ARGS'.
461.109Sahoka  object      Object file output by `PROGRAMS ARGS'.
471.349Sjschauma  DEPDIR      directory where to store dependencies.
481.126Sjruoho  depfile     Dependency file to output.
491.269Ssevan  tmpdepfile  Temporary file to use when outputing dependencies.
501.94Sjruoho  libtool     Whether libtool is used (yes/no).
511.151Sdholland
521.120SjruohoReport bugs to <bug-automake@gnu.org>.
531.131SwizEOF
541.51Sjmmv    exit $?
551.202Ssevan    ;;
561.215Sginsbach  -v | --v*)
571.52Sjmmv    echo "depcomp $scriptversion"
581.175Skamil    exit $?
591.133Sginsbach    ;;
601.120Sjruohoesac
611.121Sjruoho
621.192Sginsbachif test -z "$depmode" || test -z "$source" || test -z "$object"; then
631.96Sdholland  echo "depcomp: Variables source, object and depmode must be set" 1>&2
641.121Sjruoho  exit 1
651.261Ssevanfi
661.131Swiz
671.121Sjruoho# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
681.316Smayadepfile=${depfile-`echo "$object" |
691.53Sjmmv  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
701.120Sjruohotmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
711.265Ssevan
721.8Skeihanrm -f "$tmpdepfile"
731.199Sginsbach
741.40Skeihan# Some modes work just like other modes, but use different flags.  We
751.129Sginsbach# parameterize here, but still list the modes in the big case below,
761.197Ssevan# to make depend.m4 easier to write.  Note that we *cannot* use a case
771.196Smaya# here, because this file can only contain one case statement.
781.196Smayaif test "$depmode" = hp; then
791.145Sriz  # HP compiler uses -M and no extra arg.
801.126Sjruoho  gccflag=-M
811.110Sjruoho  depmode=gcc
821.102Sjruohofi
831.210Ssevan
841.192Sginsbachif test "$depmode" = dashXmstdout; then
851.96Sdholland   # This is just like dashmstdout with a different argument.
861.131Swiz   dashmflag=-xM
871.96Sdholland   depmode=dashmstdout
881.53Sjmmvfi
891.122Sjruoho
901.121Sjruohocase "$depmode" in
911.53Sjmmvgcc3)
921.202Ssevan## gcc 3 implements dependency tracking that does exactly what
931.209Skamil## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
941.122Sjruoho## it if -MD -MP comes after the -MF stuff.  Hmm.
951.131Swiz## Unfortunately, FreeBSD c89 acceptance of flags depends upon
961.122Sjruoho## the command line argument order; so add the flags where they
971.122Sjruoho## appear in depend2.am.  Note that the slowdown incurred here
981.215Sginsbach## affects only configure: in makefiles, %FASTDEP% shortcuts this.
991.120Sjruoho  for arg
1001.198Sginsbach  do
1011.77Sdholland    case $arg in
1021.131Swiz    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
1031.236Ssevan    *)  set fnord "$@" "$arg" ;;
1041.236Ssevan    esac
1051.122Sjruoho    shift # fnord
1061.122Sjruoho    shift # $arg
1071.121Sjruoho  done
1081.265Ssevan  "$@"
1091.79Sdholland  stat=$?
1101.204Ssevan  if test $stat -eq 0; then :
1111.120Sjruoho  else
1121.18Sjmmv    rm -f "$tmpdepfile"
1131.1Sjmmv    exit $stat
1141.70Swiz  fi
1151.62Selad  mv "$tmpdepfile" "$depfile"
1161.285Ssevan  ;;
1171.285Ssevan
1181.35Sgrantgcc)
1191.18Sjmmv## There are various ways to get dependency output from gcc.  Here's
1201.122Sjruoho## why we pick this rather obscure method:
1211.236Ssevan## - Don't want to use -MD because we'd like the dependencies to end
1221.122Sjruoho##   up in a subdir.  Having to rename by hand is ugly.
1231.122Sjruoho##   (We might end up doing this anyway to support other compilers.)
1241.293Ssevan## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
1251.127Sjruoho##   -MM, not -M (despite what the docs say).
1261.120Sjruoho## - Using -M directly means running the compiler twice (even worse
1271.78Sdholland##   than renaming).
1281.120Sjruoho  if test -z "$gccflag"; then
1291.121Sjruoho    gccflag=-MD,
1301.94Sjruoho  fi
1311.245Ssevan  "$@" -Wp,"$gccflag$tmpdepfile"
1321.141Sdholland  stat=$?
1331.108Sjruoho  if test $stat -eq 0; then :
1341.120Sjruoho  else
1351.122Sjruoho    rm -f "$tmpdepfile"
1361.127Sjruoho    exit $stat
1371.122Sjruoho  fi
1381.16Sjmmv  rm -f "$depfile"
1391.54Sjmmv  echo "$object : \\" > "$depfile"
1401.131Swiz  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
1411.199Sginsbach## The second -e expression handles DOS-style file names with drive letters.
1421.270Salnsn  sed -e 's/^[^:]*: / /' \
1431.131Swiz      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
1441.83Selad## This next piece of magic avoids the `deleted header file' problem.
1451.117Sjruoho## The problem is that when a header file which appears in a .P file
1461.121Sjruoho## is deleted, the dependency causes make to die (because there is
1471.105Sjruoho## typically no way to rebuild the header).  We avoid this by adding
1481.131Swiz## dummy dependencies for each header file.  Too bad gcc doesn't do
1491.165Sjnemeth## this for us directly.
1501.96Sdholland  tr ' ' '
1511.138Sjdf' < "$tmpdepfile" |
1521.138Sjdf## Some versions of gcc put a space before the `:'.  On the theory
1531.108Sjruoho## that the space means something, we add a space to the output as
1541.121Sjruoho## well.
1551.107Sjruoho## Some versions of the HPUX 10.20 sed can't process this invocation
1561.102Sjruoho## correctly.  Breaking it into two sed invocations is a workaround.
1571.131Swiz    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
1581.293Ssevan  rm -f "$tmpdepfile"
1591.2Sjmmv  ;;
1601.121Sjruoho
1611.101Sjruohohp)
1621.304Ssevan  # This case exists only to let depend.m4 do its work.  It works by
1631.304Ssevan  # looking at the text of this script.  This case will never be run,
1641.121Sjruoho  # since it is checked for above.
1651.121Sjruoho  exit 1
1661.121Sjruoho  ;;
1671.121Sjruoho
1681.121Sjruohosgi)
1691.131Swiz  if test "$libtool" = yes; then
1701.121Sjruoho    "$@" "-Wp,-MDupdate,$tmpdepfile"
1711.107Sjruoho  else
1721.120Sjruoho    "$@" -MDupdate "$tmpdepfile"
1731.122Sjruoho  fi
1741.167Sginsbach  stat=$?
1751.131Swiz  if test $stat -eq 0; then :
1761.121Sjruoho  else
1771.122Sjruoho    rm -f "$tmpdepfile"
1781.48Sjmmv    exit $stat
1791.127Sjruoho  fi
1801.348Sjschauma  rm -f "$depfile"
1811.95Swiz
1821.126Sjruoho  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
1831.140Sdholland    echo "$object : \\" > "$depfile"
1841.126Sjruoho
1851.135Sjdf    # Clip off the initial element (the dependent).  Don't try to be
1861.131Swiz    # clever and replace this with sed code, as IRIX sed won't handle
1871.202Ssevan    # lines with more than a fixed number of characters (4096 in
1881.121Sjruoho    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
1891.94Sjruoho    # the IRIX cc adds comments like `#:fec' to the end of the
1901.112Sdholland    # dependency line.
1911.187Sginsbach    tr ' ' '
1921.126Sjruoho' < "$tmpdepfile" \
1931.121Sjruoho    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
1941.135Sjdf    tr '
1951.91Smatt' ' ' >> $depfile
1961.135Sjdf    echo >> $depfile
1971.131Swiz
1981.95Swiz    # The second pass generates a dummy entry for each header file.
1991.122Sjruoho    tr ' ' '
2001.122Sjruoho' < "$tmpdepfile" \
2011.236Ssevan   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
2021.122Sjruoho   >> $depfile
2031.122Sjruoho  else
2041.168Sdholland    # The sourcefile does not contain any dependencies, so just
2051.120Sjruoho    # store a dummy comment line, to avoid errors with the Makefile
2061.121Sjruoho    # "include basename.Plo" scheme.
2071.219Sginsbach    echo "#dummy" > "$depfile"
2081.122Sjruoho  fi
2091.357Sjschauma  rm -f "$tmpdepfile"
2101.281Ssevan  ;;
2111.19Sjmmv
2121.103Sdhollandaix)
2131.131Swiz  # The C for AIX Compiler uses -M and outputs the dependencies
2141.102Sjruoho  # in a .u file.  In older versions, this file always lives in the
2151.131Swiz  # current directory.  Also, the AIX compiler puts `$object:' at the
2161.131Swiz  # start of each line; $object doesn't have directory information.
2171.131Swiz  # Version 6 uses the directory in both cases.
2181.102Sjruoho  stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
2191.122Sjruoho  tmpdepfile="$stripped.u"
2201.121Sjruoho  if test "$libtool" = yes; then
2211.131Swiz    "$@" -Wc,-M
2221.121Sjruoho  else
2231.121Sjruoho    "$@" -M
2241.198Sginsbach  fi
2251.297Snia  stat=$?
2261.48Sjmmv
2271.127Sjruoho  if test -f "$tmpdepfile"; then :
2281.181Skamil  else
2291.256Ssevan    stripped=`echo "$stripped" | sed 's,^.*/,,'`
2301.131Swiz    tmpdepfile="$stripped.u"
2311.9Skeihan  fi
2321.48Sjmmv
2331.241Ssevan  if test $stat -eq 0; then :
2341.126Sjruoho  else
2351.312Sginsbach    rm -f "$tmpdepfile"
2361.167Sginsbach    exit $stat
2371.16Sjmmv  fi
2381.55Skleink
2391.252Ssevan  if test -f "$tmpdepfile"; then
2401.120Sjruoho    outname="$stripped.o"
2411.172Sriastrad    # Each line is of the form `foo.o: dependent.h'.
2421.84Sdholland    # Do two passes, one to just change these to
2431.84Sdholland    # `$object: dependent.h' and one to simply `dependent.h:'.
2441.333Sfcambus    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
2451.110Sjruoho    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
2461.138Sjdf  else
2471.30Sjmmv    # The sourcefile does not contain any dependencies, so just
2481.131Swiz    # store a dummy comment line, to avoid errors with the Makefile
2491.131Swiz    # "include basename.Plo" scheme.
2501.266Ssevan    echo "#dummy" > "$depfile"
2511.1Sjmmv  fi
2521.126Sjruoho  rm -f "$tmpdepfile"
2531.131Swiz  ;;
2541.294Ssevan
2551.131Swizicc)
2561.222Ssevan  # Intel's C compiler understands `-MD -MF file'.  However on
2571.131Swiz  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
2581.117Sjruoho  # ICC 7.0 will fill foo.d with something like
2591.131Swiz  #    foo.o: sub/foo.c
2601.48Sjmmv  #    foo.o: sub/foo.h
2611.140Sdholland  # which is wrong.  We want:
2621.131Swiz  #    sub/foo.o: sub/foo.c
2631.122Sjruoho  #    sub/foo.o: sub/foo.h
2641.1Sjmmv  #    sub/foo.c:
2651.265Ssevan  #    sub/foo.h:
2661.120Sjruoho  # ICC 7.1 will output
2671.265Ssevan  #    foo.o: sub/foo.c sub/foo.h
2681.122Sjruoho  # and will wrap long lines using \ :
2691.60Suwe  #    foo.o: sub/foo.c ... \
2701.131Swiz  #     sub/foo.h ... \
2711.122Sjruoho  #     ...
2721.122Sjruoho
2731.199Sginsbach  "$@" -MD -MF "$tmpdepfile"
2741.199Sginsbach  stat=$?
2751.345Sjschauma  if test $stat -eq 0; then :
2761.184Sginsbach  else
2771.345Sjschauma    rm -f "$tmpdepfile"
2781.184Sginsbach    exit $stat
2791.110Sjruoho  fi
2801.121Sjruoho  rm -f "$depfile"
2811.120Sjruoho  # Each line is of the form `foo.o: dependent.h',
2821.50Ssalo  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
2831.131Swiz  # Do two passes, one to just change these to
2841.356Sjschauma  # `$object: dependent.h' and one to simply `dependent.h:'.
2851.120Sjruoho  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
2861.131Swiz  # Some versions of the HPUX 10.20 sed can't process this invocation
2871.267Ssevan  # correctly.  Breaking it into two sed invocations is a workaround.
2881.108Sjruoho  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
2891.127Sjruoho    sed -e 's/$/ :/' >> "$depfile"
2901.37Sgrant  rm -f "$tmpdepfile"
2911.126Sjruoho  ;;
2921.235Ssevan
2931.107Sjruohohp2)
2941.126Sjruoho  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
2951.199Sginsbach  # compilers, which have integrated preprocessors.  The correct option
2961.58Skleink  # to use with these is +Maked; it writes dependencies to a file named
2971.127Sjruoho  # 'foo.d', which lands next to the object file, wherever that
2981.297Snia  # happens to be.
2991.121Sjruoho  # Much of this is similar to the tru64 case; see comments there.
3001.218Ssevan  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3011.218Ssevan  test "x$dir" = "x$object" && dir=
3021.127Sjruoho  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3031.199Sginsbach  if test "$libtool" = yes; then
3041.199Sginsbach    tmpdepfile1=$dir$base.d
3051.121Sjruoho    tmpdepfile2=$dir.libs/$base.d
3061.218Ssevan    "$@" -Wc,+Maked
3071.110Sjruoho  else
3081.126Sjruoho    tmpdepfile1=$dir$base.d
3091.140Sdholland    tmpdepfile2=$dir$base.d
3101.120Sjruoho    "$@" +Maked
3111.255Salnsn  fi
3121.121Sjruoho  stat=$?
3131.24Skeihan  if test $stat -eq 0; then :
3141.94Sjruoho  else
3151.120Sjruoho     rm -f "$tmpdepfile1" "$tmpdepfile2"
3161.353Sjschauma     exit $stat
3171.127Sjruoho  fi
3181.1Sjmmv
3191.328Sjschauma  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
3201.290Ssevan  do
3211.19Sjmmv    test -f "$tmpdepfile" && break
3221.312Sginsbach  done
3231.199Sginsbach  if test -f "$tmpdepfile"; then
3241.94Sjruoho    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
3251.108Sjruoho    # Add `dependent.h:' lines.
3261.107Sjruoho    sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
3271.131Swiz  else
3281.193Sginsbach    echo "#dummy" > "$depfile"
3291.131Swiz  fi
3301.107Sjruoho  rm -f "$tmpdepfile" "$tmpdepfile2"
3311.53Sjmmv  ;;
3321.53Sjmmv
3331.53Sjmmvtru64)
3341.254Ssevan   # The Tru64 compiler uses -MD to generate dependencies as a side
3351.254Ssevan   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
3361.254Ssevan   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
3371.254Ssevan   # dependencies in `foo.d' instead, so we check for that too.
3381.127Sjruoho   # Subdirectories are respected.
3391.140Sdholland   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3401.1Sjmmv   test "x$dir" = "x$object" && dir=
3411.267Ssevan   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3421.122Sjruoho
3431.231Ssevan   if test "$libtool" = yes; then
3441.120Sjruoho      # With Tru64 cc, shared objects can also be used to make a
3451.172Sriastrad      # static library.  This mechanism is used in libtool 1.4 series to
3461.53Sjmmv      # handle both shared and static libraries in a single compilation.
3471.265Ssevan      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
3481.120Sjruoho      #
3491.122Sjruoho      # With libtool 1.5 this exception was removed, and libtool now
3501.122Sjruoho      # generates 2 separate objects for the 2 libraries.  These two
3511.177Sdholland      # compilations output dependencies in $dir.libs/$base.o.d and
3521.131Swiz      # in $dir$base.o.d.  We have to check for both files, because
3531.122Sjruoho      # one of the two compilations can be disabled.  We should prefer
3541.122Sjruoho      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
3551.292Ssevan      # automatically cleaned when .libs/ is deleted, while ignoring
3561.127Sjruoho      # the former would cause a distcleancheck panic.
3571.131Swiz      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
3581.94Sjruoho      tmpdepfile2=$dir$base.o.d          # libtool 1.5
3591.132Splunky      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
3601.362Sjschauma      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
3611.160Sdholland      "$@" -Wc,-MD
3621.120Sjruoho   else
3631.131Swiz      tmpdepfile1=$dir$base.o.d
3641.120Sjruoho      tmpdepfile2=$dir$base.d
3651.121Sjruoho      tmpdepfile3=$dir$base.d
3661.94Sjruoho      tmpdepfile4=$dir$base.d
3671.140Sdholland      "$@" -MD
3681.126Sjruoho   fi
3691.127Sjruoho
3701.126Sjruoho   stat=$?
3711.126Sjruoho   if test $stat -eq 0; then :
3721.117Sjruoho   else
3731.121Sjruoho      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
3741.313Snia      exit $stat
3751.120Sjruoho   fi
3761.131Swiz
3771.121Sjruoho   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
3781.121Sjruoho   do
3791.53Sjmmv     test -f "$tmpdepfile" && break
3801.53Sjmmv   done
3811.219Sginsbach   if test -f "$tmpdepfile"; then
3821.219Sginsbach      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
3831.210Ssevan      # That's a tab and a space in the [].
3841.126Sjruoho      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
3851.131Swiz   else
3861.121Sjruoho      echo "#dummy" > "$depfile"
3871.48Sjmmv   fi
3881.121Sjruoho   rm -f "$tmpdepfile"
3891.19Sjmmv   ;;
3901.120Sjruoho
3911.269Ssevan#nosideeffect)
3921.121Sjruoho  # This comment above is used by automake to tell side-effect
3931.124Sdholland  # dependency tracking mechanisms from slower ones.
3941.16Sjmmv
3951.121Sjruohodashmstdout)
3961.138Sjdf  # Important note: in order to support this mode, a compiler *must*
3971.131Swiz  # always write the preprocessed file to stdout, regardless of -o.
3981.104Sjruoho  "$@" || exit $?
3991.122Sjruoho
4001.202Ssevan  # Remove the call to Libtool.
4011.121Sjruoho  if test "$libtool" = yes; then
4021.110Sjruoho    while test $1 != '--mode=compile'; do
4031.55Skleink      shift
4041.96Sdholland    done
4051.124Sdholland    shift
4061.117Sjruoho  fi
4071.121Sjruoho
4081.94Sjruoho  # Remove `-o $object'.
4091.94Sjruoho  IFS=" "
4101.209Skamil  for arg
4111.131Swiz  do
4121.96Sdholland    case $arg in
4131.122Sjruoho    -o)
4141.304Ssevan      shift
4151.122Sjruoho      ;;
4161.131Swiz    $object)
4171.281Ssevan      shift
4181.304Ssevan      ;;
4191.53Sjmmv    *)
4201.94Sjruoho      set fnord "$@" "$arg"
4211.122Sjruoho      shift # fnord
4221.269Ssevan      shift # $arg
4231.131Swiz      ;;
4241.139Sagc    esac
4251.120Sjruoho  done
4261.252Ssevan
4271.53Sjmmv  test -z "$dashmflag" && dashmflag=-M
4281.94Sjruoho  # Require at least two characters before searching for `:'
4291.292Ssevan  # in the target name.  This is to cope with DOS-style filenames:
4301.139Sagc  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
4311.5Sjmmv  "$@" $dashmflag |
4321.110Sjruoho    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
4331.122Sjruoho  rm -f "$depfile"
4341.127Sjruoho  cat < "$tmpdepfile" > "$depfile"
4351.220Ssevan  tr ' ' '
4361.95Swiz' < "$tmpdepfile" | \
4371.140Sdholland## Some versions of the HPUX 10.20 sed can't process this invocation
4381.227Ssevan## correctly.  Breaking it into two sed invocations is a workaround.
4391.131Swiz    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
4401.351Sjschauma  rm -f "$tmpdepfile"
4411.160Sdholland  ;;
4421.122Sjruoho
4431.121SjruohodashXmstdout)
4441.94Sjruoho  # This case only exists to satisfy depend.m4.  It is never actually
4451.53Sjmmv  # run, as this mode is specially recognized in the preamble.
4461.110Sjruoho  exit 1
4471.138Sjdf  ;;
4481.354Sdholland
4491.116Sjruohomakedepend)
4501.49Swiz  "$@" || exit $?
4511.63Selad  # Remove any Libtool call
4521.355Salnsn  if test "$libtool" = yes; then
4531.131Swiz    while test $1 != '--mode=compile'; do
4541.48Sjmmv      shift
4551.110Sjruoho    done
4561.140Sdholland    shift
4571.122Sjruoho  fi
4581.190Sginsbach  # X makedepend
4591.16Sjmmv  shift
4601.172Sriastrad  cleared=no
4611.94Sjruoho  for arg in "$@"; do
4621.110Sjruoho    case $cleared in
4631.322Snia    no)
4641.122Sjruoho      set ""; shift
4651.104Sjruoho      cleared=yes ;;
4661.267Ssevan    esac
4671.311Snia    case "$arg" in
4681.311Snia    -D*|-I*)
4691.139Sagc      set fnord "$@" "$arg"; shift ;;
4701.167Sginsbach    # Strip any option that makedepend may not understand.  Remove
4711.122Sjruoho    # the object too, otherwise makedepend will parse it as a source file.
4721.267Ssevan    -*|$object)
4731.105Sjruoho      ;;
4741.245Ssevan    *)
4751.220Ssevan      set fnord "$@" "$arg"; shift ;;
4761.9Skeihan    esac
4771.120Sjruoho  done
4781.94Sjruoho  obj_suffix="`echo $object | sed 's/^.*\././'`"
4791.122Sjruoho  touch "$tmpdepfile"
4801.107Sjruoho  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
4811.110Sjruoho  rm -f "$depfile"
4821.53Sjmmv  cat < "$tmpdepfile" > "$depfile"
4831.275Ssevan  sed '1,2d' "$tmpdepfile" | tr ' ' '
4841.275Ssevan' | \
4851.1Sjmmv## Some versions of the HPUX 10.20 sed can't process this invocation
4861.53Sjmmv## correctly.  Breaking it into two sed invocations is a workaround.
4871.53Sjmmv    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
4881.110Sjruoho  rm -f "$tmpdepfile" "$tmpdepfile".bak
4891.160Sdholland  ;;
4901.275Ssevan
4911.122Sjruohocpp)
4921.126Sjruoho  # Important note: in order to support this mode, a compiler *must*
4931.104Sjruoho  # always write the preprocessed file to stdout.
4941.122Sjruoho  "$@" || exit $?
4951.9Skeihan
4961.105Sjruoho  # Remove the call to Libtool.
4971.138Sjdf  if test "$libtool" = yes; then
4981.138Sjdf    while test $1 != '--mode=compile'; do
4991.94Sjruoho      shift
5001.339Sfcambus    done
5011.70Swiz    shift
5021.126Sjruoho  fi
5031.159Sjnemeth
5041.159Sjnemeth  # Remove `-o $object'.
5051.131Swiz  IFS=" "
5061.166Sjnemeth  for arg
5071.268Ssevan  do
5081.268Ssevan    case $arg in
5091.153Sjakllsch    -o)
5101.212Smaya      shift
5111.239Ssevan      ;;
5121.122Sjruoho    $object)
5131.172Sriastrad      shift
5141.172Sriastrad      ;;
5151.121Sjruoho    *)
5161.172Sriastrad      set fnord "$@" "$arg"
5171.172Sriastrad      shift # fnord
5181.172Sriastrad      shift # $arg
5191.172Sriastrad      ;;
5201.110Sjruoho    esac
5211.94Sjruoho  done
5221.18Sjmmv
5231.121Sjruoho  "$@" -E |
5241.121Sjruoho    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
5251.199Sginsbach       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
5261.121Sjruoho    sed '$ s: \\$::' > "$tmpdepfile"
5271.172Sriastrad  rm -f "$depfile"
5281.127Sjruoho  echo "$object : \\" > "$depfile"
5291.19Sjmmv  cat < "$tmpdepfile" >> "$depfile"
5301.16Sjmmv  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
5311.121Sjruoho  rm -f "$tmpdepfile"
5321.269Ssevan  ;;
5331.269Ssevan
5341.180Sginsbachmsvisualcpp)
5351.324Sriastrad  # Important note: in order to support this mode, a compiler *must*
5361.16Sjmmv  # always write the preprocessed file to stdout, regardless of -o,
5371.72Shubertf  # because we must use -o when running libtool.
5381.121Sjruoho  "$@" || exit $?
5391.48Sjmmv  IFS=" "
5401.250Ssevan  for arg
5411.138Sjdf  do
5421.54Sjmmv    case "$arg" in
5431.122Sjruoho    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
5441.154Sjakllsch	set fnord "$@"
5451.1Sjmmv	shift
5461.199Sginsbach	shift
5471.37Sgrant	;;
5481.121Sjruoho    *)
5491.122Sjruoho	set fnord "$@" "$arg"
5501.121Sjruoho	shift
5511.122Sjruoho	shift
5521.210Ssevan	;;
5531.269Ssevan    esac
5541.66Srpaulo  done
5551.126Sjruoho  "$@" -E |
5561.225Shtodd  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
5571.225Shtodd  rm -f "$depfile"
5581.96Sdholland  echo "$object : \\" > "$depfile"
5591.66Srpaulo  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
5601.120Sjruoho  echo "	" >> "$depfile"
5611.18Sjmmv  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
5621.51Sjmmv  rm -f "$tmpdepfile"
5631.16Sjmmv  ;;
5641.301Splunky
5651.256Ssevannone)
5661.121Sjruoho  exec "$@"
5671.140Sdholland  ;;
5681.126Sjruoho
5691.199Sginsbach*)
5701.209Skamil  echo "Unknown depmode $depmode" 1>&2
5711.199Sginsbach  exit 1
5721.224Ssevan  ;;
5731.16Sjmmvesac
5741.224Ssevan
5751.121Sjruohoexit 0
5761.135Sjdf
5771.135Sjdf# Local Variables:
5781.104Sjruoho# mode: shell-script
5791.120Sjruoho# sh-indentation: 2
5801.121Sjruoho# eval: (add-hook 'write-file-hooks 'time-stamp)
5811.120Sjruoho# time-stamp-start: "scriptversion="
5821.30Sjmmv# time-stamp-format: "%:y-%02m-%02d.%02H"
5831.16Sjmmv# time-stamp-end: "$"
5841.222Ssevan# End:
5851.121Sjruoho