depcomp revision 1abf7346
11abf7346Smrg#! /bin/sh
21abf7346Smrg# depcomp - compile a program generating dependencies as side-effects
31abf7346Smrg
41abf7346Smrgscriptversion=2006-10-15.18
51abf7346Smrg
61abf7346Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software
71abf7346Smrg# Foundation, Inc.
81abf7346Smrg
91abf7346Smrg# This program is free software; you can redistribute it and/or modify
101abf7346Smrg# it under the terms of the GNU General Public License as published by
111abf7346Smrg# the Free Software Foundation; either version 2, or (at your option)
121abf7346Smrg# any later version.
131abf7346Smrg
141abf7346Smrg# This program is distributed in the hope that it will be useful,
151abf7346Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
161abf7346Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
171abf7346Smrg# GNU General Public License for more details.
181abf7346Smrg
191abf7346Smrg# You should have received a copy of the GNU General Public License
201abf7346Smrg# along with this program; if not, write to the Free Software
211abf7346Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
221abf7346Smrg# 02110-1301, USA.
231abf7346Smrg
241abf7346Smrg# As a special exception to the GNU General Public License, if you
251abf7346Smrg# distribute this file as part of a program that contains a
261abf7346Smrg# configuration script generated by Autoconf, you may include it under
271abf7346Smrg# the same distribution terms that you use for the rest of that program.
281abf7346Smrg
291abf7346Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
301abf7346Smrg
311abf7346Smrgcase $1 in
321abf7346Smrg  '')
331abf7346Smrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
341abf7346Smrg     exit 1;
351abf7346Smrg     ;;
361abf7346Smrg  -h | --h*)
371abf7346Smrg    cat <<\EOF
381abf7346SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
391abf7346Smrg
401abf7346SmrgRun PROGRAMS ARGS to compile a file, generating dependencies
411abf7346Smrgas side-effects.
421abf7346Smrg
431abf7346SmrgEnvironment variables:
441abf7346Smrg  depmode     Dependency tracking mode.
451abf7346Smrg  source      Source file read by `PROGRAMS ARGS'.
461abf7346Smrg  object      Object file output by `PROGRAMS ARGS'.
471abf7346Smrg  DEPDIR      directory where to store dependencies.
481abf7346Smrg  depfile     Dependency file to output.
491abf7346Smrg  tmpdepfile  Temporary file to use when outputing dependencies.
501abf7346Smrg  libtool     Whether libtool is used (yes/no).
511abf7346Smrg
521abf7346SmrgReport bugs to <bug-automake@gnu.org>.
531abf7346SmrgEOF
541abf7346Smrg    exit $?
551abf7346Smrg    ;;
561abf7346Smrg  -v | --v*)
571abf7346Smrg    echo "depcomp $scriptversion"
581abf7346Smrg    exit $?
591abf7346Smrg    ;;
601abf7346Smrgesac
611abf7346Smrg
621abf7346Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
631abf7346Smrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
641abf7346Smrg  exit 1
651abf7346Smrgfi
661abf7346Smrg
671abf7346Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
681abf7346Smrgdepfile=${depfile-`echo "$object" |
691abf7346Smrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
701abf7346Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
711abf7346Smrg
721abf7346Smrgrm -f "$tmpdepfile"
731abf7346Smrg
741abf7346Smrg# Some modes work just like other modes, but use different flags.  We
751abf7346Smrg# parameterize here, but still list the modes in the big case below,
761abf7346Smrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
771abf7346Smrg# here, because this file can only contain one case statement.
781abf7346Smrgif test "$depmode" = hp; then
791abf7346Smrg  # HP compiler uses -M and no extra arg.
801abf7346Smrg  gccflag=-M
811abf7346Smrg  depmode=gcc
821abf7346Smrgfi
831abf7346Smrg
841abf7346Smrgif test "$depmode" = dashXmstdout; then
851abf7346Smrg   # This is just like dashmstdout with a different argument.
861abf7346Smrg   dashmflag=-xM
871abf7346Smrg   depmode=dashmstdout
881abf7346Smrgfi
891abf7346Smrg
901abf7346Smrgcase "$depmode" in
911abf7346Smrggcc3)
921abf7346Smrg## gcc 3 implements dependency tracking that does exactly what
931abf7346Smrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
941abf7346Smrg## it if -MD -MP comes after the -MF stuff.  Hmm.
951abf7346Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
961abf7346Smrg## the command line argument order; so add the flags where they
971abf7346Smrg## appear in depend2.am.  Note that the slowdown incurred here
981abf7346Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
991abf7346Smrg  for arg
1001abf7346Smrg  do
1011abf7346Smrg    case $arg in
1021abf7346Smrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
1031abf7346Smrg    *)  set fnord "$@" "$arg" ;;
1041abf7346Smrg    esac
1051abf7346Smrg    shift # fnord
1061abf7346Smrg    shift # $arg
1071abf7346Smrg  done
1081abf7346Smrg  "$@"
1091abf7346Smrg  stat=$?
1101abf7346Smrg  if test $stat -eq 0; then :
1111abf7346Smrg  else
1121abf7346Smrg    rm -f "$tmpdepfile"
1131abf7346Smrg    exit $stat
1141abf7346Smrg  fi
1151abf7346Smrg  mv "$tmpdepfile" "$depfile"
1161abf7346Smrg  ;;
1171abf7346Smrg
1181abf7346Smrggcc)
1191abf7346Smrg## There are various ways to get dependency output from gcc.  Here's
1201abf7346Smrg## why we pick this rather obscure method:
1211abf7346Smrg## - Don't want to use -MD because we'd like the dependencies to end
1221abf7346Smrg##   up in a subdir.  Having to rename by hand is ugly.
1231abf7346Smrg##   (We might end up doing this anyway to support other compilers.)
1241abf7346Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
1251abf7346Smrg##   -MM, not -M (despite what the docs say).
1261abf7346Smrg## - Using -M directly means running the compiler twice (even worse
1271abf7346Smrg##   than renaming).
1281abf7346Smrg  if test -z "$gccflag"; then
1291abf7346Smrg    gccflag=-MD,
1301abf7346Smrg  fi
1311abf7346Smrg  "$@" -Wp,"$gccflag$tmpdepfile"
1321abf7346Smrg  stat=$?
1331abf7346Smrg  if test $stat -eq 0; then :
1341abf7346Smrg  else
1351abf7346Smrg    rm -f "$tmpdepfile"
1361abf7346Smrg    exit $stat
1371abf7346Smrg  fi
1381abf7346Smrg  rm -f "$depfile"
1391abf7346Smrg  echo "$object : \\" > "$depfile"
1401abf7346Smrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
1411abf7346Smrg## The second -e expression handles DOS-style file names with drive letters.
1421abf7346Smrg  sed -e 's/^[^:]*: / /' \
1431abf7346Smrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
1441abf7346Smrg## This next piece of magic avoids the `deleted header file' problem.
1451abf7346Smrg## The problem is that when a header file which appears in a .P file
1461abf7346Smrg## is deleted, the dependency causes make to die (because there is
1471abf7346Smrg## typically no way to rebuild the header).  We avoid this by adding
1481abf7346Smrg## dummy dependencies for each header file.  Too bad gcc doesn't do
1491abf7346Smrg## this for us directly.
1501abf7346Smrg  tr ' ' '
1511abf7346Smrg' < "$tmpdepfile" |
1521abf7346Smrg## Some versions of gcc put a space before the `:'.  On the theory
1531abf7346Smrg## that the space means something, we add a space to the output as
1541abf7346Smrg## well.
1551abf7346Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
1561abf7346Smrg## correctly.  Breaking it into two sed invocations is a workaround.
1571abf7346Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
1581abf7346Smrg  rm -f "$tmpdepfile"
1591abf7346Smrg  ;;
1601abf7346Smrg
1611abf7346Smrghp)
1621abf7346Smrg  # This case exists only to let depend.m4 do its work.  It works by
1631abf7346Smrg  # looking at the text of this script.  This case will never be run,
1641abf7346Smrg  # since it is checked for above.
1651abf7346Smrg  exit 1
1661abf7346Smrg  ;;
1671abf7346Smrg
1681abf7346Smrgsgi)
1691abf7346Smrg  if test "$libtool" = yes; then
1701abf7346Smrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
1711abf7346Smrg  else
1721abf7346Smrg    "$@" -MDupdate "$tmpdepfile"
1731abf7346Smrg  fi
1741abf7346Smrg  stat=$?
1751abf7346Smrg  if test $stat -eq 0; then :
1761abf7346Smrg  else
1771abf7346Smrg    rm -f "$tmpdepfile"
1781abf7346Smrg    exit $stat
1791abf7346Smrg  fi
1801abf7346Smrg  rm -f "$depfile"
1811abf7346Smrg
1821abf7346Smrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
1831abf7346Smrg    echo "$object : \\" > "$depfile"
1841abf7346Smrg
1851abf7346Smrg    # Clip off the initial element (the dependent).  Don't try to be
1861abf7346Smrg    # clever and replace this with sed code, as IRIX sed won't handle
1871abf7346Smrg    # lines with more than a fixed number of characters (4096 in
1881abf7346Smrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
1891abf7346Smrg    # the IRIX cc adds comments like `#:fec' to the end of the
1901abf7346Smrg    # dependency line.
1911abf7346Smrg    tr ' ' '
1921abf7346Smrg' < "$tmpdepfile" \
1931abf7346Smrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
1941abf7346Smrg    tr '
1951abf7346Smrg' ' ' >> $depfile
1961abf7346Smrg    echo >> $depfile
1971abf7346Smrg
1981abf7346Smrg    # The second pass generates a dummy entry for each header file.
1991abf7346Smrg    tr ' ' '
2001abf7346Smrg' < "$tmpdepfile" \
2011abf7346Smrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
2021abf7346Smrg   >> $depfile
2031abf7346Smrg  else
2041abf7346Smrg    # The sourcefile does not contain any dependencies, so just
2051abf7346Smrg    # store a dummy comment line, to avoid errors with the Makefile
2061abf7346Smrg    # "include basename.Plo" scheme.
2071abf7346Smrg    echo "#dummy" > "$depfile"
2081abf7346Smrg  fi
2091abf7346Smrg  rm -f "$tmpdepfile"
2101abf7346Smrg  ;;
2111abf7346Smrg
2121abf7346Smrgaix)
2131abf7346Smrg  # The C for AIX Compiler uses -M and outputs the dependencies
2141abf7346Smrg  # in a .u file.  In older versions, this file always lives in the
2151abf7346Smrg  # current directory.  Also, the AIX compiler puts `$object:' at the
2161abf7346Smrg  # start of each line; $object doesn't have directory information.
2171abf7346Smrg  # Version 6 uses the directory in both cases.
2181abf7346Smrg  stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
2191abf7346Smrg  tmpdepfile="$stripped.u"
2201abf7346Smrg  if test "$libtool" = yes; then
2211abf7346Smrg    "$@" -Wc,-M
2221abf7346Smrg  else
2231abf7346Smrg    "$@" -M
2241abf7346Smrg  fi
2251abf7346Smrg  stat=$?
2261abf7346Smrg
2271abf7346Smrg  if test -f "$tmpdepfile"; then :
2281abf7346Smrg  else
2291abf7346Smrg    stripped=`echo "$stripped" | sed 's,^.*/,,'`
2301abf7346Smrg    tmpdepfile="$stripped.u"
2311abf7346Smrg  fi
2321abf7346Smrg
2331abf7346Smrg  if test $stat -eq 0; then :
2341abf7346Smrg  else
2351abf7346Smrg    rm -f "$tmpdepfile"
2361abf7346Smrg    exit $stat
2371abf7346Smrg  fi
2381abf7346Smrg
2391abf7346Smrg  if test -f "$tmpdepfile"; then
2401abf7346Smrg    outname="$stripped.o"
2411abf7346Smrg    # Each line is of the form `foo.o: dependent.h'.
2421abf7346Smrg    # Do two passes, one to just change these to
2431abf7346Smrg    # `$object: dependent.h' and one to simply `dependent.h:'.
2441abf7346Smrg    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
2451abf7346Smrg    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
2461abf7346Smrg  else
2471abf7346Smrg    # The sourcefile does not contain any dependencies, so just
2481abf7346Smrg    # store a dummy comment line, to avoid errors with the Makefile
2491abf7346Smrg    # "include basename.Plo" scheme.
2501abf7346Smrg    echo "#dummy" > "$depfile"
2511abf7346Smrg  fi
2521abf7346Smrg  rm -f "$tmpdepfile"
2531abf7346Smrg  ;;
2541abf7346Smrg
2551abf7346Smrgicc)
2561abf7346Smrg  # Intel's C compiler understands `-MD -MF file'.  However on
2571abf7346Smrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
2581abf7346Smrg  # ICC 7.0 will fill foo.d with something like
2591abf7346Smrg  #    foo.o: sub/foo.c
2601abf7346Smrg  #    foo.o: sub/foo.h
2611abf7346Smrg  # which is wrong.  We want:
2621abf7346Smrg  #    sub/foo.o: sub/foo.c
2631abf7346Smrg  #    sub/foo.o: sub/foo.h
2641abf7346Smrg  #    sub/foo.c:
2651abf7346Smrg  #    sub/foo.h:
2661abf7346Smrg  # ICC 7.1 will output
2671abf7346Smrg  #    foo.o: sub/foo.c sub/foo.h
2681abf7346Smrg  # and will wrap long lines using \ :
2691abf7346Smrg  #    foo.o: sub/foo.c ... \
2701abf7346Smrg  #     sub/foo.h ... \
2711abf7346Smrg  #     ...
2721abf7346Smrg
2731abf7346Smrg  "$@" -MD -MF "$tmpdepfile"
2741abf7346Smrg  stat=$?
2751abf7346Smrg  if test $stat -eq 0; then :
2761abf7346Smrg  else
2771abf7346Smrg    rm -f "$tmpdepfile"
2781abf7346Smrg    exit $stat
2791abf7346Smrg  fi
2801abf7346Smrg  rm -f "$depfile"
2811abf7346Smrg  # Each line is of the form `foo.o: dependent.h',
2821abf7346Smrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
2831abf7346Smrg  # Do two passes, one to just change these to
2841abf7346Smrg  # `$object: dependent.h' and one to simply `dependent.h:'.
2851abf7346Smrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
2861abf7346Smrg  # Some versions of the HPUX 10.20 sed can't process this invocation
2871abf7346Smrg  # correctly.  Breaking it into two sed invocations is a workaround.
2881abf7346Smrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
2891abf7346Smrg    sed -e 's/$/ :/' >> "$depfile"
2901abf7346Smrg  rm -f "$tmpdepfile"
2911abf7346Smrg  ;;
2921abf7346Smrg
2931abf7346Smrghp2)
2941abf7346Smrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
2951abf7346Smrg  # compilers, which have integrated preprocessors.  The correct option
2961abf7346Smrg  # to use with these is +Maked; it writes dependencies to a file named
2971abf7346Smrg  # 'foo.d', which lands next to the object file, wherever that
2981abf7346Smrg  # happens to be.
2991abf7346Smrg  # Much of this is similar to the tru64 case; see comments there.
3001abf7346Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3011abf7346Smrg  test "x$dir" = "x$object" && dir=
3021abf7346Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3031abf7346Smrg  if test "$libtool" = yes; then
3041abf7346Smrg    tmpdepfile1=$dir$base.d
3051abf7346Smrg    tmpdepfile2=$dir.libs/$base.d
3061abf7346Smrg    "$@" -Wc,+Maked
3071abf7346Smrg  else
3081abf7346Smrg    tmpdepfile1=$dir$base.d
3091abf7346Smrg    tmpdepfile2=$dir$base.d
3101abf7346Smrg    "$@" +Maked
3111abf7346Smrg  fi
3121abf7346Smrg  stat=$?
3131abf7346Smrg  if test $stat -eq 0; then :
3141abf7346Smrg  else
3151abf7346Smrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
3161abf7346Smrg     exit $stat
3171abf7346Smrg  fi
3181abf7346Smrg
3191abf7346Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
3201abf7346Smrg  do
3211abf7346Smrg    test -f "$tmpdepfile" && break
3221abf7346Smrg  done
3231abf7346Smrg  if test -f "$tmpdepfile"; then
3241abf7346Smrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
3251abf7346Smrg    # Add `dependent.h:' lines.
3261abf7346Smrg    sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
3271abf7346Smrg  else
3281abf7346Smrg    echo "#dummy" > "$depfile"
3291abf7346Smrg  fi
3301abf7346Smrg  rm -f "$tmpdepfile" "$tmpdepfile2"
3311abf7346Smrg  ;;
3321abf7346Smrg
3331abf7346Smrgtru64)
3341abf7346Smrg   # The Tru64 compiler uses -MD to generate dependencies as a side
3351abf7346Smrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
3361abf7346Smrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
3371abf7346Smrg   # dependencies in `foo.d' instead, so we check for that too.
3381abf7346Smrg   # Subdirectories are respected.
3391abf7346Smrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3401abf7346Smrg   test "x$dir" = "x$object" && dir=
3411abf7346Smrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3421abf7346Smrg
3431abf7346Smrg   if test "$libtool" = yes; then
3441abf7346Smrg      # With Tru64 cc, shared objects can also be used to make a
3451abf7346Smrg      # static library.  This mechanism is used in libtool 1.4 series to
3461abf7346Smrg      # handle both shared and static libraries in a single compilation.
3471abf7346Smrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
3481abf7346Smrg      #
3491abf7346Smrg      # With libtool 1.5 this exception was removed, and libtool now
3501abf7346Smrg      # generates 2 separate objects for the 2 libraries.  These two
3511abf7346Smrg      # compilations output dependencies in $dir.libs/$base.o.d and
3521abf7346Smrg      # in $dir$base.o.d.  We have to check for both files, because
3531abf7346Smrg      # one of the two compilations can be disabled.  We should prefer
3541abf7346Smrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
3551abf7346Smrg      # automatically cleaned when .libs/ is deleted, while ignoring
3561abf7346Smrg      # the former would cause a distcleancheck panic.
3571abf7346Smrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
3581abf7346Smrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
3591abf7346Smrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
3601abf7346Smrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
3611abf7346Smrg      "$@" -Wc,-MD
3621abf7346Smrg   else
3631abf7346Smrg      tmpdepfile1=$dir$base.o.d
3641abf7346Smrg      tmpdepfile2=$dir$base.d
3651abf7346Smrg      tmpdepfile3=$dir$base.d
3661abf7346Smrg      tmpdepfile4=$dir$base.d
3671abf7346Smrg      "$@" -MD
3681abf7346Smrg   fi
3691abf7346Smrg
3701abf7346Smrg   stat=$?
3711abf7346Smrg   if test $stat -eq 0; then :
3721abf7346Smrg   else
3731abf7346Smrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
3741abf7346Smrg      exit $stat
3751abf7346Smrg   fi
3761abf7346Smrg
3771abf7346Smrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
3781abf7346Smrg   do
3791abf7346Smrg     test -f "$tmpdepfile" && break
3801abf7346Smrg   done
3811abf7346Smrg   if test -f "$tmpdepfile"; then
3821abf7346Smrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
3831abf7346Smrg      # That's a tab and a space in the [].
3841abf7346Smrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
3851abf7346Smrg   else
3861abf7346Smrg      echo "#dummy" > "$depfile"
3871abf7346Smrg   fi
3881abf7346Smrg   rm -f "$tmpdepfile"
3891abf7346Smrg   ;;
3901abf7346Smrg
3911abf7346Smrg#nosideeffect)
3921abf7346Smrg  # This comment above is used by automake to tell side-effect
3931abf7346Smrg  # dependency tracking mechanisms from slower ones.
3941abf7346Smrg
3951abf7346Smrgdashmstdout)
3961abf7346Smrg  # Important note: in order to support this mode, a compiler *must*
3971abf7346Smrg  # always write the preprocessed file to stdout, regardless of -o.
3981abf7346Smrg  "$@" || exit $?
3991abf7346Smrg
4001abf7346Smrg  # Remove the call to Libtool.
4011abf7346Smrg  if test "$libtool" = yes; then
4021abf7346Smrg    while test $1 != '--mode=compile'; do
4031abf7346Smrg      shift
4041abf7346Smrg    done
4051abf7346Smrg    shift
4061abf7346Smrg  fi
4071abf7346Smrg
4081abf7346Smrg  # Remove `-o $object'.
4091abf7346Smrg  IFS=" "
4101abf7346Smrg  for arg
4111abf7346Smrg  do
4121abf7346Smrg    case $arg in
4131abf7346Smrg    -o)
4141abf7346Smrg      shift
4151abf7346Smrg      ;;
4161abf7346Smrg    $object)
4171abf7346Smrg      shift
4181abf7346Smrg      ;;
4191abf7346Smrg    *)
4201abf7346Smrg      set fnord "$@" "$arg"
4211abf7346Smrg      shift # fnord
4221abf7346Smrg      shift # $arg
4231abf7346Smrg      ;;
4241abf7346Smrg    esac
4251abf7346Smrg  done
4261abf7346Smrg
4271abf7346Smrg  test -z "$dashmflag" && dashmflag=-M
4281abf7346Smrg  # Require at least two characters before searching for `:'
4291abf7346Smrg  # in the target name.  This is to cope with DOS-style filenames:
4301abf7346Smrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
4311abf7346Smrg  "$@" $dashmflag |
4321abf7346Smrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
4331abf7346Smrg  rm -f "$depfile"
4341abf7346Smrg  cat < "$tmpdepfile" > "$depfile"
4351abf7346Smrg  tr ' ' '
4361abf7346Smrg' < "$tmpdepfile" | \
4371abf7346Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
4381abf7346Smrg## correctly.  Breaking it into two sed invocations is a workaround.
4391abf7346Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
4401abf7346Smrg  rm -f "$tmpdepfile"
4411abf7346Smrg  ;;
4421abf7346Smrg
4431abf7346SmrgdashXmstdout)
4441abf7346Smrg  # This case only exists to satisfy depend.m4.  It is never actually
4451abf7346Smrg  # run, as this mode is specially recognized in the preamble.
4461abf7346Smrg  exit 1
4471abf7346Smrg  ;;
4481abf7346Smrg
4491abf7346Smrgmakedepend)
4501abf7346Smrg  "$@" || exit $?
4511abf7346Smrg  # Remove any Libtool call
4521abf7346Smrg  if test "$libtool" = yes; then
4531abf7346Smrg    while test $1 != '--mode=compile'; do
4541abf7346Smrg      shift
4551abf7346Smrg    done
4561abf7346Smrg    shift
4571abf7346Smrg  fi
4581abf7346Smrg  # X makedepend
4591abf7346Smrg  shift
4601abf7346Smrg  cleared=no
4611abf7346Smrg  for arg in "$@"; do
4621abf7346Smrg    case $cleared in
4631abf7346Smrg    no)
4641abf7346Smrg      set ""; shift
4651abf7346Smrg      cleared=yes ;;
4661abf7346Smrg    esac
4671abf7346Smrg    case "$arg" in
4681abf7346Smrg    -D*|-I*)
4691abf7346Smrg      set fnord "$@" "$arg"; shift ;;
4701abf7346Smrg    # Strip any option that makedepend may not understand.  Remove
4711abf7346Smrg    # the object too, otherwise makedepend will parse it as a source file.
4721abf7346Smrg    -*|$object)
4731abf7346Smrg      ;;
4741abf7346Smrg    *)
4751abf7346Smrg      set fnord "$@" "$arg"; shift ;;
4761abf7346Smrg    esac
4771abf7346Smrg  done
4781abf7346Smrg  obj_suffix="`echo $object | sed 's/^.*\././'`"
4791abf7346Smrg  touch "$tmpdepfile"
4801abf7346Smrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
4811abf7346Smrg  rm -f "$depfile"
4821abf7346Smrg  cat < "$tmpdepfile" > "$depfile"
4831abf7346Smrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
4841abf7346Smrg' | \
4851abf7346Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
4861abf7346Smrg## correctly.  Breaking it into two sed invocations is a workaround.
4871abf7346Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
4881abf7346Smrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
4891abf7346Smrg  ;;
4901abf7346Smrg
4911abf7346Smrgcpp)
4921abf7346Smrg  # Important note: in order to support this mode, a compiler *must*
4931abf7346Smrg  # always write the preprocessed file to stdout.
4941abf7346Smrg  "$@" || exit $?
4951abf7346Smrg
4961abf7346Smrg  # Remove the call to Libtool.
4971abf7346Smrg  if test "$libtool" = yes; then
4981abf7346Smrg    while test $1 != '--mode=compile'; do
4991abf7346Smrg      shift
5001abf7346Smrg    done
5011abf7346Smrg    shift
5021abf7346Smrg  fi
5031abf7346Smrg
5041abf7346Smrg  # Remove `-o $object'.
5051abf7346Smrg  IFS=" "
5061abf7346Smrg  for arg
5071abf7346Smrg  do
5081abf7346Smrg    case $arg in
5091abf7346Smrg    -o)
5101abf7346Smrg      shift
5111abf7346Smrg      ;;
5121abf7346Smrg    $object)
5131abf7346Smrg      shift
5141abf7346Smrg      ;;
5151abf7346Smrg    *)
5161abf7346Smrg      set fnord "$@" "$arg"
5171abf7346Smrg      shift # fnord
5181abf7346Smrg      shift # $arg
5191abf7346Smrg      ;;
5201abf7346Smrg    esac
5211abf7346Smrg  done
5221abf7346Smrg
5231abf7346Smrg  "$@" -E |
5241abf7346Smrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
5251abf7346Smrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
5261abf7346Smrg    sed '$ s: \\$::' > "$tmpdepfile"
5271abf7346Smrg  rm -f "$depfile"
5281abf7346Smrg  echo "$object : \\" > "$depfile"
5291abf7346Smrg  cat < "$tmpdepfile" >> "$depfile"
5301abf7346Smrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
5311abf7346Smrg  rm -f "$tmpdepfile"
5321abf7346Smrg  ;;
5331abf7346Smrg
5341abf7346Smrgmsvisualcpp)
5351abf7346Smrg  # Important note: in order to support this mode, a compiler *must*
5361abf7346Smrg  # always write the preprocessed file to stdout, regardless of -o,
5371abf7346Smrg  # because we must use -o when running libtool.
5381abf7346Smrg  "$@" || exit $?
5391abf7346Smrg  IFS=" "
5401abf7346Smrg  for arg
5411abf7346Smrg  do
5421abf7346Smrg    case "$arg" in
5431abf7346Smrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
5441abf7346Smrg	set fnord "$@"
5451abf7346Smrg	shift
5461abf7346Smrg	shift
5471abf7346Smrg	;;
5481abf7346Smrg    *)
5491abf7346Smrg	set fnord "$@" "$arg"
5501abf7346Smrg	shift
5511abf7346Smrg	shift
5521abf7346Smrg	;;
5531abf7346Smrg    esac
5541abf7346Smrg  done
5551abf7346Smrg  "$@" -E |
5561abf7346Smrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
5571abf7346Smrg  rm -f "$depfile"
5581abf7346Smrg  echo "$object : \\" > "$depfile"
5591abf7346Smrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
5601abf7346Smrg  echo "	" >> "$depfile"
5611abf7346Smrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
5621abf7346Smrg  rm -f "$tmpdepfile"
5631abf7346Smrg  ;;
5641abf7346Smrg
5651abf7346Smrgnone)
5661abf7346Smrg  exec "$@"
5671abf7346Smrg  ;;
5681abf7346Smrg
5691abf7346Smrg*)
5701abf7346Smrg  echo "Unknown depmode $depmode" 1>&2
5711abf7346Smrg  exit 1
5721abf7346Smrg  ;;
5731abf7346Smrgesac
5741abf7346Smrg
5751abf7346Smrgexit 0
5761abf7346Smrg
5771abf7346Smrg# Local Variables:
5781abf7346Smrg# mode: shell-script
5791abf7346Smrg# sh-indentation: 2
5801abf7346Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
5811abf7346Smrg# time-stamp-start: "scriptversion="
5821abf7346Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
5831abf7346Smrg# time-stamp-end: "$"
5841abf7346Smrg# End:
585