depcomp revision 80b026c6
19aa228fdSmrg#! /bin/sh
29aa228fdSmrg# depcomp - compile a program generating dependencies as side-effects
39aa228fdSmrg
480b026c6Smrgscriptversion=2011-12-04.11; # UTC
59aa228fdSmrg
680b026c6Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
780b026c6Smrg# 2011 Free Software Foundation, Inc.
89aa228fdSmrg
99aa228fdSmrg# This program is free software; you can redistribute it and/or modify
109aa228fdSmrg# it under the terms of the GNU General Public License as published by
119aa228fdSmrg# the Free Software Foundation; either version 2, or (at your option)
129aa228fdSmrg# any later version.
139aa228fdSmrg
149aa228fdSmrg# This program is distributed in the hope that it will be useful,
159aa228fdSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
169aa228fdSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
179aa228fdSmrg# GNU General Public License for more details.
189aa228fdSmrg
199aa228fdSmrg# You should have received a copy of the GNU General Public License
208f65982aSmrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
219aa228fdSmrg
229aa228fdSmrg# As a special exception to the GNU General Public License, if you
239aa228fdSmrg# distribute this file as part of a program that contains a
249aa228fdSmrg# configuration script generated by Autoconf, you may include it under
259aa228fdSmrg# the same distribution terms that you use for the rest of that program.
269aa228fdSmrg
279aa228fdSmrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
289aa228fdSmrg
299aa228fdSmrgcase $1 in
309aa228fdSmrg  '')
319aa228fdSmrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
329aa228fdSmrg     exit 1;
339aa228fdSmrg     ;;
349aa228fdSmrg  -h | --h*)
359aa228fdSmrg    cat <<\EOF
369aa228fdSmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
379aa228fdSmrg
389aa228fdSmrgRun PROGRAMS ARGS to compile a file, generating dependencies
399aa228fdSmrgas side-effects.
409aa228fdSmrg
419aa228fdSmrgEnvironment variables:
429aa228fdSmrg  depmode     Dependency tracking mode.
439aa228fdSmrg  source      Source file read by `PROGRAMS ARGS'.
449aa228fdSmrg  object      Object file output by `PROGRAMS ARGS'.
459aa228fdSmrg  DEPDIR      directory where to store dependencies.
469aa228fdSmrg  depfile     Dependency file to output.
4780b026c6Smrg  tmpdepfile  Temporary file to use when outputting dependencies.
489aa228fdSmrg  libtool     Whether libtool is used (yes/no).
499aa228fdSmrg
509aa228fdSmrgReport bugs to <bug-automake@gnu.org>.
519aa228fdSmrgEOF
529aa228fdSmrg    exit $?
539aa228fdSmrg    ;;
549aa228fdSmrg  -v | --v*)
559aa228fdSmrg    echo "depcomp $scriptversion"
569aa228fdSmrg    exit $?
579aa228fdSmrg    ;;
589aa228fdSmrgesac
599aa228fdSmrg
609aa228fdSmrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
619aa228fdSmrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
629aa228fdSmrg  exit 1
639aa228fdSmrgfi
649aa228fdSmrg
659aa228fdSmrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
669aa228fdSmrgdepfile=${depfile-`echo "$object" |
679aa228fdSmrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
689aa228fdSmrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
699aa228fdSmrg
709aa228fdSmrgrm -f "$tmpdepfile"
719aa228fdSmrg
729aa228fdSmrg# Some modes work just like other modes, but use different flags.  We
739aa228fdSmrg# parameterize here, but still list the modes in the big case below,
749aa228fdSmrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
759aa228fdSmrg# here, because this file can only contain one case statement.
769aa228fdSmrgif test "$depmode" = hp; then
779aa228fdSmrg  # HP compiler uses -M and no extra arg.
789aa228fdSmrg  gccflag=-M
799aa228fdSmrg  depmode=gcc
809aa228fdSmrgfi
819aa228fdSmrg
829aa228fdSmrgif test "$depmode" = dashXmstdout; then
839aa228fdSmrg   # This is just like dashmstdout with a different argument.
849aa228fdSmrg   dashmflag=-xM
859aa228fdSmrg   depmode=dashmstdout
869aa228fdSmrgfi
879aa228fdSmrg
888f65982aSmrgcygpath_u="cygpath -u -f -"
898f65982aSmrgif test "$depmode" = msvcmsys; then
908f65982aSmrg   # This is just like msvisualcpp but w/o cygpath translation.
918f65982aSmrg   # Just convert the backslash-escaped backslashes to single forward
928f65982aSmrg   # slashes to satisfy depend.m4
9380b026c6Smrg   cygpath_u='sed s,\\\\,/,g'
948f65982aSmrg   depmode=msvisualcpp
958f65982aSmrgfi
968f65982aSmrg
9780b026c6Smrgif test "$depmode" = msvc7msys; then
9880b026c6Smrg   # This is just like msvc7 but w/o cygpath translation.
9980b026c6Smrg   # Just convert the backslash-escaped backslashes to single forward
10080b026c6Smrg   # slashes to satisfy depend.m4
10180b026c6Smrg   cygpath_u='sed s,\\\\,/,g'
10280b026c6Smrg   depmode=msvc7
10380b026c6Smrgfi
10480b026c6Smrg
1059aa228fdSmrgcase "$depmode" in
1069aa228fdSmrggcc3)
1079aa228fdSmrg## gcc 3 implements dependency tracking that does exactly what
1089aa228fdSmrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
1099aa228fdSmrg## it if -MD -MP comes after the -MF stuff.  Hmm.
1109aa228fdSmrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
1119aa228fdSmrg## the command line argument order; so add the flags where they
1129aa228fdSmrg## appear in depend2.am.  Note that the slowdown incurred here
1139aa228fdSmrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
1149aa228fdSmrg  for arg
1159aa228fdSmrg  do
1169aa228fdSmrg    case $arg in
1179aa228fdSmrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
1189aa228fdSmrg    *)  set fnord "$@" "$arg" ;;
1199aa228fdSmrg    esac
1209aa228fdSmrg    shift # fnord
1219aa228fdSmrg    shift # $arg
1229aa228fdSmrg  done
1239aa228fdSmrg  "$@"
1249aa228fdSmrg  stat=$?
1259aa228fdSmrg  if test $stat -eq 0; then :
1269aa228fdSmrg  else
1279aa228fdSmrg    rm -f "$tmpdepfile"
1289aa228fdSmrg    exit $stat
1299aa228fdSmrg  fi
1309aa228fdSmrg  mv "$tmpdepfile" "$depfile"
1319aa228fdSmrg  ;;
1329aa228fdSmrg
1339aa228fdSmrggcc)
1349aa228fdSmrg## There are various ways to get dependency output from gcc.  Here's
1359aa228fdSmrg## why we pick this rather obscure method:
1369aa228fdSmrg## - Don't want to use -MD because we'd like the dependencies to end
1379aa228fdSmrg##   up in a subdir.  Having to rename by hand is ugly.
1389aa228fdSmrg##   (We might end up doing this anyway to support other compilers.)
1399aa228fdSmrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
1409aa228fdSmrg##   -MM, not -M (despite what the docs say).
1419aa228fdSmrg## - Using -M directly means running the compiler twice (even worse
1429aa228fdSmrg##   than renaming).
1439aa228fdSmrg  if test -z "$gccflag"; then
1449aa228fdSmrg    gccflag=-MD,
1459aa228fdSmrg  fi
1469aa228fdSmrg  "$@" -Wp,"$gccflag$tmpdepfile"
1479aa228fdSmrg  stat=$?
1489aa228fdSmrg  if test $stat -eq 0; then :
1499aa228fdSmrg  else
1509aa228fdSmrg    rm -f "$tmpdepfile"
1519aa228fdSmrg    exit $stat
1529aa228fdSmrg  fi
1539aa228fdSmrg  rm -f "$depfile"
1549aa228fdSmrg  echo "$object : \\" > "$depfile"
1559aa228fdSmrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
1569aa228fdSmrg## The second -e expression handles DOS-style file names with drive letters.
1579aa228fdSmrg  sed -e 's/^[^:]*: / /' \
1589aa228fdSmrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
1599aa228fdSmrg## This next piece of magic avoids the `deleted header file' problem.
1609aa228fdSmrg## The problem is that when a header file which appears in a .P file
1619aa228fdSmrg## is deleted, the dependency causes make to die (because there is
1629aa228fdSmrg## typically no way to rebuild the header).  We avoid this by adding
1639aa228fdSmrg## dummy dependencies for each header file.  Too bad gcc doesn't do
1649aa228fdSmrg## this for us directly.
1659aa228fdSmrg  tr ' ' '
1669aa228fdSmrg' < "$tmpdepfile" |
1679aa228fdSmrg## Some versions of gcc put a space before the `:'.  On the theory
1689aa228fdSmrg## that the space means something, we add a space to the output as
16980b026c6Smrg## well.  hp depmode also adds that space, but also prefixes the VPATH
17080b026c6Smrg## to the object.  Take care to not repeat it in the output.
1719aa228fdSmrg## Some versions of the HPUX 10.20 sed can't process this invocation
1729aa228fdSmrg## correctly.  Breaking it into two sed invocations is a workaround.
17380b026c6Smrg    sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
17480b026c6Smrg      | sed -e 's/$/ :/' >> "$depfile"
1759aa228fdSmrg  rm -f "$tmpdepfile"
1769aa228fdSmrg  ;;
1779aa228fdSmrg
1789aa228fdSmrghp)
1799aa228fdSmrg  # This case exists only to let depend.m4 do its work.  It works by
1809aa228fdSmrg  # looking at the text of this script.  This case will never be run,
1819aa228fdSmrg  # since it is checked for above.
1829aa228fdSmrg  exit 1
1839aa228fdSmrg  ;;
1849aa228fdSmrg
1859aa228fdSmrgsgi)
1869aa228fdSmrg  if test "$libtool" = yes; then
1879aa228fdSmrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
1889aa228fdSmrg  else
1899aa228fdSmrg    "$@" -MDupdate "$tmpdepfile"
1909aa228fdSmrg  fi
1919aa228fdSmrg  stat=$?
1929aa228fdSmrg  if test $stat -eq 0; then :
1939aa228fdSmrg  else
1949aa228fdSmrg    rm -f "$tmpdepfile"
1959aa228fdSmrg    exit $stat
1969aa228fdSmrg  fi
1979aa228fdSmrg  rm -f "$depfile"
1989aa228fdSmrg
1999aa228fdSmrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
2009aa228fdSmrg    echo "$object : \\" > "$depfile"
2019aa228fdSmrg
2029aa228fdSmrg    # Clip off the initial element (the dependent).  Don't try to be
2039aa228fdSmrg    # clever and replace this with sed code, as IRIX sed won't handle
2049aa228fdSmrg    # lines with more than a fixed number of characters (4096 in
2059aa228fdSmrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
2069aa228fdSmrg    # the IRIX cc adds comments like `#:fec' to the end of the
2079aa228fdSmrg    # dependency line.
2089aa228fdSmrg    tr ' ' '
2099aa228fdSmrg' < "$tmpdepfile" \
2109aa228fdSmrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
2119aa228fdSmrg    tr '
2128f65982aSmrg' ' ' >> "$depfile"
2138f65982aSmrg    echo >> "$depfile"
2149aa228fdSmrg
2159aa228fdSmrg    # The second pass generates a dummy entry for each header file.
2169aa228fdSmrg    tr ' ' '
2179aa228fdSmrg' < "$tmpdepfile" \
2189aa228fdSmrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
2198f65982aSmrg   >> "$depfile"
2209aa228fdSmrg  else
2219aa228fdSmrg    # The sourcefile does not contain any dependencies, so just
2229aa228fdSmrg    # store a dummy comment line, to avoid errors with the Makefile
2239aa228fdSmrg    # "include basename.Plo" scheme.
2249aa228fdSmrg    echo "#dummy" > "$depfile"
2259aa228fdSmrg  fi
2269aa228fdSmrg  rm -f "$tmpdepfile"
2279aa228fdSmrg  ;;
2289aa228fdSmrg
2299aa228fdSmrgaix)
2309aa228fdSmrg  # The C for AIX Compiler uses -M and outputs the dependencies
2319aa228fdSmrg  # in a .u file.  In older versions, this file always lives in the
2329aa228fdSmrg  # current directory.  Also, the AIX compiler puts `$object:' at the
2339aa228fdSmrg  # start of each line; $object doesn't have directory information.
2349aa228fdSmrg  # Version 6 uses the directory in both cases.
2358f65982aSmrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
2368f65982aSmrg  test "x$dir" = "x$object" && dir=
2378f65982aSmrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
2389aa228fdSmrg  if test "$libtool" = yes; then
2398f65982aSmrg    tmpdepfile1=$dir$base.u
2408f65982aSmrg    tmpdepfile2=$base.u
2418f65982aSmrg    tmpdepfile3=$dir.libs/$base.u
2429aa228fdSmrg    "$@" -Wc,-M
2439aa228fdSmrg  else
2448f65982aSmrg    tmpdepfile1=$dir$base.u
2458f65982aSmrg    tmpdepfile2=$dir$base.u
2468f65982aSmrg    tmpdepfile3=$dir$base.u
2479aa228fdSmrg    "$@" -M
2489aa228fdSmrg  fi
2499aa228fdSmrg  stat=$?
2509aa228fdSmrg
2519aa228fdSmrg  if test $stat -eq 0; then :
2529aa228fdSmrg  else
2538f65982aSmrg    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
2549aa228fdSmrg    exit $stat
2559aa228fdSmrg  fi
2569aa228fdSmrg
2578f65982aSmrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
2588f65982aSmrg  do
2598f65982aSmrg    test -f "$tmpdepfile" && break
2608f65982aSmrg  done
2619aa228fdSmrg  if test -f "$tmpdepfile"; then
2629aa228fdSmrg    # Each line is of the form `foo.o: dependent.h'.
2639aa228fdSmrg    # Do two passes, one to just change these to
2649aa228fdSmrg    # `$object: dependent.h' and one to simply `dependent.h:'.
2658f65982aSmrg    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
2668f65982aSmrg    # That's a tab and a space in the [].
2678f65982aSmrg    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
2689aa228fdSmrg  else
2699aa228fdSmrg    # The sourcefile does not contain any dependencies, so just
2709aa228fdSmrg    # store a dummy comment line, to avoid errors with the Makefile
2719aa228fdSmrg    # "include basename.Plo" scheme.
2729aa228fdSmrg    echo "#dummy" > "$depfile"
2739aa228fdSmrg  fi
2749aa228fdSmrg  rm -f "$tmpdepfile"
2759aa228fdSmrg  ;;
2769aa228fdSmrg
2779aa228fdSmrgicc)
2789aa228fdSmrg  # Intel's C compiler understands `-MD -MF file'.  However on
2799aa228fdSmrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
2809aa228fdSmrg  # ICC 7.0 will fill foo.d with something like
2819aa228fdSmrg  #    foo.o: sub/foo.c
2829aa228fdSmrg  #    foo.o: sub/foo.h
2839aa228fdSmrg  # which is wrong.  We want:
2849aa228fdSmrg  #    sub/foo.o: sub/foo.c
2859aa228fdSmrg  #    sub/foo.o: sub/foo.h
2869aa228fdSmrg  #    sub/foo.c:
2879aa228fdSmrg  #    sub/foo.h:
2889aa228fdSmrg  # ICC 7.1 will output
2899aa228fdSmrg  #    foo.o: sub/foo.c sub/foo.h
2909aa228fdSmrg  # and will wrap long lines using \ :
2919aa228fdSmrg  #    foo.o: sub/foo.c ... \
2929aa228fdSmrg  #     sub/foo.h ... \
2939aa228fdSmrg  #     ...
2949aa228fdSmrg
2959aa228fdSmrg  "$@" -MD -MF "$tmpdepfile"
2969aa228fdSmrg  stat=$?
2979aa228fdSmrg  if test $stat -eq 0; then :
2989aa228fdSmrg  else
2999aa228fdSmrg    rm -f "$tmpdepfile"
3009aa228fdSmrg    exit $stat
3019aa228fdSmrg  fi
3029aa228fdSmrg  rm -f "$depfile"
3039aa228fdSmrg  # Each line is of the form `foo.o: dependent.h',
3049aa228fdSmrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
3059aa228fdSmrg  # Do two passes, one to just change these to
3069aa228fdSmrg  # `$object: dependent.h' and one to simply `dependent.h:'.
3079aa228fdSmrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
3089aa228fdSmrg  # Some versions of the HPUX 10.20 sed can't process this invocation
3099aa228fdSmrg  # correctly.  Breaking it into two sed invocations is a workaround.
3109aa228fdSmrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
3119aa228fdSmrg    sed -e 's/$/ :/' >> "$depfile"
3129aa228fdSmrg  rm -f "$tmpdepfile"
3139aa228fdSmrg  ;;
3149aa228fdSmrg
3159aa228fdSmrghp2)
3169aa228fdSmrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
3179aa228fdSmrg  # compilers, which have integrated preprocessors.  The correct option
3189aa228fdSmrg  # to use with these is +Maked; it writes dependencies to a file named
3199aa228fdSmrg  # 'foo.d', which lands next to the object file, wherever that
3209aa228fdSmrg  # happens to be.
3219aa228fdSmrg  # Much of this is similar to the tru64 case; see comments there.
3229aa228fdSmrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3239aa228fdSmrg  test "x$dir" = "x$object" && dir=
3249aa228fdSmrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3259aa228fdSmrg  if test "$libtool" = yes; then
3269aa228fdSmrg    tmpdepfile1=$dir$base.d
3279aa228fdSmrg    tmpdepfile2=$dir.libs/$base.d
3289aa228fdSmrg    "$@" -Wc,+Maked
3299aa228fdSmrg  else
3309aa228fdSmrg    tmpdepfile1=$dir$base.d
3319aa228fdSmrg    tmpdepfile2=$dir$base.d
3329aa228fdSmrg    "$@" +Maked
3339aa228fdSmrg  fi
3349aa228fdSmrg  stat=$?
3359aa228fdSmrg  if test $stat -eq 0; then :
3369aa228fdSmrg  else
3379aa228fdSmrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
3389aa228fdSmrg     exit $stat
3399aa228fdSmrg  fi
3409aa228fdSmrg
3419aa228fdSmrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
3429aa228fdSmrg  do
3439aa228fdSmrg    test -f "$tmpdepfile" && break
3449aa228fdSmrg  done
3459aa228fdSmrg  if test -f "$tmpdepfile"; then
3469aa228fdSmrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
3479aa228fdSmrg    # Add `dependent.h:' lines.
3488f65982aSmrg    sed -ne '2,${
3498f65982aSmrg	       s/^ *//
3508f65982aSmrg	       s/ \\*$//
3518f65982aSmrg	       s/$/:/
3528f65982aSmrg	       p
3538f65982aSmrg	     }' "$tmpdepfile" >> "$depfile"
3549aa228fdSmrg  else
3559aa228fdSmrg    echo "#dummy" > "$depfile"
3569aa228fdSmrg  fi
3579aa228fdSmrg  rm -f "$tmpdepfile" "$tmpdepfile2"
3589aa228fdSmrg  ;;
3599aa228fdSmrg
3609aa228fdSmrgtru64)
3619aa228fdSmrg   # The Tru64 compiler uses -MD to generate dependencies as a side
3629aa228fdSmrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
3639aa228fdSmrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
3649aa228fdSmrg   # dependencies in `foo.d' instead, so we check for that too.
3659aa228fdSmrg   # Subdirectories are respected.
3669aa228fdSmrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3679aa228fdSmrg   test "x$dir" = "x$object" && dir=
3689aa228fdSmrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3699aa228fdSmrg
3709aa228fdSmrg   if test "$libtool" = yes; then
3719aa228fdSmrg      # With Tru64 cc, shared objects can also be used to make a
3729aa228fdSmrg      # static library.  This mechanism is used in libtool 1.4 series to
3739aa228fdSmrg      # handle both shared and static libraries in a single compilation.
3749aa228fdSmrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
3759aa228fdSmrg      #
3769aa228fdSmrg      # With libtool 1.5 this exception was removed, and libtool now
3779aa228fdSmrg      # generates 2 separate objects for the 2 libraries.  These two
3789aa228fdSmrg      # compilations output dependencies in $dir.libs/$base.o.d and
3799aa228fdSmrg      # in $dir$base.o.d.  We have to check for both files, because
3809aa228fdSmrg      # one of the two compilations can be disabled.  We should prefer
3819aa228fdSmrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
3829aa228fdSmrg      # automatically cleaned when .libs/ is deleted, while ignoring
3839aa228fdSmrg      # the former would cause a distcleancheck panic.
3849aa228fdSmrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
3859aa228fdSmrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
3869aa228fdSmrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
3879aa228fdSmrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
3889aa228fdSmrg      "$@" -Wc,-MD
3899aa228fdSmrg   else
3909aa228fdSmrg      tmpdepfile1=$dir$base.o.d
3919aa228fdSmrg      tmpdepfile2=$dir$base.d
3929aa228fdSmrg      tmpdepfile3=$dir$base.d
3939aa228fdSmrg      tmpdepfile4=$dir$base.d
3949aa228fdSmrg      "$@" -MD
3959aa228fdSmrg   fi
3969aa228fdSmrg
3979aa228fdSmrg   stat=$?
3989aa228fdSmrg   if test $stat -eq 0; then :
3999aa228fdSmrg   else
4009aa228fdSmrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
4019aa228fdSmrg      exit $stat
4029aa228fdSmrg   fi
4039aa228fdSmrg
4049aa228fdSmrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
4059aa228fdSmrg   do
4069aa228fdSmrg     test -f "$tmpdepfile" && break
4079aa228fdSmrg   done
4089aa228fdSmrg   if test -f "$tmpdepfile"; then
4099aa228fdSmrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
4109aa228fdSmrg      # That's a tab and a space in the [].
4119aa228fdSmrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
4129aa228fdSmrg   else
4139aa228fdSmrg      echo "#dummy" > "$depfile"
4149aa228fdSmrg   fi
4159aa228fdSmrg   rm -f "$tmpdepfile"
4169aa228fdSmrg   ;;
4179aa228fdSmrg
41880b026c6Smrgmsvc7)
41980b026c6Smrg  if test "$libtool" = yes; then
42080b026c6Smrg    showIncludes=-Wc,-showIncludes
42180b026c6Smrg  else
42280b026c6Smrg    showIncludes=-showIncludes
42380b026c6Smrg  fi
42480b026c6Smrg  "$@" $showIncludes > "$tmpdepfile"
42580b026c6Smrg  stat=$?
42680b026c6Smrg  grep -v '^Note: including file: ' "$tmpdepfile"
42780b026c6Smrg  if test "$stat" = 0; then :
42880b026c6Smrg  else
42980b026c6Smrg    rm -f "$tmpdepfile"
43080b026c6Smrg    exit $stat
43180b026c6Smrg  fi
43280b026c6Smrg  rm -f "$depfile"
43380b026c6Smrg  echo "$object : \\" > "$depfile"
43480b026c6Smrg  # The first sed program below extracts the file names and escapes
43580b026c6Smrg  # backslashes for cygpath.  The second sed program outputs the file
43680b026c6Smrg  # name when reading, but also accumulates all include files in the
43780b026c6Smrg  # hold buffer in order to output them again at the end.  This only
43880b026c6Smrg  # works with sed implementations that can handle large buffers.
43980b026c6Smrg  sed < "$tmpdepfile" -n '
44080b026c6Smrg/^Note: including file:  *\(.*\)/ {
44180b026c6Smrg  s//\1/
44280b026c6Smrg  s/\\/\\\\/g
44380b026c6Smrg  p
44480b026c6Smrg}' | $cygpath_u | sort -u | sed -n '
44580b026c6Smrgs/ /\\ /g
44680b026c6Smrgs/\(.*\)/	\1 \\/p
44780b026c6Smrgs/.\(.*\) \\/\1:/
44880b026c6SmrgH
44980b026c6Smrg$ {
45080b026c6Smrg  s/.*/	/
45180b026c6Smrg  G
45280b026c6Smrg  p
45380b026c6Smrg}' >> "$depfile"
45480b026c6Smrg  rm -f "$tmpdepfile"
45580b026c6Smrg  ;;
45680b026c6Smrg
45780b026c6Smrgmsvc7msys)
45880b026c6Smrg  # This case exists only to let depend.m4 do its work.  It works by
45980b026c6Smrg  # looking at the text of this script.  This case will never be run,
46080b026c6Smrg  # since it is checked for above.
46180b026c6Smrg  exit 1
46280b026c6Smrg  ;;
46380b026c6Smrg
4649aa228fdSmrg#nosideeffect)
4659aa228fdSmrg  # This comment above is used by automake to tell side-effect
4669aa228fdSmrg  # dependency tracking mechanisms from slower ones.
4679aa228fdSmrg
4689aa228fdSmrgdashmstdout)
4699aa228fdSmrg  # Important note: in order to support this mode, a compiler *must*
4709aa228fdSmrg  # always write the preprocessed file to stdout, regardless of -o.
4719aa228fdSmrg  "$@" || exit $?
4729aa228fdSmrg
4739aa228fdSmrg  # Remove the call to Libtool.
4749aa228fdSmrg  if test "$libtool" = yes; then
4758f65982aSmrg    while test "X$1" != 'X--mode=compile'; do
4769aa228fdSmrg      shift
4779aa228fdSmrg    done
4789aa228fdSmrg    shift
4799aa228fdSmrg  fi
4809aa228fdSmrg
4819aa228fdSmrg  # Remove `-o $object'.
4829aa228fdSmrg  IFS=" "
4839aa228fdSmrg  for arg
4849aa228fdSmrg  do
4859aa228fdSmrg    case $arg in
4869aa228fdSmrg    -o)
4879aa228fdSmrg      shift
4889aa228fdSmrg      ;;
4899aa228fdSmrg    $object)
4909aa228fdSmrg      shift
4919aa228fdSmrg      ;;
4929aa228fdSmrg    *)
4939aa228fdSmrg      set fnord "$@" "$arg"
4949aa228fdSmrg      shift # fnord
4959aa228fdSmrg      shift # $arg
4969aa228fdSmrg      ;;
4979aa228fdSmrg    esac
4989aa228fdSmrg  done
4999aa228fdSmrg
5009aa228fdSmrg  test -z "$dashmflag" && dashmflag=-M
5019aa228fdSmrg  # Require at least two characters before searching for `:'
5029aa228fdSmrg  # in the target name.  This is to cope with DOS-style filenames:
5039aa228fdSmrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
5049aa228fdSmrg  "$@" $dashmflag |
5059aa228fdSmrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
5069aa228fdSmrg  rm -f "$depfile"
5079aa228fdSmrg  cat < "$tmpdepfile" > "$depfile"
5089aa228fdSmrg  tr ' ' '
5099aa228fdSmrg' < "$tmpdepfile" | \
5109aa228fdSmrg## Some versions of the HPUX 10.20 sed can't process this invocation
5119aa228fdSmrg## correctly.  Breaking it into two sed invocations is a workaround.
5129aa228fdSmrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
5139aa228fdSmrg  rm -f "$tmpdepfile"
5149aa228fdSmrg  ;;
5159aa228fdSmrg
5169aa228fdSmrgdashXmstdout)
5179aa228fdSmrg  # This case only exists to satisfy depend.m4.  It is never actually
5189aa228fdSmrg  # run, as this mode is specially recognized in the preamble.
5199aa228fdSmrg  exit 1
5209aa228fdSmrg  ;;
5219aa228fdSmrg
5229aa228fdSmrgmakedepend)
5239aa228fdSmrg  "$@" || exit $?
5249aa228fdSmrg  # Remove any Libtool call
5259aa228fdSmrg  if test "$libtool" = yes; then
5268f65982aSmrg    while test "X$1" != 'X--mode=compile'; do
5279aa228fdSmrg      shift
5289aa228fdSmrg    done
5299aa228fdSmrg    shift
5309aa228fdSmrg  fi
5319aa228fdSmrg  # X makedepend
5329aa228fdSmrg  shift
5338f65982aSmrg  cleared=no eat=no
5348f65982aSmrg  for arg
5358f65982aSmrg  do
5369aa228fdSmrg    case $cleared in
5379aa228fdSmrg    no)
5389aa228fdSmrg      set ""; shift
5399aa228fdSmrg      cleared=yes ;;
5409aa228fdSmrg    esac
5418f65982aSmrg    if test $eat = yes; then
5428f65982aSmrg      eat=no
5438f65982aSmrg      continue
5448f65982aSmrg    fi
5459aa228fdSmrg    case "$arg" in
5469aa228fdSmrg    -D*|-I*)
5479aa228fdSmrg      set fnord "$@" "$arg"; shift ;;
5489aa228fdSmrg    # Strip any option that makedepend may not understand.  Remove
5499aa228fdSmrg    # the object too, otherwise makedepend will parse it as a source file.
5508f65982aSmrg    -arch)
5518f65982aSmrg      eat=yes ;;
5529aa228fdSmrg    -*|$object)
5539aa228fdSmrg      ;;
5549aa228fdSmrg    *)
5559aa228fdSmrg      set fnord "$@" "$arg"; shift ;;
5569aa228fdSmrg    esac
5579aa228fdSmrg  done
5588f65982aSmrg  obj_suffix=`echo "$object" | sed 's/^.*\././'`
5599aa228fdSmrg  touch "$tmpdepfile"
5609aa228fdSmrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
5619aa228fdSmrg  rm -f "$depfile"
56280b026c6Smrg  # makedepend may prepend the VPATH from the source file name to the object.
56380b026c6Smrg  # No need to regex-escape $object, excess matching of '.' is harmless.
56480b026c6Smrg  sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
5659aa228fdSmrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
5669aa228fdSmrg' | \
5679aa228fdSmrg## Some versions of the HPUX 10.20 sed can't process this invocation
5689aa228fdSmrg## correctly.  Breaking it into two sed invocations is a workaround.
5699aa228fdSmrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
5709aa228fdSmrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
5719aa228fdSmrg  ;;
5729aa228fdSmrg
5739aa228fdSmrgcpp)
5749aa228fdSmrg  # Important note: in order to support this mode, a compiler *must*
5759aa228fdSmrg  # always write the preprocessed file to stdout.
5769aa228fdSmrg  "$@" || exit $?
5779aa228fdSmrg
5789aa228fdSmrg  # Remove the call to Libtool.
5799aa228fdSmrg  if test "$libtool" = yes; then
5808f65982aSmrg    while test "X$1" != 'X--mode=compile'; do
5819aa228fdSmrg      shift
5829aa228fdSmrg    done
5839aa228fdSmrg    shift
5849aa228fdSmrg  fi
5859aa228fdSmrg
5869aa228fdSmrg  # Remove `-o $object'.
5879aa228fdSmrg  IFS=" "
5889aa228fdSmrg  for arg
5899aa228fdSmrg  do
5909aa228fdSmrg    case $arg in
5919aa228fdSmrg    -o)
5929aa228fdSmrg      shift
5939aa228fdSmrg      ;;
5949aa228fdSmrg    $object)
5959aa228fdSmrg      shift
5969aa228fdSmrg      ;;
5979aa228fdSmrg    *)
5989aa228fdSmrg      set fnord "$@" "$arg"
5999aa228fdSmrg      shift # fnord
6009aa228fdSmrg      shift # $arg
6019aa228fdSmrg      ;;
6029aa228fdSmrg    esac
6039aa228fdSmrg  done
6049aa228fdSmrg
6059aa228fdSmrg  "$@" -E |
6069aa228fdSmrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
6079aa228fdSmrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
6089aa228fdSmrg    sed '$ s: \\$::' > "$tmpdepfile"
6099aa228fdSmrg  rm -f "$depfile"
6109aa228fdSmrg  echo "$object : \\" > "$depfile"
6119aa228fdSmrg  cat < "$tmpdepfile" >> "$depfile"
6129aa228fdSmrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
6139aa228fdSmrg  rm -f "$tmpdepfile"
6149aa228fdSmrg  ;;
6159aa228fdSmrg
6169aa228fdSmrgmsvisualcpp)
6179aa228fdSmrg  # Important note: in order to support this mode, a compiler *must*
6188f65982aSmrg  # always write the preprocessed file to stdout.
6199aa228fdSmrg  "$@" || exit $?
6208f65982aSmrg
6218f65982aSmrg  # Remove the call to Libtool.
6228f65982aSmrg  if test "$libtool" = yes; then
6238f65982aSmrg    while test "X$1" != 'X--mode=compile'; do
6248f65982aSmrg      shift
6258f65982aSmrg    done
6268f65982aSmrg    shift
6278f65982aSmrg  fi
6288f65982aSmrg
6299aa228fdSmrg  IFS=" "
6309aa228fdSmrg  for arg
6319aa228fdSmrg  do
6329aa228fdSmrg    case "$arg" in
6338f65982aSmrg    -o)
6348f65982aSmrg      shift
6358f65982aSmrg      ;;
6368f65982aSmrg    $object)
6378f65982aSmrg      shift
6388f65982aSmrg      ;;
6399aa228fdSmrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
6409aa228fdSmrg	set fnord "$@"
6419aa228fdSmrg	shift
6429aa228fdSmrg	shift
6439aa228fdSmrg	;;
6449aa228fdSmrg    *)
6459aa228fdSmrg	set fnord "$@" "$arg"
6469aa228fdSmrg	shift
6479aa228fdSmrg	shift
6489aa228fdSmrg	;;
6499aa228fdSmrg    esac
6509aa228fdSmrg  done
6518f65982aSmrg  "$@" -E 2>/dev/null |
6528f65982aSmrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
6539aa228fdSmrg  rm -f "$depfile"
6549aa228fdSmrg  echo "$object : \\" > "$depfile"
6558f65982aSmrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
6569aa228fdSmrg  echo "	" >> "$depfile"
6578f65982aSmrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
6589aa228fdSmrg  rm -f "$tmpdepfile"
6599aa228fdSmrg  ;;
6609aa228fdSmrg
6618f65982aSmrgmsvcmsys)
6628f65982aSmrg  # This case exists only to let depend.m4 do its work.  It works by
6638f65982aSmrg  # looking at the text of this script.  This case will never be run,
6648f65982aSmrg  # since it is checked for above.
6658f65982aSmrg  exit 1
6668f65982aSmrg  ;;
6678f65982aSmrg
6689aa228fdSmrgnone)
6699aa228fdSmrg  exec "$@"
6709aa228fdSmrg  ;;
6719aa228fdSmrg
6729aa228fdSmrg*)
6739aa228fdSmrg  echo "Unknown depmode $depmode" 1>&2
6749aa228fdSmrg  exit 1
6759aa228fdSmrg  ;;
6769aa228fdSmrgesac
6779aa228fdSmrg
6789aa228fdSmrgexit 0
6799aa228fdSmrg
6809aa228fdSmrg# Local Variables:
6819aa228fdSmrg# mode: shell-script
6829aa228fdSmrg# sh-indentation: 2
6839aa228fdSmrg# eval: (add-hook 'write-file-hooks 'time-stamp)
6849aa228fdSmrg# time-stamp-start: "scriptversion="
6859aa228fdSmrg# time-stamp-format: "%:y-%02m-%02d.%02H"
6868f65982aSmrg# time-stamp-time-zone: "UTC"
6878f65982aSmrg# time-stamp-end: "; # UTC"
6889aa228fdSmrg# End:
689