Blame build-aux/depcomp

c95639
#! /bin/sh
c95639
# depcomp - compile a program generating dependencies as side-effects
c95639
c95639
scriptversion=2018-03-07.03; # UTC
c95639
c95639
# Copyright (C) 1999-2018 Free Software Foundation, Inc.
c95639
c95639
# This program is free software; you can redistribute it and/or modify
c95639
# it under the terms of the GNU General Public License as published by
c95639
# the Free Software Foundation; either version 2, or (at your option)
c95639
# any later version.
c95639
c95639
# This program is distributed in the hope that it will be useful,
c95639
# but WITHOUT ANY WARRANTY; without even the implied warranty of
c95639
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c95639
# GNU General Public License for more details.
c95639
c95639
# You should have received a copy of the GNU General Public License
c95639
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
c95639
c95639
# As a special exception to the GNU General Public License, if you
c95639
# distribute this file as part of a program that contains a
c95639
# configuration script generated by Autoconf, you may include it under
c95639
# the same distribution terms that you use for the rest of that program.
c95639
c95639
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
c95639
c95639
case $1 in
c95639
  '')
c95639
    echo "$0: No command.  Try '$0 --help' for more information." 1>&2
c95639
    exit 1;
c95639
    ;;
c95639
  -h | --h*)
c95639
    cat <<\EOF
c95639
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
c95639
c95639
Run PROGRAMS ARGS to compile a file, generating dependencies
c95639
as side-effects.
c95639
c95639
Environment variables:
c95639
  depmode     Dependency tracking mode.
c95639
  source      Source file read by 'PROGRAMS ARGS'.
c95639
  object      Object file output by 'PROGRAMS ARGS'.
c95639
  DEPDIR      directory where to store dependencies.
c95639
  depfile     Dependency file to output.
c95639
  tmpdepfile  Temporary file to use when outputting dependencies.
c95639
  libtool     Whether libtool is used (yes/no).
c95639
c95639
Report bugs to <bug-automake@gnu.org>.
c95639
EOF
c95639
    exit $?
c95639
    ;;
c95639
  -v | --v*)
c95639
    echo "depcomp $scriptversion"
c95639
    exit $?
c95639
    ;;
c95639
esac
c95639
c95639
# Get the directory component of the given path, and save it in the
c95639
# global variables '$dir'.  Note that this directory component will
c95639
# be either empty or ending with a '/' character.  This is deliberate.
c95639
set_dir_from ()
c95639
{
c95639
  case $1 in
c95639
    */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;;
c95639
      *) dir=;;
c95639
  esac
c95639
}
c95639
c95639
# Get the suffix-stripped basename of the given path, and save it the
c95639
# global variable '$base'.
c95639
set_base_from ()
c95639
{
c95639
  base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'`
c95639
}
c95639
c95639
# If no dependency file was actually created by the compiler invocation,
c95639
# we still have to create a dummy depfile, to avoid errors with the
c95639
# Makefile "include basename.Plo" scheme.
c95639
make_dummy_depfile ()
c95639
{
c95639
  echo "#dummy" > "$depfile"
c95639
}
c95639
c95639
# Factor out some common post-processing of the generated depfile.
c95639
# Requires the auxiliary global variable '$tmpdepfile' to be set.
c95639
aix_post_process_depfile ()
c95639
{
c95639
  # If the compiler actually managed to produce a dependency file,
c95639
  # post-process it.
c95639
  if test -f "$tmpdepfile"; then
c95639
    # Each line is of the form 'foo.o: dependency.h'.
c95639
    # Do two passes, one to just change these to
c95639
    #   $object: dependency.h
c95639
    # and one to simply output
c95639
    #   dependency.h:
c95639
    # which is needed to avoid the deleted-header problem.
c95639
    { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile"
c95639
      sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile"
c95639
    } > "$depfile"
c95639
    rm -f "$tmpdepfile"
c95639
  else
c95639
    make_dummy_depfile
c95639
  fi
c95639
}
c95639
c95639
# A tabulation character.
c95639
tab='	'
c95639
# A newline character.
c95639
nl='
c95639
'
c95639
# Character ranges might be problematic outside the C locale.
c95639
# These definitions help.
c95639
upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ
c95639
lower=abcdefghijklmnopqrstuvwxyz
c95639
digits=0123456789
c95639
alpha=${upper}${lower}
c95639
c95639
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
c95639
  echo "depcomp: Variables source, object and depmode must be set" 1>&2
