depcomp revision b66d1acb
14fb28925Smrg#! /bin/sh
24fb28925Smrg# depcomp - compile a program generating dependencies as side-effects
3b66d1acbSmrg
4b66d1acbSmrgscriptversion=2009-04-28.21; # UTC
5b66d1acbSmrg
6b66d1acbSmrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
7b66d1acbSmrg# Software Foundation, Inc.
84fb28925Smrg
94fb28925Smrg# This program is free software; you can redistribute it and/or modify
104fb28925Smrg# it under the terms of the GNU General Public License as published by
114fb28925Smrg# the Free Software Foundation; either version 2, or (at your option)
124fb28925Smrg# any later version.
134fb28925Smrg
144fb28925Smrg# This program is distributed in the hope that it will be useful,
154fb28925Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
164fb28925Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
174fb28925Smrg# GNU General Public License for more details.
184fb28925Smrg
194fb28925Smrg# You should have received a copy of the GNU General Public License
20b66d1acbSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
214fb28925Smrg
224fb28925Smrg# As a special exception to the GNU General Public License, if you
234fb28925Smrg# distribute this file as part of a program that contains a
244fb28925Smrg# configuration script generated by Autoconf, you may include it under
254fb28925Smrg# the same distribution terms that you use for the rest of that program.
264fb28925Smrg
274fb28925Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
284fb28925Smrg
29b66d1acbSmrgcase $1 in
30b66d1acbSmrg  '')
31b66d1acbSmrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
32b66d1acbSmrg     exit 1;
33b66d1acbSmrg     ;;
34b66d1acbSmrg  -h | --h*)
35b66d1acbSmrg    cat <<\EOF
36b66d1acbSmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
37b66d1acbSmrg
38b66d1acbSmrgRun PROGRAMS ARGS to compile a file, generating dependencies
39b66d1acbSmrgas side-effects.
40b66d1acbSmrg
41b66d1acbSmrgEnvironment variables:
42b66d1acbSmrg  depmode     Dependency tracking mode.
43b66d1acbSmrg  source      Source file read by `PROGRAMS ARGS'.
44b66d1acbSmrg  object      Object file output by `PROGRAMS ARGS'.
45b66d1acbSmrg  DEPDIR      directory where to store dependencies.
46b66d1acbSmrg  depfile     Dependency file to output.
47b66d1acbSmrg  tmpdepfile  Temporary file to use when outputing dependencies.
48b66d1acbSmrg  libtool     Whether libtool is used (yes/no).
49b66d1acbSmrg
50b66d1acbSmrgReport bugs to <bug-automake@gnu.org>.
51b66d1acbSmrgEOF
52b66d1acbSmrg    exit $?
53b66d1acbSmrg    ;;
54b66d1acbSmrg  -v | --v*)
55b66d1acbSmrg    echo "depcomp $scriptversion"
56b66d1acbSmrg    exit $?
57b66d1acbSmrg    ;;
58b66d1acbSmrgesac
59b66d1acbSmrg
604fb28925Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
614fb28925Smrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
624fb28925Smrg  exit 1
634fb28925Smrgfi
644fb28925Smrg
65b66d1acbSmrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
66b66d1acbSmrgdepfile=${depfile-`echo "$object" |
67b66d1acbSmrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
684fb28925Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
694fb28925Smrg
704fb28925Smrgrm -f "$tmpdepfile"
714fb28925Smrg
724fb28925Smrg# Some modes work just like other modes, but use different flags.  We
734fb28925Smrg# parameterize here, but still list the modes in the big case below,
744fb28925Smrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
754fb28925Smrg# here, because this file can only contain one case statement.
764fb28925Smrgif test "$depmode" = hp; then
774fb28925Smrg  # HP compiler uses -M and no extra arg.
784fb28925Smrg  gccflag=-M
794fb28925Smrg  depmode=gcc
804fb28925Smrgfi
814fb28925Smrg
824fb28925Smrgif test "$depmode" = dashXmstdout; then
834fb28925Smrg   # This is just like dashmstdout with a different argument.
844fb28925Smrg   dashmflag=-xM
854fb28925Smrg   depmode=dashmstdout
864fb28925Smrgfi
874fb28925Smrg
88b66d1acbSmrgcygpath_u="cygpath -u -f -"
89b66d1acbSmrgif test "$depmode" = msvcmsys; then
90b66d1acbSmrg   # This is just like msvisualcpp but w/o cygpath translation.
91b66d1acbSmrg   # Just convert the backslash-escaped backslashes to single forward
92b66d1acbSmrg   # slashes to satisfy depend.m4
93b66d1acbSmrg   cygpath_u="sed s,\\\\\\\\,/,g"
94b66d1acbSmrg   depmode=msvisualcpp
95b66d1acbSmrgfi
96b66d1acbSmrg
974fb28925Smrgcase "$depmode" in
984fb28925Smrggcc3)
994fb28925Smrg## gcc 3 implements dependency tracking that does exactly what
1004fb28925Smrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
1014fb28925Smrg## it if -MD -MP comes after the -MF stuff.  Hmm.
102b66d1acbSmrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
103b66d1acbSmrg## the command line argument order; so add the flags where they
104b66d1acbSmrg## appear in depend2.am.  Note that the slowdown incurred here
105b66d1acbSmrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
106b66d1acbSmrg  for arg
107b66d1acbSmrg  do
108b66d1acbSmrg    case $arg in
109b66d1acbSmrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
110b66d1acbSmrg    *)  set fnord "$@" "$arg" ;;
111b66d1acbSmrg    esac
112b66d1acbSmrg    shift # fnord
113b66d1acbSmrg    shift # $arg
114b66d1acbSmrg  done
115b66d1acbSmrg  "$@"
1164fb28925Smrg  stat=$?
1174fb28925Smrg  if test $stat -eq 0; then :
1184fb28925Smrg  else
1194fb28925Smrg    rm -f "$tmpdepfile"
1204fb28925Smrg    exit $stat
1214fb28925Smrg  fi
1224fb28925Smrg  mv "$tmpdepfile" "$depfile"
1234fb28925Smrg  ;;
1244fb28925Smrg
1254fb28925Smrggcc)
1264fb28925Smrg## There are various ways to get dependency output from gcc.  Here's
1274fb28925Smrg## why we pick this rather obscure method:
1284fb28925Smrg## - Don't want to use -MD because we'd like the dependencies to end
1294fb28925Smrg##   up in a subdir.  Having to rename by hand is ugly.
1304fb28925Smrg##   (We might end up doing this anyway to support other compilers.)
1314fb28925Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
1324fb28925Smrg##   -MM, not -M (despite what the docs say).
1334fb28925Smrg## - Using -M directly means running the compiler twice (even worse
1344fb28925Smrg##   than renaming).
1354fb28925Smrg  if test -z "$gccflag"; then
1364fb28925Smrg    gccflag=-MD,
1374fb28925Smrg  fi
1384fb28925Smrg  "$@" -Wp,"$gccflag$tmpdepfile"
1394fb28925Smrg  stat=$?
1404fb28925Smrg  if test $stat -eq 0; then :
1414fb28925Smrg  else
1424fb28925Smrg    rm -f "$tmpdepfile"
1434fb28925Smrg    exit $stat
1444fb28925Smrg  fi
1454fb28925Smrg  rm -f "$depfile"
1464fb28925Smrg  echo "$object : \\" > "$depfile"
1474fb28925Smrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
1484fb28925Smrg## The second -e expression handles DOS-style file names with drive letters.
1494fb28925Smrg  sed -e 's/^[^:]*: / /' \
1504fb28925Smrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
1514fb28925Smrg## This next piece of magic avoids the `deleted header file' problem.
1524fb28925Smrg## The problem is that when a header file which appears in a .P file
1534fb28925Smrg## is deleted, the dependency causes make to die (because there is
1544fb28925Smrg## typically no way to rebuild the header).  We avoid this by adding
1554fb28925Smrg## dummy dependencies for each header file.  Too bad gcc doesn't do
1564fb28925Smrg## this for us directly.
1574fb28925Smrg  tr ' ' '
1584fb28925Smrg' < "$tmpdepfile" |
1594fb28925Smrg## Some versions of gcc put a space before the `:'.  On the theory
1604fb28925Smrg## that the space means something, we add a space to the output as
1614fb28925Smrg## well.
1624fb28925Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
1634fb28925Smrg## correctly.  Breaking it into two sed invocations is a workaround.
1644fb28925Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
1654fb28925Smrg  rm -f "$tmpdepfile"
1664fb28925Smrg  ;;
1674fb28925Smrg
1684fb28925Smrghp)
1694fb28925Smrg  # This case exists only to let depend.m4 do its work.  It works by
1704fb28925Smrg  # looking at the text of this script.  This case will never be run,
1714fb28925Smrg  # since it is checked for above.
1724fb28925Smrg  exit 1
1734fb28925Smrg  ;;
1744fb28925Smrg
1754fb28925Smrgsgi)
1764fb28925Smrg  if test "$libtool" = yes; then
1774fb28925Smrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
1784fb28925Smrg  else
1794fb28925Smrg    "$@" -MDupdate "$tmpdepfile"
1804fb28925Smrg  fi
1814fb28925Smrg  stat=$?
1824fb28925Smrg  if test $stat -eq 0; then :
1834fb28925Smrg  else
1844fb28925Smrg    rm -f "$tmpdepfile"
1854fb28925Smrg    exit $stat
1864fb28925Smrg  fi
1874fb28925Smrg  rm -f "$depfile"
1884fb28925Smrg
1894fb28925Smrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
1904fb28925Smrg    echo "$object : \\" > "$depfile"
1914fb28925Smrg
1924fb28925Smrg    # Clip off the initial element (the dependent).  Don't try to be
1934fb28925Smrg    # clever and replace this with sed code, as IRIX sed won't handle
1944fb28925Smrg    # lines with more than a fixed number of characters (4096 in
1954fb28925Smrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
1964fb28925Smrg    # the IRIX cc adds comments like `#:fec' to the end of the
1974fb28925Smrg    # dependency line.
1984fb28925Smrg    tr ' ' '
1994fb28925Smrg' < "$tmpdepfile" \
2004fb28925Smrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
2014fb28925Smrg    tr '
202b66d1acbSmrg' ' ' >> "$depfile"
203b66d1acbSmrg    echo >> "$depfile"
2044fb28925Smrg
2054fb28925Smrg    # The second pass generates a dummy entry for each header file.
2064fb28925Smrg    tr ' ' '
2074fb28925Smrg' < "$tmpdepfile" \
2084fb28925Smrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
209b66d1acbSmrg   >> "$depfile"
2104fb28925Smrg  else
2114fb28925Smrg    # The sourcefile does not contain any dependencies, so just
2124fb28925Smrg    # store a dummy comment line, to avoid errors with the Makefile
2134fb28925Smrg    # "include basename.Plo" scheme.
2144fb28925Smrg    echo "#dummy" > "$depfile"
2154fb28925Smrg  fi
2164fb28925Smrg  rm -f "$tmpdepfile"
2174fb28925Smrg  ;;
2184fb28925Smrg
2194fb28925Smrgaix)
2204fb28925Smrg  # The C for AIX Compiler uses -M and outputs the dependencies
2214fb28925Smrg  # in a .u file.  In older versions, this file always lives in the
2224fb28925Smrg  # current directory.  Also, the AIX compiler puts `$object:' at the
2234fb28925Smrg  # start of each line; $object doesn't have directory information.
2244fb28925Smrg  # Version 6 uses the directory in both cases.
225b66d1acbSmrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
226b66d1acbSmrg  test "x$dir" = "x$object" && dir=
227b66d1acbSmrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
2284fb28925Smrg  if test "$libtool" = yes; then
229b66d1acbSmrg    tmpdepfile1=$dir$base.u
230b66d1acbSmrg    tmpdepfile2=$base.u
231b66d1acbSmrg    tmpdepfile3=$dir.libs/$base.u
2324fb28925Smrg    "$@" -Wc,-M
2334fb28925Smrg  else
234b66d1acbSmrg    tmpdepfile1=$dir$base.u
235b66d1acbSmrg    tmpdepfile2=$dir$base.u
236b66d1acbSmrg    tmpdepfile3=$dir$base.u
2374fb28925Smrg    "$@" -M
2384fb28925Smrg  fi
2394fb28925Smrg  stat=$?
2404fb28925Smrg
2414fb28925Smrg  if test $stat -eq 0; then :
2424fb28925Smrg  else
243b66d1acbSmrg    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
2444fb28925Smrg    exit $stat
2454fb28925Smrg  fi
2464fb28925Smrg
247b66d1acbSmrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
248b66d1acbSmrg  do
249b66d1acbSmrg    test -f "$tmpdepfile" && break
250b66d1acbSmrg  done
2514fb28925Smrg  if test -f "$tmpdepfile"; then
2524fb28925Smrg    # Each line is of the form `foo.o: dependent.h'.
2534fb28925Smrg    # Do two passes, one to just change these to
2544fb28925Smrg    # `$object: dependent.h' and one to simply `dependent.h:'.
255b66d1acbSmrg    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
256b66d1acbSmrg    # That's a tab and a space in the [].
257b66d1acbSmrg    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
2584fb28925Smrg  else
2594fb28925Smrg    # The sourcefile does not contain any dependencies, so just
2604fb28925Smrg    # store a dummy comment line, to avoid errors with the Makefile
2614fb28925Smrg    # "include basename.Plo" scheme.
2624fb28925Smrg    echo "#dummy" > "$depfile"
2634fb28925Smrg  fi
2644fb28925Smrg  rm -f "$tmpdepfile"
2654fb28925Smrg  ;;
2664fb28925Smrg
2674fb28925Smrgicc)
2684fb28925Smrg  # Intel's C compiler understands `-MD -MF file'.  However on
2694fb28925Smrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
2704fb28925Smrg  # ICC 7.0 will fill foo.d with something like
2714fb28925Smrg  #    foo.o: sub/foo.c
2724fb28925Smrg  #    foo.o: sub/foo.h
2734fb28925Smrg  # which is wrong.  We want:
2744fb28925Smrg  #    sub/foo.o: sub/foo.c
2754fb28925Smrg  #    sub/foo.o: sub/foo.h
2764fb28925Smrg  #    sub/foo.c:
2774fb28925Smrg  #    sub/foo.h:
2784fb28925Smrg  # ICC 7.1 will output
2794fb28925Smrg  #    foo.o: sub/foo.c sub/foo.h
2804fb28925Smrg  # and will wrap long lines using \ :
2814fb28925Smrg  #    foo.o: sub/foo.c ... \
2824fb28925Smrg  #     sub/foo.h ... \
2834fb28925Smrg  #     ...
2844fb28925Smrg
2854fb28925Smrg  "$@" -MD -MF "$tmpdepfile"
2864fb28925Smrg  stat=$?
2874fb28925Smrg  if test $stat -eq 0; then :
2884fb28925Smrg  else
2894fb28925Smrg    rm -f "$tmpdepfile"
2904fb28925Smrg    exit $stat
2914fb28925Smrg  fi
2924fb28925Smrg  rm -f "$depfile"
2934fb28925Smrg  # Each line is of the form `foo.o: dependent.h',
2944fb28925Smrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
2954fb28925Smrg  # Do two passes, one to just change these to
2964fb28925Smrg  # `$object: dependent.h' and one to simply `dependent.h:'.
2974fb28925Smrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
2984fb28925Smrg  # Some versions of the HPUX 10.20 sed can't process this invocation
2994fb28925Smrg  # correctly.  Breaking it into two sed invocations is a workaround.
3004fb28925Smrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
3014fb28925Smrg    sed -e 's/$/ :/' >> "$depfile"
3024fb28925Smrg  rm -f "$tmpdepfile"
3034fb28925Smrg  ;;
3044fb28925Smrg
305b66d1acbSmrghp2)
306b66d1acbSmrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
307b66d1acbSmrg  # compilers, which have integrated preprocessors.  The correct option
308b66d1acbSmrg  # to use with these is +Maked; it writes dependencies to a file named
309b66d1acbSmrg  # 'foo.d', which lands next to the object file, wherever that
310b66d1acbSmrg  # happens to be.
311b66d1acbSmrg  # Much of this is similar to the tru64 case; see comments there.
312b66d1acbSmrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
313b66d1acbSmrg  test "x$dir" = "x$object" && dir=
314b66d1acbSmrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
315b66d1acbSmrg  if test "$libtool" = yes; then
316b66d1acbSmrg    tmpdepfile1=$dir$base.d
317b66d1acbSmrg    tmpdepfile2=$dir.libs/$base.d
318b66d1acbSmrg    "$@" -Wc,+Maked
319b66d1acbSmrg  else
320b66d1acbSmrg    tmpdepfile1=$dir$base.d
321b66d1acbSmrg    tmpdepfile2=$dir$base.d
322b66d1acbSmrg    "$@" +Maked
323b66d1acbSmrg  fi
324b66d1acbSmrg  stat=$?
325b66d1acbSmrg  if test $stat -eq 0; then :
326b66d1acbSmrg  else
327b66d1acbSmrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
328b66d1acbSmrg     exit $stat
329b66d1acbSmrg  fi
330b66d1acbSmrg
331b66d1acbSmrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
332b66d1acbSmrg  do
333b66d1acbSmrg    test -f "$tmpdepfile" && break
334b66d1acbSmrg  done
335b66d1acbSmrg  if test -f "$tmpdepfile"; then
336b66d1acbSmrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
337b66d1acbSmrg    # Add `dependent.h:' lines.
338b66d1acbSmrg    sed -ne '2,${
339b66d1acbSmrg	       s/^ *//
340b66d1acbSmrg	       s/ \\*$//
341b66d1acbSmrg	       s/$/:/
342b66d1acbSmrg	       p
343b66d1acbSmrg	     }' "$tmpdepfile" >> "$depfile"
344b66d1acbSmrg  else
345b66d1acbSmrg    echo "#dummy" > "$depfile"
346b66d1acbSmrg  fi
347b66d1acbSmrg  rm -f "$tmpdepfile" "$tmpdepfile2"
348b66d1acbSmrg  ;;
349b66d1acbSmrg
3504fb28925Smrgtru64)
3514fb28925Smrg   # The Tru64 compiler uses -MD to generate dependencies as a side
3524fb28925Smrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
3534fb28925Smrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
3544fb28925Smrg   # dependencies in `foo.d' instead, so we check for that too.
3554fb28925Smrg   # Subdirectories are respected.
3564fb28925Smrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3574fb28925Smrg   test "x$dir" = "x$object" && dir=
3584fb28925Smrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3594fb28925Smrg
3604fb28925Smrg   if test "$libtool" = yes; then
361b66d1acbSmrg      # With Tru64 cc, shared objects can also be used to make a
362b66d1acbSmrg      # static library.  This mechanism is used in libtool 1.4 series to
363b66d1acbSmrg      # handle both shared and static libraries in a single compilation.
364b66d1acbSmrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
365b66d1acbSmrg      #
366b66d1acbSmrg      # With libtool 1.5 this exception was removed, and libtool now
367b66d1acbSmrg      # generates 2 separate objects for the 2 libraries.  These two
368b66d1acbSmrg      # compilations output dependencies in $dir.libs/$base.o.d and
369b66d1acbSmrg      # in $dir$base.o.d.  We have to check for both files, because
370b66d1acbSmrg      # one of the two compilations can be disabled.  We should prefer
371b66d1acbSmrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
372b66d1acbSmrg      # automatically cleaned when .libs/ is deleted, while ignoring
373b66d1acbSmrg      # the former would cause a distcleancheck panic.
374b66d1acbSmrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
375b66d1acbSmrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
376b66d1acbSmrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
377b66d1acbSmrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
3784fb28925Smrg      "$@" -Wc,-MD
3794fb28925Smrg   else
380b66d1acbSmrg      tmpdepfile1=$dir$base.o.d
381b66d1acbSmrg      tmpdepfile2=$dir$base.d
382b66d1acbSmrg      tmpdepfile3=$dir$base.d
383b66d1acbSmrg      tmpdepfile4=$dir$base.d
3844fb28925Smrg      "$@" -MD
3854fb28925Smrg   fi
3864fb28925Smrg
3874fb28925Smrg   stat=$?
3884fb28925Smrg   if test $stat -eq 0; then :
3894fb28925Smrg   else
390b66d1acbSmrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
3914fb28925Smrg      exit $stat
3924fb28925Smrg   fi
3934fb28925Smrg
394b66d1acbSmrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
395b66d1acbSmrg   do
396b66d1acbSmrg     test -f "$tmpdepfile" && break
397b66d1acbSmrg   done
3984fb28925Smrg   if test -f "$tmpdepfile"; then
3994fb28925Smrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
4004fb28925Smrg      # That's a tab and a space in the [].
4014fb28925Smrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
4024fb28925Smrg   else
4034fb28925Smrg      echo "#dummy" > "$depfile"
4044fb28925Smrg   fi
4054fb28925Smrg   rm -f "$tmpdepfile"
4064fb28925Smrg   ;;
4074fb28925Smrg
4084fb28925Smrg#nosideeffect)
4094fb28925Smrg  # This comment above is used by automake to tell side-effect
4104fb28925Smrg  # dependency tracking mechanisms from slower ones.
4114fb28925Smrg
4124fb28925Smrgdashmstdout)
4134fb28925Smrg  # Important note: in order to support this mode, a compiler *must*
4144fb28925Smrg  # always write the preprocessed file to stdout, regardless of -o.
4154fb28925Smrg  "$@" || exit $?
4164fb28925Smrg
4174fb28925Smrg  # Remove the call to Libtool.
4184fb28925Smrg  if test "$libtool" = yes; then
419b66d1acbSmrg    while test "X$1" != 'X--mode=compile'; do
4204fb28925Smrg      shift
4214fb28925Smrg    done
4224fb28925Smrg    shift
4234fb28925Smrg  fi
4244fb28925Smrg
4254fb28925Smrg  # Remove `-o $object'.
4264fb28925Smrg  IFS=" "
4274fb28925Smrg  for arg
4284fb28925Smrg  do
4294fb28925Smrg    case $arg in
4304fb28925Smrg    -o)
4314fb28925Smrg      shift
4324fb28925Smrg      ;;
4334fb28925Smrg    $object)
4344fb28925Smrg      shift
4354fb28925Smrg      ;;
4364fb28925Smrg    *)
4374fb28925Smrg      set fnord "$@" "$arg"
4384fb28925Smrg      shift # fnord
4394fb28925Smrg      shift # $arg
4404fb28925Smrg      ;;
4414fb28925Smrg    esac
4424fb28925Smrg  done
4434fb28925Smrg
4444fb28925Smrg  test -z "$dashmflag" && dashmflag=-M
4454fb28925Smrg  # Require at least two characters before searching for `:'
4464fb28925Smrg  # in the target name.  This is to cope with DOS-style filenames:
4474fb28925Smrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
4484fb28925Smrg  "$@" $dashmflag |
4494fb28925Smrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
4504fb28925Smrg  rm -f "$depfile"
4514fb28925Smrg  cat < "$tmpdepfile" > "$depfile"
4524fb28925Smrg  tr ' ' '
4534fb28925Smrg' < "$tmpdepfile" | \
4544fb28925Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
4554fb28925Smrg## correctly.  Breaking it into two sed invocations is a workaround.
4564fb28925Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
4574fb28925Smrg  rm -f "$tmpdepfile"
4584fb28925Smrg  ;;
4594fb28925Smrg
4604fb28925SmrgdashXmstdout)
4614fb28925Smrg  # This case only exists to satisfy depend.m4.  It is never actually
4624fb28925Smrg  # run, as this mode is specially recognized in the preamble.
4634fb28925Smrg  exit 1
4644fb28925Smrg  ;;
4654fb28925Smrg
4664fb28925Smrgmakedepend)
4674fb28925Smrg  "$@" || exit $?
4684fb28925Smrg  # Remove any Libtool call
4694fb28925Smrg  if test "$libtool" = yes; then
470b66d1acbSmrg    while test "X$1" != 'X--mode=compile'; do
4714fb28925Smrg      shift
4724fb28925Smrg    done
4734fb28925Smrg    shift
4744fb28925Smrg  fi
4754fb28925Smrg  # X makedepend
4764fb28925Smrg  shift
477b66d1acbSmrg  cleared=no eat=no
478b66d1acbSmrg  for arg
479b66d1acbSmrg  do
4804fb28925Smrg    case $cleared in
4814fb28925Smrg    no)
4824fb28925Smrg      set ""; shift
4834fb28925Smrg      cleared=yes ;;
4844fb28925Smrg    esac
485b66d1acbSmrg    if test $eat = yes; then
486b66d1acbSmrg      eat=no
487b66d1acbSmrg      continue
488b66d1acbSmrg    fi
4894fb28925Smrg    case "$arg" in
4904fb28925Smrg    -D*|-I*)
4914fb28925Smrg      set fnord "$@" "$arg"; shift ;;
4924fb28925Smrg    # Strip any option that makedepend may not understand.  Remove
4934fb28925Smrg    # the object too, otherwise makedepend will parse it as a source file.
494b66d1acbSmrg    -arch)
495b66d1acbSmrg      eat=yes ;;
4964fb28925Smrg    -*|$object)
4974fb28925Smrg      ;;
4984fb28925Smrg    *)
4994fb28925Smrg      set fnord "$@" "$arg"; shift ;;
5004fb28925Smrg    esac
5014fb28925Smrg  done
502b66d1acbSmrg  obj_suffix=`echo "$object" | sed 's/^.*\././'`
5034fb28925Smrg  touch "$tmpdepfile"
5044fb28925Smrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
5054fb28925Smrg  rm -f "$depfile"
5064fb28925Smrg  cat < "$tmpdepfile" > "$depfile"
5074fb28925Smrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
5084fb28925Smrg' | \
5094fb28925Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
5104fb28925Smrg## correctly.  Breaking it into two sed invocations is a workaround.
5114fb28925Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
5124fb28925Smrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
5134fb28925Smrg  ;;
5144fb28925Smrg
5154fb28925Smrgcpp)
5164fb28925Smrg  # Important note: in order to support this mode, a compiler *must*
5174fb28925Smrg  # always write the preprocessed file to stdout.
5184fb28925Smrg  "$@" || exit $?
5194fb28925Smrg
5204fb28925Smrg  # Remove the call to Libtool.
5214fb28925Smrg  if test "$libtool" = yes; then
522b66d1acbSmrg    while test "X$1" != 'X--mode=compile'; do
5234fb28925Smrg      shift
5244fb28925Smrg    done
5254fb28925Smrg    shift
5264fb28925Smrg  fi
5274fb28925Smrg
5284fb28925Smrg  # Remove `-o $object'.
5294fb28925Smrg  IFS=" "
5304fb28925Smrg  for arg
5314fb28925Smrg  do
5324fb28925Smrg    case $arg in
5334fb28925Smrg    -o)
5344fb28925Smrg      shift
5354fb28925Smrg      ;;
5364fb28925Smrg    $object)
5374fb28925Smrg      shift
5384fb28925Smrg      ;;
5394fb28925Smrg    *)
5404fb28925Smrg      set fnord "$@" "$arg"
5414fb28925Smrg      shift # fnord
5424fb28925Smrg      shift # $arg
5434fb28925Smrg      ;;
5444fb28925Smrg    esac
5454fb28925Smrg  done
5464fb28925Smrg
5474fb28925Smrg  "$@" -E |
548b66d1acbSmrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
549b66d1acbSmrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
5504fb28925Smrg    sed '$ s: \\$::' > "$tmpdepfile"
5514fb28925Smrg  rm -f "$depfile"
5524fb28925Smrg  echo "$object : \\" > "$depfile"
5534fb28925Smrg  cat < "$tmpdepfile" >> "$depfile"
5544fb28925Smrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
5554fb28925Smrg  rm -f "$tmpdepfile"
5564fb28925Smrg  ;;
5574fb28925Smrg
5584fb28925Smrgmsvisualcpp)
5594fb28925Smrg  # Important note: in order to support this mode, a compiler *must*
560b66d1acbSmrg  # always write the preprocessed file to stdout.
5614fb28925Smrg  "$@" || exit $?
562b66d1acbSmrg
563b66d1acbSmrg  # Remove the call to Libtool.
564b66d1acbSmrg  if test "$libtool" = yes; then
565b66d1acbSmrg    while test "X$1" != 'X--mode=compile'; do
566b66d1acbSmrg      shift
567b66d1acbSmrg    done
568b66d1acbSmrg    shift
569b66d1acbSmrg  fi
570b66d1acbSmrg
5714fb28925Smrg  IFS=" "
5724fb28925Smrg  for arg
5734fb28925Smrg  do
5744fb28925Smrg    case "$arg" in
575b66d1acbSmrg    -o)
576b66d1acbSmrg      shift
577b66d1acbSmrg      ;;
578b66d1acbSmrg    $object)
579b66d1acbSmrg      shift
580b66d1acbSmrg      ;;
5814fb28925Smrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
5824fb28925Smrg	set fnord "$@"
5834fb28925Smrg	shift
5844fb28925Smrg	shift
5854fb28925Smrg	;;
5864fb28925Smrg    *)
5874fb28925Smrg	set fnord "$@" "$arg"
5884fb28925Smrg	shift
5894fb28925Smrg	shift
5904fb28925Smrg	;;
5914fb28925Smrg    esac
5924fb28925Smrg  done
593b66d1acbSmrg  "$@" -E 2>/dev/null |
594b66d1acbSmrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
5954fb28925Smrg  rm -f "$depfile"
5964fb28925Smrg  echo "$object : \\" > "$depfile"
597b66d1acbSmrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
5984fb28925Smrg  echo "	" >> "$depfile"
599b66d1acbSmrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
6004fb28925Smrg  rm -f "$tmpdepfile"
6014fb28925Smrg  ;;
6024fb28925Smrg
603b66d1acbSmrgmsvcmsys)
604b66d1acbSmrg  # This case exists only to let depend.m4 do its work.  It works by
605b66d1acbSmrg  # looking at the text of this script.  This case will never be run,
606b66d1acbSmrg  # since it is checked for above.
607b66d1acbSmrg  exit 1
608b66d1acbSmrg  ;;
609b66d1acbSmrg
6104fb28925Smrgnone)
6114fb28925Smrg  exec "$@"
6124fb28925Smrg  ;;
6134fb28925Smrg
6144fb28925Smrg*)
6154fb28925Smrg  echo "Unknown depmode $depmode" 1>&2
6164fb28925Smrg  exit 1
6174fb28925Smrg  ;;
6184fb28925Smrgesac
6194fb28925Smrg
6204fb28925Smrgexit 0
621b66d1acbSmrg
622b66d1acbSmrg# Local Variables:
623b66d1acbSmrg# mode: shell-script
624b66d1acbSmrg# sh-indentation: 2
625b66d1acbSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
626b66d1acbSmrg# time-stamp-start: "scriptversion="
627b66d1acbSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
628b66d1acbSmrg# time-stamp-time-zone: "UTC"
629b66d1acbSmrg# time-stamp-end: "; # UTC"
630b66d1acbSmrg# End:
631