depcomp revision 4e411241
18c9fbc29Smrg#! /bin/sh
28c9fbc29Smrg# depcomp - compile a program generating dependencies as side-effects
38c9fbc29Smrg
44e411241Smrgscriptversion=2009-04-28.21; # UTC
58c9fbc29Smrg
64e411241Smrg# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
74e411241Smrg# Software Foundation, Inc.
88c9fbc29Smrg
98c9fbc29Smrg# This program is free software; you can redistribute it and/or modify
108c9fbc29Smrg# it under the terms of the GNU General Public License as published by
118c9fbc29Smrg# the Free Software Foundation; either version 2, or (at your option)
128c9fbc29Smrg# any later version.
138c9fbc29Smrg
148c9fbc29Smrg# This program is distributed in the hope that it will be useful,
158c9fbc29Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
168c9fbc29Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
178c9fbc29Smrg# GNU General Public License for more details.
188c9fbc29Smrg
198c9fbc29Smrg# You should have received a copy of the GNU General Public License
204e411241Smrg# along with this program.  If not, see <http://www.gnu.org/licenses/>.
218c9fbc29Smrg
228c9fbc29Smrg# As a special exception to the GNU General Public License, if you
238c9fbc29Smrg# distribute this file as part of a program that contains a
248c9fbc29Smrg# configuration script generated by Autoconf, you may include it under
258c9fbc29Smrg# the same distribution terms that you use for the rest of that program.
268c9fbc29Smrg
278c9fbc29Smrg# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
288c9fbc29Smrg
298c9fbc29Smrgcase $1 in
308c9fbc29Smrg  '')
318c9fbc29Smrg     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
328c9fbc29Smrg     exit 1;
338c9fbc29Smrg     ;;
348c9fbc29Smrg  -h | --h*)
358c9fbc29Smrg    cat <<\EOF
368c9fbc29SmrgUsage: depcomp [--help] [--version] PROGRAM [ARGS]
378c9fbc29Smrg
388c9fbc29SmrgRun PROGRAMS ARGS to compile a file, generating dependencies
398c9fbc29Smrgas side-effects.
408c9fbc29Smrg
418c9fbc29SmrgEnvironment variables:
428c9fbc29Smrg  depmode     Dependency tracking mode.
438c9fbc29Smrg  source      Source file read by `PROGRAMS ARGS'.
448c9fbc29Smrg  object      Object file output by `PROGRAMS ARGS'.
458c9fbc29Smrg  DEPDIR      directory where to store dependencies.
468c9fbc29Smrg  depfile     Dependency file to output.
478c9fbc29Smrg  tmpdepfile  Temporary file to use when outputing dependencies.
488c9fbc29Smrg  libtool     Whether libtool is used (yes/no).
498c9fbc29Smrg
508c9fbc29SmrgReport bugs to <bug-automake@gnu.org>.
518c9fbc29SmrgEOF
528c9fbc29Smrg    exit $?
538c9fbc29Smrg    ;;
548c9fbc29Smrg  -v | --v*)
558c9fbc29Smrg    echo "depcomp $scriptversion"
568c9fbc29Smrg    exit $?
578c9fbc29Smrg    ;;
588c9fbc29Smrgesac
598c9fbc29Smrg
608c9fbc29Smrgif test -z "$depmode" || test -z "$source" || test -z "$object"; then
618c9fbc29Smrg  echo "depcomp: Variables source, object and depmode must be set" 1>&2
628c9fbc29Smrg  exit 1
638c9fbc29Smrgfi
648c9fbc29Smrg
658c9fbc29Smrg# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
668c9fbc29Smrgdepfile=${depfile-`echo "$object" |
678c9fbc29Smrg  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
688c9fbc29Smrgtmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
698c9fbc29Smrg
708c9fbc29Smrgrm -f "$tmpdepfile"
718c9fbc29Smrg
728c9fbc29Smrg# Some modes work just like other modes, but use different flags.  We
738c9fbc29Smrg# parameterize here, but still list the modes in the big case below,
748c9fbc29Smrg# to make depend.m4 easier to write.  Note that we *cannot* use a case
758c9fbc29Smrg# here, because this file can only contain one case statement.
768c9fbc29Smrgif test "$depmode" = hp; then
778c9fbc29Smrg  # HP compiler uses -M and no extra arg.
788c9fbc29Smrg  gccflag=-M
798c9fbc29Smrg  depmode=gcc
808c9fbc29Smrgfi
818c9fbc29Smrg
828c9fbc29Smrgif test "$depmode" = dashXmstdout; then
838c9fbc29Smrg   # This is just like dashmstdout with a different argument.
848c9fbc29Smrg   dashmflag=-xM
858c9fbc29Smrg   depmode=dashmstdout
868c9fbc29Smrgfi
878c9fbc29Smrg
884e411241Smrgcygpath_u="cygpath -u -f -"
894e411241Smrgif test "$depmode" = msvcmsys; then
904e411241Smrg   # This is just like msvisualcpp but w/o cygpath translation.
914e411241Smrg   # Just convert the backslash-escaped backslashes to single forward
924e411241Smrg   # slashes to satisfy depend.m4
934e411241Smrg   cygpath_u="sed s,\\\\\\\\,/,g"
944e411241Smrg   depmode=msvisualcpp
954e411241Smrgfi
964e411241Smrg
978c9fbc29Smrgcase "$depmode" in
988c9fbc29Smrggcc3)
998c9fbc29Smrg## gcc 3 implements dependency tracking that does exactly what
1008c9fbc29Smrg## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
1018c9fbc29Smrg## it if -MD -MP comes after the -MF stuff.  Hmm.
1028c9fbc29Smrg## Unfortunately, FreeBSD c89 acceptance of flags depends upon
1038c9fbc29Smrg## the command line argument order; so add the flags where they
1048c9fbc29Smrg## appear in depend2.am.  Note that the slowdown incurred here
1058c9fbc29Smrg## affects only configure: in makefiles, %FASTDEP% shortcuts this.
1068c9fbc29Smrg  for arg
1078c9fbc29Smrg  do
1088c9fbc29Smrg    case $arg in
1098c9fbc29Smrg    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
1108c9fbc29Smrg    *)  set fnord "$@" "$arg" ;;
1118c9fbc29Smrg    esac
1128c9fbc29Smrg    shift # fnord
1138c9fbc29Smrg    shift # $arg
1148c9fbc29Smrg  done
1158c9fbc29Smrg  "$@"
1168c9fbc29Smrg  stat=$?
1178c9fbc29Smrg  if test $stat -eq 0; then :
1188c9fbc29Smrg  else
1198c9fbc29Smrg    rm -f "$tmpdepfile"
1208c9fbc29Smrg    exit $stat
1218c9fbc29Smrg  fi
1228c9fbc29Smrg  mv "$tmpdepfile" "$depfile"
1238c9fbc29Smrg  ;;
1248c9fbc29Smrg
1258c9fbc29Smrggcc)
1268c9fbc29Smrg## There are various ways to get dependency output from gcc.  Here's
1278c9fbc29Smrg## why we pick this rather obscure method:
1288c9fbc29Smrg## - Don't want to use -MD because we'd like the dependencies to end
1298c9fbc29Smrg##   up in a subdir.  Having to rename by hand is ugly.
1308c9fbc29Smrg##   (We might end up doing this anyway to support other compilers.)
1318c9fbc29Smrg## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
1328c9fbc29Smrg##   -MM, not -M (despite what the docs say).
1338c9fbc29Smrg## - Using -M directly means running the compiler twice (even worse
1348c9fbc29Smrg##   than renaming).
1358c9fbc29Smrg  if test -z "$gccflag"; then
1368c9fbc29Smrg    gccflag=-MD,
1378c9fbc29Smrg  fi
1388c9fbc29Smrg  "$@" -Wp,"$gccflag$tmpdepfile"
1398c9fbc29Smrg  stat=$?
1408c9fbc29Smrg  if test $stat -eq 0; then :
1418c9fbc29Smrg  else
1428c9fbc29Smrg    rm -f "$tmpdepfile"
1438c9fbc29Smrg    exit $stat
1448c9fbc29Smrg  fi
1458c9fbc29Smrg  rm -f "$depfile"
1468c9fbc29Smrg  echo "$object : \\" > "$depfile"
1478c9fbc29Smrg  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
1488c9fbc29Smrg## The second -e expression handles DOS-style file names with drive letters.
1498c9fbc29Smrg  sed -e 's/^[^:]*: / /' \
1508c9fbc29Smrg      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
1518c9fbc29Smrg## This next piece of magic avoids the `deleted header file' problem.
1528c9fbc29Smrg## The problem is that when a header file which appears in a .P file
1538c9fbc29Smrg## is deleted, the dependency causes make to die (because there is
1548c9fbc29Smrg## typically no way to rebuild the header).  We avoid this by adding
1558c9fbc29Smrg## dummy dependencies for each header file.  Too bad gcc doesn't do
1568c9fbc29Smrg## this for us directly.
1578c9fbc29Smrg  tr ' ' '
1588c9fbc29Smrg' < "$tmpdepfile" |
1598c9fbc29Smrg## Some versions of gcc put a space before the `:'.  On the theory
1608c9fbc29Smrg## that the space means something, we add a space to the output as
1618c9fbc29Smrg## well.
1628c9fbc29Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
1638c9fbc29Smrg## correctly.  Breaking it into two sed invocations is a workaround.
1648c9fbc29Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
1658c9fbc29Smrg  rm -f "$tmpdepfile"
1668c9fbc29Smrg  ;;
1678c9fbc29Smrg
1688c9fbc29Smrghp)
1698c9fbc29Smrg  # This case exists only to let depend.m4 do its work.  It works by
1708c9fbc29Smrg  # looking at the text of this script.  This case will never be run,
1718c9fbc29Smrg  # since it is checked for above.
1728c9fbc29Smrg  exit 1
1738c9fbc29Smrg  ;;
1748c9fbc29Smrg
1758c9fbc29Smrgsgi)
1768c9fbc29Smrg  if test "$libtool" = yes; then
1778c9fbc29Smrg    "$@" "-Wp,-MDupdate,$tmpdepfile"
1788c9fbc29Smrg  else
1798c9fbc29Smrg    "$@" -MDupdate "$tmpdepfile"
1808c9fbc29Smrg  fi
1818c9fbc29Smrg  stat=$?
1828c9fbc29Smrg  if test $stat -eq 0; then :
1838c9fbc29Smrg  else
1848c9fbc29Smrg    rm -f "$tmpdepfile"
1858c9fbc29Smrg    exit $stat
1868c9fbc29Smrg  fi
1878c9fbc29Smrg  rm -f "$depfile"
1888c9fbc29Smrg
1898c9fbc29Smrg  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
1908c9fbc29Smrg    echo "$object : \\" > "$depfile"
1918c9fbc29Smrg
1928c9fbc29Smrg    # Clip off the initial element (the dependent).  Don't try to be
1938c9fbc29Smrg    # clever and replace this with sed code, as IRIX sed won't handle
1948c9fbc29Smrg    # lines with more than a fixed number of characters (4096 in
1958c9fbc29Smrg    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
1968c9fbc29Smrg    # the IRIX cc adds comments like `#:fec' to the end of the
1978c9fbc29Smrg    # dependency line.
1988c9fbc29Smrg    tr ' ' '
1998c9fbc29Smrg' < "$tmpdepfile" \
2008c9fbc29Smrg    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
2018c9fbc29Smrg    tr '
2024e411241Smrg' ' ' >> "$depfile"
2034e411241Smrg    echo >> "$depfile"
2048c9fbc29Smrg
2058c9fbc29Smrg    # The second pass generates a dummy entry for each header file.
2068c9fbc29Smrg    tr ' ' '
2078c9fbc29Smrg' < "$tmpdepfile" \
2088c9fbc29Smrg   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
2094e411241Smrg   >> "$depfile"
2108c9fbc29Smrg  else
2118c9fbc29Smrg    # The sourcefile does not contain any dependencies, so just
2128c9fbc29Smrg    # store a dummy comment line, to avoid errors with the Makefile
2138c9fbc29Smrg    # "include basename.Plo" scheme.
2148c9fbc29Smrg    echo "#dummy" > "$depfile"
2158c9fbc29Smrg  fi
2168c9fbc29Smrg  rm -f "$tmpdepfile"
2178c9fbc29Smrg  ;;
2188c9fbc29Smrg
2198c9fbc29Smrgaix)
2208c9fbc29Smrg  # The C for AIX Compiler uses -M and outputs the dependencies
2218c9fbc29Smrg  # in a .u file.  In older versions, this file always lives in the
2228c9fbc29Smrg  # current directory.  Also, the AIX compiler puts `$object:' at the
2238c9fbc29Smrg  # start of each line; $object doesn't have directory information.
2248c9fbc29Smrg  # Version 6 uses the directory in both cases.
2254e411241Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
2264e411241Smrg  test "x$dir" = "x$object" && dir=
2274e411241Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
2288c9fbc29Smrg  if test "$libtool" = yes; then
2294e411241Smrg    tmpdepfile1=$dir$base.u
2304e411241Smrg    tmpdepfile2=$base.u
2314e411241Smrg    tmpdepfile3=$dir.libs/$base.u
2328c9fbc29Smrg    "$@" -Wc,-M
2338c9fbc29Smrg  else
2344e411241Smrg    tmpdepfile1=$dir$base.u
2354e411241Smrg    tmpdepfile2=$dir$base.u
2364e411241Smrg    tmpdepfile3=$dir$base.u
2378c9fbc29Smrg    "$@" -M
2388c9fbc29Smrg  fi
2398c9fbc29Smrg  stat=$?
2408c9fbc29Smrg
2418c9fbc29Smrg  if test $stat -eq 0; then :
2428c9fbc29Smrg  else
2434e411241Smrg    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
2448c9fbc29Smrg    exit $stat
2458c9fbc29Smrg  fi
2468c9fbc29Smrg
2474e411241Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
2484e411241Smrg  do
2494e411241Smrg    test -f "$tmpdepfile" && break
2504e411241Smrg  done
2518c9fbc29Smrg  if test -f "$tmpdepfile"; then
2528c9fbc29Smrg    # Each line is of the form `foo.o: dependent.h'.
2538c9fbc29Smrg    # Do two passes, one to just change these to
2548c9fbc29Smrg    # `$object: dependent.h' and one to simply `dependent.h:'.
2554e411241Smrg    sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
2564e411241Smrg    # That's a tab and a space in the [].
2574e411241Smrg    sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
2588c9fbc29Smrg  else
2598c9fbc29Smrg    # The sourcefile does not contain any dependencies, so just
2608c9fbc29Smrg    # store a dummy comment line, to avoid errors with the Makefile
2618c9fbc29Smrg    # "include basename.Plo" scheme.
2628c9fbc29Smrg    echo "#dummy" > "$depfile"
2638c9fbc29Smrg  fi
2648c9fbc29Smrg  rm -f "$tmpdepfile"
2658c9fbc29Smrg  ;;
2668c9fbc29Smrg
2678c9fbc29Smrgicc)
2688c9fbc29Smrg  # Intel's C compiler understands `-MD -MF file'.  However on
2698c9fbc29Smrg  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
2708c9fbc29Smrg  # ICC 7.0 will fill foo.d with something like
2718c9fbc29Smrg  #    foo.o: sub/foo.c
2728c9fbc29Smrg  #    foo.o: sub/foo.h
2738c9fbc29Smrg  # which is wrong.  We want:
2748c9fbc29Smrg  #    sub/foo.o: sub/foo.c
2758c9fbc29Smrg  #    sub/foo.o: sub/foo.h
2768c9fbc29Smrg  #    sub/foo.c:
2778c9fbc29Smrg  #    sub/foo.h:
2788c9fbc29Smrg  # ICC 7.1 will output
2798c9fbc29Smrg  #    foo.o: sub/foo.c sub/foo.h
2808c9fbc29Smrg  # and will wrap long lines using \ :
2818c9fbc29Smrg  #    foo.o: sub/foo.c ... \
2828c9fbc29Smrg  #     sub/foo.h ... \
2838c9fbc29Smrg  #     ...
2848c9fbc29Smrg
2858c9fbc29Smrg  "$@" -MD -MF "$tmpdepfile"
2868c9fbc29Smrg  stat=$?
2878c9fbc29Smrg  if test $stat -eq 0; then :
2888c9fbc29Smrg  else
2898c9fbc29Smrg    rm -f "$tmpdepfile"
2908c9fbc29Smrg    exit $stat
2918c9fbc29Smrg  fi
2928c9fbc29Smrg  rm -f "$depfile"
2938c9fbc29Smrg  # Each line is of the form `foo.o: dependent.h',
2948c9fbc29Smrg  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
2958c9fbc29Smrg  # Do two passes, one to just change these to
2968c9fbc29Smrg  # `$object: dependent.h' and one to simply `dependent.h:'.
2978c9fbc29Smrg  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
2988c9fbc29Smrg  # Some versions of the HPUX 10.20 sed can't process this invocation
2998c9fbc29Smrg  # correctly.  Breaking it into two sed invocations is a workaround.
3008c9fbc29Smrg  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
3018c9fbc29Smrg    sed -e 's/$/ :/' >> "$depfile"
3028c9fbc29Smrg  rm -f "$tmpdepfile"
3038c9fbc29Smrg  ;;
3048c9fbc29Smrg
3058c9fbc29Smrghp2)
3068c9fbc29Smrg  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
3078c9fbc29Smrg  # compilers, which have integrated preprocessors.  The correct option
3088c9fbc29Smrg  # to use with these is +Maked; it writes dependencies to a file named
3098c9fbc29Smrg  # 'foo.d', which lands next to the object file, wherever that
3108c9fbc29Smrg  # happens to be.
3118c9fbc29Smrg  # Much of this is similar to the tru64 case; see comments there.
3128c9fbc29Smrg  dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3138c9fbc29Smrg  test "x$dir" = "x$object" && dir=
3148c9fbc29Smrg  base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3158c9fbc29Smrg  if test "$libtool" = yes; then
3168c9fbc29Smrg    tmpdepfile1=$dir$base.d
3178c9fbc29Smrg    tmpdepfile2=$dir.libs/$base.d
3188c9fbc29Smrg    "$@" -Wc,+Maked
3198c9fbc29Smrg  else
3208c9fbc29Smrg    tmpdepfile1=$dir$base.d
3218c9fbc29Smrg    tmpdepfile2=$dir$base.d
3228c9fbc29Smrg    "$@" +Maked
3238c9fbc29Smrg  fi
3248c9fbc29Smrg  stat=$?
3258c9fbc29Smrg  if test $stat -eq 0; then :
3268c9fbc29Smrg  else
3278c9fbc29Smrg     rm -f "$tmpdepfile1" "$tmpdepfile2"
3288c9fbc29Smrg     exit $stat
3298c9fbc29Smrg  fi
3308c9fbc29Smrg
3318c9fbc29Smrg  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
3328c9fbc29Smrg  do
3338c9fbc29Smrg    test -f "$tmpdepfile" && break
3348c9fbc29Smrg  done
3358c9fbc29Smrg  if test -f "$tmpdepfile"; then
3368c9fbc29Smrg    sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
3378c9fbc29Smrg    # Add `dependent.h:' lines.
3384e411241Smrg    sed -ne '2,${
3394e411241Smrg	       s/^ *//
3404e411241Smrg	       s/ \\*$//
3414e411241Smrg	       s/$/:/
3424e411241Smrg	       p
3434e411241Smrg	     }' "$tmpdepfile" >> "$depfile"
3448c9fbc29Smrg  else
3458c9fbc29Smrg    echo "#dummy" > "$depfile"
3468c9fbc29Smrg  fi
3478c9fbc29Smrg  rm -f "$tmpdepfile" "$tmpdepfile2"
3488c9fbc29Smrg  ;;
3498c9fbc29Smrg
3508c9fbc29Smrgtru64)
3518c9fbc29Smrg   # The Tru64 compiler uses -MD to generate dependencies as a side
3528c9fbc29Smrg   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
3538c9fbc29Smrg   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
3548c9fbc29Smrg   # dependencies in `foo.d' instead, so we check for that too.
3558c9fbc29Smrg   # Subdirectories are respected.
3568c9fbc29Smrg   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
3578c9fbc29Smrg   test "x$dir" = "x$object" && dir=
3588c9fbc29Smrg   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
3598c9fbc29Smrg
3608c9fbc29Smrg   if test "$libtool" = yes; then
3618c9fbc29Smrg      # With Tru64 cc, shared objects can also be used to make a
3628c9fbc29Smrg      # static library.  This mechanism is used in libtool 1.4 series to
3638c9fbc29Smrg      # handle both shared and static libraries in a single compilation.
3648c9fbc29Smrg      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
3658c9fbc29Smrg      #
3668c9fbc29Smrg      # With libtool 1.5 this exception was removed, and libtool now
3678c9fbc29Smrg      # generates 2 separate objects for the 2 libraries.  These two
3688c9fbc29Smrg      # compilations output dependencies in $dir.libs/$base.o.d and
3698c9fbc29Smrg      # in $dir$base.o.d.  We have to check for both files, because
3708c9fbc29Smrg      # one of the two compilations can be disabled.  We should prefer
3718c9fbc29Smrg      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
3728c9fbc29Smrg      # automatically cleaned when .libs/ is deleted, while ignoring
3738c9fbc29Smrg      # the former would cause a distcleancheck panic.
3748c9fbc29Smrg      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
3758c9fbc29Smrg      tmpdepfile2=$dir$base.o.d          # libtool 1.5
3768c9fbc29Smrg      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
3778c9fbc29Smrg      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
3788c9fbc29Smrg      "$@" -Wc,-MD
3798c9fbc29Smrg   else
3808c9fbc29Smrg      tmpdepfile1=$dir$base.o.d
3818c9fbc29Smrg      tmpdepfile2=$dir$base.d
3828c9fbc29Smrg      tmpdepfile3=$dir$base.d
3838c9fbc29Smrg      tmpdepfile4=$dir$base.d
3848c9fbc29Smrg      "$@" -MD
3858c9fbc29Smrg   fi
3868c9fbc29Smrg
3878c9fbc29Smrg   stat=$?
3888c9fbc29Smrg   if test $stat -eq 0; then :
3898c9fbc29Smrg   else
3908c9fbc29Smrg      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
3918c9fbc29Smrg      exit $stat
3928c9fbc29Smrg   fi
3938c9fbc29Smrg
3948c9fbc29Smrg   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
3958c9fbc29Smrg   do
3968c9fbc29Smrg     test -f "$tmpdepfile" && break
3978c9fbc29Smrg   done
3988c9fbc29Smrg   if test -f "$tmpdepfile"; then
3998c9fbc29Smrg      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
4008c9fbc29Smrg      # That's a tab and a space in the [].
4018c9fbc29Smrg      sed -e 's,^.*\.[a-z]*:[	 ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
4028c9fbc29Smrg   else
4038c9fbc29Smrg      echo "#dummy" > "$depfile"
4048c9fbc29Smrg   fi
4058c9fbc29Smrg   rm -f "$tmpdepfile"
4068c9fbc29Smrg   ;;
4078c9fbc29Smrg
4088c9fbc29Smrg#nosideeffect)
4098c9fbc29Smrg  # This comment above is used by automake to tell side-effect
4108c9fbc29Smrg  # dependency tracking mechanisms from slower ones.
4118c9fbc29Smrg
4128c9fbc29Smrgdashmstdout)
4138c9fbc29Smrg  # Important note: in order to support this mode, a compiler *must*
4148c9fbc29Smrg  # always write the preprocessed file to stdout, regardless of -o.
4158c9fbc29Smrg  "$@" || exit $?
4168c9fbc29Smrg
4178c9fbc29Smrg  # Remove the call to Libtool.
4188c9fbc29Smrg  if test "$libtool" = yes; then
4194e411241Smrg    while test "X$1" != 'X--mode=compile'; do
4208c9fbc29Smrg      shift
4218c9fbc29Smrg    done
4228c9fbc29Smrg    shift
4238c9fbc29Smrg  fi
4248c9fbc29Smrg
4258c9fbc29Smrg  # Remove `-o $object'.
4268c9fbc29Smrg  IFS=" "
4278c9fbc29Smrg  for arg
4288c9fbc29Smrg  do
4298c9fbc29Smrg    case $arg in
4308c9fbc29Smrg    -o)
4318c9fbc29Smrg      shift
4328c9fbc29Smrg      ;;
4338c9fbc29Smrg    $object)
4348c9fbc29Smrg      shift
4358c9fbc29Smrg      ;;
4368c9fbc29Smrg    *)
4378c9fbc29Smrg      set fnord "$@" "$arg"
4388c9fbc29Smrg      shift # fnord
4398c9fbc29Smrg      shift # $arg
4408c9fbc29Smrg      ;;
4418c9fbc29Smrg    esac
4428c9fbc29Smrg  done
4438c9fbc29Smrg
4448c9fbc29Smrg  test -z "$dashmflag" && dashmflag=-M
4458c9fbc29Smrg  # Require at least two characters before searching for `:'
4468c9fbc29Smrg  # in the target name.  This is to cope with DOS-style filenames:
4478c9fbc29Smrg  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
4488c9fbc29Smrg  "$@" $dashmflag |
4498c9fbc29Smrg    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
4508c9fbc29Smrg  rm -f "$depfile"
4518c9fbc29Smrg  cat < "$tmpdepfile" > "$depfile"
4528c9fbc29Smrg  tr ' ' '
4538c9fbc29Smrg' < "$tmpdepfile" | \
4548c9fbc29Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
4558c9fbc29Smrg## correctly.  Breaking it into two sed invocations is a workaround.
4568c9fbc29Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
4578c9fbc29Smrg  rm -f "$tmpdepfile"
4588c9fbc29Smrg  ;;
4598c9fbc29Smrg
4608c9fbc29SmrgdashXmstdout)
4618c9fbc29Smrg  # This case only exists to satisfy depend.m4.  It is never actually
4628c9fbc29Smrg  # run, as this mode is specially recognized in the preamble.
4638c9fbc29Smrg  exit 1
4648c9fbc29Smrg  ;;
4658c9fbc29Smrg
4668c9fbc29Smrgmakedepend)
4678c9fbc29Smrg  "$@" || exit $?
4688c9fbc29Smrg  # Remove any Libtool call
4698c9fbc29Smrg  if test "$libtool" = yes; then
4704e411241Smrg    while test "X$1" != 'X--mode=compile'; do
4718c9fbc29Smrg      shift
4728c9fbc29Smrg    done
4738c9fbc29Smrg    shift
4748c9fbc29Smrg  fi
4758c9fbc29Smrg  # X makedepend
4768c9fbc29Smrg  shift
4774e411241Smrg  cleared=no eat=no
4784e411241Smrg  for arg
4794e411241Smrg  do
4808c9fbc29Smrg    case $cleared in
4818c9fbc29Smrg    no)
4828c9fbc29Smrg      set ""; shift
4838c9fbc29Smrg      cleared=yes ;;
4848c9fbc29Smrg    esac
4854e411241Smrg    if test $eat = yes; then
4864e411241Smrg      eat=no
4874e411241Smrg      continue
4884e411241Smrg    fi
4898c9fbc29Smrg    case "$arg" in
4908c9fbc29Smrg    -D*|-I*)
4918c9fbc29Smrg      set fnord "$@" "$arg"; shift ;;
4928c9fbc29Smrg    # Strip any option that makedepend may not understand.  Remove
4938c9fbc29Smrg    # the object too, otherwise makedepend will parse it as a source file.
4944e411241Smrg    -arch)
4954e411241Smrg      eat=yes ;;
4968c9fbc29Smrg    -*|$object)
4978c9fbc29Smrg      ;;
4988c9fbc29Smrg    *)
4998c9fbc29Smrg      set fnord "$@" "$arg"; shift ;;
5008c9fbc29Smrg    esac
5018c9fbc29Smrg  done
5024e411241Smrg  obj_suffix=`echo "$object" | sed 's/^.*\././'`
5038c9fbc29Smrg  touch "$tmpdepfile"
5048c9fbc29Smrg  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
5058c9fbc29Smrg  rm -f "$depfile"
5068c9fbc29Smrg  cat < "$tmpdepfile" > "$depfile"
5078c9fbc29Smrg  sed '1,2d' "$tmpdepfile" | tr ' ' '
5088c9fbc29Smrg' | \
5098c9fbc29Smrg## Some versions of the HPUX 10.20 sed can't process this invocation
5108c9fbc29Smrg## correctly.  Breaking it into two sed invocations is a workaround.
5118c9fbc29Smrg    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
5128c9fbc29Smrg  rm -f "$tmpdepfile" "$tmpdepfile".bak
5138c9fbc29Smrg  ;;
5148c9fbc29Smrg
5158c9fbc29Smrgcpp)
5168c9fbc29Smrg  # Important note: in order to support this mode, a compiler *must*
5178c9fbc29Smrg  # always write the preprocessed file to stdout.
5188c9fbc29Smrg  "$@" || exit $?
5198c9fbc29Smrg
5208c9fbc29Smrg  # Remove the call to Libtool.
5218c9fbc29Smrg  if test "$libtool" = yes; then
5224e411241Smrg    while test "X$1" != 'X--mode=compile'; do
5238c9fbc29Smrg      shift
5248c9fbc29Smrg    done
5258c9fbc29Smrg    shift
5268c9fbc29Smrg  fi
5278c9fbc29Smrg
5288c9fbc29Smrg  # Remove `-o $object'.
5298c9fbc29Smrg  IFS=" "
5308c9fbc29Smrg  for arg
5318c9fbc29Smrg  do
5328c9fbc29Smrg    case $arg in
5338c9fbc29Smrg    -o)
5348c9fbc29Smrg      shift
5358c9fbc29Smrg      ;;
5368c9fbc29Smrg    $object)
5378c9fbc29Smrg      shift
5388c9fbc29Smrg      ;;
5398c9fbc29Smrg    *)
5408c9fbc29Smrg      set fnord "$@" "$arg"
5418c9fbc29Smrg      shift # fnord
5428c9fbc29Smrg      shift # $arg
5438c9fbc29Smrg      ;;
5448c9fbc29Smrg    esac
5458c9fbc29Smrg  done
5468c9fbc29Smrg
5478c9fbc29Smrg  "$@" -E |
5488c9fbc29Smrg    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
5498c9fbc29Smrg       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
5508c9fbc29Smrg    sed '$ s: \\$::' > "$tmpdepfile"
5518c9fbc29Smrg  rm -f "$depfile"
5528c9fbc29Smrg  echo "$object : \\" > "$depfile"
5538c9fbc29Smrg  cat < "$tmpdepfile" >> "$depfile"
5548c9fbc29Smrg  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
5558c9fbc29Smrg  rm -f "$tmpdepfile"
5568c9fbc29Smrg  ;;
5578c9fbc29Smrg
5588c9fbc29Smrgmsvisualcpp)
5598c9fbc29Smrg  # Important note: in order to support this mode, a compiler *must*
5604e411241Smrg  # always write the preprocessed file to stdout.
5618c9fbc29Smrg  "$@" || exit $?
5624e411241Smrg
5634e411241Smrg  # Remove the call to Libtool.
5644e411241Smrg  if test "$libtool" = yes; then
5654e411241Smrg    while test "X$1" != 'X--mode=compile'; do
5664e411241Smrg      shift
5674e411241Smrg    done
5684e411241Smrg    shift
5694e411241Smrg  fi
5704e411241Smrg
5718c9fbc29Smrg  IFS=" "
5728c9fbc29Smrg  for arg
5738c9fbc29Smrg  do
5748c9fbc29Smrg    case "$arg" in
5754e411241Smrg    -o)
5764e411241Smrg      shift
5774e411241Smrg      ;;
5784e411241Smrg    $object)
5794e411241Smrg      shift
5804e411241Smrg      ;;
5818c9fbc29Smrg    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
5828c9fbc29Smrg	set fnord "$@"
5838c9fbc29Smrg	shift
5848c9fbc29Smrg	shift
5858c9fbc29Smrg	;;
5868c9fbc29Smrg    *)
5878c9fbc29Smrg	set fnord "$@" "$arg"
5888c9fbc29Smrg	shift
5898c9fbc29Smrg	shift
5908c9fbc29Smrg	;;
5918c9fbc29Smrg    esac
5928c9fbc29Smrg  done
5934e411241Smrg  "$@" -E 2>/dev/null |
5944e411241Smrg  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
5958c9fbc29Smrg  rm -f "$depfile"
5968c9fbc29Smrg  echo "$object : \\" > "$depfile"
5974e411241Smrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::	\1 \\:p' >> "$depfile"
5988c9fbc29Smrg  echo "	" >> "$depfile"
5994e411241Smrg  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
6008c9fbc29Smrg  rm -f "$tmpdepfile"
6018c9fbc29Smrg  ;;
6028c9fbc29Smrg
6034e411241Smrgmsvcmsys)
6044e411241Smrg  # This case exists only to let depend.m4 do its work.  It works by
6054e411241Smrg  # looking at the text of this script.  This case will never be run,
6064e411241Smrg  # since it is checked for above.
6074e411241Smrg  exit 1
6084e411241Smrg  ;;
6094e411241Smrg
6108c9fbc29Smrgnone)
6118c9fbc29Smrg  exec "$@"
6128c9fbc29Smrg  ;;
6138c9fbc29Smrg
6148c9fbc29Smrg*)
6158c9fbc29Smrg  echo "Unknown depmode $depmode" 1>&2
6168c9fbc29Smrg  exit 1
6178c9fbc29Smrg  ;;
6188c9fbc29Smrgesac
6198c9fbc29Smrg
6208c9fbc29Smrgexit 0
6218c9fbc29Smrg
6228c9fbc29Smrg# Local Variables:
6238c9fbc29Smrg# mode: shell-script
6248c9fbc29Smrg# sh-indentation: 2
6258c9fbc29Smrg# eval: (add-hook 'write-file-hooks 'time-stamp)
6268c9fbc29Smrg# time-stamp-start: "scriptversion="
6278c9fbc29Smrg# time-stamp-format: "%:y-%02m-%02d.%02H"
6284e411241Smrg# time-stamp-time-zone: "UTC"
6294e411241Smrg# time-stamp-end: "; # UTC"
6308c9fbc29Smrg# End:
631