c95639
  exit 1
c95639
fi
c95639
c95639
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
c95639
depfile=${depfile-`echo "$object" |
c95639
  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
c95639
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
c95639
c95639
rm -f "$tmpdepfile"
c95639
c95639
# Avoid interferences from the environment.
c95639
gccflag= dashmflag=
c95639
c95639
# Some modes work just like other modes, but use different flags.  We
c95639
# parameterize here, but still list the modes in the big case below,
c95639
# to make depend.m4 easier to write.  Note that we *cannot* use a case
c95639
# here, because this file can only contain one case statement.
c95639
if test "$depmode" = hp; then
c95639
  # HP compiler uses -M and no extra arg.
c95639
  gccflag=-M
c95639
  depmode=gcc
c95639
fi
c95639
c95639
if test "$depmode" = dashXmstdout; then
c95639
  # This is just like dashmstdout with a different argument.
c95639
  dashmflag=-xM
c95639
  depmode=dashmstdout
c95639
fi
c95639
c95639
cygpath_u="cygpath -u -f -"
c95639
if test "$depmode" = msvcmsys; then
c95639
  # This is just like msvisualcpp but w/o cygpath translation.
c95639
  # Just convert the backslash-escaped backslashes to single forward
c95639
  # slashes to satisfy depend.m4
c95639
  cygpath_u='sed s,\\\\,/,g'
c95639
  depmode=msvisualcpp
c95639
fi
c95639
c95639
if test "$depmode" = msvc7msys; then
c95639
  # This is just like msvc7 but w/o cygpath translation.
c95639
  # Just convert the backslash-escaped backslashes to single forward
c95639
  # slashes to satisfy depend.m4
c95639
  cygpath_u='sed s,\\\\,/,g'
c95639
  depmode=msvc7
c95639
fi
c95639
c95639
if test "$depmode" = xlc; then
c95639
  # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.
c95639
  gccflag=-qmakedep=gcc,-MF
c95639
  depmode=gcc
c95639
fi
c95639
c95639
case "$depmode" in
c95639
gcc3)
c95639
## gcc 3 implements dependency tracking that does exactly what
c95639
## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
c95639
## it if -MD -MP comes after the -MF stuff.  Hmm.
c95639
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
c95639
## the command line argument order; so add the flags where they
c95639
## appear in depend2.am.  Note that the slowdown incurred here
c95639
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
c95639
  for arg
c95639
  do
c95639
    case $arg in
c95639
    -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
c95639
    *)  set fnord "$@" "$arg" ;;
c95639
    esac
c95639
    shift # fnord
c95639
    shift # $arg
c95639
  done
c95639
  "$@"
c95639
  stat=$?
c95639
  if test $stat -ne 0; then
c95639
    rm -f "$tmpdepfile"
c95639
    exit $stat
c95639
  fi
c95639
  mv "$tmpdepfile" "$depfile"
c95639
  ;;
c95639
c95639
gcc)
c95639
## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.
c95639
## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.
c95639
## (see the conditional assignment to $gccflag above).
c95639
## There are various ways to get dependency output from gcc.  Here's
c95639
## why we pick this rather obscure method:
c95639
## - Don't want to use -MD because we'd like the dependencies to end
c95639
##   up in a subdir.  Having to rename by hand is ugly.
c95639
##   (We might end up doing this anyway to support other compilers.)
c95639
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
c95639
##   -MM, not -M (despite what the docs say).  Also, it might not be
c95639
##   supported by the other compilers which use the 'gcc' depmode.
c95639
## - Using -M directly means running the compiler twice (even worse
c95639
##   than renaming).
c95639
  if test -z "$gccflag"; then
c95639
    gccflag=-MD,
c95639
  fi
c95639
  "$@" -Wp,"$gccflag$tmpdepfile"
c95639
  stat=$?
c95639
  if test $stat -ne 0; then
c95639
    rm -f "$tmpdepfile"
c95639
    exit $stat
c95639
  fi
c95639
  rm -f "$depfile"
c95639
  echo "$object : \\" > "$depfile"
c95639
  # The second -e expression handles DOS-style file names with drive
c95639
  # letters.
c95639
  sed -e 's/^[^:]*: / /' \
c95639
      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
c95639
## This next piece of magic avoids the "deleted header file" problem.
c95639
## The problem is that when a header file which appears in a .P file
c95639
## is deleted, the dependency causes make to die (because there is
c95639
## typically no way to rebuild the header).  We avoid this by adding
c95639
## dummy dependencies for each header file.  Too bad gcc doesn't do
c95639
## this for us directly.
c95639
## Some versions of gcc put a space before the ':'.  On the theory
c95639
## that the space means something, we add a space to the output as
c95639
## well.  hp depmode also adds that space, but also prefixes the VPATH
c95639
## to the object.  Take care to not repeat it in the output.
c95639
## Some versions of the HPUX 10.20 sed can't process this invocation
c95639
## correctly.  Breaking it into two sed invocations is a workaround.
c95639
  tr ' ' "$nl" < "$tmpdepfile" \
c95639
    | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
c95639
    | sed -e 's/$/ :/' >> "$depfile"
c95639
  rm -f "$tmpdepfile"
c95639
  ;;
c95639
c95639
hp)
c95639
  # This case exists only to let depend.m4 do its work.  It works by
c95639
  # looking at the text of this script.  This case will never be run,
c95639
  # since it is checked for above.
c95639
  exit 1
c95639
  ;;
c95639
c95639
sgi)
c95639
  if test "$libtool" = yes; then
c95639
    "$@" "-Wp,-MDupdate,$tmpdepfile"
c95639
  else
c95639
    "$@" -MDupdate "$tmpdepfile"
c95639
  fi
c95639
  stat=$?
c95639
  if test $stat -ne 0; then
c95639
    rm -f "$tmpdepfile"
c95639
    exit $stat
c95639
  fi
c95639
  rm -f "$depfile"
c95639
c95639
  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
c95639
    echo "$object : \\" > "$depfile"
c95639
    # Clip off the initial element (the dependent).  Don't try to be
c95639
    # clever and replace this with sed code, as IRIX sed won't handle
c95639
    # lines with more than a fixed number of characters (4096 in
c95639
    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
c95639
    # the IRIX cc adds comments like '#:fec' to the end of the
c95639
    # dependency line.
c95639
    tr ' ' "$nl" < "$tmpdepfile" \
c95639
      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \
c95639
      | tr "$nl" ' ' >> "$depfile"
c95639
    echo >> "$depfile"
c95639
    # The second pass generates a dummy entry for each header file.
c95639
    tr ' ' "$nl" < "$tmpdepfile" \
c95639
      | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
c95639
      >> "$depfile"
c95639
  else
c95639
    make_dummy_depfile
c95639
  fi
c95639
  rm -f "$tmpdepfile"
c95639
  ;;
c95639
c95639
xlc)
c95639
  # This case exists only to let depend.m4 do its work.  It works by
c95639
  # looking at the text of this script.  This case will never be run,
c95639
  # since it is checked for above.
c95639
  exit 1
c95639
  ;;
c95639
c95639
aix)
c95639
  # The C for AIX Compiler uses -M and outputs the dependencies
c95639
  # in a .u file.  In older versions, this file always lives in the
c95639
  # current directory.  Also, the AIX compiler puts '$object:' at the
c95639
  # start of each line; $object doesn't have directory information.
c95639
  # Version 6 uses the directory in both cases.
c95639
  set_dir_from "$object"
c95639
  set_base_from "$object"
c95639
  if test "$libtool" = yes; then
c95639
    tmpdepfile1=$dir$base.u
c95639
    tmpdepfile2=$base.u
c95639
    tmpdepfile3=$dir.libs/$base.u
c95639
    "$@" -Wc,-M
c95639
  else
c95639
    tmpdepfile1=$dir$base.u
c95639
    tmpdepfile2=$dir$base.u
c95639
    tmpdepfile3=$dir$base.u
c95639
    "$@" -M
c95639
  fi
c95639
  stat=$?
c95639
  if test $stat -ne 0; then
c95639
    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
c95639
    exit $stat
c95639
  fi
c95639
c95639
  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
c95639
  do
c95639
    test -f "$tmpdepfile" && break
c95639
  done
c95639
  aix_post_process_depfile
c95639
  ;;
c95639
c95639
tcc)
c95639
  # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26
c95639
  # FIXME: That version still under development at the moment of writing.
c95639
  #        Make that this statement remains true also for stable, released
c95639
  #        versions.
c95639
  # It will wrap lines (doesn't matter whether long or short) with a
c95639
  # trailing '\', as in:
c95639
  #
c95639
  #   foo.o : \
c95639
  #    foo.c \
c95639
  #    foo.h \
c95639
  #
c95639
  # It will put a trailing '\' even on the last line, and will use leading
c95639
  # spaces rather than leading tabs (at least since its commit 0394caf7
c95639
  # "Emit spaces for -MD").
c95639
  "$@" -MD -MF "$tmpdepfile"
c95639
  stat=$?
c95639
  if test $stat -ne 0; then
c95639
    rm -f "$tmpdepfile"
c95639
    exit $stat
c95639
  fi
c95639
  rm -f "$depfile"
c95639
  # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'.
c95639
  # We have to change lines of the first kind to '$object: \'.
c95639
  sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile"
c95639
  # And for each line of the second kind, we have to emit a 'dep.h:'
c95639
  # dummy dependency, to avoid the deleted-header problem.
c95639
  sed -n -e 's|^  *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile"
c95639
  rm -f "$tmpdepfile"
c95639
  ;;
c95639
c95639
## The order of this option in the case statement is important, since the
c95639
## shell code in configure will try each of these formats in the order
c95639
## listed in this file.  A plain '-MD' option would be understood by many
c95639
## compilers, so we must ensure this comes after the gcc and icc options.
c95639
pgcc)
c95639
  # Portland's C compiler understands '-MD'.
c95639
  # Will always output deps to 'file.d' where file is the root name of the
c95639
  # source file under compilation, even if file resides in a subdirectory.
c95639
  # The object file name does not affect the name of the '.d' file.
c95639
  # pgcc 10.2 will output
c95639
  #    foo.o: sub/foo.c sub/foo.h
c95639
  # and will wrap long lines using '\' :
c95639
  #    foo.o: sub/foo.c ... \
c95639
  #     sub/foo.h ... \
c95639
  #     ...
c95639
  set_dir_from "$object"
c95639
  # Use the source, not the object, to determine the base name, since
c95639
  # that's sadly what pgcc will do too.
c95639
  set_base_from "$source"
c95639
  tmpdepfile=$base.d
c95639
c95639
  # For projects that build the same source file twice into different object
c95639
  # files, the pgcc approach of using the *source* file root name can cause
c95639
  # problems in parallel builds.  Use a locking strategy to avoid stomping on
c95639
  # the same $tmpdepfile.
c95639
  lockdir=$base.d-lock
c95639
  trap "
c95639
    echo '$0: caught signal, cleaning up...' >&2
c95639
    rmdir '$lockdir'
c95639
    exit 1
c95639
  " 1 2 13 15
c95639
  numtries=100
c95639
  i=$numtries
c95639
  while test $i -gt 0; do
c95639
    # mkdir is a portable test-and-set.
c95639
    if mkdir "$lockdir" 2>/dev/null; then
c95639
      # This process acquired the lock.
c95639
      "$@" -MD
c95639
      stat=$?
c95639
      # Release the lock.
c95639
      rmdir "$lockdir"
c95639
      break
c95639
    else
c95639
      # If the lock is being held by a different process, wait
c95639
      # until the winning process is done or we timeout.
c95639
      while test -d "$lockdir" && test $i -gt 0; do
c95639
        sleep 1
c95639
        i=`expr $i - 1`
c95639
      done
c95639
    fi
c95639
    i=`expr $i - 1`
c95639
  done
c95639
  trap - 1 2 13 15
c95639
  if test $i -le 0; then
c95639
    echo "$0: failed to acquire lock after $numtries attempts" >&2
c95639
    echo "$0: check lockdir '$lockdir'" >&2
c95639
    exit 1
c95639
  fi
c95639
c95639
  if test $stat -ne 0; then
c95639
    rm -f "$tmpdepfile"
c95639
    exit $stat
c95639
  fi
c95639
  rm -f "$depfile"
c95639
  # Each line is of the form `foo.o: dependent.h',
c95639
  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
c95639
  # Do two passes, one to just change these to
c95639
  # `$object: dependent.h' and one to simply `dependent.h:'.
c95639
  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
c95639
  # Some versions of the HPUX 10.20 sed can't process this invocation
c95639
  # correctly.  Breaking it into two sed invocations is a workaround.
c95639
  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \
c95639
    | sed -e 's/$/ :/' >> "$depfile"
c95639
  rm -f "$tmpdepfile"
c95639
  ;;
c95639
c95639
hp2)
c95639
  # The "hp" stanza above does not work with aCC (C++) and HP's ia64
