Blame build-aux/depcomp

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