Blame build-aux/depcomp

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