c95639
  # compilers, which have integrated preprocessors.  The correct option
c95639
  # to use with these is +Maked; it writes dependencies to a file named
c95639
  # 'foo.d', which lands next to the object file, wherever that
c95639
  # happens to be.
c95639
  # Much of this is similar to the tru64 case; see comments there.
c95639
  set_dir_from  "$object"
c95639
  set_base_from "$object"
c95639
  if test "$libtool" = yes; then
c95639
    tmpdepfile1=$dir$base.d
c95639
    tmpdepfile2=$dir.libs/$base.d
c95639
    "$@" -Wc,+Maked
c95639
  else
c95639
    tmpdepfile1=$dir$base.d
c95639
    tmpdepfile2=$dir$base.d
c95639
    "$@" +Maked
c95639
  fi
c95639
  stat=$?
c95639
  if test $stat -ne 0; then
c95639
     rm -f "$tmpdepfile1" "$tmpdepfile2"
c95639
     exit $stat
c95639
  fi
c95639
c95639
  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
c95639
  do
c95639
    test -f "$tmpdepfile" && break
c95639
  done
c95639
  if test -f "$tmpdepfile"; then
c95639
    sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile"
c95639
    # Add 'dependent.h:' lines.
c95639
    sed -ne '2,${
c95639
               s/^ *//
