Blame build-aux/depcomp

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