Blame depcomp

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