c95639
               s/ \\*$//
c95639
               s/$/:/
c95639
               p
c95639
             }' "$tmpdepfile" >> "$depfile"
c95639
  else
c95639
    make_dummy_depfile
c95639
  fi
c95639
  rm -f "$tmpdepfile" "$tmpdepfile2"
c95639
  ;;
c95639
c95639
tru64)
c95639
  # The Tru64 compiler uses -MD to generate dependencies as a side
c95639
  # effect.  'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
c95639
  # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
c95639
  # dependencies in 'foo.d' instead, so we check for that too.
c95639
  # Subdirectories are respected.
c95639
  set_dir_from  "$object"
c95639
  set_base_from "$object"
c95639
c95639
  if test "$libtool" = yes; then
c95639
    # Libtool generates 2 separate objects for the 2 libraries.  These
c95639
    # two compilations output dependencies in $dir.libs/$base.o.d and
c95639
    # in $dir$base.o.d.  We have to check for both files, because
c95639
    # one of the two compilations can be disabled.  We should prefer
c95639
    # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
c95639
    # automatically cleaned when .libs/ is deleted, while ignoring
c95639
    # the former would cause a distcleancheck panic.
c95639
    tmpdepfile1=$dir$base.o.d          # libtool 1.5
c95639
    tmpdepfile2=$dir.libs/$base.o.d    # Likewise.
