depcomp revision 48c85eb7
13da084b3Smrg#! /bin/sh
23da084b3Smrg# depcomp - compile a program generating dependencies as side-effects
33da084b3Smrg
448c85eb7Smrgscriptversion=2011-12-04.11; # UTC
53da084b3Smrg
648c85eb7Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
748c85eb7Smrg# 2011 Free Software Foundation, Inc.
83da084b3Smrg
93da084b3Smrg# This program is free software; you can redistribute it and/or modify
103da084b3Smrg# it under the terms of the GNU General Public License as published by
113da084b3Smrg# the Free Software Foundation; either version 2, or (at your option)
123da084b3Smrg# any later version.
133da084b3Smrg
143da084b3Smrg# This program is distributed in the hope that it will be useful,
153da084b3Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
163da084b3Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
173da084b3Smrg# GNU General Public License for more details.
183da084b3Smrg
193da084b3Smrg# You should have received a copy of the GNU General Public License
2055acc8fcSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
213da084b3Smrg
223da084b3Smrg# As a special exception to the GNU General Public License, if you
233da084b3Smrg# distribute this file as part of a program that contains a
243da084b3Smrg# configuration script generated by Autoconf, you may include it under
253da084b3Smrg# the same distribution terms that you use for the rest of that program.
263da084b3Smrg
273da084b3Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
283da084b3Smrg
293da084b3Smrgcase $1 in
303da084b3Smrg  '')
313da084b3Smrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
323da084b3Smrg     exit 1;
333da084b3Smrg     ;;
343da084b3Smrg  -h | --h*)
353da084b3Smrg    cat <<\EOF
363da084b3SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
373da084b3Smrg
383da084b3SmrgRun PROGRAMS ARGS to compile a file, generating dependencies
393da084b3Smrgas side-effects.
403da084b3Smrg
413da084b3SmrgEnvironment variables:
423da084b3Smrg  depmode     Dependency tracking mode.
433da084b3Smrg  source      Source file read by `PROGRAMS ARGS'.
443da084b3Smrg  object      Object file output by `PROGRAMS ARGS'.
453da084b3Smrg  DEPDIR      directory where to store dependencies.
463da084b3Smrg  depfile     Dependency file to output.
4748c85eb7Smrg  tmpdepfile  Temporary file to use when outputting dependencies.
483da084b3Smrg  libtool     Whether libtool is used (yes/no).
493da084b3Smrg
503da084b3SmrgReport bugs to <bug-automake@gnu.org>.
513da084b3SmrgEOF
523da084b3Smrg    exit $?
533da084b3Smrg    ;;
543da084b3Smrg  -v | --v*)
553da084b3Smrg    echo "depcomp $scriptversion"
563da084b3Smrg    exit $?
573da084b3Smrg    ;;
583da084b3Smrgesac
593da084b3Smrg
603da084b3Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
613da084b3Smrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
623da084b3Smrg  exit 1
633da084b3Smrgfi
643da084b3Smrg
653da084b3Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
663da084b3Smrgdepfile=${depfile-`echo "$object" |
673da084b3Smrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
683da084b3Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
693da084b3Smrg
703da084b3Smrgrm -f "$tmpdepfile"
713da084b3Smrg
723da084b3Smrg# Some modes work just like other modes, but use different flags.  We
733da084b3Smrg# parameterize here, but still list the modes in the big case below,
743da084b3Smrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
753da084b3Smrg# here, because this file can only contain one case statement.
763da084b3Smrgif test "$depmode" = hp; then
773da084b3Smrg  # HP compiler uses -M and no extra arg.
783da084b3Smrg  gccflag=-M
793da084b3Smrg  depmode=gcc
803da084b3Smrgfi
813da084b3Smrg
823da084b3Smrgif test "$depmode" = dashXmstdout; then
833da084b3Smrg   # This is just like dashmstdout with a different argument.
843da084b3Smrg   dashmflag=-xM
853da084b3Smrg   depmode=dashmstdout
863da084b3Smrgfi
873da084b3Smrg
8855acc8fcSmrgcygpath_u="cygpath -u -f -"
8955acc8fcSmrgif test "$depmode" = msvcmsys; then
9055acc8fcSmrg   # This is just like msvisualcpp but w/o cygpath translation.
9155acc8fcSmrg   # Just convert the backslash-escaped backslashes to single forward
9255acc8fcSmrg   # slashes to satisfy depend.m4
9348c85eb7Smrg   cygpath_u='sed s,\\\\,/,g'
9455acc8fcSmrg   depmode=msvisualcpp
9555acc8fcSmrgfi
9655acc8fcSmrg
9748c85eb7Smrgif test "$depmode" = msvc7msys; then
9848c85eb7Smrg   # This is just like msvc7 but w/o cygpath translation.
9948c85eb7Smrg   # Just convert the backslash-escaped backslashes to single forward
10048c85eb7Smrg   # slashes to satisfy depend.m4
10148c85eb7Smrg   cygpath_u='sed s,\\\\,/,g'
10248c85eb7Smrg   depmode=msvc7
10348c85eb7Smrgfi
10448c85eb7Smrg
1053da084b3Smrgcase "$depmode" in
1063da084b3Smrggcc3)
1073da084b3Smrg## gcc 3 implements dependency tracking that does exactly what
1083da084b3Smrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
1093da084b3Smrg## it if -MD -MP comes after the -MF stuff.  Hmm.
110d63fdb69Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
111d63fdb69Smrg## the command line argument order; so add the flags where they
112d63fdb69Smrg## appear in depend2.am.  Note that the slowdown incurred here
113d63fdb69Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
114d63fdb69Smrg  for arg
115d63fdb69Smrg  do
116d63fdb69Smrg    case $arg in
117d63fdb69Smrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
118d63fdb69Smrg    *)  set fnord "$@" "$arg" ;;
119d63fdb69Smrg    esac
120d63fdb69Smrg    shift # fnord
121d63fdb69Smrg    shift # $arg
122d63fdb69Smrg  done
123d63fdb69Smrg  "$@"
1243da084b3Smrg  stat=$?
1253da084b3Smrg  if test $stat -eq 0; then :
1263da084b3Smrg  else
1273da084b3Smrg    rm -f "$tmpdepfile"
1283da084b3Smrg    exit $stat
1293da084b3Smrg  fi
1303da084b3Smrg  mv "$tmpdepfile" "$depfile"
1313da084b3Smrg  ;;
1323da084b3Smrg
1333da084b3Smrggcc)
1343da084b3Smrg## There are various ways to get dependency output from gcc.  Here's
1353da084b3Smrg## why we pick this rather obscure method:
1363da084b3Smrg## - Don't want to use -MD because we'd like the dependencies to end
1373da084b3Smrg##   up in a subdir.  Having to rename by hand is ugly.
1383da084b3Smrg##   (We might end up doing this anyway to support other compilers.)
1393da084b3Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
1403da084b3Smrg##   -MM, not -M (despite what the docs say).
1413da084b3Smrg## - Using -M directly means running the compiler twice (even worse
1423da084b3Smrg##   than renaming).
1433da084b3Smrg  if test -z "$gccflag"; then
1443da084b3Smrg    gccflag=-MD,
1453da084b3Smrg  fi
1463da084b3Smrg  "$@" -Wp,"$gccflag$tmpdepfile"
1473da084b3Smrg  stat=$?
1483da084b3Smrg  if test $stat -eq 0; then :
1493da084b3Smrg  else
1503da084b3Smrg    rm -f "$tmpdepfile"
1513da084b3Smrg    exit $stat
1523da084b3Smrg  fi
1533da084b3Smrg  rm -f "$depfile"
1543da084b3Smrg  echo "$object : \\" > "$depfile"
1553da084b3Smrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
1563da084b3Smrg## The second -e expression handles DOS-style file names with drive letters.
1573da084b3Smrg  sed -e 's/^[^:]*: / /' \
1583da084b3Smrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
1593da084b3Smrg## This next piece of magic avoids the `deleted header file' problem.
1603da084b3Smrg## The problem is that when a header file which appears in a .P file
1613da084b3Smrg## is deleted, the dependency causes make to die (because there is
1623da084b3Smrg## typically no way to rebuild the header).  We avoid this by adding
1633da084b3Smrg## dummy dependencies for each header file.  Too bad gcc doesn't do
1643da084b3Smrg## this for us directly.
1653da084b3Smrg  tr ' ' '
1663da084b3Smrg' < "$tmpdepfile" |
1673da084b3Smrg## Some versions of gcc put a space before the `:'.  On the theory
1683da084b3Smrg## that the space means something, we add a space to the output as
16948c85eb7Smrg## well.  hp depmode also adds that space, but also prefixes the VPATH
17048c85eb7Smrg## to the object.  Take care to not repeat it in the output.
1713da084b3Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
1723da084b3Smrg## correctly.  Breaking it into two sed invocations is a workaround.
17348c85eb7Smrg    sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
17448c85eb7Smrg      | sed -e 's/$/ :/' >> "$depfile"
1753da084b3Smrg  rm -f "$tmpdepfile"
1763da084b3Smrg  ;;
1773da084b3Smrg
1783da084b3Smrghp)
1793da084b3Smrg  # This case exists only to let depend.m4 do its work.  It works by
1803da084b3Smrg  # looking at the text of this script.  This case will never be run,
1813da084b3Smrg  # since it is checked for above.
1823da084b3Smrg  exit 1
1833da084b3Smrg  ;;
1843da084b3Smrg
1853da084b3Smrgsgi)
1863da084b3Smrg  if test "$libtool" = yes; then
1873da084b3Smrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
1883da084b3Smrg  else
1893da084b3Smrg    "$@" -MDupdate "$tmpdepfile"
1903da084b3Smrg  fi
1913da084b3Smrg  stat=$?
1923da084b3Smrg  if test $stat -eq 0; then :
1933da084b3Smrg  else
1943da084b3Smrg    rm -f "$tmpdepfile"
1953da084b3Smrg    exit $stat
1963da084b3Smrg  fi
1973da084b3Smrg  rm -f "$depfile"
1983da084b3Smrg
1993da084b3Smrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
2003da084b3Smrg    echo "$object : \\" > "$depfile"
2013da084b3Smrg
2023da084b3Smrg    # Clip off the initial element (the dependent).  Don't try to be
2033da084b3Smrg    # clever and replace this with sed code, as IRIX sed won't handle
2043da084b3Smrg    # lines with more than a fixed number of characters (4096 in
2053da084b3Smrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
2063da084b3Smrg    # the IRIX cc adds comments like `#:fec' to the end of the
2073da084b3Smrg    # dependency line.
2083da084b3Smrg    tr ' ' '
2093da084b3Smrg' < "$tmpdepfile" \
2103da084b3Smrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
2113da084b3Smrg    tr '
21255acc8fcSmrg' ' ' >> "$depfile"
21355acc8fcSmrg    echo >> "$depfile"
2143da084b3Smrg
2153da084b3Smrg    # The second pass generates a dummy entry for each header file.
2163da084b3Smrg    tr ' ' '
2173da084b3Smrg' < "$tmpdepfile" \
2183da084b3Smrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
21955acc8fcSmrg   >> "$depfile"
2203da084b3Smrg  else
2213da084b3Smrg    # The sourcefile does not contain any dependencies, so just
2223da084b3Smrg    # store a dummy comment line, to avoid errors with the Makefile
2233da084b3Smrg    # "include basename.Plo" scheme.
2243da084b3Smrg    echo "#dummy" > "$depfile"
2253da084b3Smrg  fi
2263da084b3Smrg  rm -f "$tmpdepfile"
2273da084b3Smrg  ;;
2283da084b3Smrg
2293da084b3Smrgaix)
2303da084b3Smrg  # The C for AIX Compiler uses -M and outputs the dependencies
2313da084b3Smrg  # in a .u file.  In older versions, this file always lives in the
2323da084b3Smrg  # current directory.  Also, the AIX compiler puts `$object:' at the
2333da084b3Smrg  # start of each line; $object doesn't have directory information.
2343da084b3Smrg  # Version 6 uses the directory in both cases.
235d63fdb69Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
236d63fdb69Smrg  test "x$dir" = "x$object" && dir=
237d63fdb69Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
2383da084b3Smrg  if test "$libtool" = yes; then
239d63fdb69Smrg    tmpdepfile1=$dir$base.u
240d63fdb69Smrg    tmpdepfile2=$base.u
241d63fdb69Smrg    tmpdepfile3=$dir.libs/$base.u
2423da084b3Smrg    "$@" -Wc,-M
2433da084b3Smrg  else
244d63fdb69Smrg    tmpdepfile1=$dir$base.u
245d63fdb69Smrg    tmpdepfile2=$dir$base.u
246d63fdb69Smrg    tmpdepfile3=$dir$base.u
2473da084b3Smrg    "$@" -M
2483da084b3Smrg  fi
2493da084b3Smrg  stat=$?
2503da084b3Smrg
2513da084b3Smrg  if test $stat -eq 0; then :
2523da084b3Smrg  else
253d63fdb69Smrg    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
2543da084b3Smrg    exit $stat
2553da084b3Smrg  fi
2563da084b3Smrg
257d63fdb69Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
258d63fdb69Smrg  do
259d63fdb69Smrg    test -f "$tmpdepfile" && break
260d63fdb69Smrg  done
2613da084b3Smrg  if test -f "$tmpdepfile"; then
2623da084b3Smrg    # Each line is of the form `foo.o: dependent.h'.
2633da084b3Smrg    # Do two passes, one to just change these to
2643da084b3Smrg    # `$object: dependent.h' and one to simply `dependent.h:'.
265d63fdb69Smrg    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
266d63fdb69Smrg    # That's a tab and a space in the [].
267d63fdb69Smrg    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
2683da084b3Smrg  else
2693da084b3Smrg    # The sourcefile does not contain any dependencies, so just
2703da084b3Smrg    # store a dummy comment line, to avoid errors with the Makefile
2713da084b3Smrg    # "include basename.Plo" scheme.
2723da084b3Smrg    echo "#dummy" > "$depfile"
2733da084b3Smrg  fi
2743da084b3Smrg  rm -f "$tmpdepfile"
2753da084b3Smrg  ;;
2763da084b3Smrg
2773da084b3Smrgicc)
2783da084b3Smrg  # Intel's C compiler understands `-MD -MF file'.  However on
2793da084b3Smrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
2803da084b3Smrg  # ICC 7.0 will fill foo.d with something like
2813da084b3Smrg  #    foo.o: sub/foo.c
2823da084b3Smrg  #    foo.o: sub/foo.h
2833da084b3Smrg  # which is wrong.  We want:
2843da084b3Smrg  #    sub/foo.o: sub/foo.c
2853da084b3Smrg  #    sub/foo.o: sub/foo.h
2863da084b3Smrg  #    sub/foo.c:
2873da084b3Smrg  #    sub/foo.h:
2883da084b3Smrg  # ICC 7.1 will output
2893da084b3Smrg  #    foo.o: sub/foo.c sub/foo.h
2903da084b3Smrg  # and will wrap long lines using \ :
2913da084b3Smrg  #    foo.o: sub/foo.c ... \
2923da084b3Smrg  #     sub/foo.h ... \
2933da084b3Smrg  #     ...
2943da084b3Smrg
2953da084b3Smrg  "$@" -MD -MF "$tmpdepfile"
2963da084b3Smrg  stat=$?
2973da084b3Smrg  if test $stat -eq 0; then :
2983da084b3Smrg  else
2993da084b3Smrg    rm -f "$tmpdepfile"
3003da084b3Smrg    exit $stat
3013da084b3Smrg  fi
3023da084b3Smrg  rm -f "$depfile"
3033da084b3Smrg  # Each line is of the form `foo.o: dependent.h',
3043da084b3Smrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
3053da084b3Smrg  # Do two passes, one to just change these to
3063da084b3Smrg  # `$object: dependent.h' and one to simply `dependent.h:'.
3073da084b3Smrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
3083da084b3Smrg  # Some versions of the HPUX 10.20 sed can't process this invocation
3093da084b3Smrg  # correctly.  Breaking it into two sed invocations is a workaround.
3103da084b3Smrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
3113da084b3Smrg    sed -e 's/$/ :/' >> "$depfile"
3123da084b3Smrg  rm -f "$tmpdepfile"
3133da084b3Smrg  ;;
3143da084b3Smrg
315d63fdb69Smrghp2)
316d63fdb69Smrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
317d63fdb69Smrg  # compilers, which have integrated preprocessors.  The correct option
318d63fdb69Smrg  # to use with these is +Maked; it writes dependencies to a file named
319d63fdb69Smrg  # 'foo.d', which lands next to the object file, wherever that
320d63fdb69Smrg  # happens to be.
321d63fdb69Smrg  # Much of this is similar to the tru64 case; see comments there.
322d63fdb69Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
323d63fdb69Smrg  test "x$dir" = "x$object" && dir=
324d63fdb69Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
325d63fdb69Smrg  if test "$libtool" = yes; then
326d63fdb69Smrg    tmpdepfile1=$dir$base.d
327d63fdb69Smrg    tmpdepfile2=$dir.libs/$base.d
328d63fdb69Smrg    "$@" -Wc,+Maked
329d63fdb69Smrg  else
330d63fdb69Smrg    tmpdepfile1=$dir$base.d
331d63fdb69Smrg    tmpdepfile2=$dir$base.d
332d63fdb69Smrg    "$@" +Maked
333d63fdb69Smrg  fi
334d63fdb69Smrg  stat=$?
335d63fdb69Smrg  if test $stat -eq 0; then :
336d63fdb69Smrg  else
337d63fdb69Smrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
338d63fdb69Smrg     exit $stat
339d63fdb69Smrg  fi
340d63fdb69Smrg
341d63fdb69Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
342d63fdb69Smrg  do
343d63fdb69Smrg    test -f "$tmpdepfile" && break
344d63fdb69Smrg  done
345d63fdb69Smrg  if test -f "$tmpdepfile"; then
346d63fdb69Smrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
347d63fdb69Smrg    # Add `dependent.h:' lines.
34855acc8fcSmrg    sed -ne '2,${
34955acc8fcSmrg	       s/^ *//
35055acc8fcSmrg	       s/ \\*$//
35155acc8fcSmrg	       s/$/:/
35255acc8fcSmrg	       p
35355acc8fcSmrg	     }' "$tmpdepfile" >> "$depfile"
354d63fdb69Smrg  else
355d63fdb69Smrg    echo "#dummy" > "$depfile"
356d63fdb69Smrg  fi
357d63fdb69Smrg  rm -f "$tmpdepfile" "$tmpdepfile2"
358d63fdb69Smrg  ;;
359d63fdb69Smrg
3603da084b3Smrgtru64)
3613da084b3Smrg   # The Tru64 compiler uses -MD to generate dependencies as a side
3623da084b3Smrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
3633da084b3Smrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
3643da084b3Smrg   # dependencies in `foo.d' instead, so we check for that too.
3653da084b3Smrg   # Subdirectories are respected.
3663da084b3Smrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3673da084b3Smrg   test "x$dir" = "x$object" && dir=
3683da084b3Smrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3693da084b3Smrg
3703da084b3Smrg   if test "$libtool" = yes; then
3713da084b3Smrg      # With Tru64 cc, shared objects can also be used to make a
372d63fdb69Smrg      # static library.  This mechanism is used in libtool 1.4 series to
3733da084b3Smrg      # handle both shared and static libraries in a single compilation.
3743da084b3Smrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
3753da084b3Smrg      #
3763da084b3Smrg      # With libtool 1.5 this exception was removed, and libtool now
3773da084b3Smrg      # generates 2 separate objects for the 2 libraries.  These two
378d63fdb69Smrg      # compilations output dependencies in $dir.libs/$base.o.d and
3793da084b3Smrg      # in $dir$base.o.d.  We have to check for both files, because
3803da084b3Smrg      # one of the two compilations can be disabled.  We should prefer
3813da084b3Smrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
3823da084b3Smrg      # automatically cleaned when .libs/ is deleted, while ignoring
3833da084b3Smrg      # the former would cause a distcleancheck panic.
3843da084b3Smrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
3853da084b3Smrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
3863da084b3Smrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
3873da084b3Smrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
3883da084b3Smrg      "$@" -Wc,-MD
3893da084b3Smrg   else
3903da084b3Smrg      tmpdepfile1=$dir$base.o.d
3913da084b3Smrg      tmpdepfile2=$dir$base.d
3923da084b3Smrg      tmpdepfile3=$dir$base.d
3933da084b3Smrg      tmpdepfile4=$dir$base.d
3943da084b3Smrg      "$@" -MD
3953da084b3Smrg   fi
3963da084b3Smrg
3973da084b3Smrg   stat=$?
3983da084b3Smrg   if test $stat -eq 0; then :
3993da084b3Smrg   else
4003da084b3Smrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
4013da084b3Smrg      exit $stat
4023da084b3Smrg   fi
4033da084b3Smrg
4043da084b3Smrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
4053da084b3Smrg   do
4063da084b3Smrg     test -f "$tmpdepfile" && break
4073da084b3Smrg   done
4083da084b3Smrg   if test -f "$tmpdepfile"; then
4093da084b3Smrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
4103da084b3Smrg      # That's a tab and a space in the [].
4113da084b3Smrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
4123da084b3Smrg   else
4133da084b3Smrg      echo "#dummy" > "$depfile"
4143da084b3Smrg   fi
4153da084b3Smrg   rm -f "$tmpdepfile"
4163da084b3Smrg   ;;
4173da084b3Smrg
41848c85eb7Smrgmsvc7)
41948c85eb7Smrg  if test "$libtool" = yes; then
42048c85eb7Smrg    showIncludes=-Wc,-showIncludes
42148c85eb7Smrg  else
42248c85eb7Smrg    showIncludes=-showIncludes
42348c85eb7Smrg  fi
42448c85eb7Smrg  "$@" $showIncludes > "$tmpdepfile"
42548c85eb7Smrg  stat=$?
42648c85eb7Smrg  grep -v '^Note: including file: ' "$tmpdepfile"
42748c85eb7Smrg  if test "$stat" = 0; then :
42848c85eb7Smrg  else
42948c85eb7Smrg    rm -f "$tmpdepfile"
43048c85eb7Smrg    exit $stat
43148c85eb7Smrg  fi
43248c85eb7Smrg  rm -f "$depfile"
43348c85eb7Smrg  echo "$object : \\" > "$depfile"
43448c85eb7Smrg  # The first sed program below extracts the file names and escapes
43548c85eb7Smrg  # backslashes for cygpath.  The second sed program outputs the file
43648c85eb7Smrg  # name when reading, but also accumulates all include files in the
43748c85eb7Smrg  # hold buffer in order to output them again at the end.  This only
43848c85eb7Smrg  # works with sed implementations that can handle large buffers.
43948c85eb7Smrg  sed < "$tmpdepfile" -n '
44048c85eb7Smrg/^Note: including file:  *\(.*\)/ {
44148c85eb7Smrg  s//\1/
44248c85eb7Smrg  s/\\/\\\\/g
44348c85eb7Smrg  p
44448c85eb7Smrg}' | $cygpath_u | sort -u | sed -n '
44548c85eb7Smrgs/ /\\ /g
44648c85eb7Smrgs/\(.*\)/	\1 \\/p
44748c85eb7Smrgs/.\(.*\) \\/\1:/
44848c85eb7SmrgH
44948c85eb7Smrg$ {
45048c85eb7Smrg  s/.*/	/
45148c85eb7Smrg  G
45248c85eb7Smrg  p
45348c85eb7Smrg}' >> "$depfile"
45448c85eb7Smrg  rm -f "$tmpdepfile"
45548c85eb7Smrg  ;;
45648c85eb7Smrg
45748c85eb7Smrgmsvc7msys)
45848c85eb7Smrg  # This case exists only to let depend.m4 do its work.  It works by
45948c85eb7Smrg  # looking at the text of this script.  This case will never be run,
46048c85eb7Smrg  # since it is checked for above.
46148c85eb7Smrg  exit 1
46248c85eb7Smrg  ;;
46348c85eb7Smrg
4643da084b3Smrg#nosideeffect)
4653da084b3Smrg  # This comment above is used by automake to tell side-effect
4663da084b3Smrg  # dependency tracking mechanisms from slower ones.
4673da084b3Smrg
4683da084b3Smrgdashmstdout)
4693da084b3Smrg  # Important note: in order to support this mode, a compiler *must*
4703da084b3Smrg  # always write the preprocessed file to stdout, regardless of -o.
4713da084b3Smrg  "$@" || exit $?
4723da084b3Smrg
4733da084b3Smrg  # Remove the call to Libtool.
4743da084b3Smrg  if test "$libtool" = yes; then
47555acc8fcSmrg    while test "X$1" != 'X--mode=compile'; do
4763da084b3Smrg      shift
4773da084b3Smrg    done
4783da084b3Smrg    shift
4793da084b3Smrg  fi
4803da084b3Smrg
4813da084b3Smrg  # Remove `-o $object'.
4823da084b3Smrg  IFS=" "
4833da084b3Smrg  for arg
4843da084b3Smrg  do
4853da084b3Smrg    case $arg in
4863da084b3Smrg    -o)
4873da084b3Smrg      shift
4883da084b3Smrg      ;;
4893da084b3Smrg    $object)
4903da084b3Smrg      shift
4913da084b3Smrg      ;;
4923da084b3Smrg    *)
4933da084b3Smrg      set fnord "$@" "$arg"
4943da084b3Smrg      shift # fnord
4953da084b3Smrg      shift # $arg
4963da084b3Smrg      ;;
4973da084b3Smrg    esac
4983da084b3Smrg  done
4993da084b3Smrg
5003da084b3Smrg  test -z "$dashmflag" && dashmflag=-M
5013da084b3Smrg  # Require at least two characters before searching for `:'
5023da084b3Smrg  # in the target name.  This is to cope with DOS-style filenames:
5033da084b3Smrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
5043da084b3Smrg  "$@" $dashmflag |
5053da084b3Smrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
5063da084b3Smrg  rm -f "$depfile"
5073da084b3Smrg  cat < "$tmpdepfile" > "$depfile"
5083da084b3Smrg  tr ' ' '
5093da084b3Smrg' < "$tmpdepfile" | \
5103da084b3Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
5113da084b3Smrg## correctly.  Breaking it into two sed invocations is a workaround.
5123da084b3Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
5133da084b3Smrg  rm -f "$tmpdepfile"
5143da084b3Smrg  ;;
5153da084b3Smrg
5163da084b3SmrgdashXmstdout)
5173da084b3Smrg  # This case only exists to satisfy depend.m4.  It is never actually
5183da084b3Smrg  # run, as this mode is specially recognized in the preamble.
5193da084b3Smrg  exit 1
5203da084b3Smrg  ;;
5213da084b3Smrg
5223da084b3Smrgmakedepend)
5233da084b3Smrg  "$@" || exit $?
5243da084b3Smrg  # Remove any Libtool call
5253da084b3Smrg  if test "$libtool" = yes; then
52655acc8fcSmrg    while test "X$1" != 'X--mode=compile'; do
5273da084b3Smrg      shift
5283da084b3Smrg    done
5293da084b3Smrg    shift
5303da084b3Smrg  fi
5313da084b3Smrg  # X makedepend
5323da084b3Smrg  shift
53355acc8fcSmrg  cleared=no eat=no
53455acc8fcSmrg  for arg
53555acc8fcSmrg  do
5363da084b3Smrg    case $cleared in
5373da084b3Smrg    no)
5383da084b3Smrg      set ""; shift
5393da084b3Smrg      cleared=yes ;;
5403da084b3Smrg    esac
54155acc8fcSmrg    if test $eat = yes; then
54255acc8fcSmrg      eat=no
54355acc8fcSmrg      continue
54455acc8fcSmrg    fi
5453da084b3Smrg    case "$arg" in
5463da084b3Smrg    -D*|-I*)
5473da084b3Smrg      set fnord "$@" "$arg"; shift ;;
5483da084b3Smrg    # Strip any option that makedepend may not understand.  Remove
5493da084b3Smrg    # the object too, otherwise makedepend will parse it as a source file.
55055acc8fcSmrg    -arch)
55155acc8fcSmrg      eat=yes ;;
5523da084b3Smrg    -*|$object)
5533da084b3Smrg      ;;
5543da084b3Smrg    *)
5553da084b3Smrg      set fnord "$@" "$arg"; shift ;;
5563da084b3Smrg    esac
5573da084b3Smrg  done
55855acc8fcSmrg  obj_suffix=`echo "$object" | sed 's/^.*\././'`
5593da084b3Smrg  touch "$tmpdepfile"
5603da084b3Smrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
5613da084b3Smrg  rm -f "$depfile"
56248c85eb7Smrg  # makedepend may prepend the VPATH from the source file name to the object.
56348c85eb7Smrg  # No need to regex-escape $object, excess matching of '.' is harmless.
56448c85eb7Smrg  sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
5653da084b3Smrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
5663da084b3Smrg' | \
5673da084b3Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
5683da084b3Smrg## correctly.  Breaking it into two sed invocations is a workaround.
5693da084b3Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
5703da084b3Smrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
5713da084b3Smrg  ;;
5723da084b3Smrg
5733da084b3Smrgcpp)
5743da084b3Smrg  # Important note: in order to support this mode, a compiler *must*
5753da084b3Smrg  # always write the preprocessed file to stdout.
5763da084b3Smrg  "$@" || exit $?
5773da084b3Smrg
5783da084b3Smrg  # Remove the call to Libtool.
5793da084b3Smrg  if test "$libtool" = yes; then
58055acc8fcSmrg    while test "X$1" != 'X--mode=compile'; do
5813da084b3Smrg      shift
5823da084b3Smrg    done
5833da084b3Smrg    shift
5843da084b3Smrg  fi
5853da084b3Smrg
5863da084b3Smrg  # Remove `-o $object'.
5873da084b3Smrg  IFS=" "
5883da084b3Smrg  for arg
5893da084b3Smrg  do
5903da084b3Smrg    case $arg in
5913da084b3Smrg    -o)
5923da084b3Smrg      shift
5933da084b3Smrg      ;;
5943da084b3Smrg    $object)
5953da084b3Smrg      shift
5963da084b3Smrg      ;;
5973da084b3Smrg    *)
5983da084b3Smrg      set fnord "$@" "$arg"
5993da084b3Smrg      shift # fnord
6003da084b3Smrg      shift # $arg
6013da084b3Smrg      ;;
6023da084b3Smrg    esac
6033da084b3Smrg  done
6043da084b3Smrg
6053da084b3Smrg  "$@" -E |
6063da084b3Smrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
6073da084b3Smrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
6083da084b3Smrg    sed '$ s: \\$::' > "$tmpdepfile"
6093da084b3Smrg  rm -f "$depfile"
6103da084b3Smrg  echo "$object : \\" > "$depfile"
6113da084b3Smrg  cat < "$tmpdepfile" >> "$depfile"
6123da084b3Smrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
6133da084b3Smrg  rm -f "$tmpdepfile"
6143da084b3Smrg  ;;
6153da084b3Smrg
6163da084b3Smrgmsvisualcpp)
6173da084b3Smrg  # Important note: in order to support this mode, a compiler *must*
61855acc8fcSmrg  # always write the preprocessed file to stdout.
6193da084b3Smrg  "$@" || exit $?
62055acc8fcSmrg
62155acc8fcSmrg  # Remove the call to Libtool.
62255acc8fcSmrg  if test "$libtool" = yes; then
62355acc8fcSmrg    while test "X$1" != 'X--mode=compile'; do
62455acc8fcSmrg      shift
62555acc8fcSmrg    done
62655acc8fcSmrg    shift
62755acc8fcSmrg  fi
62855acc8fcSmrg
6293da084b3Smrg  IFS=" "
6303da084b3Smrg  for arg
6313da084b3Smrg  do
6323da084b3Smrg    case "$arg" in
63355acc8fcSmrg    -o)
63455acc8fcSmrg      shift
63555acc8fcSmrg      ;;
63655acc8fcSmrg    $object)
63755acc8fcSmrg      shift
63855acc8fcSmrg      ;;
6393da084b3Smrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
6403da084b3Smrg	set fnord "$@"
6413da084b3Smrg	shift
6423da084b3Smrg	shift
6433da084b3Smrg	;;
6443da084b3Smrg    *)
6453da084b3Smrg	set fnord "$@" "$arg"
6463da084b3Smrg	shift
6473da084b3Smrg	shift
6483da084b3Smrg	;;
6493da084b3Smrg    esac
6503da084b3Smrg  done
65155acc8fcSmrg  "$@" -E 2>/dev/null |
65255acc8fcSmrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
6533da084b3Smrg  rm -f "$depfile"
6543da084b3Smrg  echo "$object : \\" > "$depfile"
65555acc8fcSmrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
6563da084b3Smrg  echo "	" >> "$depfile"
65755acc8fcSmrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
6583da084b3Smrg  rm -f "$tmpdepfile"
6593da084b3Smrg  ;;
6603da084b3Smrg
66155acc8fcSmrgmsvcmsys)
66255acc8fcSmrg  # This case exists only to let depend.m4 do its work.  It works by
66355acc8fcSmrg  # looking at the text of this script.  This case will never be run,
66455acc8fcSmrg  # since it is checked for above.
66555acc8fcSmrg  exit 1
66655acc8fcSmrg  ;;
66755acc8fcSmrg
6683da084b3Smrgnone)
6693da084b3Smrg  exec "$@"
6703da084b3Smrg  ;;
6713da084b3Smrg
6723da084b3Smrg*)
6733da084b3Smrg  echo "Unknown depmode $depmode" 1>&2
6743da084b3Smrg  exit 1
6753da084b3Smrg  ;;
6763da084b3Smrgesac
6773da084b3Smrg
6783da084b3Smrgexit 0
6793da084b3Smrg
6803da084b3Smrg# Local Variables:
6813da084b3Smrg# mode: shell-script
6823da084b3Smrg# sh-indentation: 2
6833da084b3Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
6843da084b3Smrg# time-stamp-start: "scriptversion="
6853da084b3Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
68655acc8fcSmrg# time-stamp-time-zone: "UTC"
68755acc8fcSmrg# time-stamp-end: "; # UTC"
6883da084b3Smrg# End:
689