Blame build/depcomp

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