c95639
    tmpdepfile3=$dir.libs/$base.d      # Compaq CCC V6.2-504
c95639
    "$@" -Wc,-MD
c95639
  else
c95639
    tmpdepfile1=$dir$base.d
c95639
    tmpdepfile2=$dir$base.d
c95639
    tmpdepfile3=$dir$base.d
c95639
    "$@" -MD
c95639
  fi
c95639
c95639
  stat=$?
c95639
  if test $stat -ne 0; then
c95639
    rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
c95639
    exit $stat
c95639
  fi
c95639
c95639
  for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
c95639
  do
c95639
    test -f "$tmpdepfile" && break
c95639
  done
c95639
  # Same post-processing that is required for AIX mode.
c95639
  aix_post_process_depfile
c95639
  ;;
c95639
c95639
msvc7)
c95639
  if test "$libtool" = yes; then
c95639
    showIncludes=-Wc,-showIncludes
c95639
  else
c95639
    showIncludes=-showIncludes
c95639
  fi
c95639
  "$@" $showIncludes > "$tmpdepfile"
c95639
  stat=$?
c95639
  grep -v '^Note: including file: ' "$tmpdepfile"
c95639
  if test $stat -ne 0; then
c95639
    rm -f "$tmpdepfile"
c95639
    exit $stat
c95639
  fi
c95639
  rm -f "$depfile"
c95639
  echo "$object : \\" > "$depfile"
c95639
  # The first sed program below extracts the file names and escapes
c95639
  # backslashes for cygpath.  The second sed program outputs the file
c95639
  # name when reading, but also accumulates all include files in the
c95639
  # hold buffer in order to output them again at the end.  This only
