Blame depcomp

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