depcomp revision 5eefee25
15eefee25Smacallan#! /bin/sh
25eefee25Smacallan# depcomp - compile a program generating dependencies as side-effects
35eefee25Smacallan
45eefee25Smacallanscriptversion=2005-07-09.11
55eefee25Smacallan
65eefee25Smacallan# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
75eefee25Smacallan
85eefee25Smacallan# This program is free software; you can redistribute it and/or modify
95eefee25Smacallan# it under the terms of the GNU General Public License as published by
105eefee25Smacallan# the Free Software Foundation; either version 2, or (at your option)
115eefee25Smacallan# any later version.
125eefee25Smacallan
135eefee25Smacallan# This program is distributed in the hope that it will be useful,
145eefee25Smacallan# but WITHOUT ANY WARRANTY; without even the implied warranty of
155eefee25Smacallan# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
165eefee25Smacallan# GNU General Public License for more details.
175eefee25Smacallan
185eefee25Smacallan# You should have received a copy of the GNU General Public License
195eefee25Smacallan# along with this program; if not, write to the Free Software
205eefee25Smacallan# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
215eefee25Smacallan# 02110-1301, USA.
225eefee25Smacallan
235eefee25Smacallan# As a special exception to the GNU General Public License, if you
245eefee25Smacallan# distribute this file as part of a program that contains a
255eefee25Smacallan# configuration script generated by Autoconf, you may include it under
265eefee25Smacallan# the same distribution terms that you use for the rest of that program.
275eefee25Smacallan
285eefee25Smacallan# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
295eefee25Smacallan
305eefee25Smacallancase $1 in
315eefee25Smacallan  '')
325eefee25Smacallan     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
335eefee25Smacallan     exit 1;
345eefee25Smacallan     ;;
355eefee25Smacallan  -h | --h*)
365eefee25Smacallan    cat <<\EOF
375eefee25SmacallanUsage: depcomp [--help] [--version] PROGRAM [ARGS]
385eefee25Smacallan
395eefee25SmacallanRun PROGRAMS ARGS to compile a file, generating dependencies
405eefee25Smacallanas side-effects.
415eefee25Smacallan
425eefee25SmacallanEnvironment variables:
435eefee25Smacallan  depmode     Dependency tracking mode.
445eefee25Smacallan  source      Source file read by `PROGRAMS ARGS'.
455eefee25Smacallan  object      Object file output by `PROGRAMS ARGS'.
465eefee25Smacallan  DEPDIR      directory where to store dependencies.
475eefee25Smacallan  depfile     Dependency file to output.
485eefee25Smacallan  tmpdepfile  Temporary file to use when outputing dependencies.
495eefee25Smacallan  libtool     Whether libtool is used (yes/no).
505eefee25Smacallan
515eefee25SmacallanReport bugs to <bug-automake@gnu.org>.
525eefee25SmacallanEOF
535eefee25Smacallan    exit $?
545eefee25Smacallan    ;;
555eefee25Smacallan  -v | --v*)
565eefee25Smacallan    echo "depcomp $scriptversion"
575eefee25Smacallan    exit $?
585eefee25Smacallan    ;;
595eefee25Smacallanesac
605eefee25Smacallan
615eefee25Smacallanif test -z "$depmode" || test -z "$source" || test -z "$object"; then
625eefee25Smacallan  echo "depcomp: Variables source, object and depmode must be set" 1>&2
635eefee25Smacallan  exit 1
645eefee25Smacallanfi
655eefee25Smacallan
665eefee25Smacallan# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
675eefee25Smacallandepfile=${depfile-`echo "$object" |
685eefee25Smacallan  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
695eefee25Smacallantmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
705eefee25Smacallan
715eefee25Smacallanrm -f "$tmpdepfile"
725eefee25Smacallan
735eefee25Smacallan# Some modes work just like other modes, but use different flags.  We
745eefee25Smacallan# parameterize here, but still list the modes in the big case below,
755eefee25Smacallan# to make depend.m4 easier to write.  Note that we *cannot* use a case
765eefee25Smacallan# here, because this file can only contain one case statement.
775eefee25Smacallanif test "$depmode" = hp; then
785eefee25Smacallan  # HP compiler uses -M and no extra arg.
795eefee25Smacallan  gccflag=-M
805eefee25Smacallan  depmode=gcc
815eefee25Smacallanfi
825eefee25Smacallan
835eefee25Smacallanif test "$depmode" = dashXmstdout; then
845eefee25Smacallan   # This is just like dashmstdout with a different argument.
855eefee25Smacallan   dashmflag=-xM
865eefee25Smacallan   depmode=dashmstdout
875eefee25Smacallanfi
885eefee25Smacallan
895eefee25Smacallancase "$depmode" in
905eefee25Smacallangcc3)
915eefee25Smacallan## gcc 3 implements dependency tracking that does exactly what
925eefee25Smacallan## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
935eefee25Smacallan## it if -MD -MP comes after the -MF stuff.  Hmm.
945eefee25Smacallan  "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
955eefee25Smacallan  stat=$?
965eefee25Smacallan  if test $stat -eq 0; then :
975eefee25Smacallan  else
985eefee25Smacallan    rm -f "$tmpdepfile"
995eefee25Smacallan    exit $stat
1005eefee25Smacallan  fi
1015eefee25Smacallan  mv "$tmpdepfile" "$depfile"
1025eefee25Smacallan  ;;
1035eefee25Smacallan
1045eefee25Smacallangcc)
1055eefee25Smacallan## There are various ways to get dependency output from gcc.  Here's
1065eefee25Smacallan## why we pick this rather obscure method:
1075eefee25Smacallan## - Don't want to use -MD because we'd like the dependencies to end
1085eefee25Smacallan##   up in a subdir.  Having to rename by hand is ugly.
1095eefee25Smacallan##   (We might end up doing this anyway to support other compilers.)
1105eefee25Smacallan## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
1115eefee25Smacallan##   -MM, not -M (despite what the docs say).
1125eefee25Smacallan## - Using -M directly means running the compiler twice (even worse
1135eefee25Smacallan##   than renaming).
1145eefee25Smacallan  if test -z "$gccflag"; then
1155eefee25Smacallan    gccflag=-MD,
1165eefee25Smacallan  fi
1175eefee25Smacallan  "$@" -Wp,"$gccflag$tmpdepfile"
1185eefee25Smacallan  stat=$?
1195eefee25Smacallan  if test $stat -eq 0; then :
1205eefee25Smacallan  else
1215eefee25Smacallan    rm -f "$tmpdepfile"
1225eefee25Smacallan    exit $stat
1235eefee25Smacallan  fi
1245eefee25Smacallan  rm -f "$depfile"
1255eefee25Smacallan  echo "$object : \\" > "$depfile"
1265eefee25Smacallan  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
1275eefee25Smacallan## The second -e expression handles DOS-style file names with drive letters.
1285eefee25Smacallan  sed -e 's/^[^:]*: / /' \
1295eefee25Smacallan      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
1305eefee25Smacallan## This next piece of magic avoids the `deleted header file' problem.
1315eefee25Smacallan## The problem is that when a header file which appears in a .P file
1325eefee25Smacallan## is deleted, the dependency causes make to die (because there is
1335eefee25Smacallan## typically no way to rebuild the header).  We avoid this by adding
1345eefee25Smacallan## dummy dependencies for each header file.  Too bad gcc doesn't do
1355eefee25Smacallan## this for us directly.
1365eefee25Smacallan  tr ' ' '
1375eefee25Smacallan' < "$tmpdepfile" |
1385eefee25Smacallan## Some versions of gcc put a space before the `:'.  On the theory
1395eefee25Smacallan## that the space means something, we add a space to the output as
1405eefee25Smacallan## well.
1415eefee25Smacallan## Some versions of the HPUX 10.20 sed can't process this invocation
1425eefee25Smacallan## correctly.  Breaking it into two sed invocations is a workaround.
1435eefee25Smacallan    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
1445eefee25Smacallan  rm -f "$tmpdepfile"
1455eefee25Smacallan  ;;
1465eefee25Smacallan
1475eefee25Smacallanhp)
1485eefee25Smacallan  # This case exists only to let depend.m4 do its work.  It works by
1495eefee25Smacallan  # looking at the text of this script.  This case will never be run,
1505eefee25Smacallan  # since it is checked for above.
1515eefee25Smacallan  exit 1
1525eefee25Smacallan  ;;
1535eefee25Smacallan
1545eefee25Smacallansgi)
1555eefee25Smacallan  if test "$libtool" = yes; then
1565eefee25Smacallan    "$@" "-Wp,-MDupdate,$tmpdepfile"
1575eefee25Smacallan  else
1585eefee25Smacallan    "$@" -MDupdate "$tmpdepfile"
1595eefee25Smacallan  fi
1605eefee25Smacallan  stat=$?
1615eefee25Smacallan  if test $stat -eq 0; then :
1625eefee25Smacallan  else
1635eefee25Smacallan    rm -f "$tmpdepfile"
1645eefee25Smacallan    exit $stat
1655eefee25Smacallan  fi
1665eefee25Smacallan  rm -f "$depfile"
1675eefee25Smacallan
1685eefee25Smacallan  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
1695eefee25Smacallan    echo "$object : \\" > "$depfile"
1705eefee25Smacallan
1715eefee25Smacallan    # Clip off the initial element (the dependent).  Don't try to be
1725eefee25Smacallan    # clever and replace this with sed code, as IRIX sed won't handle
1735eefee25Smacallan    # lines with more than a fixed number of characters (4096 in
1745eefee25Smacallan    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
1755eefee25Smacallan    # the IRIX cc adds comments like `#:fec' to the end of the
1765eefee25Smacallan    # dependency line.
1775eefee25Smacallan    tr ' ' '
1785eefee25Smacallan' < "$tmpdepfile" \
1795eefee25Smacallan    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
1805eefee25Smacallan    tr '
1815eefee25Smacallan' ' ' >> $depfile
1825eefee25Smacallan    echo >> $depfile
1835eefee25Smacallan
1845eefee25Smacallan    # The second pass generates a dummy entry for each header file.
1855eefee25Smacallan    tr ' ' '
1865eefee25Smacallan' < "$tmpdepfile" \
1875eefee25Smacallan   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
1885eefee25Smacallan   >> $depfile
1895eefee25Smacallan  else
1905eefee25Smacallan    # The sourcefile does not contain any dependencies, so just
1915eefee25Smacallan    # store a dummy comment line, to avoid errors with the Makefile
1925eefee25Smacallan    # "include basename.Plo" scheme.
1935eefee25Smacallan    echo "#dummy" > "$depfile"
1945eefee25Smacallan  fi
1955eefee25Smacallan  rm -f "$tmpdepfile"
1965eefee25Smacallan  ;;
1975eefee25Smacallan
1985eefee25Smacallanaix)
1995eefee25Smacallan  # The C for AIX Compiler uses -M and outputs the dependencies
2005eefee25Smacallan  # in a .u file.  In older versions, this file always lives in the
2015eefee25Smacallan  # current directory.  Also, the AIX compiler puts `$object:' at the
2025eefee25Smacallan  # start of each line; $object doesn't have directory information.
2035eefee25Smacallan  # Version 6 uses the directory in both cases.
2045eefee25Smacallan  stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
2055eefee25Smacallan  tmpdepfile="$stripped.u"
2065eefee25Smacallan  if test "$libtool" = yes; then
2075eefee25Smacallan    "$@" -Wc,-M
2085eefee25Smacallan  else
2095eefee25Smacallan    "$@" -M
2105eefee25Smacallan  fi
2115eefee25Smacallan  stat=$?
2125eefee25Smacallan
2135eefee25Smacallan  if test -f "$tmpdepfile"; then :
2145eefee25Smacallan  else
2155eefee25Smacallan    stripped=`echo "$stripped" | sed 's,^.*/,,'`
2165eefee25Smacallan    tmpdepfile="$stripped.u"
2175eefee25Smacallan  fi
2185eefee25Smacallan
2195eefee25Smacallan  if test $stat -eq 0; then :
2205eefee25Smacallan  else
2215eefee25Smacallan    rm -f "$tmpdepfile"
2225eefee25Smacallan    exit $stat
2235eefee25Smacallan  fi
2245eefee25Smacallan
2255eefee25Smacallan  if test -f "$tmpdepfile"; then
2265eefee25Smacallan    outname="$stripped.o"
2275eefee25Smacallan    # Each line is of the form `foo.o: dependent.h'.
2285eefee25Smacallan    # Do two passes, one to just change these to
2295eefee25Smacallan    # `$object: dependent.h' and one to simply `dependent.h:'.
2305eefee25Smacallan    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
2315eefee25Smacallan    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
2325eefee25Smacallan  else
2335eefee25Smacallan    # The sourcefile does not contain any dependencies, so just
2345eefee25Smacallan    # store a dummy comment line, to avoid errors with the Makefile
2355eefee25Smacallan    # "include basename.Plo" scheme.
2365eefee25Smacallan    echo "#dummy" > "$depfile"
2375eefee25Smacallan  fi
2385eefee25Smacallan  rm -f "$tmpdepfile"
2395eefee25Smacallan  ;;
2405eefee25Smacallan
2415eefee25Smacallanicc)
2425eefee25Smacallan  # Intel's C compiler understands `-MD -MF file'.  However on
2435eefee25Smacallan  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
2445eefee25Smacallan  # ICC 7.0 will fill foo.d with something like
2455eefee25Smacallan  #    foo.o: sub/foo.c
2465eefee25Smacallan  #    foo.o: sub/foo.h
2475eefee25Smacallan  # which is wrong.  We want:
2485eefee25Smacallan  #    sub/foo.o: sub/foo.c
2495eefee25Smacallan  #    sub/foo.o: sub/foo.h
2505eefee25Smacallan  #    sub/foo.c:
2515eefee25Smacallan  #    sub/foo.h:
2525eefee25Smacallan  # ICC 7.1 will output
2535eefee25Smacallan  #    foo.o: sub/foo.c sub/foo.h
2545eefee25Smacallan  # and will wrap long lines using \ :
2555eefee25Smacallan  #    foo.o: sub/foo.c ... \
2565eefee25Smacallan  #     sub/foo.h ... \
2575eefee25Smacallan  #     ...
2585eefee25Smacallan
2595eefee25Smacallan  "$@" -MD -MF "$tmpdepfile"
2605eefee25Smacallan  stat=$?
2615eefee25Smacallan  if test $stat -eq 0; then :
2625eefee25Smacallan  else
2635eefee25Smacallan    rm -f "$tmpdepfile"
2645eefee25Smacallan    exit $stat
2655eefee25Smacallan  fi
2665eefee25Smacallan  rm -f "$depfile"
2675eefee25Smacallan  # Each line is of the form `foo.o: dependent.h',
2685eefee25Smacallan  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
2695eefee25Smacallan  # Do two passes, one to just change these to
2705eefee25Smacallan  # `$object: dependent.h' and one to simply `dependent.h:'.
2715eefee25Smacallan  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
2725eefee25Smacallan  # Some versions of the HPUX 10.20 sed can't process this invocation
2735eefee25Smacallan  # correctly.  Breaking it into two sed invocations is a workaround.
2745eefee25Smacallan  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
2755eefee25Smacallan    sed -e 's/$/ :/' >> "$depfile"
2765eefee25Smacallan  rm -f "$tmpdepfile"
2775eefee25Smacallan  ;;
2785eefee25Smacallan
2795eefee25Smacallantru64)
2805eefee25Smacallan   # The Tru64 compiler uses -MD to generate dependencies as a side
2815eefee25Smacallan   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
2825eefee25Smacallan   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
2835eefee25Smacallan   # dependencies in `foo.d' instead, so we check for that too.
2845eefee25Smacallan   # Subdirectories are respected.
2855eefee25Smacallan   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
2865eefee25Smacallan   test "x$dir" = "x$object" && dir=
2875eefee25Smacallan   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
2885eefee25Smacallan
2895eefee25Smacallan   if test "$libtool" = yes; then
2905eefee25Smacallan      # With Tru64 cc, shared objects can also be used to make a
2915eefee25Smacallan      # static library.  This mecanism is used in libtool 1.4 series to
2925eefee25Smacallan      # handle both shared and static libraries in a single compilation.
2935eefee25Smacallan      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
2945eefee25Smacallan      #
2955eefee25Smacallan      # With libtool 1.5 this exception was removed, and libtool now
2965eefee25Smacallan      # generates 2 separate objects for the 2 libraries.  These two
2975eefee25Smacallan      # compilations output dependencies in in $dir.libs/$base.o.d and
2985eefee25Smacallan      # in $dir$base.o.d.  We have to check for both files, because
2995eefee25Smacallan      # one of the two compilations can be disabled.  We should prefer
3005eefee25Smacallan      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
3015eefee25Smacallan      # automatically cleaned when .libs/ is deleted, while ignoring
3025eefee25Smacallan      # the former would cause a distcleancheck panic.
3035eefee25Smacallan      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
3045eefee25Smacallan      tmpdepfile2=$dir$base.o.d          # libtool 1.5
3055eefee25Smacallan      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
3065eefee25Smacallan      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
3075eefee25Smacallan      "$@" -Wc,-MD
3085eefee25Smacallan   else
3095eefee25Smacallan      tmpdepfile1=$dir$base.o.d
3105eefee25Smacallan      tmpdepfile2=$dir$base.d
3115eefee25Smacallan      tmpdepfile3=$dir$base.d
3125eefee25Smacallan      tmpdepfile4=$dir$base.d
3135eefee25Smacallan      "$@" -MD
3145eefee25Smacallan   fi
3155eefee25Smacallan
3165eefee25Smacallan   stat=$?
3175eefee25Smacallan   if test $stat -eq 0; then :
3185eefee25Smacallan   else
3195eefee25Smacallan      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
3205eefee25Smacallan      exit $stat
3215eefee25Smacallan   fi
3225eefee25Smacallan
3235eefee25Smacallan   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
3245eefee25Smacallan   do
3255eefee25Smacallan     test -f "$tmpdepfile" && break
3265eefee25Smacallan   done
3275eefee25Smacallan   if test -f "$tmpdepfile"; then
3285eefee25Smacallan      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
3295eefee25Smacallan      # That's a tab and a space in the [].
3305eefee25Smacallan      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
3315eefee25Smacallan   else
3325eefee25Smacallan      echo "#dummy" > "$depfile"
3335eefee25Smacallan   fi
3345eefee25Smacallan   rm -f "$tmpdepfile"
3355eefee25Smacallan   ;;
3365eefee25Smacallan
3375eefee25Smacallan#nosideeffect)
3385eefee25Smacallan  # This comment above is used by automake to tell side-effect
3395eefee25Smacallan  # dependency tracking mechanisms from slower ones.
3405eefee25Smacallan
3415eefee25Smacallandashmstdout)
3425eefee25Smacallan  # Important note: in order to support this mode, a compiler *must*
3435eefee25Smacallan  # always write the preprocessed file to stdout, regardless of -o.
3445eefee25Smacallan  "$@" || exit $?
3455eefee25Smacallan
3465eefee25Smacallan  # Remove the call to Libtool.
3475eefee25Smacallan  if test "$libtool" = yes; then
3485eefee25Smacallan    while test $1 != '--mode=compile'; do
3495eefee25Smacallan      shift
3505eefee25Smacallan    done
3515eefee25Smacallan    shift
3525eefee25Smacallan  fi
3535eefee25Smacallan
3545eefee25Smacallan  # Remove `-o $object'.
3555eefee25Smacallan  IFS=" "
3565eefee25Smacallan  for arg
3575eefee25Smacallan  do
3585eefee25Smacallan    case $arg in
3595eefee25Smacallan    -o)
3605eefee25Smacallan      shift
3615eefee25Smacallan      ;;
3625eefee25Smacallan    $object)
3635eefee25Smacallan      shift
3645eefee25Smacallan      ;;
3655eefee25Smacallan    *)
3665eefee25Smacallan      set fnord "$@" "$arg"
3675eefee25Smacallan      shift # fnord
3685eefee25Smacallan      shift # $arg
3695eefee25Smacallan      ;;
3705eefee25Smacallan    esac
3715eefee25Smacallan  done
3725eefee25Smacallan
3735eefee25Smacallan  test -z "$dashmflag" && dashmflag=-M
3745eefee25Smacallan  # Require at least two characters before searching for `:'
3755eefee25Smacallan  # in the target name.  This is to cope with DOS-style filenames:
3765eefee25Smacallan  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
3775eefee25Smacallan  "$@" $dashmflag |
3785eefee25Smacallan    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
3795eefee25Smacallan  rm -f "$depfile"
3805eefee25Smacallan  cat < "$tmpdepfile" > "$depfile"
3815eefee25Smacallan  tr ' ' '
3825eefee25Smacallan' < "$tmpdepfile" | \
3835eefee25Smacallan## Some versions of the HPUX 10.20 sed can't process this invocation
3845eefee25Smacallan## correctly.  Breaking it into two sed invocations is a workaround.
3855eefee25Smacallan    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
3865eefee25Smacallan  rm -f "$tmpdepfile"
3875eefee25Smacallan  ;;
3885eefee25Smacallan
3895eefee25SmacallandashXmstdout)
3905eefee25Smacallan  # This case only exists to satisfy depend.m4.  It is never actually
3915eefee25Smacallan  # run, as this mode is specially recognized in the preamble.
3925eefee25Smacallan  exit 1
3935eefee25Smacallan  ;;
3945eefee25Smacallan
3955eefee25Smacallanmakedepend)
3965eefee25Smacallan  "$@" || exit $?
3975eefee25Smacallan  # Remove any Libtool call
3985eefee25Smacallan  if test "$libtool" = yes; then
3995eefee25Smacallan    while test $1 != '--mode=compile'; do
4005eefee25Smacallan      shift
4015eefee25Smacallan    done
4025eefee25Smacallan    shift
4035eefee25Smacallan  fi
4045eefee25Smacallan  # X makedepend
4055eefee25Smacallan  shift
4065eefee25Smacallan  cleared=no
4075eefee25Smacallan  for arg in "$@"; do
4085eefee25Smacallan    case $cleared in
4095eefee25Smacallan    no)
4105eefee25Smacallan      set ""; shift
4115eefee25Smacallan      cleared=yes ;;
4125eefee25Smacallan    esac
4135eefee25Smacallan    case "$arg" in
4145eefee25Smacallan    -D*|-I*)
4155eefee25Smacallan      set fnord "$@" "$arg"; shift ;;
4165eefee25Smacallan    # Strip any option that makedepend may not understand.  Remove
4175eefee25Smacallan    # the object too, otherwise makedepend will parse it as a source file.
4185eefee25Smacallan    -*|$object)
4195eefee25Smacallan      ;;
4205eefee25Smacallan    *)
4215eefee25Smacallan      set fnord "$@" "$arg"; shift ;;
4225eefee25Smacallan    esac
4235eefee25Smacallan  done
4245eefee25Smacallan  obj_suffix="`echo $object | sed 's/^.*\././'`"
4255eefee25Smacallan  touch "$tmpdepfile"
4265eefee25Smacallan  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
4275eefee25Smacallan  rm -f "$depfile"
4285eefee25Smacallan  cat < "$tmpdepfile" > "$depfile"
4295eefee25Smacallan  sed '1,2d' "$tmpdepfile" | tr ' ' '
4305eefee25Smacallan' | \
4315eefee25Smacallan## Some versions of the HPUX 10.20 sed can't process this invocation
4325eefee25Smacallan## correctly.  Breaking it into two sed invocations is a workaround.
4335eefee25Smacallan    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
4345eefee25Smacallan  rm -f "$tmpdepfile" "$tmpdepfile".bak
4355eefee25Smacallan  ;;
4365eefee25Smacallan
4375eefee25Smacallancpp)
4385eefee25Smacallan  # Important note: in order to support this mode, a compiler *must*
4395eefee25Smacallan  # always write the preprocessed file to stdout.
4405eefee25Smacallan  "$@" || exit $?
4415eefee25Smacallan
4425eefee25Smacallan  # Remove the call to Libtool.
4435eefee25Smacallan  if test "$libtool" = yes; then
4445eefee25Smacallan    while test $1 != '--mode=compile'; do
4455eefee25Smacallan      shift
4465eefee25Smacallan    done
4475eefee25Smacallan    shift
4485eefee25Smacallan  fi
4495eefee25Smacallan
4505eefee25Smacallan  # Remove `-o $object'.
4515eefee25Smacallan  IFS=" "
4525eefee25Smacallan  for arg
4535eefee25Smacallan  do
4545eefee25Smacallan    case $arg in
4555eefee25Smacallan    -o)
4565eefee25Smacallan      shift
4575eefee25Smacallan      ;;
4585eefee25Smacallan    $object)
4595eefee25Smacallan      shift
4605eefee25Smacallan      ;;
4615eefee25Smacallan    *)
4625eefee25Smacallan      set fnord "$@" "$arg"
4635eefee25Smacallan      shift # fnord
4645eefee25Smacallan      shift # $arg
4655eefee25Smacallan      ;;
4665eefee25Smacallan    esac
4675eefee25Smacallan  done
4685eefee25Smacallan
4695eefee25Smacallan  "$@" -E |
4705eefee25Smacallan    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
4715eefee25Smacallan       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
4725eefee25Smacallan    sed '$ s: \\$::' > "$tmpdepfile"
4735eefee25Smacallan  rm -f "$depfile"
4745eefee25Smacallan  echo "$object : \\" > "$depfile"
4755eefee25Smacallan  cat < "$tmpdepfile" >> "$depfile"
4765eefee25Smacallan  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
4775eefee25Smacallan  rm -f "$tmpdepfile"
4785eefee25Smacallan  ;;
4795eefee25Smacallan
4805eefee25Smacallanmsvisualcpp)
4815eefee25Smacallan  # Important note: in order to support this mode, a compiler *must*
4825eefee25Smacallan  # always write the preprocessed file to stdout, regardless of -o,
4835eefee25Smacallan  # because we must use -o when running libtool.
4845eefee25Smacallan  "$@" || exit $?
4855eefee25Smacallan  IFS=" "
4865eefee25Smacallan  for arg
4875eefee25Smacallan  do
4885eefee25Smacallan    case "$arg" in
4895eefee25Smacallan    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
4905eefee25Smacallan	set fnord "$@"
4915eefee25Smacallan	shift
4925eefee25Smacallan	shift
4935eefee25Smacallan	;;
4945eefee25Smacallan    *)
4955eefee25Smacallan	set fnord "$@" "$arg"
4965eefee25Smacallan	shift
4975eefee25Smacallan	shift
4985eefee25Smacallan	;;
4995eefee25Smacallan    esac
5005eefee25Smacallan  done
5015eefee25Smacallan  "$@" -E |
5025eefee25Smacallan  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
5035eefee25Smacallan  rm -f "$depfile"
5045eefee25Smacallan  echo "$object : \\" > "$depfile"
5055eefee25Smacallan  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
5065eefee25Smacallan  echo "	" >> "$depfile"
5075eefee25Smacallan  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
5085eefee25Smacallan  rm -f "$tmpdepfile"
5095eefee25Smacallan  ;;
5105eefee25Smacallan
5115eefee25Smacallannone)
5125eefee25Smacallan  exec "$@"
5135eefee25Smacallan  ;;
5145eefee25Smacallan
5155eefee25Smacallan*)
5165eefee25Smacallan  echo "Unknown depmode $depmode" 1>&2
5175eefee25Smacallan  exit 1
5185eefee25Smacallan  ;;
5195eefee25Smacallanesac
5205eefee25Smacallan
5215eefee25Smacallanexit 0
5225eefee25Smacallan
5235eefee25Smacallan# Local Variables:
5245eefee25Smacallan# mode: shell-script
5255eefee25Smacallan# sh-indentation: 2
5265eefee25Smacallan# eval: (add-hook 'write-file-hooks 'time-stamp)
5275eefee25Smacallan# time-stamp-start: "scriptversion="
5285eefee25Smacallan# time-stamp-format: "%:y-%02m-%02d.%02H"
5295eefee25Smacallan# time-stamp-end: "$"
5305eefee25Smacallan# End:
531