c95639
  # works with sed implementations that can handle large buffers.
c95639
  sed < "$tmpdepfile" -n '
c95639
/^Note: including file:  *\(.*\)/ {
c95639
  s//\1/
c95639
  s/\\/\\\\/g
c95639
  p
c95639
}' | $cygpath_u | sort -u | sed -n '
c95639
s/ /\\ /g
c95639
s/\(.*\)/'"$tab"'\1 \\/p
c95639
s/.\(.*\) \\/\1:/
c95639
H
c95639
$ {
c95639
  s/.*/'"$tab"'/
c95639
  G
c95639
  p
c95639
}' >> "$depfile"
c95639
  echo >> "$depfile" # make sure the fragment doesn't end with a backslash
c95639
  rm -f "$tmpdepfile"
c95639
  ;;
c95639
c95639
msvc7msys)
c95639
  # This case exists only to let depend.m4 do its work.  It works by
c95639
  # looking at the text of this script.  This case will never be run,
c95639
  # since it is checked for above.
c95639
  exit 1
c95639
  ;;
c95639
c95639
#nosideeffect)
c95639
  # This comment above is used by automake to tell side-effect
c95639
  # dependency tracking mechanisms from slower ones.
c95639
c95639
dashmstdout)
c95639
  # Important note: in order to support this mode, a compiler *must*
c95639
  # always write the preprocessed file to stdout, regardless of -o.
c95639
  "$@" || exit $?
c95639
c95639
  # Remove the call to Libtool.
c95639
  if test "$libtool" = yes; then
c95639
    while test "X$1" != 'X--mode=compile'; do
c95639
      shift
c95639
    done
c95639
    shift
c95639
  fi
c95639
c95639
  # Remove '-o $object'.
c95639
  IFS=" "
c95639
  for arg
c95639
  do
c95639
    case $arg in
c95639
    -o)
c95639
      shift
c95639
      ;;
c95639
    $object)
c95639
      shift
c95639
      ;;
c95639
    *)
c95639
      set fnord "$@" "$arg"
c95639
      shift # fnord
c95639
      shift # $arg
c95639
      ;;
c95639
    esac
c95639
  done
c95639
c95639
  test -z "$dashmflag" && dashmflag=-M
c95639
  # Require at least two characters before searching for ':'
c95639
  # in the target name.  This is to cope with DOS-style filenames:
c95639
  # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
c95639
  "$@" $dashmflag |
c95639
    sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile"
c95639
  rm -f "$depfile"
c95639
  cat < "$tmpdepfile" > "$depfile"
c95639
  # Some versions of the HPUX 10.20 sed can't process this sed invocation
c95639
  # correctly.  Breaking it into two sed invocations is a workaround.
c95639
  tr ' ' "$nl" < "$tmpdepfile" \
c95639
    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
c95639
    | sed -e 's/$/ :/' >> "$depfile"
c95639
  rm -f "$tmpdepfile"
c95639
  ;;
c95639
c95639
dashXmstdout)
c95639
  # This case only exists to satisfy depend.m4.  It is never actually
c95639
  # run, as this mode is specially recognized in the preamble.
c95639
  exit 1
c95639
  ;;
c95639
c95639
makedepend)
c95639
  "$@" || exit $?
c95639
  # Remove any Libtool call
c95639
  if test "$libtool" = yes; then
c95639
    while test "X$1" != 'X--mode=compile'; do
c95639
      shift
c95639
    done
c95639
    shift
c95639
  fi
c95639
  # X makedepend
c95639
  shift
c95639
  cleared=no eat=no
c95639
  for arg
c95639
  do
c95639
    case $cleared in
c95639
    no)
c95639
      set ""; shift
c95639
      cleared=yes ;;
c95639
    esac
c95639
    if test $eat = yes; then
c95639
      eat=no
c95639
      continue
c95639
    fi
c95639
    case "$arg" in
c95639
    -D*|-I*)
c95639
      set fnord "$@" "$arg"; shift ;;
c95639
    # Strip any option that makedepend may not understand.  Remove
c95639
    # the object too, otherwise makedepend will parse it as a source file.
c95639
    -arch)
c95639
      eat=yes ;;
c95639
    -*|$object)
c95639
      ;;
c95639
    *)
c95639
      set fnord "$@" "$arg"; shift ;;
c95639
    esac
c95639
  done
