depcomp revision 7a0395d0
17a0395d0Smrg#! /bin/sh
27a0395d0Smrg# depcomp - compile a program generating dependencies as side-effects
37a0395d0Smrg
47a0395d0Smrgscriptversion=2007-03-29.01
57a0395d0Smrg
67a0395d0Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software
77a0395d0Smrg# Foundation, Inc.
87a0395d0Smrg
97a0395d0Smrg# This program is free software; you can redistribute it and/or modify
107a0395d0Smrg# it under the terms of the GNU General Public License as published by
117a0395d0Smrg# the Free Software Foundation; either version 2, or (at your option)
127a0395d0Smrg# any later version.
137a0395d0Smrg
147a0395d0Smrg# This program is distributed in the hope that it will be useful,
157a0395d0Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
167a0395d0Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
177a0395d0Smrg# GNU General Public License for more details.
187a0395d0Smrg
197a0395d0Smrg# You should have received a copy of the GNU General Public License
207a0395d0Smrg# along with this program; if not, write to the Free Software
217a0395d0Smrg# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
227a0395d0Smrg# 02110-1301, USA.
237a0395d0Smrg
247a0395d0Smrg# As a special exception to the GNU General Public License, if you
257a0395d0Smrg# distribute this file as part of a program that contains a
267a0395d0Smrg# configuration script generated by Autoconf, you may include it under
277a0395d0Smrg# the same distribution terms that you use for the rest of that program.
287a0395d0Smrg
297a0395d0Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
307a0395d0Smrg
317a0395d0Smrgcase $1 in
327a0395d0Smrg  '')
337a0395d0Smrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
347a0395d0Smrg     exit 1;
357a0395d0Smrg     ;;
367a0395d0Smrg  -h | --h*)
377a0395d0Smrg    cat <<\EOF
387a0395d0SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
397a0395d0Smrg
407a0395d0SmrgRun PROGRAMS ARGS to compile a file, generating dependencies
417a0395d0Smrgas side-effects.
427a0395d0Smrg
437a0395d0SmrgEnvironment variables:
447a0395d0Smrg  depmode     Dependency tracking mode.
457a0395d0Smrg  source      Source file read by `PROGRAMS ARGS'.
467a0395d0Smrg  object      Object file output by `PROGRAMS ARGS'.
477a0395d0Smrg  DEPDIR      directory where to store dependencies.
487a0395d0Smrg  depfile     Dependency file to output.
497a0395d0Smrg  tmpdepfile  Temporary file to use when outputing dependencies.
507a0395d0Smrg  libtool     Whether libtool is used (yes/no).
517a0395d0Smrg
527a0395d0SmrgReport bugs to <bug-automake@gnu.org>.
537a0395d0SmrgEOF
547a0395d0Smrg    exit $?
557a0395d0Smrg    ;;
567a0395d0Smrg  -v | --v*)
577a0395d0Smrg    echo "depcomp $scriptversion"
587a0395d0Smrg    exit $?
597a0395d0Smrg    ;;
607a0395d0Smrgesac
617a0395d0Smrg
627a0395d0Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
637a0395d0Smrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
647a0395d0Smrg  exit 1
657a0395d0Smrgfi
667a0395d0Smrg
677a0395d0Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
687a0395d0Smrgdepfile=${depfile-`echo "$object" |
697a0395d0Smrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
707a0395d0Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
717a0395d0Smrg
727a0395d0Smrgrm -f "$tmpdepfile"
737a0395d0Smrg
747a0395d0Smrg# Some modes work just like other modes, but use different flags.  We
757a0395d0Smrg# parameterize here, but still list the modes in the big case below,
767a0395d0Smrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
777a0395d0Smrg# here, because this file can only contain one case statement.
787a0395d0Smrgif test "$depmode" = hp; then
797a0395d0Smrg  # HP compiler uses -M and no extra arg.
807a0395d0Smrg  gccflag=-M
817a0395d0Smrg  depmode=gcc
827a0395d0Smrgfi
837a0395d0Smrg
847a0395d0Smrgif test "$depmode" = dashXmstdout; then
857a0395d0Smrg   # This is just like dashmstdout with a different argument.
867a0395d0Smrg   dashmflag=-xM
877a0395d0Smrg   depmode=dashmstdout
887a0395d0Smrgfi
897a0395d0Smrg
907a0395d0Smrgcase "$depmode" in
917a0395d0Smrggcc3)
927a0395d0Smrg## gcc 3 implements dependency tracking that does exactly what
937a0395d0Smrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
947a0395d0Smrg## it if -MD -MP comes after the -MF stuff.  Hmm.
957a0395d0Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
967a0395d0Smrg## the command line argument order; so add the flags where they
977a0395d0Smrg## appear in depend2.am.  Note that the slowdown incurred here
987a0395d0Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
997a0395d0Smrg  for arg
1007a0395d0Smrg  do
1017a0395d0Smrg    case $arg in
1027a0395d0Smrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
1037a0395d0Smrg    *)  set fnord "$@" "$arg" ;;
1047a0395d0Smrg    esac
1057a0395d0Smrg    shift # fnord
1067a0395d0Smrg    shift # $arg
1077a0395d0Smrg  done
1087a0395d0Smrg  "$@"
1097a0395d0Smrg  stat=$?
1107a0395d0Smrg  if test $stat -eq 0; then :
1117a0395d0Smrg  else
1127a0395d0Smrg    rm -f "$tmpdepfile"
1137a0395d0Smrg    exit $stat
1147a0395d0Smrg  fi
1157a0395d0Smrg  mv "$tmpdepfile" "$depfile"
1167a0395d0Smrg  ;;
1177a0395d0Smrg
1187a0395d0Smrggcc)
1197a0395d0Smrg## There are various ways to get dependency output from gcc.  Here's
1207a0395d0Smrg## why we pick this rather obscure method:
1217a0395d0Smrg## - Don't want to use -MD because we'd like the dependencies to end
1227a0395d0Smrg##   up in a subdir.  Having to rename by hand is ugly.
1237a0395d0Smrg##   (We might end up doing this anyway to support other compilers.)
1247a0395d0Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
1257a0395d0Smrg##   -MM, not -M (despite what the docs say).
1267a0395d0Smrg## - Using -M directly means running the compiler twice (even worse
1277a0395d0Smrg##   than renaming).
1287a0395d0Smrg  if test -z "$gccflag"; then
1297a0395d0Smrg    gccflag=-MD,
1307a0395d0Smrg  fi
1317a0395d0Smrg  "$@" -Wp,"$gccflag$tmpdepfile"
1327a0395d0Smrg  stat=$?
1337a0395d0Smrg  if test $stat -eq 0; then :
1347a0395d0Smrg  else
1357a0395d0Smrg    rm -f "$tmpdepfile"
1367a0395d0Smrg    exit $stat
1377a0395d0Smrg  fi
1387a0395d0Smrg  rm -f "$depfile"
1397a0395d0Smrg  echo "$object : \\" > "$depfile"
1407a0395d0Smrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
1417a0395d0Smrg## The second -e expression handles DOS-style file names with drive letters.
1427a0395d0Smrg  sed -e 's/^[^:]*: / /' \
1437a0395d0Smrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
1447a0395d0Smrg## This next piece of magic avoids the `deleted header file' problem.
1457a0395d0Smrg## The problem is that when a header file which appears in a .P file
1467a0395d0Smrg## is deleted, the dependency causes make to die (because there is
1477a0395d0Smrg## typically no way to rebuild the header).  We avoid this by adding
1487a0395d0Smrg## dummy dependencies for each header file.  Too bad gcc doesn't do
1497a0395d0Smrg## this for us directly.
1507a0395d0Smrg  tr ' ' '
1517a0395d0Smrg' < "$tmpdepfile" |
1527a0395d0Smrg## Some versions of gcc put a space before the `:'.  On the theory
1537a0395d0Smrg## that the space means something, we add a space to the output as
1547a0395d0Smrg## well.
1557a0395d0Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
1567a0395d0Smrg## correctly.  Breaking it into two sed invocations is a workaround.
1577a0395d0Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
1587a0395d0Smrg  rm -f "$tmpdepfile"
1597a0395d0Smrg  ;;
1607a0395d0Smrg
1617a0395d0Smrghp)
1627a0395d0Smrg  # This case exists only to let depend.m4 do its work.  It works by
1637a0395d0Smrg  # looking at the text of this script.  This case will never be run,
1647a0395d0Smrg  # since it is checked for above.
1657a0395d0Smrg  exit 1
1667a0395d0Smrg  ;;
1677a0395d0Smrg
1687a0395d0Smrgsgi)
1697a0395d0Smrg  if test "$libtool" = yes; then
1707a0395d0Smrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
1717a0395d0Smrg  else
1727a0395d0Smrg    "$@" -MDupdate "$tmpdepfile"
1737a0395d0Smrg  fi
1747a0395d0Smrg  stat=$?
1757a0395d0Smrg  if test $stat -eq 0; then :
1767a0395d0Smrg  else
1777a0395d0Smrg    rm -f "$tmpdepfile"
1787a0395d0Smrg    exit $stat
1797a0395d0Smrg  fi
1807a0395d0Smrg  rm -f "$depfile"
1817a0395d0Smrg
1827a0395d0Smrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
1837a0395d0Smrg    echo "$object : \\" > "$depfile"
1847a0395d0Smrg
1857a0395d0Smrg    # Clip off the initial element (the dependent).  Don't try to be
1867a0395d0Smrg    # clever and replace this with sed code, as IRIX sed won't handle
1877a0395d0Smrg    # lines with more than a fixed number of characters (4096 in
1887a0395d0Smrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
1897a0395d0Smrg    # the IRIX cc adds comments like `#:fec' to the end of the
1907a0395d0Smrg    # dependency line.
1917a0395d0Smrg    tr ' ' '
1927a0395d0Smrg' < "$tmpdepfile" \
1937a0395d0Smrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
1947a0395d0Smrg    tr '
1957a0395d0Smrg' ' ' >> $depfile
1967a0395d0Smrg    echo >> $depfile
1977a0395d0Smrg
1987a0395d0Smrg    # The second pass generates a dummy entry for each header file.
1997a0395d0Smrg    tr ' ' '
2007a0395d0Smrg' < "$tmpdepfile" \
2017a0395d0Smrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
2027a0395d0Smrg   >> $depfile
2037a0395d0Smrg  else
2047a0395d0Smrg    # The sourcefile does not contain any dependencies, so just
2057a0395d0Smrg    # store a dummy comment line, to avoid errors with the Makefile
2067a0395d0Smrg    # "include basename.Plo" scheme.
2077a0395d0Smrg    echo "#dummy" > "$depfile"
2087a0395d0Smrg  fi
2097a0395d0Smrg  rm -f "$tmpdepfile"
2107a0395d0Smrg  ;;
2117a0395d0Smrg
2127a0395d0Smrgaix)
2137a0395d0Smrg  # The C for AIX Compiler uses -M and outputs the dependencies
2147a0395d0Smrg  # in a .u file.  In older versions, this file always lives in the
2157a0395d0Smrg  # current directory.  Also, the AIX compiler puts `$object:' at the
2167a0395d0Smrg  # start of each line; $object doesn't have directory information.
2177a0395d0Smrg  # Version 6 uses the directory in both cases.
2187a0395d0Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
2197a0395d0Smrg  test "x$dir" = "x$object" && dir=
2207a0395d0Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
2217a0395d0Smrg  if test "$libtool" = yes; then
2227a0395d0Smrg    tmpdepfile1=$dir$base.u
2237a0395d0Smrg    tmpdepfile2=$base.u
2247a0395d0Smrg    tmpdepfile3=$dir.libs/$base.u
2257a0395d0Smrg    "$@" -Wc,-M
2267a0395d0Smrg  else
2277a0395d0Smrg    tmpdepfile1=$dir$base.u
2287a0395d0Smrg    tmpdepfile2=$dir$base.u
2297a0395d0Smrg    tmpdepfile3=$dir$base.u
2307a0395d0Smrg    "$@" -M
2317a0395d0Smrg  fi
2327a0395d0Smrg  stat=$?
2337a0395d0Smrg
2347a0395d0Smrg  if test $stat -eq 0; then :
2357a0395d0Smrg  else
2367a0395d0Smrg    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
2377a0395d0Smrg    exit $stat
2387a0395d0Smrg  fi
2397a0395d0Smrg
2407a0395d0Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
2417a0395d0Smrg  do
2427a0395d0Smrg    test -f "$tmpdepfile" && break
2437a0395d0Smrg  done
2447a0395d0Smrg  if test -f "$tmpdepfile"; then
2457a0395d0Smrg    # Each line is of the form `foo.o: dependent.h'.
2467a0395d0Smrg    # Do two passes, one to just change these to
2477a0395d0Smrg    # `$object: dependent.h' and one to simply `dependent.h:'.
2487a0395d0Smrg    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
2497a0395d0Smrg    # That's a tab and a space in the [].
2507a0395d0Smrg    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
2517a0395d0Smrg  else
2527a0395d0Smrg    # The sourcefile does not contain any dependencies, so just
2537a0395d0Smrg    # store a dummy comment line, to avoid errors with the Makefile
2547a0395d0Smrg    # "include basename.Plo" scheme.
2557a0395d0Smrg    echo "#dummy" > "$depfile"
2567a0395d0Smrg  fi
2577a0395d0Smrg  rm -f "$tmpdepfile"
2587a0395d0Smrg  ;;
2597a0395d0Smrg
2607a0395d0Smrgicc)
2617a0395d0Smrg  # Intel's C compiler understands `-MD -MF file'.  However on
2627a0395d0Smrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
2637a0395d0Smrg  # ICC 7.0 will fill foo.d with something like
2647a0395d0Smrg  #    foo.o: sub/foo.c
2657a0395d0Smrg  #    foo.o: sub/foo.h
2667a0395d0Smrg  # which is wrong.  We want:
2677a0395d0Smrg  #    sub/foo.o: sub/foo.c
2687a0395d0Smrg  #    sub/foo.o: sub/foo.h
2697a0395d0Smrg  #    sub/foo.c:
2707a0395d0Smrg  #    sub/foo.h:
2717a0395d0Smrg  # ICC 7.1 will output
2727a0395d0Smrg  #    foo.o: sub/foo.c sub/foo.h
2737a0395d0Smrg  # and will wrap long lines using \ :
2747a0395d0Smrg  #    foo.o: sub/foo.c ... \
2757a0395d0Smrg  #     sub/foo.h ... \
2767a0395d0Smrg  #     ...
2777a0395d0Smrg
2787a0395d0Smrg  "$@" -MD -MF "$tmpdepfile"
2797a0395d0Smrg  stat=$?
2807a0395d0Smrg  if test $stat -eq 0; then :
2817a0395d0Smrg  else
2827a0395d0Smrg    rm -f "$tmpdepfile"
2837a0395d0Smrg    exit $stat
2847a0395d0Smrg  fi
2857a0395d0Smrg  rm -f "$depfile"
2867a0395d0Smrg  # Each line is of the form `foo.o: dependent.h',
2877a0395d0Smrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
2887a0395d0Smrg  # Do two passes, one to just change these to
2897a0395d0Smrg  # `$object: dependent.h' and one to simply `dependent.h:'.
2907a0395d0Smrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
2917a0395d0Smrg  # Some versions of the HPUX 10.20 sed can't process this invocation
2927a0395d0Smrg  # correctly.  Breaking it into two sed invocations is a workaround.
2937a0395d0Smrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
2947a0395d0Smrg    sed -e 's/$/ :/' >> "$depfile"
2957a0395d0Smrg  rm -f "$tmpdepfile"
2967a0395d0Smrg  ;;
2977a0395d0Smrg
2987a0395d0Smrghp2)
2997a0395d0Smrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
3007a0395d0Smrg  # compilers, which have integrated preprocessors.  The correct option
3017a0395d0Smrg  # to use with these is +Maked; it writes dependencies to a file named
3027a0395d0Smrg  # 'foo.d', which lands next to the object file, wherever that
3037a0395d0Smrg  # happens to be.
3047a0395d0Smrg  # Much of this is similar to the tru64 case; see comments there.
3057a0395d0Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3067a0395d0Smrg  test "x$dir" = "x$object" && dir=
3077a0395d0Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3087a0395d0Smrg  if test "$libtool" = yes; then
3097a0395d0Smrg    tmpdepfile1=$dir$base.d
3107a0395d0Smrg    tmpdepfile2=$dir.libs/$base.d
3117a0395d0Smrg    "$@" -Wc,+Maked
3127a0395d0Smrg  else
3137a0395d0Smrg    tmpdepfile1=$dir$base.d
3147a0395d0Smrg    tmpdepfile2=$dir$base.d
3157a0395d0Smrg    "$@" +Maked
3167a0395d0Smrg  fi
3177a0395d0Smrg  stat=$?
3187a0395d0Smrg  if test $stat -eq 0; then :
3197a0395d0Smrg  else
3207a0395d0Smrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
3217a0395d0Smrg     exit $stat
3227a0395d0Smrg  fi
3237a0395d0Smrg
3247a0395d0Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
3257a0395d0Smrg  do
3267a0395d0Smrg    test -f "$tmpdepfile" && break
3277a0395d0Smrg  done
3287a0395d0Smrg  if test -f "$tmpdepfile"; then
3297a0395d0Smrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
3307a0395d0Smrg    # Add `dependent.h:' lines.
3317a0395d0Smrg    sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
3327a0395d0Smrg  else
3337a0395d0Smrg    echo "#dummy" > "$depfile"
3347a0395d0Smrg  fi
3357a0395d0Smrg  rm -f "$tmpdepfile" "$tmpdepfile2"
3367a0395d0Smrg  ;;
3377a0395d0Smrg
3387a0395d0Smrgtru64)
3397a0395d0Smrg   # The Tru64 compiler uses -MD to generate dependencies as a side
3407a0395d0Smrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
3417a0395d0Smrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
3427a0395d0Smrg   # dependencies in `foo.d' instead, so we check for that too.
3437a0395d0Smrg   # Subdirectories are respected.
3447a0395d0Smrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3457a0395d0Smrg   test "x$dir" = "x$object" && dir=
3467a0395d0Smrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3477a0395d0Smrg
3487a0395d0Smrg   if test "$libtool" = yes; then
3497a0395d0Smrg      # With Tru64 cc, shared objects can also be used to make a
3507a0395d0Smrg      # static library.  This mechanism is used in libtool 1.4 series to
3517a0395d0Smrg      # handle both shared and static libraries in a single compilation.
3527a0395d0Smrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
3537a0395d0Smrg      #
3547a0395d0Smrg      # With libtool 1.5 this exception was removed, and libtool now
3557a0395d0Smrg      # generates 2 separate objects for the 2 libraries.  These two
3567a0395d0Smrg      # compilations output dependencies in $dir.libs/$base.o.d and
3577a0395d0Smrg      # in $dir$base.o.d.  We have to check for both files, because
3587a0395d0Smrg      # one of the two compilations can be disabled.  We should prefer
3597a0395d0Smrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
3607a0395d0Smrg      # automatically cleaned when .libs/ is deleted, while ignoring
3617a0395d0Smrg      # the former would cause a distcleancheck panic.
3627a0395d0Smrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
3637a0395d0Smrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
3647a0395d0Smrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
3657a0395d0Smrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
3667a0395d0Smrg      "$@" -Wc,-MD
3677a0395d0Smrg   else
3687a0395d0Smrg      tmpdepfile1=$dir$base.o.d
3697a0395d0Smrg      tmpdepfile2=$dir$base.d
3707a0395d0Smrg      tmpdepfile3=$dir$base.d
3717a0395d0Smrg      tmpdepfile4=$dir$base.d
3727a0395d0Smrg      "$@" -MD
3737a0395d0Smrg   fi
3747a0395d0Smrg
3757a0395d0Smrg   stat=$?
3767a0395d0Smrg   if test $stat -eq 0; then :
3777a0395d0Smrg   else
3787a0395d0Smrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
3797a0395d0Smrg      exit $stat
3807a0395d0Smrg   fi
3817a0395d0Smrg
3827a0395d0Smrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
3837a0395d0Smrg   do
3847a0395d0Smrg     test -f "$tmpdepfile" && break
3857a0395d0Smrg   done
3867a0395d0Smrg   if test -f "$tmpdepfile"; then
3877a0395d0Smrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
3887a0395d0Smrg      # That's a tab and a space in the [].
3897a0395d0Smrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
3907a0395d0Smrg   else
3917a0395d0Smrg      echo "#dummy" > "$depfile"
3927a0395d0Smrg   fi
3937a0395d0Smrg   rm -f "$tmpdepfile"
3947a0395d0Smrg   ;;
3957a0395d0Smrg
3967a0395d0Smrg#nosideeffect)
3977a0395d0Smrg  # This comment above is used by automake to tell side-effect
3987a0395d0Smrg  # dependency tracking mechanisms from slower ones.
3997a0395d0Smrg
4007a0395d0Smrgdashmstdout)
4017a0395d0Smrg  # Important note: in order to support this mode, a compiler *must*
4027a0395d0Smrg  # always write the preprocessed file to stdout, regardless of -o.
4037a0395d0Smrg  "$@" || exit $?
4047a0395d0Smrg
4057a0395d0Smrg  # Remove the call to Libtool.
4067a0395d0Smrg  if test "$libtool" = yes; then
4077a0395d0Smrg    while test $1 != '--mode=compile'; do
4087a0395d0Smrg      shift
4097a0395d0Smrg    done
4107a0395d0Smrg    shift
4117a0395d0Smrg  fi
4127a0395d0Smrg
4137a0395d0Smrg  # Remove `-o $object'.
4147a0395d0Smrg  IFS=" "
4157a0395d0Smrg  for arg
4167a0395d0Smrg  do
4177a0395d0Smrg    case $arg in
4187a0395d0Smrg    -o)
4197a0395d0Smrg      shift
4207a0395d0Smrg      ;;
4217a0395d0Smrg    $object)
4227a0395d0Smrg      shift
4237a0395d0Smrg      ;;
4247a0395d0Smrg    *)
4257a0395d0Smrg      set fnord "$@" "$arg"
4267a0395d0Smrg      shift # fnord
4277a0395d0Smrg      shift # $arg
4287a0395d0Smrg      ;;
4297a0395d0Smrg    esac
4307a0395d0Smrg  done
4317a0395d0Smrg
4327a0395d0Smrg  test -z "$dashmflag" && dashmflag=-M
4337a0395d0Smrg  # Require at least two characters before searching for `:'
4347a0395d0Smrg  # in the target name.  This is to cope with DOS-style filenames:
4357a0395d0Smrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
4367a0395d0Smrg  "$@" $dashmflag |
4377a0395d0Smrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
4387a0395d0Smrg  rm -f "$depfile"
4397a0395d0Smrg  cat < "$tmpdepfile" > "$depfile"
4407a0395d0Smrg  tr ' ' '
4417a0395d0Smrg' < "$tmpdepfile" | \
4427a0395d0Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
4437a0395d0Smrg## correctly.  Breaking it into two sed invocations is a workaround.
4447a0395d0Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
4457a0395d0Smrg  rm -f "$tmpdepfile"
4467a0395d0Smrg  ;;
4477a0395d0Smrg
4487a0395d0SmrgdashXmstdout)
4497a0395d0Smrg  # This case only exists to satisfy depend.m4.  It is never actually
4507a0395d0Smrg  # run, as this mode is specially recognized in the preamble.
4517a0395d0Smrg  exit 1
4527a0395d0Smrg  ;;
4537a0395d0Smrg
4547a0395d0Smrgmakedepend)
4557a0395d0Smrg  "$@" || exit $?
4567a0395d0Smrg  # Remove any Libtool call
4577a0395d0Smrg  if test "$libtool" = yes; then
4587a0395d0Smrg    while test $1 != '--mode=compile'; do
4597a0395d0Smrg      shift
4607a0395d0Smrg    done
4617a0395d0Smrg    shift
4627a0395d0Smrg  fi
4637a0395d0Smrg  # X makedepend
4647a0395d0Smrg  shift
4657a0395d0Smrg  cleared=no
4667a0395d0Smrg  for arg in "$@"; do
4677a0395d0Smrg    case $cleared in
4687a0395d0Smrg    no)
4697a0395d0Smrg      set ""; shift
4707a0395d0Smrg      cleared=yes ;;
4717a0395d0Smrg    esac
4727a0395d0Smrg    case "$arg" in
4737a0395d0Smrg    -D*|-I*)
4747a0395d0Smrg      set fnord "$@" "$arg"; shift ;;
4757a0395d0Smrg    # Strip any option that makedepend may not understand.  Remove
4767a0395d0Smrg    # the object too, otherwise makedepend will parse it as a source file.
4777a0395d0Smrg    -*|$object)
4787a0395d0Smrg      ;;
4797a0395d0Smrg    *)
4807a0395d0Smrg      set fnord "$@" "$arg"; shift ;;
4817a0395d0Smrg    esac
4827a0395d0Smrg  done
4837a0395d0Smrg  obj_suffix="`echo $object | sed 's/^.*\././'`"
4847a0395d0Smrg  touch "$tmpdepfile"
4857a0395d0Smrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
4867a0395d0Smrg  rm -f "$depfile"
4877a0395d0Smrg  cat < "$tmpdepfile" > "$depfile"
4887a0395d0Smrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
4897a0395d0Smrg' | \
4907a0395d0Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
4917a0395d0Smrg## correctly.  Breaking it into two sed invocations is a workaround.
4927a0395d0Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
4937a0395d0Smrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
4947a0395d0Smrg  ;;
4957a0395d0Smrg
4967a0395d0Smrgcpp)
4977a0395d0Smrg  # Important note: in order to support this mode, a compiler *must*
4987a0395d0Smrg  # always write the preprocessed file to stdout.
4997a0395d0Smrg  "$@" || exit $?
5007a0395d0Smrg
5017a0395d0Smrg  # Remove the call to Libtool.
5027a0395d0Smrg  if test "$libtool" = yes; then
5037a0395d0Smrg    while test $1 != '--mode=compile'; do
5047a0395d0Smrg      shift
5057a0395d0Smrg    done
5067a0395d0Smrg    shift
5077a0395d0Smrg  fi
5087a0395d0Smrg
5097a0395d0Smrg  # Remove `-o $object'.
5107a0395d0Smrg  IFS=" "
5117a0395d0Smrg  for arg
5127a0395d0Smrg  do
5137a0395d0Smrg    case $arg in
5147a0395d0Smrg    -o)
5157a0395d0Smrg      shift
5167a0395d0Smrg      ;;
5177a0395d0Smrg    $object)
5187a0395d0Smrg      shift
5197a0395d0Smrg      ;;
5207a0395d0Smrg    *)
5217a0395d0Smrg      set fnord "$@" "$arg"
5227a0395d0Smrg      shift # fnord
5237a0395d0Smrg      shift # $arg
5247a0395d0Smrg      ;;
5257a0395d0Smrg    esac
5267a0395d0Smrg  done
5277a0395d0Smrg
5287a0395d0Smrg  "$@" -E |
5297a0395d0Smrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
5307a0395d0Smrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
5317a0395d0Smrg    sed '$ s: \\$::' > "$tmpdepfile"
5327a0395d0Smrg  rm -f "$depfile"
5337a0395d0Smrg  echo "$object : \\" > "$depfile"
5347a0395d0Smrg  cat < "$tmpdepfile" >> "$depfile"
5357a0395d0Smrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
5367a0395d0Smrg  rm -f "$tmpdepfile"
5377a0395d0Smrg  ;;
5387a0395d0Smrg
5397a0395d0Smrgmsvisualcpp)
5407a0395d0Smrg  # Important note: in order to support this mode, a compiler *must*
5417a0395d0Smrg  # always write the preprocessed file to stdout, regardless of -o,
5427a0395d0Smrg  # because we must use -o when running libtool.
5437a0395d0Smrg  "$@" || exit $?
5447a0395d0Smrg  IFS=" "
5457a0395d0Smrg  for arg
5467a0395d0Smrg  do
5477a0395d0Smrg    case "$arg" in
5487a0395d0Smrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
5497a0395d0Smrg	set fnord "$@"
5507a0395d0Smrg	shift
5517a0395d0Smrg	shift
5527a0395d0Smrg	;;
5537a0395d0Smrg    *)
5547a0395d0Smrg	set fnord "$@" "$arg"
5557a0395d0Smrg	shift
5567a0395d0Smrg	shift
5577a0395d0Smrg	;;
5587a0395d0Smrg    esac
5597a0395d0Smrg  done
5607a0395d0Smrg  "$@" -E |
5617a0395d0Smrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
5627a0395d0Smrg  rm -f "$depfile"
5637a0395d0Smrg  echo "$object : \\" > "$depfile"
5647a0395d0Smrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
5657a0395d0Smrg  echo "	" >> "$depfile"
5667a0395d0Smrg  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
5677a0395d0Smrg  rm -f "$tmpdepfile"
5687a0395d0Smrg  ;;
5697a0395d0Smrg
5707a0395d0Smrgnone)
5717a0395d0Smrg  exec "$@"
5727a0395d0Smrg  ;;
5737a0395d0Smrg
5747a0395d0Smrg*)
5757a0395d0Smrg  echo "Unknown depmode $depmode" 1>&2
5767a0395d0Smrg  exit 1
5777a0395d0Smrg  ;;
5787a0395d0Smrgesac
5797a0395d0Smrg
5807a0395d0Smrgexit 0
5817a0395d0Smrg
5827a0395d0Smrg# Local Variables:
5837a0395d0Smrg# mode: shell-script
5847a0395d0Smrg# sh-indentation: 2
5857a0395d0Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
5867a0395d0Smrg# time-stamp-start: "scriptversion="
5877a0395d0Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
5887a0395d0Smrg# time-stamp-end: "$"
5897a0395d0Smrg# End:
590