c95639
  obj_suffix=`echo "$object" | sed 's/^.*\././'`
c95639
  touch "$tmpdepfile"
c95639
  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
c95639
  rm -f "$depfile"
c95639
  # makedepend may prepend the VPATH from the source file name to the object.
c95639
  # No need to regex-escape $object, excess matching of '.' is harmless.
c95639
  sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
c95639
  # Some versions of the HPUX 10.20 sed can't process the last invocation
c95639
  # correctly.  Breaking it into two sed invocations is a workaround.
c95639
  sed '1,2d' "$tmpdepfile" \
c95639
    | tr ' ' "$nl" \
c95639
    | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \
c95639
    | sed -e 's/$/ :/' >> "$depfile"
c95639
  rm -f "$tmpdepfile" "$tmpdepfile".bak
c95639
  ;;
c95639
c95639
cpp)
c95639
  # Important note: in order to support this mode, a compiler *must*
c95639
  # always write the preprocessed file to stdout.
c95639
  "$@" || exit $?
c95639
c95639
  # Remove the call to Libtool.
c95639
  if test "$libtool" = yes; then
c95639
    while test "X$1" != 'X--mode=compile'; do
c95639
      shift
c95639
    done
c95639
    shift
c95639
  fi
c95639
c95639
  # Remove '-o $object'.
c95639
  IFS=" "
c95639
  for arg
c95639
  do
c95639
    case $arg in
c95639
    -o)
c95639
      shift
c95639
      ;;
c95639
    $object)
c95639
      shift
c95639
      ;;
c95639
    *)
c95639
      set fnord "$@" "$arg"
c95639
      shift # fnord
c95639
      shift # $arg
c95639
      ;;
c95639
    esac
c95639
  done
c95639
c95639
  "$@" -E \
c95639
    | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
c95639
             -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
c95639
    | sed '$ s: \\$::' > "$tmpdepfile"
c95639
  rm -f "$depfile"
c95639
  echo "$object : \\" > "$depfile"
c95639
  cat < "$tmpdepfile" >> "$depfile"
c95639
  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
c95639
  rm -f "$tmpdepfile"
c95639
  ;;
c95639
c95639
msvisualcpp)
c95639
  # Important note: in order to support this mode, a compiler *must*
c95639
  # always write the preprocessed file to stdout.
c95639
  "$@" || exit $?
c95639
c95639
  # Remove the call to Libtool.
c95639
  if test "$libtool" = yes; then
c95639
    while test "X$1" != 'X--mode=compile'; do
c95639
      shift
c95639
    done
c95639
    shift
c95639
  fi
c95639
c95639
  IFS=" "
c95639
  for arg
c95639
  do
c95639
    case "$arg" in
c95639
    -o)
c95639
      shift
c95639
      ;;
c95639
    $object)
c95639
      shift
c95639
      ;;
c95639
    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
c95639
        set fnord "$@"
c95639
        shift
c95639
        shift
c95639
        ;;
c95639
    *)
c95639
        set fnord "$@" "$arg"
c95639
        shift
c95639
        shift
c95639
        ;;
c95639
    esac
c95639
  done
c95639
  "$@" -E 2>/dev/null |
c95639
  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
c95639
  rm -f "$depfile"
c95639
  echo "$object : \\" > "$depfile"
c95639
  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
c95639
  echo "$tab" >> "$depfile"
c95639
  sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
c95639
  rm -f "$tmpdepfile"
c95639
  ;;
c95639
c95639
msvcmsys)
c95639
  # This case exists only to let depend.m4 do its work.  It works by
c95639
  # looking at the text of this script.  This case will never be run,
c95639
  # since it is checked for above.
c95639
  exit 1
c95639
  ;;
c95639
c95639
none)
c95639
  exec "$@"
c95639
  ;;
c95639
c95639
*)
c95639
  echo "Unknown depmode $depmode" 1>&2
c95639
  exit 1
c95639
  ;;
c95639
esac
c95639
c95639
exit 0
c95639
c95639
# Local Variables:
c95639
# mode: shell-script
c95639
# sh-indentation: 2
c95639
# eval: (add-hook 'before-save-hook 'time-stamp)
c95639
# time-stamp-start: "scriptversion="
c95639
# time-stamp-format: "%:y-%02m-%02d.%02H"
c95639
# time-stamp-time-zone: "UTC0"
c95639
# time-stamp-end: "; # UTC"
c95639
# End: